Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » CDO standalone
CDO standalone [message #110218] Wed, 30 January 2008 09:06 Go to next message
Eclipse UserFriend
Hi Eike,
For the CDO Teneo integration, I can just work with the standalone cdo version probably, correct?

I remember that you posted some code for standalone cdo somewhere, can you repost it for me?

Thanks!

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: CDO standalone [message #110330 is a reply to message #110218] Wed, 30 January 2008 09:24 Go to previous message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

This is a multi-part message in MIME format.
--------------060508000704090200020809
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin Taal schrieb:
> Hi Eike,
> For the CDO Teneo integration, I can just work with the standalone cdo
> version probably, correct?
Yes, I'd choose the easiest setup: client and server in one vm, start
with a MEMStore and look at its implementation.


>
> I remember that you posted some code for standalone cdo somewhere, can
> you repost it for me?
I think you mean the one I gave Stefan. It's also in CVS:
org.eclipse.emf.cdo.tests.ImportXML
Here's the code:

|/********************************************************** *****************
* Copyright (c) 2004 - 2008 Eike Stepper, Germany.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
************************************************************ **************/
*package *org.eclipse.emf.cdo.tests;

*import *org.eclipse.emf.cdo.CDOSession;
*import *org.eclipse.emf.cdo.CDOTransaction;
*import *org.eclipse.emf.cdo.server.CDOServerUtil;
*import *org.eclipse.emf.cdo.server.IRepository;
*import *org.eclipse.emf.cdo.server.IStore;
*import *org.eclipse.emf.cdo.server.StoreUtil;
*import *org.eclipse.emf.cdo.server.IRepository.Props;
*import *org.eclipse.emf.cdo.tests.model1.Category;
*import *org.eclipse.emf.cdo.tests.model1.Model1Factory;
*import *org.eclipse.emf.cdo.tests.model1.Model1Package;
*import *org.eclipse.emf.cdo.tests.model1.Product;
*import *org.eclipse.emf.cdo.util.CDOUtil;

*import *org.eclipse.net4j.Net4jUtil;
*import *org.eclipse.net4j.connector.IConnector;
*import *org.eclipse.net4j.jvm.JVMUtil;
*import *org.eclipse.net4j.util.container.ContainerUtil;
*import *org.eclipse.net4j.util.container.IManagedContainer;
*import *org.eclipse.net4j.util.om.OMPlatform;

*import *org.eclipse.emf.ecore.EObject;
*import *org.eclipse.emf.ecore.resource.Resource;

*import *java.util.HashMap;
*import *java.util.Map;

/**
* @author Eike Stepper
*/
*public class *ImportXML
{
*private static final *String REPOSITORY_NAME = "repo1";

*public static **void *main(String[] args)
{
// Turn on tracing
OMPlatform.INSTANCE.setDebugging(*true*);

// Prepare the standalone infra structure (not needed when running inside Eclipse)
IManagedContainer container = ContainerUtil.createContainer(); // Create a wiring container
Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
JVMUtil.prepareContainer(container); // Prepare the JVM transport
CDOServerUtil.prepareContainer(container); // Prepare the CDO server
CDOUtil.prepareContainer(container, *false*); // Prepare the CDO client

// Start the transport and create a repository
JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository

// Establish a communications connection and open a session with the repository
IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
CDOSession session = CDOUtil.openSession(connector, REPOSITORY_NAME, *true*);// Open a CDO session
session.getPackageRegistry().putEPackage(Model1Package.eINST ANCE);// Not needed after first commit!!!

CDOTransaction transaction = session.openTransaction();// Open a CDO transaction
Resource resource = transaction.createResource("/my/big/resource");// Create a new EMF resource

// Work normally with the EMF resource
EObject inputModel = getInputModel();
resource.getContents().add(inputModel);
transaction.commit();
session.close();
connector.disconnect();
}

*private static *IRepository createRepository()
{
Map<String, String> props = *new *HashMap<String, String>();
props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "true");
props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
*return *CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
}

*private static *IStore createStore()
{
// You might want to create an IDBStore here instead if memory is an issue!
*return *StoreUtil.createMEMStore();
}

*private static *EObject getInputModel()
{
Category cat1 = Model1Factory.eINSTANCE.createCategory();
cat1.setName("CAT1");
Category cat2 = Model1Factory.eINSTANCE.createCategory();
cat2.setName("CAT2");
cat1.getCategories().add(cat2);
Product p1 = Model1Factory.eINSTANCE.createProduct();
p1.setName("P1");
cat1.getProducts().add(p1);
Product p2 = Model1Factory.eINSTANCE.createProduct();
p2.setName("P2");
cat1.getProducts().add(p2);
Product p3 = Model1Factory.eINSTANCE.createProduct();
p3.setName("P3");
cat2.getProducts().add(p3);
*return *cat1;
}
}|


It works out of the box here as a Java Application launch config.

Regards,
Eike Stepper
----
http://wiki.eclipse.org/CDO
http://wiki.eclipse.org/Net4j



--------------060508000704090200020809
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin Taal schrieb:
<blockquote cite="mid:fnq09p$28r$1@build.eclipse.org" type="cite">Hi
Eike,
<br>
For the CDO Teneo integration, I can just work with the standalone cdo
version probably, correct?
<br>
</blockquote>
Yes, I'd choose the easiest setup: client and server in one vm, start
with a MEMStore and look at its implementation.<br>
<br>
<br>
<blockquote cite="mid:fnq09p$28r$1@build.eclipse.org" type="cite"><br>
I remember that you posted some code for standalone cdo somewhere, can
you repost it for me?
<br>
</blockquote>
I think you mean the one I gave Stefan. It's also in CVS:
org.eclipse.emf.cdo.tests.ImportXML<br>
Here's the code:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#3f5fbf"> /*********************************************************** **************** </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;Copyright&nbsp;(c)&nbsp;2004&nbsp;-&a mp;nbsp;2008&nbsp;Eike&nbsp;Stepper,&nbsp;German y. </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;All&nbsp;rights&nbsp;reserved.&nbsp;T his&nbsp;program&nbsp;and&nbsp;the&nbsp;acco mpanying&nbsp;materials </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;are&nbsp;made&nbsp;available&nbsp;und er&nbsp;the&nbsp;terms&nbsp;of&nbsp;the& nbsp;Eclipse&nbsp;Public&nbsp;License&nbsp;v1.0 </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;which&nbsp;accompanies&nbsp;this&nbsp ;distribution,&nbsp;and&nbsp;is&nbsp;available&a mp;nbsp;at </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;<a class="moz-txt-link-freetext" href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;Contributors:</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;&nbsp;&nbsp;&nbsp;Eike&nbsp;Stepp er&nbsp;-&nbsp;initial&nbsp;API&nbsp;and& ;nbsp;implementation </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> ************************************************************ **************/ </font><br>
<font color="#7f0055"><b>package&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests;</font><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.CDOSession;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.CDOTransaction;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.CDOServerUtil;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IRepository;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IStore;</font> <br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.StoreUtil;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IRepository.Props; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Category; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Model1Factory; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Model1Package; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Product;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.util.CDOUtil;</font><br >
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.Net4jUtil;</font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.connector.IConnector;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.jvm.JVMUtil;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.container.ContainerUtil; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.container.IManagedContainer; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.om.OMPlatform;</font ><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.ecore.EObject;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.ecore.resource.Resource;</font ><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.HashMap;</font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.Map;</font><br>
<font color="#ffffff"></font><br>
<font color="#3f5fbf">/**</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;</font><font
color="#7f9fbf">@author&nbsp;</font><font color="#3f5fbf">Eike&nbsp;Stepper</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*/</font><br>
<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font ><font
color="#000000">ImportXML</font><br>
<font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;final&nbsp; </b></font><font
color="#000000">String&nbsp;REPOSITORY_NAME&nbsp;=&nbsp; </font><font color="#2a00ff">"repo1"</font><font
color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;static&nbsp;</b></font ><font
color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">main</font><font
color="#000000">(</font><font color="#000000">String</font><font
color="#000000">[]&nbsp;</font><font color="#000000">args</font><font
color="#000000">)</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f">//&nbsp;Turn&nbsp;on&nbsp;tracing </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">OMPlatform.INSTANCE.setDebugging</font><font
color="#000000">(</font><font color="#7f0055"><b>true</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;standalone&nbs p;infra&nbsp;structure&nbsp;(not&nbsp;needed& ;nbsp;when&nbsp;running&nbsp;inside&nbsp;Eclipse ) </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> IManagedContainer&nbsp;container&nbsp;=&nbsp;Con tainerUtil.createContainer </font><font
color="#000000">()</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Create&nbsp;a&nbsp;wiring&nbsp;conta iner </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">Net4jUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;Net4j&nbsp;ker nel </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">JVMUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;JVM&nbsp;trans port </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOServerUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;CDO&nbsp;serve r </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#7f0055"><b>false</b></font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;CDO&nbsp;clien t </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Start&nbsp;the&nbsp;transport&nbsp;a nd&nbsp;create&nbsp;a&nbsp;repository </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">JVMUtil.getAcceptor</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#2a00ff">"default"</font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Start&nbsp;the&nbsp;JVM&nbsp;transpo rt </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOServerUtil.addRepository</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;createRepository</font ><font
color="#000000">())</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Start&nbsp;a&nbsp;CDO&nbsp;resposito ry </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Establish&nbsp;a&nbsp;communications& ;nbsp;connection&nbsp;and&nbsp;open&nbsp;a&n bsp;session&nbsp;with&nbsp;the&nbsp;repository </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> IConnector&nbsp;connector&nbsp;=&nbsp;JVMUtil.ge tConnector </font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#2a00ff">"default"</font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Open&nbsp;a&nbsp;JVM&nbsp;connection </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> CDOSession&nbsp;session&nbsp;=&nbsp;CDOUtil.open Session </font><font
color="#000000">(</font><font color="#000000">connector,&nbsp;REPOSITORY_NAME,&nbsp; </font><font
color="#7f0055"><b>true</b></font><font color="#000000">)</font><font
color="#000000">;</font><font color="#3f7f5f">//&nbsp;Open&nbsp;a&nbsp;CDO&nbsp;session </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">session.getPackageRegistry</font><font
color="#000000">()</font><font color="#000000">.putEPackage</font><font
color="#000000">(</font><font color="#000000">Model1Package.eINSTANCE</font><font
color="#000000">)</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Not&nbsp;needed&nbsp;after&nbsp;firs t&nbsp;commit!!! </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> CDOTransaction&nbsp;transaction&nbsp;=&nbsp;sess ion.openTransaction </font><font
color="#000000">()</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Open&nbsp;a&nbsp;CDO&nbsp;transactio n </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Resource&nbsp;resource&nbsp;=&nbsp;transaction.c reateResource </font><font
color="#000000">(</font><font color="#2a00ff">"/my/big/resource"</font><font
color="#000000">)</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Create&nbsp;a&nbsp;new&nbsp;EMF& nbsp;resource </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Work&nbsp;normally&nbsp;with&nbsp;th e&nbsp;EMF&nbsp;resource </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> EObject&nbsp;inputModel&nbsp;=&nbsp;getInputMode l </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">resource.getContents</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">inputModel</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">transaction.commit</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">session.close</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">connector.disconnect</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">IRepository&nbsp;createRepository</font ><font
color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Map&lt;String,&nbsp;String&gt;&nbsp;props&am p;nbsp;=&nbsp; </font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">HashMap&lt;String,&nbsp;String&gt; </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_SUPPORTING_REVISION_DELTAS,&nbsp; </font><font
color="#2a00ff">"true"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_CURRENT_LRU_CAPACITY,&nbsp; </font><font
color="#2a00ff">"10000"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_REVISED_LRU_CAPACITY,&nbsp; </font><font
color="#2a00ff">"10000"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">CDOServerUtil.createRepository</font><font
color="#000000">(</font><font color="#000000">REPOSITORY_NAME,&nbsp;createStore</font ><font
color="#000000">()</font><font color="#000000">,&nbsp;props</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">IStore&nbsp;createStore</font><font color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;You&nbsp;might&nbsp;want&nbsp;to& ;nbsp;create&nbsp;an&nbsp;IDBStore&nbsp;here& ;nbsp;instead&nbsp;if&nbsp;memory&nbsp;is&nb sp;an&nbsp;issue! </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">StoreUtil.createMEMStore</font><font color="#000000">()</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">EObject&nbsp;getInputModel</font><font color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Category&nbsp;cat1&nbsp;=&nbsp;Model1Factory.eIN STANCE.createCategory </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.setName</font><font
color="#000000">(</font><font color="#2a00ff">"CAT1"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Category&nbsp;cat2&nbsp;=&nbsp;Model1Factory.eIN STANCE.createCategory </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat2.setName</font><font
color="#000000">(</font><font color="#2a00ff">"CAT2"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getCategories</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">cat2</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p1&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p1.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P1"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p1</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p2&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p2.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P2"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p2</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p3&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p3.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P3"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat2.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p3</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">cat1;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#000000">}</font></code> </td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --> <br>
It works out of the box here as a Java Application launch config.<br>
<br>
Regards,<br>
Eike Stepper<br>
----<br>
<a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/CDO">http://wiki.eclipse.org/CDO</a><br>
<a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/Net4j">http://wiki.eclipse.org/Net4j</a><br>
<br>
<br>
</body>
</html>

--------------060508000704090200020809--
Re: CDO standalone [message #614340 is a reply to message #110218] Wed, 30 January 2008 09:24 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------060508000704090200020809
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin Taal schrieb:
> Hi Eike,
> For the CDO Teneo integration, I can just work with the standalone cdo
> version probably, correct?
Yes, I'd choose the easiest setup: client and server in one vm, start
with a MEMStore and look at its implementation.


>
> I remember that you posted some code for standalone cdo somewhere, can
> you repost it for me?
I think you mean the one I gave Stefan. It's also in CVS:
org.eclipse.emf.cdo.tests.ImportXML
Here's the code:

|/********************************************************** *****************
* Copyright (c) 2004 - 2008 Eike Stepper, Germany.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
************************************************************ **************/
*package *org.eclipse.emf.cdo.tests;

*import *org.eclipse.emf.cdo.CDOSession;
*import *org.eclipse.emf.cdo.CDOTransaction;
*import *org.eclipse.emf.cdo.server.CDOServerUtil;
*import *org.eclipse.emf.cdo.server.IRepository;
*import *org.eclipse.emf.cdo.server.IStore;
*import *org.eclipse.emf.cdo.server.StoreUtil;
*import *org.eclipse.emf.cdo.server.IRepository.Props;
*import *org.eclipse.emf.cdo.tests.model1.Category;
*import *org.eclipse.emf.cdo.tests.model1.Model1Factory;
*import *org.eclipse.emf.cdo.tests.model1.Model1Package;
*import *org.eclipse.emf.cdo.tests.model1.Product;
*import *org.eclipse.emf.cdo.util.CDOUtil;

*import *org.eclipse.net4j.Net4jUtil;
*import *org.eclipse.net4j.connector.IConnector;
*import *org.eclipse.net4j.jvm.JVMUtil;
*import *org.eclipse.net4j.util.container.ContainerUtil;
*import *org.eclipse.net4j.util.container.IManagedContainer;
*import *org.eclipse.net4j.util.om.OMPlatform;

*import *org.eclipse.emf.ecore.EObject;
*import *org.eclipse.emf.ecore.resource.Resource;

*import *java.util.HashMap;
*import *java.util.Map;

/**
* @author Eike Stepper
*/
*public class *ImportXML
{
*private static final *String REPOSITORY_NAME = "repo1";

*public static **void *main(String[] args)
{
// Turn on tracing
OMPlatform.INSTANCE.setDebugging(*true*);

// Prepare the standalone infra structure (not needed when running inside Eclipse)
IManagedContainer container = ContainerUtil.createContainer(); // Create a wiring container
Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
JVMUtil.prepareContainer(container); // Prepare the JVM transport
CDOServerUtil.prepareContainer(container); // Prepare the CDO server
CDOUtil.prepareContainer(container, *false*); // Prepare the CDO client

// Start the transport and create a repository
JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository

// Establish a communications connection and open a session with the repository
IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
CDOSession session = CDOUtil.openSession(connector, REPOSITORY_NAME, *true*);// Open a CDO session
session.getPackageRegistry().putEPackage(Model1Package.eINST ANCE);// Not needed after first commit!!!

CDOTransaction transaction = session.openTransaction();// Open a CDO transaction
Resource resource = transaction.createResource("/my/big/resource");// Create a new EMF resource

// Work normally with the EMF resource
EObject inputModel = getInputModel();
resource.getContents().add(inputModel);
transaction.commit();
session.close();
connector.disconnect();
}

*private static *IRepository createRepository()
{
Map<String, String> props = *new *HashMap<String, String>();
props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "true");
props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
*return *CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
}

*private static *IStore createStore()
{
// You might want to create an IDBStore here instead if memory is an issue!
*return *StoreUtil.createMEMStore();
}

*private static *EObject getInputModel()
{
Category cat1 = Model1Factory.eINSTANCE.createCategory();
cat1.setName("CAT1");
Category cat2 = Model1Factory.eINSTANCE.createCategory();
cat2.setName("CAT2");
cat1.getCategories().add(cat2);
Product p1 = Model1Factory.eINSTANCE.createProduct();
p1.setName("P1");
cat1.getProducts().add(p1);
Product p2 = Model1Factory.eINSTANCE.createProduct();
p2.setName("P2");
cat1.getProducts().add(p2);
Product p3 = Model1Factory.eINSTANCE.createProduct();
p3.setName("P3");
cat2.getProducts().add(p3);
*return *cat1;
}
}|


It works out of the box here as a Java Application launch config.

Regards,
Eike Stepper
----
http://wiki.eclipse.org/CDO
http://wiki.eclipse.org/Net4j



--------------060508000704090200020809
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin Taal schrieb:
<blockquote cite="mid:fnq09p$28r$1@build.eclipse.org" type="cite">Hi
Eike,
<br>
For the CDO Teneo integration, I can just work with the standalone cdo
version probably, correct?
<br>
</blockquote>
Yes, I'd choose the easiest setup: client and server in one vm, start
with a MEMStore and look at its implementation.<br>
<br>
<br>
<blockquote cite="mid:fnq09p$28r$1@build.eclipse.org" type="cite"><br>
I remember that you posted some code for standalone cdo somewhere, can
you repost it for me?
<br>
</blockquote>
I think you mean the one I gave Stefan. It's also in CVS:
org.eclipse.emf.cdo.tests.ImportXML<br>
Here's the code:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#3f5fbf"> /*********************************************************** **************** </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;Copyright&nbsp;(c)&nbsp;2004&nbsp;-&a mp;nbsp;2008&nbsp;Eike&nbsp;Stepper,&nbsp;German y. </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;All&nbsp;rights&nbsp;reserved.&nbsp;T his&nbsp;program&nbsp;and&nbsp;the&nbsp;acco mpanying&nbsp;materials </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;are&nbsp;made&nbsp;available&nbsp;und er&nbsp;the&nbsp;terms&nbsp;of&nbsp;the& nbsp;Eclipse&nbsp;Public&nbsp;License&nbsp;v1.0 </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;which&nbsp;accompanies&nbsp;this&nbsp ;distribution,&nbsp;and&nbsp;is&nbsp;available&a mp;nbsp;at </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;<a class="moz-txt-link-freetext" href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;Contributors:</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> *&nbsp;&nbsp;&nbsp;&nbsp;Eike&nbsp;Stepp er&nbsp;-&nbsp;initial&nbsp;API&nbsp;and& ;nbsp;implementation </font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf"> ************************************************************ **************/ </font><br>
<font color="#7f0055"><b>package&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests;</font><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.CDOSession;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.CDOTransaction;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.CDOServerUtil;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IRepository;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IStore;</font> <br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.StoreUtil;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.server.IRepository.Props; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Category; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Model1Factory; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Model1Package; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.tests.model1.Product;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.cdo.util.CDOUtil;</font><br >
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.Net4jUtil;</font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.connector.IConnector;</font ><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.jvm.JVMUtil;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.container.ContainerUtil; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.container.IManagedContainer; </font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.net4j.util.om.OMPlatform;</font ><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.ecore.EObject;</font><br >
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">org.eclipse.emf.ecore.resource.Resource;</font ><br>
<font color="#ffffff"></font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.HashMap;</font><br>
<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.Map;</font><br>
<font color="#ffffff"></font><br>
<font color="#3f5fbf">/**</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;</font><font
color="#7f9fbf">@author&nbsp;</font><font color="#3f5fbf">Eike&nbsp;Stepper</font><br>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*/</font><br>
<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font ><font
color="#000000">ImportXML</font><br>
<font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;final&nbsp; </b></font><font
color="#000000">String&nbsp;REPOSITORY_NAME&nbsp;=&nbsp; </font><font color="#2a00ff">"repo1"</font><font
color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;static&nbsp;</b></font ><font
color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">main</font><font
color="#000000">(</font><font color="#000000">String</font><font
color="#000000">[]&nbsp;</font><font color="#000000">args</font><font
color="#000000">)</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f">//&nbsp;Turn&nbsp;on&nbsp;tracing </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">OMPlatform.INSTANCE.setDebugging</font><font
color="#000000">(</font><font color="#7f0055"><b>true</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;standalone&nbs p;infra&nbsp;structure&nbsp;(not&nbsp;needed& ;nbsp;when&nbsp;running&nbsp;inside&nbsp;Eclipse ) </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> IManagedContainer&nbsp;container&nbsp;=&nbsp;Con tainerUtil.createContainer </font><font
color="#000000">()</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Create&nbsp;a&nbsp;wiring&nbsp;conta iner </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">Net4jUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;Net4j&nbsp;ker nel </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">JVMUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;JVM&nbsp;trans port </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOServerUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container</font><font
color="#000000">)</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;CDO&nbsp;serve r </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOUtil.prepareContainer</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#7f0055"><b>false</b></font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Prepare&nbsp;the&nbsp;CDO&nbsp;clien t </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Start&nbsp;the&nbsp;transport&nbsp;a nd&nbsp;create&nbsp;a&nbsp;repository </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">JVMUtil.getAcceptor</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#2a00ff">"default"</font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Start&nbsp;the&nbsp;JVM&nbsp;transpo rt </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">CDOServerUtil.addRepository</font><font
color="#000000">(</font><font color="#000000">container,&nbsp;createRepository</font ><font
color="#000000">())</font><font color="#000000">;&nbsp;</font><font
color="#3f7f5f"> //&nbsp;Start&nbsp;a&nbsp;CDO&nbsp;resposito ry </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Establish&nbsp;a&nbsp;communications& ;nbsp;connection&nbsp;and&nbsp;open&nbsp;a&n bsp;session&nbsp;with&nbsp;the&nbsp;repository </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> IConnector&nbsp;connector&nbsp;=&nbsp;JVMUtil.ge tConnector </font><font
color="#000000">(</font><font color="#000000">container,&nbsp;</font><font
color="#2a00ff">"default"</font><font color="#000000">)</font><font
color="#000000">;&nbsp;</font><font color="#3f7f5f"> //&nbsp;Open&nbsp;a&nbsp;JVM&nbsp;connection </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> CDOSession&nbsp;session&nbsp;=&nbsp;CDOUtil.open Session </font><font
color="#000000">(</font><font color="#000000">connector,&nbsp;REPOSITORY_NAME,&nbsp; </font><font
color="#7f0055"><b>true</b></font><font color="#000000">)</font><font
color="#000000">;</font><font color="#3f7f5f">//&nbsp;Open&nbsp;a&nbsp;CDO&nbsp;session </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">session.getPackageRegistry</font><font
color="#000000">()</font><font color="#000000">.putEPackage</font><font
color="#000000">(</font><font color="#000000">Model1Package.eINSTANCE</font><font
color="#000000">)</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Not&nbsp;needed&nbsp;after&nbsp;firs t&nbsp;commit!!! </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> CDOTransaction&nbsp;transaction&nbsp;=&nbsp;sess ion.openTransaction </font><font
color="#000000">()</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Open&nbsp;a&nbsp;CDO&nbsp;transactio n </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Resource&nbsp;resource&nbsp;=&nbsp;transaction.c reateResource </font><font
color="#000000">(</font><font color="#2a00ff">"/my/big/resource"</font><font
color="#000000">)</font><font color="#000000">;</font><font
color="#3f7f5f"> //&nbsp;Create&nbsp;a&nbsp;new&nbsp;EMF& nbsp;resource </font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;Work&nbsp;normally&nbsp;with&nbsp;th e&nbsp;EMF&nbsp;resource </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> EObject&nbsp;inputModel&nbsp;=&nbsp;getInputMode l </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">resource.getContents</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">inputModel</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">transaction.commit</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">session.close</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">connector.disconnect</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">IRepository&nbsp;createRepository</font ><font
color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Map&lt;String,&nbsp;String&gt;&nbsp;props&am p;nbsp;=&nbsp; </font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">HashMap&lt;String,&nbsp;String&gt; </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_SUPPORTING_REVISION_DELTAS,&nbsp; </font><font
color="#2a00ff">"true"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_CURRENT_LRU_CAPACITY,&nbsp; </font><font
color="#2a00ff">"10000"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">props.put</font><font
color="#000000">(</font><font color="#000000">Props.PROP_REVISED_LRU_CAPACITY,&nbsp; </font><font
color="#2a00ff">"10000"</font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">CDOServerUtil.createRepository</font><font
color="#000000">(</font><font color="#000000">REPOSITORY_NAME,&nbsp;createStore</font ><font
color="#000000">()</font><font color="#000000">,&nbsp;props</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">IStore&nbsp;createStore</font><font color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#3f7f5f"> //&nbsp;You&nbsp;might&nbsp;want&nbsp;to& ;nbsp;create&nbsp;an&nbsp;IDBStore&nbsp;here& ;nbsp;instead&nbsp;if&nbsp;memory&nbsp;is&nb sp;an&nbsp;issue! </font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">StoreUtil.createMEMStore</font><font color="#000000">()</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;static&nbsp;</b> </font><font
color="#000000">EObject&nbsp;getInputModel</font><font color="#000000">()</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Category&nbsp;cat1&nbsp;=&nbsp;Model1Factory.eIN STANCE.createCategory </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.setName</font><font
color="#000000">(</font><font color="#2a00ff">"CAT1"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Category&nbsp;cat2&nbsp;=&nbsp;Model1Factory.eIN STANCE.createCategory </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat2.setName</font><font
color="#000000">(</font><font color="#2a00ff">"CAT2"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getCategories</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">cat2</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p1&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p1.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P1"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p1</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p2&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p2.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P2"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat1.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p2</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000"> Product&nbsp;p3&nbsp;=&nbsp;Model1Factory.eINSTA NCE.createProduct </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">p3.setName</font><font
color="#000000">(</font><font color="#2a00ff">"P3"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">cat2.getProducts</font><font
color="#000000">()</font><font color="#000000">.add</font><font
color="#000000">(</font><font color="#000000">p3</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>return&nbsp;</b></font><font
color="#000000">cat1;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br>
<font color="#000000">}</font></code> </td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --> <br>
It works out of the box here as a Java Application launch config.<br>
<br>
Regards,<br>
Eike Stepper<br>
----<br>
<a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/CDO">http://wiki.eclipse.org/CDO</a><br>
<a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/Net4j">http://wiki.eclipse.org/Net4j</a><br>
<br>
<br>
</body>
</html>

--------------060508000704090200020809--
Previous Topic:CDO standalone
Next Topic:Teneo or CDO?
Goto Forum:
  


Current Time: Tue Jul 22 13:58:19 EDT 2025

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

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

Back to the top