Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Usage of "org.eclipse.emf.ecore.factory_override"
Usage of "org.eclipse.emf.ecore.factory_override" [message #995931] Mon, 31 December 2012 09:57 Go to next message
Vincenzo Caselli is currently offline Vincenzo Caselli
Messages: 100
Registered: January 2012
Senior Member
Hi all,
we are trying to use the "org.eclipse.emf.ecore.factory_override" extension point, but have some problem.
We have 2 plug-ins:
1) Model1: it defines an ecore with entity Variable
2) Model2: defines an ecore with entity CustomVariable that has Model1.Variable as super type

Model2 has also a JUnit class that has the following code:
Variable var = Model1Factory.eINSTANCE.createVariable();
var.setName("a");
System.out.println(var.getClass());


obviously the output is:
class model1.impl.VariableImpl


now, in Model2 plugin, we add the extension
 <extension
         point="org.eclipse.emf.ecore.factory_override">
      <factory
            class="org.eclipse.emf.model2.EFactory1"
            uri="http://model1/1.0">
      </factory>
   </extension>


and create the class
public class EFactory1 extends Model1FactoryImpl {

	@Override
	public Variable createVariable() {
		return Model2Factory.eINSTANCE.createCustomVariable();
	}
	
}


still the object created is
class model1.impl.VariableImpl


What is the correct way to override the EMF Model1 Factory?
Thank you
and Happy New Year!!!!!
Vincenzo

P.S. I uploaded this sample
Re: Usage of &quot;org.eclipse.emf.ecore.factory_override&quot; [message #995948 is a reply to message #995931] Mon, 31 December 2012 10:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
Vincenco,

Comments below.

On 31/12/2012 3:57 PM, Vincenzo Caselli wrote:
> Hi all,
> we are trying to use the "org.eclipse.emf.ecore.factory_override" extension point, but have some problem.
> We have 2 plug-ins:
> 1) Model1: it defines an ecore with entity Variable
> 2) Model2: defines an ecore with entity CustomVariable that has Model1.Variable as super type
No, there shouldn't be two models. Only one, with alternative
implementation classes.
>
> Model2 has also a JUnit class that has the following code:
> Variable var = Model1Factory.eINSTANCE.createVariable();
> var.setName("a");
> System.out.println(var.getClass());
>
> obviously the output is:
> class model1.impl.VariableImpl
>
> now, in Model2 plugin, we add the extension
> <extension
> point="org.eclipse.emf.ecore.factory_override">
> <factory
> class="org.eclipse.emf.model2.EFactory1"
> uri="http://model1/1.0">
> </factory>
> </extension>
>
> and create the class
> public class EFactory1 extends Model1FactoryImpl {
This has a public constructor?
>
> @Override
> public Variable createVariable() {
> return Model2Factory.eINSTANCE.createCustomVariable();
> }
>
> }
>
>
> still the object created is
> class model1.impl.VariableImpl
>
> What is the correct way to override the EMF Model1 Factory?
No, the overriding factory should create the proper instances. The
eClass() of what it creates should be the right one from Model1.
> Thank you
> and Happy New Year!!!!!
> Vincenzo
>
> P.S. I uploaded this sample
I'll have a closer look when I have more time, but your use case sounds
not so good...
Re: Usage of &quot;org.eclipse.emf.ecore.factory_override&quot; [message #996643 is a reply to message #995948] Wed, 02 January 2013 10:30 Go to previous message
Vincenzo Caselli is currently offline Vincenzo Caselli
Messages: 100
Registered: January 2012
Senior Member
Sorry Ed,
it is working!
My fault was to launch a test from JUnit Embarrassed : I just called the same test from a rcp plug-in and all is working fine!!!
Thank you Ed
Cheers
Vincenzo
Previous Topic:Embedding arbitrary models in a model
Next Topic:[CDO] StringIndexOutOfBoundsException thrown for a column containing a single space using H2
Goto Forum:
  


Current Time: Mon Sep 01 07:26:26 EDT 2014

Powered by FUDForum. Page generated in 0.02125 seconds