Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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 UserFriend
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 DrapeauFriend
Messages: 199
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 UserFriend
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 DrapeauFriend
Messages: 199
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 IstriaFriend
Messages: 865
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: Fri Apr 19 17:09:34 GMT 2024

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

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

Back to the top