Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Meta-model extensibility issues(How do you extend old meta-models to add new containments?)
Meta-model extensibility issues [message #496878] Wed, 11 November 2009 15:57 Go to next message
Colin Snook is currently offline Colin SnookFriend
Messages: 18
Registered: July 2009
Location: University of Southampton
Junior Member
I would like to extend (in a separate ecore/plugin) an old meta-model to add a new containment to an old meta-class. The containment will contain instances of a new meta-class defined in the new meta-model and should only be available on one specific kind of parent (which is in the old meta-model).
Old instance models should be able to have this containment added retrospectively. In the future I want to make other such extensions to the old meta-class which should be able to co-exist with this extension.

is there a recommended way to do this? Subclassing the parent obviously doesn't work since it is not retrospective and could not be combined with other extensions. We built an 'extensions' containment into our original meta-model's base class so that you can subtype an abstract target. But I can't see how I could restrict the allowed parent kind of the new containment.

I have thought about the following but not sure which way to go.

1) add a dynamically created EReference to the old meta-class
(I have tried doing this in the new EPackage init, the new Plug-in activator class, the old EPackage init (via a extension point). The containment is there but I variously get null pointer exceptions or stack overflows as the reflective methods keep calling back to the generated ones. Also I am not sure how I would extend the ChildCreation in the editor).

2) could i use an adapter to extend the old meta-class with a new containment?

3) switch to a simpler structure in the old meta-model so that for each parent, I just have one containment of an abstract target class for all its contents. Use feature mapping to simulate more structure. Then i could just subclass the abstract target class. i would still need to add a derived containment dynamically but maybe this would be easier. I will need a different abstract target class for each parent so that extensions don't appear everywhere. This way would make the editor extension easy.

i prefer 1) if i could get it to work.

Thanks
Colin
Re: Meta-model extensibility issues [message #496894 is a reply to message #496878] Wed, 11 November 2009 16:37 Go to previous messageGo to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Hi Colin,

Please check if this solves your problem
http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html

Regards,
Nirmal
Re: Meta-model extensibility issues [message #497156 is a reply to message #496894] Thu, 12 November 2009 17:25 Go to previous messageGo to next message
Colin Snook is currently offline Colin SnookFriend
Messages: 18
Registered: July 2009
Location: University of Southampton
Junior Member
Hi Nirmal,

Thanks, Yes, I have seen Ed's blog and I already tried Child extenders (it is the last sentence of item 3 in my original post). However, it seems to rely entirely on the new child-type subclassing the target-type of an existing containment. The reasons I am not rushing down this route are ...

I want a way to make the new containment only appear on a particular parent. I guess I could change the old meta-model to have a different child-target-type for each parent.

In the API and UI, I need to be able to distinguish different collections within the parent. I might be able to add this even though they are really in the same catch-all containment? I don't know much about feature maps, would that do it?

Ideally, I would like to be able to have several different collections of the same target-type in one parent. However i might be able to achieve this by introducing different kinds of intermediate container objects to distinguish usage.

Colin
Re: Meta-model extensibility issues [message #497171 is a reply to message #497156] Thu, 12 November 2009 17:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Colin,

I'm not really sure I followed all this old and new stuff you talked
about. You definitely can't modify generated classes dynamically to add
new containment features and you can't modify an instance to become an
instance of a subclass.. For XML Schema-based models, you can use
element wildcards perhaps to do something like what you're talking
about, i.e., elements of arbitrary type defined in other models can be
used as containment references in the base model.


Colin Snook wrote:
> Hi Nirmal,
>
> Thanks, Yes, I have seen Ed's blog and I already tried Child extenders
> (it is the last sentence of item 3 in my original post). However, it
> seems to rely entirely on the new child-type subclassing the
> target-type of an existing containment. The reasons I am not rushing
> down this route are ...
>
> I want a way to make the new containment only appear on a particular
> parent. I guess I could change the old meta-model to have a different
> child-target-type for each parent.
>
> In the API and UI, I need to be able to distinguish different
> collections within the parent. I might be able to add this even though
> they are really in the same catch-all containment? I don't know much
> about feature maps, would that do it?
>
> Ideally, I would like to be able to have several different collections
> of the same target-type in one parent. However i might be able to
> achieve this by introducing different kinds of intermediate container
> objects to distinguish usage.
>
> Colin


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[net4j] ClassCastException when starting org.eclipse.net4j.util bundle in Equinox
Next Topic:Scope of ID's
Goto Forum:
  


Current Time: Thu Apr 25 04:33:39 GMT 2024

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

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

Back to the top