Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Retrieving the registered packages from the ECore
Retrieving the registered packages from the ECore [message #636019] Fri, 29 October 2010 03:12 Go to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 79
Registered: September 2010
Location: Bangalore
Member
Hi,

I wanted to retrieve all the registered packages in all the ecores present in my file system. I have already written the code to index all the files in the filesystem (provided they have registered extensions). But i don't know how to retrieve the .ecore files and then to retrieve the EPackages from there. In doing this memory consumption in my prime concern so can anyone suggest me a API which can retrieve the EPackages without much of memory consumption.

I found an API to get the EPackage from the Package registry, but that requires an EClass. The code is something like this: -

EClass productClass = productType.getProductCass();
if (productClass.getInstanceClassName() == null)
{
String nsURI = productClass.getEPackage().getNsURI();
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
productClass = (EClass) ePackage.getEClassifier(productClass.getName());
}


But i don't have any such information.. I have just indexed the files. I want to retrieve the ecore files and from there the packages.

Is there any API to do this ? If not, how else can i proceed ?


Regards,
Animesh
Re: Retrieving the registered packages from the ECore [message #636022 is a reply to message #636019] Fri, 29 October 2010 03:36 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

You can use the api on resourceset and access the package registr and hence the map containing all the registered packages.

<ResourceSetIntance>.getPackageRegistry()

Regards,
Ashwani Kr Sharma
Re: Retrieving the registered packages from the ECore [message #636030 is a reply to message #636019] Fri, 29 October 2010 05:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Animesh,

Comments below.

Animesh Kumar wrote:
> Hi,
>
> I wanted to retrieve all the registered packages in all the ecores
> present in my file system.
In your file system as opposed to the workspace, or those in
EPackage.Registry.INSTANCE?
> I have already written the code to index all the files in the
> filesystem (provided they have registered extensions).
Are you referring to the workspace.
> But i don't know how to retrieve the .ecore files and then to retrieve
> the EPackages from there.
ResourceSet.getResource should do the trick.
> In doing this memory consumption in my prime concern so can anyone
> suggest me a API which can retrieve the EPackages without much of
> memory consumption.
If you need to load them, they'll use as much memory as they use...
>
> I found an API to get the EPackage from the Package registry, but that
> requires an EClass. The code is something like this: -
>
>
> EClass productClass = productType.getProductCass();
> if (productClass.getInstanceClassName() == null)
> {
> String nsURI = productClass.getEPackage().getNsURI();
> EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
> productClass = (EClass) ePackage.getEClassifier(productClass.getName());
I'm confused. Is this not a giant no-op?
> }
>
>
> But i don't have any such information.. I have just indexed the files.
> I want to retrieve the ecore files and from there the packages.
Load them into a resource set and then inspect the resource's contents.
>
> Is there any API to do this ? If not, how else can i proceed ?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Define Containment Childrens in second Ecore Model
Next Topic:Zip & encrypt resource
Goto Forum:
  


Current Time: Fri Sep 20 02:06:30 GMT 2024

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

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

Back to the top