summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-31 14:04:53 (EDT)
committerEike Stepper2008-05-31 14:04:53 (EDT)
commit0e1f9a92042a83a6df23bc21718223c6cd05a742 (patch)
tree35ba97db107e996228439bf89de519edf6b727a2
parentf4b878cc6ee276bb82a93f6b6c1a5a3425111ea3 (diff)
downloadcdo-0e1f9a92042a83a6df23bc21718223c6cd05a742.zip
cdo-0e1f9a92042a83a6df23bc21718223c6cd05a742.tar.gz
cdo-0e1f9a92042a83a6df23bc21718223c6cd05a742.tar.bz2
Added example for client API usage
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/internal/examples/bundle/Examples.java55
2 files changed, 57 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
index 5a9d99c..1c3d7ac 100644
--- a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
@@ -10,5 +10,6 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
- org.eclipse.net4j.tcp;bundle-version="[1.0.0,2.0.0)";visibility:=reexport
+ org.eclipse.net4j.tcp;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.model1;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/internal/examples/bundle/Examples.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/internal/examples/bundle/Examples.java
new file mode 100644
index 0000000..5f9dde4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/internal/examples/bundle/Examples.java
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * 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.internal.examples.bundle;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.net4j.connector.IConnector;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Eike Stepper
+ */
+public class Examples
+{
+ public static void commonPattern()
+ {
+ IConnector connector = getConnector();
+
+ CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
+ configuration.setConnector(connector);
+ configuration.setRepositoryName("my-repo");
+
+ CDOSession session = configuration.openSession();
+ session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource("/path/to/my/resource");
+
+ EObject object = Model1Factory.eINSTANCE.createCompany();
+ resource.getContents().add(object);
+
+ transaction.commit();
+ session.close();
+ }
+
+ private static IConnector getConnector()
+ {
+ throw new UnsupportedOperationException();
+ }
+}