Edyta:
I would like to change the package names
from
org.eclipse.corona.server.container
org.eclipse.corona.server.container.project
to
org.eclipse.corona.container
org.eclipse.corona.container.project
since these packages will be use to
read/write containers on both the server and client side.
Glenn Everitt
From: corona-dev-bounces@xxxxxxxxxxx [mailto:corona-dev-bounces@xxxxxxxxxxx] On Behalf Of Kalka, Edyta
Sent: Friday, July 14, 2006 10:16
AM
To: Corona
development
Subject: [corona-dev] loading
ProjectContainer from an XML file
This is
a summary of mail thread between me and Glenn on loading project container from
an xml file:
So far for loading project container from
xml I used sdo/emf api but not the one generated from our model (from model
only factoryImpl, packageImpl were used).
To load project container I’ve done
the following:
ResourceSet resourceSet = SDOUtil.createResourceSet();
//
ProjectPackageImpl and ProjectFactoryImpl is from our generated model
ProjectPackageImpl.eINSTANCE.getName();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml",
new ProjectFactoryImpl());
ExtendedMetaData
metadata = new BasicExtendedMetaData(resourceSet.getPackageRegistry());
Map loadOptions =
new HashMap();
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, metaData);
FileInputStream
inputStream = new FileInputStream("D:/EclipseStuff/SDO/sampleEclipseProjectSdoModel.xml");
//
loading data graph with our serialized project container
DataGraph
dataGraph = SDOUtil.loadDataGraph(inputStream,
loadOptions);
inputStream.close();
//
retrieving our project container from data graph
ProjectContextContainer
root = (ProjectContextContainer)dataGraph.getRootObject();
String
containerName = root.getName();
String
containerUri = root.getContainerUri ();
System.out.println
(“project container name: ” + containerName);
System.out.println
(“project container uri: ” + containerUri);
Above api was used also inside some
emf/sdo performance tests.
Regarding manually creating a project
container:
I haven’t used editor but only
model.
After model code generation I run the project
as eclipse application and inside new eclipse workbench I create new project
and add to it data graph model with chosen:
model uri as http://www.eclipse.org/corona/server/container/project,
model object as ProjectContextContainer. Than I can define a project container
with the use of eclipse.
After opening defined project container
data graph model within text editor – it looks like:
<?xml version="1.0"
encoding="UTF-8"?>
<sdo:datagraph
xmlns:project="http://www.eclipse.org/corona/server/container/project"
xmlns:sdo="commonj.sdo">
<changeSummary xmlns=""/>
<project:project-context-container
name="SampleEclipseProject">
<container-uri>http://www.eclipse.org/corona/server/container/sampleEclipseProject</container-uri>
<container-path>
<container-path-element>http://www.eclipse.org/corona/server/container/sampleEclipseProject</container-path-element>
</container-path>
<container-type>http://www.eclipse.org/corona/server/containerTypes/eclipseProject</container-type>
<container-description>Sample eclipse
project</container-description>
<repositories>
<repository name="TeamMemberRepository"
type="http://www.eclipse.org/corona/repositoryTypes/xmlRepository"
uri="http://www.eclipse.org/corona/repository/TeamMemberRepository">
<description>Team member repository definition</description>
<repository-configurations
default-configuration-name="members_1">
<repository-configuration name="members_1">
<repository-connection-parameters>
<repository-connection-parameter name="fileURI"
value="file:///model/data/teamMembers.xml"/>
</repository-connection-parameters>
<resource-subset selection-criteria="//team/members"
type="http://www.eclipse.org/corona/server/resourceSubsetTypes/XPathResultSet"/>
</repository-configuration>
</repository-configurations>
</repository>
</repositories>
</project:project-context-container>
</sdo:datagraph>
And such xml is used as an input for loadDataGraph
method.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Regarding usage of generated model code
for project container loading:
There is a class called
ProjectXMLProcessor extending org.eclipse.emf.ecore.xmi.util.XMLProcessor.
It looks like
the only thing needed to load serialized model is to call this:
FileInputStream
inputStream = new FileInputStream("D:/EclipseStuff/SDO/sampleEclipseProjectSdoModel.xml");
ProjectXMLProcessor xmlProcessor = new ProjectXMLProcessor();
Resource
resource = xmlProcessor.load(inputStream, null);
However, junit
test fails with such trace:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
Package with uri 'commonj.sdo' not found.
(file:///D:/CORONA/ProjectContainer_20_06/sdoWorkspace1/pc8.tests/xml, 3, 29)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:80)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:189)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1089)
at org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcessor.java:232)
at
org.eclipse.corona.server.container.project.tests.ProjectContextContainerTest.load(ProjectContextContainerTest.java:96)
at
org.eclipse.corona.server.container.project.tests.ProjectContextContainerTest.testDeserializeProjectContextContainerWithGeneratedApi(ProjectContextContainerTest.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
org.eclipse.emf.commonj.sdo is included in
plugin dependencies.
Also adding such initialization before calling load on
project xml processor instance did not help:
ResourceSet resourceSet =
SDOUtil.createResourceSet();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml",
new ProjectFactoryImpl());
ExtendedMetaData
metadata = new BasicExtendedMetaData(resourceSet.getPackageRegistry());
Map loadOptions =
new HashMap();
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, metaData);
FileInputStream
inputStream = new FileInputStream("D:/EclipseStuff/SDO/sampleEclipseProjectSdoModel.xml");
ProjectXMLProcessor xmlProcessor = new ProjectXMLProcessor();
Resource
resource = xmlProcessor.load(inputStream, loadOptions);
The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the named addressee
or an authorized designee, you may not copy or use it, or disclose it to anyone
else. If you received it in error please notify us immediately and then destroy
it.
The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.