Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Service Component Architecture (SCA) Tools » Load an SCA composite model programmatically
Load an SCA composite model programmatically [message #5178] Wed, 04 February 2009 15:08 Go to next message
Eclipse User
Originally posted by: mickael.istria.openwide.fr

Hi all,

I'm trying to load an SCA model programmatically to get data form a
..composite file by navigating in the EMF objects instead of using a ugly
XPath resolver. I'm using SCA editor and metamodel v1.0.1

However, when using the classic EMF code to load a Resource:
// Create a resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Register the default resource factory -- only needed for
// stand-alone!
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
// Get the URI of the model file.
URI fileURI = URI.createFileURI(new
File(scaApp.getCompositeFile()).getAbsolutePath());
// Demand load the resource for this file.
Resource resource = resourceSet.getResource(fileURI, true);
Composite compositeModel = (Composite)resource.getContents().get(0);

on a composite file generated with the sca modeler (so conform to the
SCA metamodel), I got the following error:

org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'composite' not
found.
(file:/home/mistria/runtime-EclipseApplication/test/default. composite,
2, 78)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2229)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2220)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1318)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
....

When looking at variables when the exception is raised, it seems like
the ScaFactory is found and used to unserialize model (a good point!)...


Do you have any idea of why this ScaFactory cannot resolve "composite"???


