Usage of "org.eclipse.emf.ecore.factory_override" [message #995931] |
Mon, 31 December 2012 14:57 |
|
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 "org.eclipse.emf.ecore.factory_override" [message #995948 is a reply to message #995931] |
Mon, 31 December 2012 15:58 |
Ed Merks Messages: 33140 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...
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03124 seconds