Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Sharing a Resource across multiple ResourceSets
Sharing a Resource across multiple ResourceSets [message #668325] Thu, 05 May 2011 08:55 Go to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Hello,

Can a Resource belong to multiple ResourceSets?
I have a Resource that I'd like to share (contains an UML Profile). I'd like to do something like this:

Resource mySharedResource = ...;

ResourceSet rs1 = AdapterFactoryEditingDomainResourceSet();
rs1.getResources().add(mySharedResource);
Resource loadedModel1 = rs1.getResource(uri1);

ResourceSet rs2 = AdapterFactoryEditingDomainResourceSet();
rs2.getResources().add(mySharedResource);
Resource loadedModel2 = rs2.getResource(uri2);


Is this a "legal" construct?

Thank you.
Best regards,
Cristian.
Re: Sharing a Resource across multiple ResourceSets [message #668332 is a reply to message #668325] Thu, 05 May 2011 09:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Cristian,

Comments below.

Cristian wrote:
> Hello,
>
> Can a Resource belong to multiple ResourceSets?
No, Resource.getResourceSet and ResourceSet.getResources are effectively
a bidirectional reference.
> I have a Resource that I'd like to share (contains an UML Profile).
> I'd like to do something like this:
>
>
> Resource mySharedResource = ...;
>
> ResourceSet rs1 = AdapterFactoryEditingDomainResourceSet();
> rs1.getResources().add(mySharedResource);
> Resource loadedModel1 = rs1.getResource(uri1);
>
> ResourceSet rs2 = AdapterFactoryEditingDomainResourceSet();
> rs2.getResources().add(mySharedResource);
> Resource loadedModel2 = rs2.getResource(uri2);
>
>
> Is this a "legal" construct?
It's legal but you'll move the resource from one resource set to
another, which doesn't sound like what you want. You could specialize
ResourceSetImpl's delegatedResource to look resources up in another
resource set...
> Thank you.
> Best regards,
> Cristian.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Sharing a Resource across multiple ResourceSets [message #668339 is a reply to message #668332] Thu, 05 May 2011 09:25 Go to previous messageGo to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Thanks Ed.

You mean delegatedGetResource(URI uri, boolean loadOnDemand)?

So if I have an implementation of the above method that does for example:

// if uri == sharedResourceUri
return sharedResource;


That means that when I load a new resource that references sharedResource, it won't be loaded again, and the instance that I provide above will be used, right?

Best regards,
Cristian.
Re: Sharing a Resource across multiple ResourceSets [message #668349 is a reply to message #668339] Thu, 05 May 2011 09:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Cristian,

That's right. Often you'd delegate the call to ResourceSet.getResource
on some resource set that contains all the shared resources...


Cristian wrote:
> Thanks Ed.
>
> You mean delegatedGetResource(URI uri, boolean loadOnDemand)?
>
> So if I have an implementation of the above method that does for example:
>
>
> // if uri == sharedResourceUri
> return sharedResource;
>
>
> That means that when I load a new resource that references
> sharedResource, it won't be loaded again, and the instance that I
> provide above will be used, right?
>
> Best regards,
> Cristian.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF.Edit] AddCommand to add root object to resource
Next Topic:XSD Restrictions not validated?
Goto Forum:
  


Current Time: Thu Apr 25 18:48:53 GMT 2024

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

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

Back to the top