Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-06-17 09:41:26 +0000
committerEike Stepper2008-06-17 09:41:26 +0000
commitda24208ebd0f5e1486ae5af7461c242a6271f718 (patch)
tree625368fe304291475eff6601865c5efef7bc84f7 /plugins
parente1c686baa817bffd0ea4436412b516d036b68c98 (diff)
downloadcdo-da24208ebd0f5e1486ae5af7461c242a6271f718.tar.gz
cdo-da24208ebd0f5e1486ae5af7461c242a6271f718.tar.xz
cdo-da24208ebd0f5e1486ae5af7461c242a6271f718.zip
*** empty log message ***
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneTCPExample.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneTCPExample.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneTCPExample.java
index 9a14644dab..23ea587b35 100644
--- a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneTCPExample.java
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneTCPExample.java
@@ -23,6 +23,7 @@ import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.tcp.TCPUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.emf.ecore.EObject;
@@ -33,26 +34,37 @@ public class StandaloneTCPExample
{
public static void main(String[] args)
{
+ // Prepare container
IManagedContainer container = ContainerUtil.createContainer();
Net4jUtil.prepareContainer(container); // Register Net4j factories
TCPUtil.prepareContainer(container); // Register TCP factories
CDOUtil.prepareContainer(container, false); // Register CDO factories
+
+ // Create connector
IConnector connector = TCPUtil.getConnector(container, "localhost:2036");
+ // Create configuration
CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
configuration.setConnector(connector);
configuration.setRepositoryName("my-repo");
+ // Open session
CDOSession session = configuration.openSession();
session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
+ // Open transaction
CDOTransaction transaction = session.openTransaction();
+
+ // Get or create resource
CDOResource resource = transaction.getOrCreateResource("/path/to/my/resource");
+ // Work with the resource and commit the transaction
EObject object = Model1Factory.eINSTANCE.createCompany();
resource.getContents().add(object);
-
transaction.commit();
+
+ // Cleanup
session.close();
+ LifecycleUtil.deactivate(connector);
}
}

Back to the top