summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-23 15:29:48 (EDT)
committerEike Stepper2006-10-23 15:29:48 (EDT)
commitc723d4a246535c397b0d67c7b2ec31273964256b (patch)
tree07ed148038aa145418188c5bb5cfcf2574334d79
parent23c06b895f9b472914055e7ad751163203d7a272 (diff)
downloadcdo-c723d4a246535c397b0d67c7b2ec31273964256b.zip
cdo-c723d4a246535c397b0d67c7b2ec31273964256b.tar.gz
cdo-c723d4a246535c397b0d67c7b2ec31273964256b.tar.bz2
Net4jFactory
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java1
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java98
2 files changed, 98 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
index 4bc7693..8cad688 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPUtil.java
@@ -26,7 +26,6 @@ public final class TCPUtil
public static String toString(ServerSocketChannel channel)
{
return channel.toString();
- // + "]";
}
public static String toString(SocketChannel channel)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java
new file mode 100644
index 0000000..1e5e635
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java
@@ -0,0 +1,98 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.net4j;
+
+import org.eclipse.net4j.transport.BufferProvider;
+import org.eclipse.net4j.transport.tcp.TCPAcceptor;
+import org.eclipse.net4j.transport.tcp.TCPConnector;
+import org.eclipse.net4j.transport.tcp.TCPSelector;
+
+import org.eclipse.internal.net4j.transport.BufferFactoryImpl;
+import org.eclipse.internal.net4j.transport.BufferPoolImpl;
+import org.eclipse.internal.net4j.transport.BufferUtil;
+import org.eclipse.internal.net4j.transport.tcp.ClientTCPConnectorImpl;
+import org.eclipse.internal.net4j.transport.tcp.TCPAcceptorImpl;
+import org.eclipse.internal.net4j.transport.tcp.TCPSelectorImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public final class Net4jFactory
+{
+ private Net4jFactory()
+ {
+ }
+
+ public static BufferProvider createBufferFactory(short bufferCapacity)
+ {
+ return new BufferFactoryImpl(bufferCapacity);
+ }
+
+ public static BufferProvider createBufferFactory()
+ {
+ return new BufferFactoryImpl(BufferUtil.DEFAULT_BUFFER_CAPACITY);
+ }
+
+ public static BufferProvider createBufferPool(BufferProvider factory)
+ {
+ return new BufferPoolImpl(factory);
+ }
+
+ public static BufferProvider createBufferPool(short bufferCapacity)
+ {
+ return createBufferPool(createBufferFactory(bufferCapacity));
+ }
+
+ public static BufferProvider createBufferPool()
+ {
+ return createBufferPool(BufferUtil.DEFAULT_BUFFER_CAPACITY);
+ }
+
+ public static TCPSelector createTCPSelector()
+ {
+ TCPSelectorImpl selector = new TCPSelectorImpl();
+ return selector;
+ }
+
+ public static TCPAcceptor createTCPAcceptor(BufferProvider bufferProvider, TCPSelector selector,
+ String address, int port)
+ {
+ TCPAcceptorImpl acceptor = new TCPAcceptorImpl();
+ acceptor.setBufferProvider(bufferProvider);
+ acceptor.setSelector(selector);
+ acceptor.setListenPort(port);
+ acceptor.setListenAddr(address);
+ return acceptor;
+ }
+
+ public static TCPAcceptor createTCPAcceptor(BufferProvider bufferProvider, TCPSelector selector)
+ {
+ return createTCPAcceptor(bufferProvider, selector, TCPAcceptor.DEFAULT_ADDRESS,
+ TCPAcceptor.DEFAULT_PORT);
+ }
+
+ public static TCPConnector createTCPConnector(BufferProvider bufferProvider,
+ TCPSelector selector, String host, int port)
+ {
+ ClientTCPConnectorImpl connector = new ClientTCPConnectorImpl();
+ connector.setBufferProvider(bufferProvider);
+ connector.setSelector(selector);
+ connector.setHost(host);
+ connector.setPort(port);
+ return connector;
+ }
+
+ public static TCPConnector createTCPConnector(BufferProvider bufferProvider,
+ TCPSelector selector, String host)
+ {
+ return createTCPConnector(bufferProvider, selector, host, TCPConnector.DEFAULT_PORT);
+ }
+}