Regards,
Mickael
Re: Load an SCA composite model programmatically [message #5246 is a reply to message #5178] Wed, 04 February 2009 16:09 Go to previous messageGo to next message
Stephane Drapeau is currently offline Stephane Drapeau
Messages: 198
Registered: July 2009
Senior Member
Hi Mickael,

Use the SCA resource factory
(org.eclipse.stp.sca.util.ScaResourceFactoryImpl) instead of the XMI
resource factory.

Regards,

Stephane Drapeau
Obeo

Mickael Istria a écrit :
> Hi all,
>
> I'm trying to load an SCA model programmatically to get data form a
> ..composite file by navigating in the EMF objects instead of using a
> ugly XPath resolver. I'm using SCA editor and metamodel v1.0.1
>
> However, when using the classic EMF code to load a Resource:
> // Create a resource set.
> ResourceSet resourceSet = new ResourceSetImpl();
> // Register the default resource factory -- only needed for
> // stand-alone!
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new XMIResourceFactoryImpl());
> // Get the URI of the model file.
> URI fileURI = URI.createFileURI(new
> File(scaApp.getCompositeFile()).getAbsolutePath());
> // Demand load the resource for this file.
> Resource resource = resourceSet.getResource(fileURI, true);
> Composite compositeModel = (Composite)resource.getContents().get(0);
>
> on a composite file generated with the sca modeler (so conform to the
> SCA metamodel), I got the following error:
>
> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'composite' not
> found.
> (file:/home/mistria/runtime-EclipseApplication/test/default. composite,
> 2, 78)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2229)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2220)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1318)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
>
> ....
>
> When looking at variables when the exception is raised, it seems like
> the ScaFactory is found and used to unserialize model (a good point!)...
>
>
> Do you have any idea of why this ScaFactory cannot resolve "composite"???
>
>
> Regards,
> Mickael
Re: Load an SCA composite model programmatically [message #5312 is a reply to message #5246] Wed, 04 February 2009 16:23 Go to previous message
Eclipse User
Originally posted by: mickael.istria.openwide.fr

Thanks Stephane,
it works!

Mickael

Stephane Drapeau a écrit :
> Hi Mickael,
>
> Use the SCA resource factory
> (org.eclipse.stp.sca.util.ScaResourceFactoryImpl) instead of the XMI
> resource factory.
>
> Regards,
>
> Stephane Drapeau
> Obeo
>
> Mickael Istria a écrit :
>> Hi all,
>>
>> I'm trying to load an SCA model programmatically to get data form a
>> ..composite file by navigating in the EMF objects instead of using a
>> ugly XPath resolver. I'm using SCA editor and metamodel v1.0.1
>>
>> However, when using the classic EMF code to load a Resource:
>> // Create a resource set.
>> ResourceSet resourceSet = new ResourceSetImpl();
>> // Register the default resource factory -- only needed for
>> // stand-alone!
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>> new XMIResourceFactoryImpl());
>> // Get the URI of the model file.
>> URI fileURI = URI.createFileURI(new
>> File(scaApp.getCompositeFile()).getAbsolutePath());
>> // Demand load the resource for this file.
>> Resource resource = resourceSet.getResource(fileURI, true);
>> Composite compositeModel = (Composite)resource.getContents().get(0);
>>
>> on a composite file generated with the sca modeler (so conform to the
>> SCA metamodel), I got the following error:
>>
>> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'composite'
>> not found.
>> (file:/home/mistria/runtime-EclipseApplication/test/default. composite,
>> 2, 78)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2229)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2220)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1318)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
>>
>> ....
>>
>> When looking at variables when the exception is raised, it seems like
>> the ScaFactory is found and used to unserialize model (a good point!)...
>>
>>
>> Do you have any idea of why this ScaFactory cannot resolve "composite"???
>>
>>
>> Regards,
>> Mickael
Re: Load an SCA composite model programmatically [message #574114 is a reply to message #5178] Wed, 04 February 2009 16:09 Go to previous message
Stephane Drapeau is currently offline Stephane Drapeau
Messages: 198
Registered: July 2009
Senior Member
Hi Mickael,

Use the SCA resource factory
(org.eclipse.stp.sca.util.ScaResourceFactoryImpl) instead of the XMI
resource factory.

Regards,

Stephane Drapeau
Obeo

Mickael Istria a écrit :
> Hi all,
>
> I'm trying to load an SCA model programmatically to get data form a
> ..composite file by navigating in the EMF objects instead of using a
> ugly XPath resolver. I'm using SCA editor and metamodel v1.0.1
>
> However, when using the classic EMF code to load a Resource:
> // Create a resource set.
> ResourceSet resourceSet = new ResourceSetImpl();
> // Register the default resource factory -- only needed for
> // stand-alone!
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new XMIResourceFactoryImpl());
> // Get the URI of the model file.
> URI fileURI = URI.createFileURI(new
> File(scaApp.getCompositeFile()).getAbsolutePath());
> // Demand load the resource for this file.
> Resource resource = resourceSet.getResource(fileURI, true);
> Composite compositeModel = (Composite)resource.getContents().get(0);
>
> on a composite file generated with the sca modeler (so conform to the
> SCA metamodel), I got the following error:
>
> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'composite' not
> found.
> (file:/home/mistria/runtime-EclipseApplication/test/default. composite,
> 2, 78)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2229)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2220)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1318)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
>
> ....
>
> When looking at variables when the exception is raised, it seems like
> the ScaFactory is found and used to unserialize model (a good point!)...
>
>
> Do you have any idea of why this ScaFactory cannot resolve "composite"???
>
>
> Regards,
> Mickael
Re: Load an SCA composite model programmatically [message #574188 is a reply to message #5246] Wed, 04 February 2009 16:23 Go to previous message
Mickael Istria is currently offline Mickael Istria
Messages: 765
Registered: July 2009
Location: Grenoble, France
Senior Member
Thanks Stephane,
it works!

Mickael

Stephane Drapeau a écrit :
> Hi Mickael,
>
> Use the SCA resource factory
> (org.eclipse.stp.sca.util.ScaResourceFactoryImpl) instead of the XMI
> resource factory.
>
> Regards,
>
> Stephane Drapeau
> Obeo
>
> Mickael Istria a écrit :
>> Hi all,
>>
>> I'm trying to load an SCA model programmatically to get data form a
>> ..composite file by navigating in the EMF objects instead of using a
>> ugly XPath resolver. I'm using SCA editor and metamodel v1.0.1
>>
>> However, when using the classic EMF code to load a Resource:
>> // Create a resource set.
>> ResourceSet resourceSet = new ResourceSetImpl();
>> // Register the default resource factory -- only needed for
>> // stand-alone!
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>> new XMIResourceFactoryImpl());
>> // Get the URI of the model file.
>> URI fileURI = URI.createFileURI(new
>> File(scaApp.getCompositeFile()).getAbsolutePath());
>> // Demand load the resource for this file.
>> Resource resource = resourceSet.getResource(fileURI, true);
>> Composite compositeModel = (Composite)resource.getContents().get(0);
>>
>> on a composite file generated with the sca modeler (so conform to the
>> SCA metamodel), I got the following error:
>>
>> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'composite'
>> not found.
>> (file:/home/mistria/runtime-EclipseApplication/test/default. composite,
>> 2, 78)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2229)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObje ctFromFactory(XMLHandler.java:2220)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1318)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
>>
>> ....
>>
>> When looking at variables when the exception is raised, it seems like
>> the ScaFactory is found and used to unserialize model (a good point!)...
>>
>>
>> Do you have any idea of why this ScaFactory cannot resolve "composite"???
>>
>>
>> Regards,
>> Mickael
Previous Topic:Load an SCA composite model programmatically
Next Topic:Creating an initialized SCA diagram file programmatically
Goto Forum:
  


Current Time: Sat Oct 25 10:22:58 GMT 2014

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

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