diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneManualExample.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneManualExample.java | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneManualExample.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneManualExample.java deleted file mode 100644 index d5f018577d..0000000000 --- a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/StandaloneManualExample.java +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** - * 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.examples; - -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.Net4jUtil; -import org.eclipse.net4j.buffer.IBufferProvider; -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.log.PrintLogHandler; -import org.eclipse.net4j.util.om.trace.PrintTraceHandler; -import org.eclipse.net4j.util.registry.HashMapRegistry; -import org.eclipse.net4j.util.registry.IRegistry; - -import org.eclipse.emf.ecore.EObject; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -/** - * @author Eike Stepper - */ -public class StandaloneManualExample -{ - @SuppressWarnings("restriction") - public static void main(String[] args) - { - // Enable logging and tracing - OMPlatform.INSTANCE.setDebugging(true); - OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE); - OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE); - - // Prepare receiveExecutor - final ThreadGroup threadGroup = new ThreadGroup("net4j"); - ExecutorService receiveExecutor = Executors.newCachedThreadPool(new ThreadFactory() - { - public Thread newThread(Runnable r) - { - Thread thread = new Thread(threadGroup, r); - thread.setDaemon(true); - return thread; - } - }); - - // Prepare bufferProvider - IBufferProvider bufferProvider = Net4jUtil.createBufferPool(); - LifecycleUtil.activate(bufferProvider); - - // Prepare protocolFactoryRegistry - IFactory protocolFactory = new org.eclipse.emf.internal.cdo.protocol.CDOClientProtocolFactory(); - IRegistry<IFactoryKey, IFactory> protocolFactoryRegistry = new HashMapRegistry<IFactoryKey, IFactory>(); - protocolFactoryRegistry.put(protocolFactory.getKey(), protocolFactory); - LifecycleUtil.activate(protocolFactoryRegistry); - - // Prepare selector - org.eclipse.net4j.internal.tcp.TCPSelector selector = new org.eclipse.net4j.internal.tcp.TCPSelector(); - selector.activate(); - - // Prepare connector - org.eclipse.net4j.internal.tcp.TCPClientConnector connector = new org.eclipse.net4j.internal.tcp.TCPClientConnector(); - connector.setReceiveExecutor(receiveExecutor); - connector.setBufferProvider(bufferProvider); - connector.setProtocolFactoryRegistry(protocolFactoryRegistry); - connector.setSelector(selector); - connector.setNegotiator(null); - connector.setHost("localhost"); - connector.setPort(2036); - connector.activate(); - - // Create configuration - CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration(); - configuration.setConnector(connector); - configuration.setRepositoryName("repo1"); - - // 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(); - connector.deactivate(); - } -} |