Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to write an EMF model which has to implemment an external Java interface
How to write an EMF model which has to implemment an external Java interface [message #423615] Fri, 03 October 2008 08:30 Go to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hello,

I would like my EMF model to implement an external Java interface (which
provide simple graph/node/edge management), but I am not too sure how to
do this.

Fisrt of all I tried to find a way to express in my ecore file that some
partiular EClass should implements my custom java interface, but
apparently this is impossible.

I then tried to mimic this external by defining an EMF Eclass interface,
that woudl provide the same servcies, however I realized that some of
its methods had to return a Set<T> object, which again seems impossible
to specify in ecore.

Now I am considering hiding this interface in the model implementation
classes by directly extending the methods available in the generated code.

Are there any other way to do this (this last approach really looks
tlike a hack to me) ?

Thanks in advance,

Steven
Re: How to write an EMF model which has to implemment an external Java interface [message #423618 is a reply to message #423615] Fri, 03 October 2008 09:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31478
Registered: July 2009
Senior Member
Steve,

Comments below.


news.eclipse.org wrote:
> Hello,
>
> I would like my EMF model to implement an external Java interface
> (which provide simple graph/node/edge management), but I am not too
> sure how to do this.
Define an EClass, set it's instance class name tot he external
interface, mark abstract and interface true, and then use it in the
super types of any class you want.
>
> Fisrt of all I tried to find a way to express in my ecore file that
> some partiular EClass should implements my custom java interface, but
> apparently this is impossible.
Just not obvious.
>
> I then tried to mimic this external by defining an EMF Eclass
> interface, that woudl provide the same servcies, however I realized
> that some of its methods had to return a Set<T> object, which again
> seems impossible to specify in ecore.
Nope, EMF 2.3 fully support anything form of generics you can express in
Java 5.0. If using the Sample Ecore Editor, be sure to enable Sample
Ecore Editor -> Show Generics to have control over this. The same kind
of instructions as above apply for java.util.Set. You'll want to add a
type parameter to it (like EcorePackage's EEList). When using it in a
generic type, you can pass in type arguments (like EcoreEPackage's
EObject's eContents).
>
> Now I am considering hiding this interface in the model implementation
> classes by directly extending the methods available in the generated
> code.
You can always use @extends/@implements to mix in interfaces into a
generated class or interface. You'd put that in the user-doc-section so
it's not merged away.
>
> Are there any other way to do this (this last approach really looks
> tlike a hack to me) ?
It's okay to have some things not explicitly part of the hierarchy, but
you can choose how best to do it...
>
> Thanks in advance,
>
> Steven


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to write an EMF model which has to implemment an external Java interface [message #423652 is a reply to message #423618] Sat, 04 October 2008 10:55 Go to previous message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hello Ed,

Thank you for your detailled answer, this is exactly the information
that I needed (I'll use your first suggested apporcha, which is much
simpler for me).

Steven


Ed Merks a écrit :
> Steve,
>
> Comments below.
>
>
> news.eclipse.org wrote:
>> Hello,
>>
>> I would like my EMF model to implement an external Java interface
>> (which provide simple graph/node/edge management), but I am not too
>> sure how to do this.

> Define an EClass, set it's instance class name tot he external
> interface, mark abstract and interface true, and then use it in the
> super types of any class you want.


>>
>> Fisrt of all I tried to find a way to express in my ecore file that
>> some partiular EClass should implements my custom java interface, but
>> apparently this is impossible.
> Just not obvious.
>>
>> I then tried to mimic this external by defining an EMF Eclass
>> interface, that woudl provide the same servcies, however I realized
>> that some of its methods had to return a Set<T> object, which again
>> seems impossible to specify in ecore.
> Nope, EMF 2.3 fully support anything form of generics you can express in
> Java 5.0. If using the Sample Ecore Editor, be sure to enable Sample
> Ecore Editor -> Show Generics to have control over this. The same kind
> of instructions as above apply for java.util.Set. You'll want to add a
> type parameter to it (like EcorePackage's EEList). When using it in a
> generic type, you can pass in type arguments (like EcoreEPackage's
> EObject's eContents).


>>
>> Now I am considering hiding this interface in the model implementation
>> classes by directly extending the methods available in the generated
>> code.
> You can always use @extends/@implements to mix in interfaces into a
> generated class or interface. You'd put that in the user-doc-section so
> it's not merged away.
>>
>> Are there any other way to do this (this last approach really looks
>> tlike a hack to me) ?
> It's okay to have some things not explicitly part of the hierarchy, but
> you can choose how best to do it...
>>
>> Thanks in advance,
>>
>> Steven
Previous Topic:Aspect Orientet Programming (AOP) using reflective feature delegation?
Next Topic:[CDO] using the query interface
Goto Forum:
  


Current Time: Thu Sep 24 11:44:30 GMT 2020

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

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

Back to the top