Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Call methods that need plugin's resource factory from launch configuration
Call methods that need plugin's resource factory from launch configuration [message #1245294] Thu, 13 February 2014 15:42 Go to next message
Christine Gerpheide is currently offline Christine GerpheideFriend
Messages: 21
Registered: January 2014
Location: Netherlands
Junior Member

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 Smile

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 #1245331 is a reply to message #1245294] Thu, 13 February 2014 16:54 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
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 #1245417 is a reply to message #1245331] Thu, 13 February 2014 19:42 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous message
Christine Gerpheide is currently offline Christine GerpheideFriend
Messages: 21
Registered: January 2014
Location: Netherlands
Junior Member

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.
Previous Topic:Call for Submission: Modeling Symposium @ EclipseCon North America 2014
Next Topic:EditingDomain by EMF Data Binding
Goto Forum:
  


Current Time: Thu Dec 12 20:10:29 GMT 2019

Powered by FUDForum. Page generated in 0.01813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top