Call methods that need plugin's resource factory from launch configuration [message #1245294] |
Thu, 13 February 2014 15:42 |
|
This may be more of a plugin development question than an EMF question, but I'm not sure since I'm not very experienced in either.
I have a plugin. Currently (for my testing purposes) I've added a menu command that runs my Handler. What the handler does is executes a QVTo transformation with a specified input model URI, which is currently hardcoded in my plugin. So I start a new Eclipse application with my plugin installed and this works
But what I'd like to is let the person running the plugin to choose the input model URI. So I was thinking of defining a new launch configuration where the user can do that. To test whether this is possible (and because I'm still learning plugin development), I was first trying to just add a java configuration which calls my handler method. This required importing my plugin project inside my new Eclipse application, and then pointing a new run configuration to the appropriate method. But when I run that (in the same instance where my menu-command way works), I get the error:
"Cannot create a resource for 'myURI.mymetamodel'; a registered resource factory is needed.
I guess this happens because the menu-command takes advantage of any preloaded resource factories from plugins insalled in my instance, whereas calling my plugin code from a run configuration is more... blackboxed.
So do you think it's possible to use a new launch configuration type altogether and have it actually run the plugin code? Or is there a better way to run the code so that it indeed can find the appropriate resource factories?
Probably I just need to find more examples, but any hints for places to look would be appreciated.
Chris
|
|
|
|
Re: Call methods that need plugin's resource factory from launch configuration [message #1245417 is a reply to message #1245331] |
Thu, 13 February 2014 19:42 |
|
Hi,
EMF 2.9 added a very handy utility: EcorePlugin.ExtensionProcessor,
which scans the classpath for plugin.xml files and parses them into an
instance of the Equinox extension registry to automatically load all of
EMF's extension points. It requires a small part of the Equinox
footprint at run-time, but is quite convenient. And, in 2.10 (Luna)
release, it will also work on non-Windows platforms!
Cheers,
Christian
On 2014-02-13 16:54:11 +0000, Felix Dorner said:
> On 13/02/2014 16:42, Chris Gerpheide wrote:
>> "Cannot create a resource for 'myURI.mymetamodel'; a registered resource
>> factory is needed.
>>
>> I guess this happens because the menu-command takes advantage of any
>> preloaded resource factories from plugins insalled in my instance,
>> whereas calling my plugin code from a run configuration is more...
>> blackboxed.
>
> Yes this is just running your plugin-code in a standalone context. Your
> metamodels are registered via plugin extension points which are of
> course not available in standalone. So you would have to register your
> factory manually, I think simply accessing the generated EPackage would
> do. I wonder if QVT wouldn't already provide such a custom launch
> configuration type... At least JET does and I'm quite sure that
> Acceleo3 would too.
>
> Felix
|
|
|
Re: Call methods that need plugin's resource factory from launch configuration [message #1245845 is a reply to message #1245294] |
Fri, 14 February 2014 10:48 |
|
Thank you for your answers!
@Felix, Indeed there is a QVTo launch configuration. But in my case I don't want the configuration to directly call QVTo, but rather a Java file (which happens to execute a QVTo transformation, but also does other things). Thank you for the explanation though, it clarifies what's happening.
I have found a way that looks like it may work though, which is instead of using the Java application launch configuration, going ahead and creating my custom launch configuration, where my calling-qvto-transformation Java code is inside the launch method of my LaunchConfigurationDelegate implementation. I haven't figured out all the pieces of it, but it at least looks like then all my plugin metamodels are still accessible to my code.
@Christian That sounds very handy indeed. For my purposes adding to the footprint is not a problem, so I will look into this (and I do currently use Windows). It may give me more options for how I run my code.
|
|
|
Powered by
FUDForum. Page generated in 0.03327 seconds