summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-01-07 10:21:49 (EST)
committerEike Stepper2007-01-07 10:21:49 (EST)
commit9affaca3a22f514927ccf90c21e0db68a52946fe (patch)
tree8711a1cd40959b70033624a7edf8f86f4970f2ce
parent7bbd0b7c934191cf9ee245a135a2e82c86eb4e3b (diff)
downloadcdo-9affaca3a22f514927ccf90c21e0db68a52946fe.zip
cdo-9affaca3a22f514927ccf90c21e0db68a52946fe.tar.gz
cdo-9affaca3a22f514927ccf90c21e0db68a52946fe.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ClientEmbeddedConnectorImpl.java37
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/EmbeddedUtil.java33
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ServerEmbeddedConnectorImpl.java9
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java8
10 files changed, 88 insertions, 52 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
index 3f14c60..5b143f9 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
@@ -13,6 +13,8 @@ package org.eclipse.internal.net4j.transport;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.transport.Connector.Type;
+import java.text.MessageFormat;
+
/**
* @author Eike Stepper
*/
@@ -36,4 +38,10 @@ public abstract class AbstractProtocolFactory implements ProtocolFactory
{
return isForClients() && isForServers();
}
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("Protocol.Factory({0}, {1})", getProtocolID(), getConnectorTypes());
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
index e14ddc8..bfbba2e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
@@ -6,9 +6,19 @@ import org.eclipse.net4j.util.registry.HashMapRegistry;
/**
* @author Eike Stepper
*/
-public final class ClientProtocolFactoryRegistry extends
- HashMapRegistry<String, ProtocolFactory>
+public final class ClientProtocolFactoryRegistry extends HashMapRegistry<String, ProtocolFactory>
{
+ public void register(ProtocolFactory factory)
+ {
+ String key = factory.getProtocolID();
+ if (containsKey(key))
+ {
+ throw new IllegalStateException("Duplicate key: " + factory);
+ }
+
+ put(key, factory);
+ }
+
@Override
protected ProtocolFactory register(String protocolName, ProtocolFactory factory)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
index cd2e621..db291e1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
@@ -6,9 +6,19 @@ import org.eclipse.net4j.util.registry.HashMapRegistry;
/**
* @author Eike Stepper
*/
-public final class ServerProtocolFactoryRegistry extends
- HashMapRegistry<String, ProtocolFactory>
+public final class ServerProtocolFactoryRegistry extends HashMapRegistry<String, ProtocolFactory>
{
+ public void register(ProtocolFactory factory)
+ {
+ String key = factory.getProtocolID();
+ if (containsKey(key))
+ {
+ throw new IllegalStateException("Duplicate key: " + factory);
+ }
+
+ put(key, factory);
+ }
+
@Override
protected ProtocolFactory register(String protocolName, ProtocolFactory factory)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
index ffbd48a..351e150 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
@@ -80,11 +80,4 @@ public abstract class AbstractEmbeddedConnector extends AbstractConnector
Buffer buffer = localQueue.poll();
peerChannel.handleBufferFromMultiplexer(buffer);
}
-
- @Override
- protected void onDeactivate() throws Exception
- {
- LifecycleUtil.deactivateNoisy(getPeer());
- super.onDeactivate();
- }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ClientEmbeddedConnectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ClientEmbeddedConnectorImpl.java
index 824348e..faa9406 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ClientEmbeddedConnectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ClientEmbeddedConnectorImpl.java
@@ -10,10 +10,15 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.embedded;
+import org.eclipse.net4j.util.lifecycle.LifecycleListener;
+import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
/**
* @author Eike Stepper
*/
-public class ClientEmbeddedConnectorImpl extends AbstractEmbeddedConnector
+public class ClientEmbeddedConnectorImpl extends AbstractEmbeddedConnector implements
+ LifecycleListener
{
public ClientEmbeddedConnectorImpl()
{
@@ -24,6 +29,20 @@ public class ClientEmbeddedConnectorImpl extends AbstractEmbeddedConnector
return Type.CLIENT;
}
+ public void notifyLifecycleAboutToActivate(LifecycleNotifier notifier)
+ {
+ }
+
+ public void notifyLifecycleActivated(LifecycleNotifier notifier)
+ {
+ }
+
+ public void notifyLifecycleDeactivating(LifecycleNotifier notifier)
+ {
+ setPeer(null);
+ deactivate();
+ }
+
@Override
protected void onActivate() throws Exception
{
@@ -31,8 +50,20 @@ public class ClientEmbeddedConnectorImpl extends AbstractEmbeddedConnector
setPeer(createServerPeer());
}
- protected AbstractEmbeddedConnector createServerPeer()
+ @Override
+ protected void onDeactivate() throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(getPeer());
+ super.onDeactivate();
+ }
+
+ protected AbstractEmbeddedConnector createServerPeer() throws Exception
{
- return new ServerEmbeddedConnectorImpl(this);
+ ServerEmbeddedConnectorImpl server = new ServerEmbeddedConnectorImpl(this);
+ server.setBufferProvider(getBufferProvider());
+ server.setReceiveExecutor(getReceiveExecutor());
+ server.addLifecycleListener(this);
+ server.activate();
+ return server;
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/EmbeddedUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/EmbeddedUtil.java
deleted file mode 100644
index 182ca8e..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/EmbeddedUtil.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/***************************************************************************
- * 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.internal.net4j.transport.embedded;
-
-import org.eclipse.net4j.transport.BufferProvider;
-import org.eclipse.net4j.transport.Connector;
-import org.eclipse.net4j.transport.tcp.TCPSelector;
-
-/**
- * @author Eike Stepper
- */
-public final class EmbeddedUtil
-{
- private EmbeddedUtil()
- {
- }
-
- public static Connector createConnector(BufferProvider bufferProvider, TCPSelector selector,
- String host, int port)
- {
- ClientEmbeddedConnectorImpl connector = new ClientEmbeddedConnectorImpl();
- connector.setBufferProvider(bufferProvider);
- return connector;
- }
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ServerEmbeddedConnectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ServerEmbeddedConnectorImpl.java
index 0e97758..3638783 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ServerEmbeddedConnectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/ServerEmbeddedConnectorImpl.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.embedded;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
/**
* @author Eike Stepper
*/
@@ -24,4 +26,11 @@ public class ServerEmbeddedConnectorImpl extends AbstractEmbeddedConnector
{
return Type.SERVER;
}
+
+ @Override
+ protected void onDeactivate() throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(getPeer());
+ super.onDeactivate();
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
index 6838e6c..2f06f3d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
@@ -11,7 +11,9 @@
package org.eclipse.net4j.transport;
import org.eclipse.net4j.transport.Connector.Type;
-import org.eclipse.net4j.util.registry.IRegistry;
+
+import org.eclipse.internal.net4j.transport.ClientProtocolFactoryRegistry;
+import org.eclipse.internal.net4j.transport.ServerProtocolFactoryRegistry;
import java.util.Arrays;
import java.util.Collections;
@@ -23,9 +25,9 @@ import java.util.Set;
*/
public interface ProtocolFactory
{
- public static final IRegistry<String, ProtocolFactory> CLIENT_REGISTRY = new org.eclipse.internal.net4j.transport.ClientProtocolFactoryRegistry();
+ public static final ClientProtocolFactoryRegistry CLIENT_REGISTRY = new ClientProtocolFactoryRegistry();
- public static final IRegistry<String, ProtocolFactory> SERVER_REGISTRY = new org.eclipse.internal.net4j.transport.ServerProtocolFactoryRegistry();
+ public static final ServerProtocolFactoryRegistry SERVER_REGISTRY = new ServerProtocolFactoryRegistry();
public static final Set<Type> FOR_CLIENTS = Collections.singleton(Type.CLIENT);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
index 2cae5bd..47daab5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
@@ -94,7 +94,7 @@ public final class LifecycleUtil
{
return ((Lifecycle)object).deactivate();
}
- else if (useAnnotation)
+ else if (object != null && useAnnotation)
{
invokeAnnotation(object, Deactivator.class);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
index 747fc08..499f70f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
@@ -149,7 +149,7 @@ public abstract class AbstractRegistry<K, V> implements IRegistry<K, V>
*/
public synchronized void clear()
{
- if (isEmpty())
+ if (!isEmpty())
{
Set<K> keys = keySet();
for (K key : keys)
@@ -196,6 +196,12 @@ public abstract class AbstractRegistry<K, V> implements IRegistry<K, V>
listeners.clear();
}
+ @Override
+ public String toString()
+ {
+ return getMap().toString();
+ }
+
protected V register(K key, V value)
{
Transaction transaction = getTransaction();