attaching POJO to genmodel elements [message #404730] |
Fri, 20 October 2006 19:10  |
Eclipse User |
|
|
|
Originally posted by: woodri.us.ibm.com
Having added config info to ecore classes and attributes using
annotations, I'd like to write a generator that uses that info to do
something. The generator wants each genmodel element (genclass or
genattribute) to maintain state during generation. This might look like
an iterator attached to the element, where the iterator is a POJO. Is
there a place in genmodel elements to attach a POJO, or should I derive
off them and add my own field?
Thanks,
Rick
|
|
|
Re: attaching POJO to genmodel elements [message #404732 is a reply to message #404730] |
Sat, 21 October 2006 08:40   |
Eclipse User |
|
|
|
Rick,
During 2.2 development, we redesigned our generator to be an adapter
based design to make it extensible. It's certainly possible to use
stateful adapters to associate additional state with each object that
will be generated. Of course it's also possible to associate additional
state simply by using just a map. Extending the GenModel's classes
themselves is probably the least flexible approach, because you'll need
to be sure that instances of your extended model are created; the UML2
project does this, so it's certainly feasible. Note too that the
GenModel now supports GenAnnotations so that you could decorate any
GenModel model with your own annotations, which could be used to contain
any type of EObject which in turn could model your additional data...
Rick Wood wrote:
> Having added config info to ecore classes and attributes using
> annotations, I'd like to write a generator that uses that info to do
> something. The generator wants each genmodel element (genclass or
> genattribute) to maintain state during generation. This might look
> like an iterator attached to the element, where the iterator is a
> POJO. Is there a place in genmodel elements to attach a POJO, or
> should I derive off them and add my own field?
>
> Thanks,
> Rick
|
|
|
Re: attaching POJO to genmodel elements [message #404735 is a reply to message #404732] |
Sat, 21 October 2006 11:06   |
Eclipse User |
|
|
|
Originally posted by: woodri.us.ibm.com
Ed, I realized after some reading (chapter 2 from "Eclipse Modeling
Framework") that adapters are probably the way to go. I'm glad you're
confirming this. There's no notification involved (that I can see at
this point), but that shouldn't matter. A nice point is that the adapter
could be attached to the ecore (instead of genmodel) element, and so
could maybe replace the annotation as carrier of config info. Not sure
about that from a design standpoint. One question, how would you use a
map to associate additional state (i.e. to what would the map with POJO
be attached)?
Rick
Ed Merks wrote:
> Rick,
>
> During 2.2 development, we redesigned our generator to be an adapter
> based design to make it extensible. It's certainly possible to use
> stateful adapters to associate additional state with each object that
> will be generated. Of course it's also possible to associate additional
> state simply by using just a map. Extending the GenModel's classes
> themselves is probably the least flexible approach, because you'll need
> to be sure that instances of your extended model are created; the UML2
> project does this, so it's certainly feasible. Note too that the
> GenModel now supports GenAnnotations so that you could decorate any
> GenModel model with your own annotations, which could be used to contain
> any type of EObject which in turn could model your additional data...
>
>
> Rick Wood wrote:
>> Having added config info to ecore classes and attributes using
>> annotations, I'd like to write a generator that uses that info to do
>> something. The generator wants each genmodel element (genclass or
>> genattribute) to maintain state during generation. This might look
>> like an iterator attached to the element, where the iterator is a
>> POJO. Is there a place in genmodel elements to attach a POJO, or
>> should I derive off them and add my own field?
>>
>> Thanks,
>> Rick
|
|
|
Re: attaching POJO to genmodel elements [message #404738 is a reply to message #404735] |
Sat, 21 October 2006 16:54  |
Eclipse User |
|
|
|
Rick,
Yep that makes sense. EAnnotations are most useful and applicable when
you wish to associate persistent state with your Ecore model so that it
will even be available at runtime and GenAnnotations are most useful and
applicable when you wish to associate persistent state that is used only
at code generation time. In terms of using a map, your generator could
keep a map in its "context" in which it looks up associated information
with either the EModelElements of the Ecore model or the GenBases of the
GenModel and any time that information is needed it can be looked up in
that map...
Rick Wood wrote:
> Ed, I realized after some reading (chapter 2 from "Eclipse Modeling
> Framework") that adapters are probably the way to go. I'm glad you're
> confirming this. There's no notification involved (that I can see at
> this point), but that shouldn't matter. A nice point is that the
> adapter could be attached to the ecore (instead of genmodel) element,
> and so could maybe replace the annotation as carrier of config info.
> Not sure about that from a design standpoint. One question, how would
> you use a map to associate additional state (i.e. to what would the
> map with POJO be attached)?
>
> Rick
>
> Ed Merks wrote:
>> Rick,
>>
>> During 2.2 development, we redesigned our generator to be an adapter
>> based design to make it extensible. It's certainly possible to use
>> stateful adapters to associate additional state with each object that
>> will be generated. Of course it's also possible to associate
>> additional state simply by using just a map. Extending the
>> GenModel's classes themselves is probably the least flexible
>> approach, because you'll need to be sure that instances of your
>> extended model are created; the UML2 project does this, so it's
>> certainly feasible. Note too that the GenModel now supports
>> GenAnnotations so that you could decorate any GenModel model with
>> your own annotations, which could be used to contain any type of
>> EObject which in turn could model your additional data...
>>
>>
>> Rick Wood wrote:
>>> Having added config info to ecore classes and attributes using
>>> annotations, I'd like to write a generator that uses that info to do
>>> something. The generator wants each genmodel element (genclass or
>>> genattribute) to maintain state during generation. This might look
>>> like an iterator attached to the element, where the iterator is a
>>> POJO. Is there a place in genmodel elements to attach a POJO, or
>>> should I derive off them and add my own field?
>>>
>>> Thanks,
>>> Rick
|
|
|
Powered by
FUDForum. Page generated in 0.30013 seconds