Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ResourceImpl and delegation to XMIResourceImpl
ResourceImpl and delegation to XMIResourceImpl [message #502531] Tue, 08 December 2009 17:45 Go to next message
Gregoire Cacheux is currently offline Gregoire CacheuxFriend
Messages: 9
Registered: July 2009
Junior Member
I am creating a custom Resource implementation extending ResourceImpl.

Upon load and save, i want to delegate the actual action to an instance of XMIResourceImpl in order to leverage the xmi serialization. I can not simply extends XMIResourceImpl Sad

For my XMIResourceImpl instance to get the contents of the top level resource, i am delegating eContents back to it. I did the same for getObject and getURIFragment.

It almost works. I can persist, but at load time i have instances from my model that are "duplicated", as if proxy or in-resource reference were not properly resolved.

Has it been tried before ? with success ?
Is there a better way to re-use XMIResourceImpl (or any other Resource in fact) through composition rather that inheritance.
Thanks
Gregoire
Re: ResourceImpl and delegation to XMIResourceImpl [message #502595 is a reply to message #502531] Wed, 09 December 2009 00:04 Go to previous messageGo to next message
Gregoire Cacheux is currently offline Gregoire CacheuxFriend
Messages: 9
Registered: July 2009
Junior Member
I have uploaded a small sample with tests of what i am trying to do.
I have modified the ExtendedPO model to fit my needs : the shipTo reference of PurchaseOrder is non containment and non resolving proxies.

I am saving as plain xmi and using the delegation in order to compare the xml. The shipTo reference is saved differently (element vs attribute for plain xmi). and at load time, i get a proxy. which is not what i expected.

Gregoire
Re: ResourceImpl and delegation to XMIResourceImpl [message #502727 is a reply to message #502595] Wed, 09 December 2009 14:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26215
Registered: July 2009
Senior Member
Gregoire,

It's impossible to understand what you've done based on what you've
described so far. I'd expect you to extend XMIResourceImpl and then
further extend things like XMLSaveImpl...

Gregoire Cacheux wrote:
> I have uploaded a small sample with tests of what i am trying to do.
> I have modified the ExtendedPO model to fit my needs : the shipTo
> reference of PurchaseOrder is non containment and non resolving proxies.
>
> I am saving as plain xmi and using the delegation in order to compare
> the xml. The shipTo reference is saved differently (element vs
> attribute for plain xmi). and at load time, i get a proxy. which is
> not what i expected.
>
> Gregoire
Re: ResourceImpl and delegation to XMIResourceImpl [message #502750 is a reply to message #502727] Wed, 09 December 2009 15:39 Go to previous messageGo to next message
Gregoire Cacheux is currently offline Gregoire CacheuxFriend
Messages: 9
Registered: July 2009
Junior Member
I have a CustomResource that extends ResourceImpl.

Let's say I want to serialize both in xmi and in binary format. I can not extend XMIResourceImpl and BinaryResourceImpl.

As inheritance can not work, i want to use composition and delegate at runtime the save and load operations to an instance of the right resource.

I managed to cheat the inner resource by routing calls to the CustomResource.

It is working well up to the point where XMIResourceImpl is cheking if a reference is cross document or not. There, the XMLSaveImpl is using == (identity) to check if the resource of the target object (CustomResource) is the current resource (XMIResource).

Is there a way to delegate that check so that i can re-use the XMIResourceImpl implementation while having my own Resource Implementation.

I can try overloading XMISaveImpl ... but then i wonder what is going to be next hurdle. Thus the more generic question about Resource extensibility. It looks like existing Resource (XML or XMI) are to be extended through inheritance more than through composition/delegation.
Re: ResourceImpl and delegation to XMIResourceImpl [message #502763 is a reply to message #502750] Wed, 09 December 2009 16:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26215
Registered: July 2009
Senior Member
Gregoire,

Comments below.

Gregoire Cacheux wrote:
> I have a CustomResource that extends ResourceImpl.
>
> Let's say I want to serialize both in xmi and in binary format. I can
> not extend XMIResourceImpl and BinaryResourceImpl.
Is that the real example? BinaryResourceImpl has easily reusable parts
whereas XMIResourceImpl is pretty tightly integrated with various
classes like XMISaveImpl and XMIHandler so best to extend
XMIResourceImpl and reuse the parts of BinaryResourceImpl.
>
> As inheritance can not work, i want to use composition and delegate at
> runtime the save and load operations to an instance of the right
> resource.
>
> I managed to cheat the inner resource by routing calls to the
> CustomResource.
>
> It is working well up to the point where XMIResourceImpl is cheking if
> a reference is cross document or not. There, the XMLSaveImpl is using
> == (identity) to check if the resource of the target object
> (CustomResource) is the current resource (XMIResource).
>
> Is there a way to delegate that check so that i can re-use the
> XMIResourceImpl implementation while having my own Resource
> Implementation.
Delegation involves specializing the class, and the classes that create
it, and then overriding the method to behave differently. There's no
special EMF magic I can offer.
>
> I can try overloading XMISaveImpl ... but then i wonder what is going
> to be next hurdle. Thus the more generic question about Resource
> extensibility. It looks like existing Resource (XML or XMI) are to be
> extended through inheritance more than through composition/delegation.
Yes, composition was not a design goal.
Re: ResourceImpl and delegation to XMIResourceImpl [message #502779 is a reply to message #502763] Wed, 09 December 2009 16:46 Go to previous messageGo to next message
Gregoire Cacheux is currently offline Gregoire CacheuxFriend
Messages: 9
Registered: July 2009
Junior Member
Ed Merks wrote on Wed, 09 December 2009 11:10
Gregoire,

Comments below.

Gregoire Cacheux wrote:
> I have a CustomResource that extends ResourceImpl.
>
> Let's say I want to serialize both in xmi and in binary format. I can
> not extend XMIResourceImpl and BinaryResourceImpl.
Is that the real example? BinaryResourceImpl has easily reusable parts
whereas XMIResourceImpl is pretty tightly integrated with various
classes like XMISaveImpl and XMIHandler so best to extend
XMIResourceImpl and reuse the parts of BinaryResourceImpl.
>

Yes it is close to the real example. I would like to have a zip archive that can contain xmi and binary, along with other non strictly emf based info.I think need more control on the zip format that what the XMIResourceImpl gives , but i am going to have a second look at it.


> As inheritance can not work, i want to use composition and delegate at
> runtime the save and load operations to an instance of the right
> resource.
>
> I managed to cheat the inner resource by routing calls to the
> CustomResource.
>
> It is working well up to the point where XMIResourceImpl is cheking if
> a reference is cross document or not. There, the XMLSaveImpl is using
> == (identity) to check if the resource of the target object
> (CustomResource) is the current resource (XMIResource).
>
> Is there a way to delegate that check so that i can re-use the
> XMIResourceImpl implementation while having my own Resource
> Implementation.
Delegation involves specializing the class, and the classes that create
it, and then overriding the method to behave differently. There's no
special EMF magic I can offer.
>
> I can try overloading XMISaveImpl ... but then i wonder what is going
> to be next hurdle. Thus the more generic question about Resource
> extensibility. It looks like existing Resource (XML or XMI) are to be
> extended through inheritance more than through composition/delegation.
Yes, composition was not a design goal.


Re: ResourceImpl and delegation to XMIResourceImpl [message #502812 is a reply to message #502779] Wed, 09 December 2009 18:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26215
Registered: July 2009
Senior Member
Gregoire,

Comments below.


Gregoire Cacheux wrote:
> Ed Merks wrote on Wed, 09 December 2009 11:10
>> Gregoire,
>>
>> Comments below.
>>
>> Gregoire Cacheux wrote:
>> > I have a CustomResource that extends ResourceImpl.
>> >
>> > Let's say I want to serialize both in xmi and in binary format. I
>> can > not extend XMIResourceImpl and BinaryResourceImpl.
>> Is that the real example? BinaryResourceImpl has easily reusable
>> parts whereas XMIResourceImpl is pretty tightly integrated with
>> various classes like XMISaveImpl and XMIHandler so best to extend
>> XMIResourceImpl and reuse the parts of BinaryResourceImpl.
>> >
>>
>> Yes it is close to the real example. I would like to have a zip
>> archive that can contain xmi and binary, along with other non
>> strictly emf based info.I think need more control on the zip format
>> that what the XMIResourceImpl gives , but i am going to have a second
>> look at it.
Note that you can use URIs to access parts of a zip, e.g.,
archive:platform:/resource/project/file.zip!/path/file.exten sion
>>
>> > As inheritance can not work, i want to use composition and delegate
>> at > runtime the save and load operations to an instance of the right
>> > resource.
>> >
>> > I managed to cheat the inner resource by routing calls to the >
>> CustomResource.
>> >
>> > It is working well up to the point where XMIResourceImpl is cheking
>> if > a reference is cross document or not. There, the XMLSaveImpl is
>> using > == (identity) to check if the resource of the target object >
>> (CustomResource) is the current resource (XMIResource).
>> >
>> > Is there a way to delegate that check so that i can re-use the >
>> XMIResourceImpl implementation while having my own Resource >
>> Implementation.
>> Delegation involves specializing the class, and the classes that
>> create it, and then overriding the method to behave differently.
>> There's no special EMF magic I can offer.
>> >
>> > I can try overloading XMISaveImpl ... but then i wonder what is
>> going > to be next hurdle. Thus the more generic question about
>> Resource > extensibility. It looks like existing Resource (XML or
>> XMI) are to be > extended through inheritance more than through
>> composition/delegation.
>> Yes, composition was not a design goal.
>
>
>
Previous Topic:How do I model a statically defined constant?
Next Topic:Error in closing generated GMF editor
Goto Forum:
  


Current Time: Sun Nov 23 02:27:19 GMT 2014

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

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