Retrieving the registered packages from the ECore [message #636019] |
Fri, 29 October 2010 03:12 |
|
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 #636030 is a reply to message #636019] |
Fri, 29 October 2010 05:23 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.04370 seconds