summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-13 02:08:26 (EDT)
committerEike Stepper2007-08-13 02:08:26 (EDT)
commit8169bfc820d25e8644750c7f7857f97f2e664db5 (patch)
tree097ec1e2935bc5d97526c7056796470b546838dd
parentd431996e86d5230bff9aeabd84e088a6c6b3469c (diff)
downloadcdo-8169bfc820d25e8644750c7f7857f97f2e664db5.zip
cdo-8169bfc820d25e8644750c7f7857f97f2e664db5.tar.gz
cdo-8169bfc820d25e8644750c7f7857f97f2e664db5.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionViewsEvent.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java36
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java31
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSConnectionSessionsEvent.java26
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java52
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java2
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java64
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEvent.java35
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEventAdapter.java67
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistryEvent.java23
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java37
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java33
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptorEvent.java41
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnectorChannelsEvent.java34
17 files changed, 118 insertions, 398 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionViewsEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionViewsEvent.java
deleted file mode 100644
index 022803e..0000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionViewsEvent.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004-2007 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;
-
-import org.eclipse.net4j.util.container.IContainerEvent;
-
-/**
- * @author Eike Stepper
- */
-public interface CDOSessionViewsEvent extends CDOSessionEvent, IContainerEvent<CDOView>
-{
- public CDOView getView();
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 8325b67..027f832 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -12,7 +12,6 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.CDOSessionViewsEvent;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
@@ -27,15 +26,12 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.ConnectorException;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IConnector;
-import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent;
+import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.internal.util.event.Event;
-import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.IContainerDelta;
-import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.EventUtil;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
@@ -68,7 +64,7 @@ import java.util.concurrent.ConcurrentMap;
/**
* @author Eike Stepper
*/
-public class CDOSessionImpl extends Lifecycle implements CDOSession
+public class CDOSessionImpl extends Container<CDOView> implements CDOSession
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class);
@@ -241,6 +237,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
return getViews();
}
+ @Override
public boolean isEmpty()
{
return views.isEmpty();
@@ -266,7 +263,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
throw WrappedException.wrap(ex);
}
- fireEvent(new ViewsEvent(view, IContainerDelta.Kind.REMOVED));
+ fireElementRemovedEvent(view);
}
public CDOIDRange getTemporaryIDRange(long count)
@@ -496,7 +493,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
resourceSet.eAdapters().add(view);
sendViewsNotification(view);
- fireEvent(new ViewsEvent(view, IContainerDelta.Kind.ADDED));
+ fireElementAddedEvent(view);
}
private void sendViewsNotification(CDOViewImpl view)
@@ -529,29 +526,6 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
throw new ImplementationError("Invalid view type: " + type);
}
- /**
- * @author Eike Stepper
- */
- private final class ViewsEvent extends SingleDeltaContainerEvent<CDOView> implements CDOSessionViewsEvent
- {
- private static final long serialVersionUID = 1L;
-
- public ViewsEvent(CDOView view, Kind kind)
- {
- super(CDOSessionImpl.this, view, kind);
- }
-
- public CDOSession getSession()
- {
- return CDOSessionImpl.this;
- }
-
- public CDOView getView()
- {
- return getDeltaElement();
- }
- }
-
private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java
index 01fabd8..05521e6 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java
@@ -17,9 +17,9 @@ import org.eclipse.net4j.internal.jms.bundle.OM;
import org.eclipse.net4j.internal.jms.protocol.JMSClientProtocol;
import org.eclipse.net4j.internal.jms.protocol.JMSLogonRequest;
import org.eclipse.net4j.internal.jms.protocol.JMSOpenSessionRequest;
+import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.internal.util.container.LifecycleEventConverter;
import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent;
-import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.jms.JMSUtil;
import org.eclipse.net4j.util.container.IContainer;
@@ -43,7 +43,7 @@ import javax.jms.Topic;
import java.util.ArrayList;
import java.util.List;
-public class ConnectionImpl extends Lifecycle implements Connection, IContainer<Session>
+public class ConnectionImpl extends Container<Session> implements Connection
{
private String connectorType;
@@ -77,7 +77,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer<
removeSession((SessionImpl)element);
}
- return new ConnectionSessionsEvent((ConnectionImpl)container, (SessionImpl)element, kind);
+ return new SingleDeltaContainerEvent(container, element, kind);
}
};
@@ -336,6 +336,7 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer<
return getSessions();
}
+ @Override
public boolean isEmpty()
{
return getSessions().length == 0;
@@ -402,28 +403,4 @@ public class ConnectionImpl extends Lifecycle implements Connection, IContainer<
throw new IllegalStateException("channel == null");
}
}
-
- /**
- * @author Eike Stepper
- */
- private static class ConnectionSessionsEvent extends SingleDeltaContainerEvent<Session> implements
- JMSConnectionSessionsEvent
- {
- private static final long serialVersionUID = 1L;
-
- public ConnectionSessionsEvent(ConnectionImpl connection, Session session, Kind kind)
- {
- super(connection, session, kind);
- }
-
- public Connection getConnection()
- {
- return (Connection)getContainer();
- }
-
- public Session getSession()
- {
- return getDeltaElement();
- }
- }
}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSConnectionSessionsEvent.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSConnectionSessionsEvent.java
deleted file mode 100644
index 201ea96..0000000
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSConnectionSessionsEvent.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.internal.jms;
-
-import org.eclipse.net4j.util.container.IContainerEvent;
-
-import javax.jms.Connection;
-import javax.jms.Session;
-
-/**
- * @author Eike Stepper
- */
-public interface JMSConnectionSessionsEvent extends IContainerEvent<Session>
-{
- public Connection getConnection();
-
- public Session getSession();
-}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
index 2ee0eb5..f633ecc 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
@@ -10,16 +10,16 @@
**************************************************************************/
package org.eclipse.net4j.tests;
-import org.eclipse.net4j.IAcceptorEvent;
import org.eclipse.net4j.IBuffer;
import org.eclipse.net4j.IBufferProvider;
import org.eclipse.net4j.IChannel;
-import org.eclipse.net4j.IConnectorChannelsEvent;
+import org.eclipse.net4j.IConnector;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.stream.ChannelInputStream;
import org.eclipse.net4j.stream.ChannelOutputStream;
import org.eclipse.net4j.tests.signal.TestSignalServerProtocolFactory;
import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
@@ -159,19 +159,19 @@ public class TCPTransportTest extends AbstractTransportTest
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IAcceptorEvent)
+ if (event instanceof IContainerEvent)
{
- IAcceptorEvent e = (IAcceptorEvent)event;
- e.getConnector().addListener(new IListener()
+ IContainerEvent<IConnector> e = (IContainerEvent)event;
+ e.getDeltaElement().addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IConnectorChannelsEvent)
+ if (event instanceof IContainerEvent)
{
- IConnectorChannelsEvent e = (IConnectorChannelsEvent)event;
+ IContainerEvent<IChannel> e = (IContainerEvent)event;
if (e.getDeltaKind() == IContainerDelta.Kind.ADDED)
{
- inputStream[0] = new ChannelInputStream(e.getChannel(), 2000);
+ inputStream[0] = new ChannelInputStream(e.getDeltaElement(), 2000);
counter.countDown();
}
}
@@ -222,19 +222,19 @@ public class TCPTransportTest extends AbstractTransportTest
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IAcceptorEvent)
+ if (event instanceof IContainerEvent)
{
- IAcceptorEvent e = (IAcceptorEvent)event;
- e.getConnector().addListener(new IListener()
+ IContainerEvent<IConnector> e = (IContainerEvent)event;
+ e.getDeltaElement().addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IConnectorChannelsEvent)
+ if (event instanceof IContainerEvent)
{
- IConnectorChannelsEvent e = (IConnectorChannelsEvent)event;
+ IContainerEvent<IChannel> e = (IContainerEvent)event;
if (e.getDeltaKind() == IContainerDelta.Kind.ADDED)
{
- inputStream[0] = new ChannelInputStream(e.getChannel(), 2000);
+ inputStream[0] = new ChannelInputStream(e.getDeltaElement(), 2000);
counter.countDown();
}
}
@@ -288,19 +288,19 @@ public class TCPTransportTest extends AbstractTransportTest
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IAcceptorEvent)
+ if (event instanceof IContainerEvent)
{
- IAcceptorEvent e = (IAcceptorEvent)event;
- e.getConnector().addListener(new IListener()
+ IContainerEvent<IConnector> e = (IContainerEvent)event;
+ e.getDeltaElement().addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IConnectorChannelsEvent)
+ if (event instanceof IContainerEvent)
{
- IConnectorChannelsEvent e = (IConnectorChannelsEvent)event;
+ IContainerEvent<IChannel> e = (IContainerEvent)event;
if (e.getDeltaKind() == IContainerDelta.Kind.ADDED)
{
- inputStream[0] = new ChannelInputStream(e.getChannel(), 2000);
+ inputStream[0] = new ChannelInputStream(e.getDeltaElement(), 2000);
counter.countDown();
}
}
@@ -370,19 +370,19 @@ public class TCPTransportTest extends AbstractTransportTest
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IAcceptorEvent)
+ if (event instanceof IContainerEvent)
{
- IAcceptorEvent e = (IAcceptorEvent)event;
- e.getConnector().addListener(new IListener()
+ IContainerEvent<IConnector> e = (IContainerEvent)event;
+ e.getDeltaElement().addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
- if (event instanceof IConnectorChannelsEvent)
+ if (event instanceof IContainerEvent)
{
- IConnectorChannelsEvent e = (IConnectorChannelsEvent)event;
+ IContainerEvent<IChannel> e = (IContainerEvent)event;
if (e.getDeltaKind() == IContainerDelta.Kind.ADDED)
{
- inputStream[0] = new ChannelInputStream(e.getChannel(), 2000);
+ inputStream[0] = new ChannelInputStream(e.getDeltaElement(), 2000);
counter.countDown();
}
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
index f10da07..d1ed159 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
@@ -86,7 +86,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer> extends ItemPro
}
catch (RuntimeException ex)
{
- return NO_CHILDREN;
+ return NO_ELEMENTS;
}
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
index 1607821..d40c335 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
@@ -29,7 +29,7 @@ import java.util.List;
public abstract class ItemProvider<INPUT> extends StructuredContentProvider<INPUT> implements ITreeContentProvider,
ILabelProvider
{
- protected static final Object[] NO_CHILDREN = new Object[0];
+ public static final Object[] NO_ELEMENTS = {};
private List<ILabelProviderListener> listeners = new ArrayList(0);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java
new file mode 100644
index 0000000..b873058
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.internal.util.container;
+
+import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IContainerDelta.Kind;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Container<E> extends Lifecycle implements IContainer<E>
+{
+ public Container()
+ {
+ }
+
+ public boolean isEmpty()
+ {
+ E[] elements = getElements();
+ return elements == null || elements.length == 0;
+ }
+
+ public void fireElementAddedEvent(E element)
+ {
+ fireContainerEvent(element, IContainerDelta.Kind.ADDED);
+ }
+
+ public void fireElementRemovedEvent(E element)
+ {
+ fireContainerEvent(element, IContainerDelta.Kind.REMOVED);
+ }
+
+ public void fireContainerEvent(E element, Kind kind)
+ {
+ fireEvent(newContainerEvent(element, kind));
+ }
+
+ public void fireContainerEvent(List<IContainerDelta<E>> deltas)
+ {
+ fireEvent(new ContainerEvent(this, deltas));
+ }
+
+ protected SingleDeltaContainerEvent newContainerEvent(E element, Kind kind)
+ {
+ return new SingleDeltaContainerEvent(this, element, kind);
+ }
+
+ protected ContainerEvent newContainerEvent()
+ {
+ return new ContainerEvent(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java
index 3342476..6e9eb74 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java
@@ -11,7 +11,8 @@
package org.eclipse.net4j.internal.util.registry;
import org.eclipse.net4j.internal.util.bundle.OM;
-import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.internal.util.container.Container;
+import org.eclipse.net4j.internal.util.container.ContainerEvent;
import org.eclipse.net4j.util.container.IContainerDelta;
import org.eclipse.net4j.util.registry.IRegistry;
@@ -23,7 +24,7 @@ import java.util.Set;
/**
* @author Eike Stepper
*/
-public abstract class Registry<K, V> extends Lifecycle implements IRegistry<K, V>
+public abstract class Registry<K, V> extends Container<Map.Entry<K, V>> implements IRegistry<K, V>
{
private boolean autoCommit;
@@ -39,6 +40,7 @@ public abstract class Registry<K, V> extends Lifecycle implements IRegistry<K, V
this(true);
}
+ @Override
public boolean isEmpty()
{
return keySet().isEmpty();
@@ -246,7 +248,7 @@ public abstract class Registry<K, V> extends Lifecycle implements IRegistry<K, V
{
private int nesting = 1;
- private RegistryEvent<K, V> event;
+ private ContainerEvent<Map.Entry<K, V>> event;
private Thread owner;
@@ -258,7 +260,7 @@ public abstract class Registry<K, V> extends Lifecycle implements IRegistry<K, V
private void initEvent()
{
- event = new RegistryEvent(Registry.this);
+ event = newContainerEvent();
}
public boolean isOwned()
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEvent.java
deleted file mode 100644
index 20409ed..0000000
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.internal.util.registry;
-
-import org.eclipse.net4j.internal.util.container.ContainerEvent;
-import org.eclipse.net4j.util.registry.IRegistry;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class RegistryEvent<K, V> extends ContainerEvent<Map.Entry<K, V>> implements IRegistryEvent<K, V>
-{
- private static final long serialVersionUID = 1L;
-
- public RegistryEvent(IRegistry registry)
- {
- super(registry);
- }
-
- public IRegistry getRegistry()
- {
- return (IRegistry)getContainer();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEventAdapter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEventAdapter.java
deleted file mode 100644
index 2e39583..0000000
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/RegistryEventAdapter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.internal.util.registry;
-
-import org.eclipse.net4j.util.container.IContainerEventVisitor;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.registry.IRegistry;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class RegistryEventAdapter<K, V> implements IListener
-{
- public final void notifyEvent(IEvent event)
- {
- if (event instanceof IRegistryEvent)
- {
- IRegistryEvent e = (IRegistryEvent)event;
- notifyRegistryEvent(e);
- }
- else
- {
- notifyOtherEvent(event);
- }
- }
-
- protected void notifyRegistryEvent(IRegistryEvent<K, V> event)
- {
- final IRegistry<K, V> registry = event.getRegistry();
- event.accept(new IContainerEventVisitor<Map.Entry<K, V>>()
- {
- public void added(Map.Entry<K, V> entry)
- {
- onAdded(registry, entry.getKey(), entry.getValue());
- }
-
- public void removed(Map.Entry<K, V> entry)
- {
- onRemoved(registry, entry.getKey(), entry.getValue());
- }
- });
- }
-
- protected void notifyOtherEvent(IEvent event)
- {
- }
-
- protected void onAdded(IRegistry<K, V> registry, K key, V value)
- {
- }
-
- protected void onRemoved(IRegistry<K, V> registry, K key, V value)
- {
- }
-}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
index de99b00..e9b6ee9 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
@@ -15,7 +15,7 @@ package org.eclipse.net4j.util.container;
*/
public final class ContainerUtil
{
- private static final Object[] NO_ELEMENTS = new Object[0];
+ private static final Object[] NO_ELEMENTS = {};
private ContainerUtil()
{
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistryEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistryEvent.java
deleted file mode 100644
index 8ca5d02..0000000
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistryEvent.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.util.registry;
-
-import org.eclipse.net4j.util.container.IContainerEvent;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public interface IRegistryEvent<K, V> extends IContainerEvent<Map.Entry<K, V>>
-{
- public IRegistry getRegistry();
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
index 402586b..e6e5459 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
@@ -11,15 +11,12 @@
package org.eclipse.internal.net4j;
import org.eclipse.net4j.IAcceptor;
-import org.eclipse.net4j.IAcceptorEvent;
import org.eclipse.net4j.IBufferProvider;
import org.eclipse.net4j.IConnector;
+import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.internal.util.container.LifecycleEventConverter;
-import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent;
-import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IContainerDelta;
import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.IListener;
@@ -37,7 +34,7 @@ import java.util.concurrent.ExecutorService;
/**
* @author Eike Stepper
*/
-public abstract class Acceptor extends Lifecycle implements IAcceptor
+public abstract class Acceptor extends Container<IConnector> implements IAcceptor
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_ACCEPTOR, Acceptor.class);
@@ -56,7 +53,7 @@ public abstract class Acceptor extends Lifecycle implements IAcceptor
@Override
protected IContainerEvent createContainerEvent(IContainer container, Object element, Kind kind)
{
- return new AcceptorEvent((IAcceptor)container, (IConnector)element, kind);
+ return newContainerEvent((IConnector)element, kind);
}
};
@@ -115,6 +112,7 @@ public abstract class Acceptor extends Lifecycle implements IAcceptor
}
}
+ @Override
public boolean isEmpty()
{
return acceptedConnectors.isEmpty();
@@ -145,7 +143,7 @@ public abstract class Acceptor extends Lifecycle implements IAcceptor
TRACER.trace("Added connector " + connector); //$NON-NLS-1$
}
- fireEvent(new AcceptorEvent(this, connector, IContainerDelta.Kind.ADDED));
+ fireElementAddedEvent(connector);
}
catch (Exception ex)
{
@@ -166,7 +164,7 @@ public abstract class Acceptor extends Lifecycle implements IAcceptor
TRACER.trace("Removed connector " + connector); //$NON-NLS-1$
}
- fireEvent(new AcceptorEvent(this, connector, IContainerDelta.Kind.REMOVED));
+ fireElementRemovedEvent(connector);
}
@Override
@@ -201,27 +199,4 @@ public abstract class Acceptor extends Lifecycle implements IAcceptor
super.doDeactivate();
}
-
- /**
- * @author Eike Stepper
- */
- private static class AcceptorEvent extends SingleDeltaContainerEvent<IConnector> implements IAcceptorEvent
- {
- private static final long serialVersionUID = 1L;
-
- public AcceptorEvent(IAcceptor acceptor, IConnector connector, Kind kind)
- {
- super(acceptor, connector, kind);
- }
-
- public IAcceptor getAcceptor()
- {
- return (IAcceptor)getContainer();
- }
-
- public IConnector getConnector()
- {
- return getDeltaElement();
- }
- }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
index 8ad2e3e..68829ee 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
@@ -17,15 +17,13 @@ import org.eclipse.net4j.IBuffer;
import org.eclipse.net4j.IBufferProvider;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IConnector;
-import org.eclipse.net4j.IConnectorChannelsEvent;
import org.eclipse.net4j.IConnectorCredentials;
import org.eclipse.net4j.IConnectorStateEvent;
import org.eclipse.net4j.IProtocol;
+import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.internal.util.container.LifecycleEventConverter;
-import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent;
import org.eclipse.net4j.internal.util.event.Event;
import org.eclipse.net4j.internal.util.factory.FactoryKey;
-import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.WrappedException;
@@ -54,7 +52,7 @@ import java.util.concurrent.TimeoutException;
/**
* @author Eike Stepper
*/
-public abstract class Connector extends Lifecycle implements IConnector
+public abstract class Connector extends Container<IChannel> implements IConnector
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONNECTOR, Connector.class);
@@ -89,7 +87,7 @@ public abstract class Connector extends Lifecycle implements IConnector
@Override
protected IContainerEvent createContainerEvent(IContainer container, Object element, Kind kind)
{
- return new ConnectorChannelsEvent((IConnector)container, (IChannel)element, kind);
+ return newContainerEvent((IChannel)element, kind);
}
};
@@ -311,6 +309,7 @@ public abstract class Connector extends Lifecycle implements IConnector
return result.toArray(new IChannel[result.size()]);
}
+ @Override
public boolean isEmpty()
{
return getElements().length == 0;
@@ -674,28 +673,4 @@ public abstract class Connector extends Lifecycle implements IConnector
return newState;
}
}
-
- /**
- * @author Eike Stepper
- */
- private static class ConnectorChannelsEvent extends SingleDeltaContainerEvent<IChannel> implements
- IConnectorChannelsEvent
- {
- private static final long serialVersionUID = 1L;
-
- public ConnectorChannelsEvent(IConnector connector, IChannel channel, Kind kind)
- {
- super(connector, channel, kind);
- }
-
- public IConnector getConnector()
- {
- return (IConnector)getContainer();
- }
-
- public IChannel getChannel()
- {
- return getDeltaElement();
- }
- }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptorEvent.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptorEvent.java
deleted file mode 100644
index 5fcc6cc..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptorEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.util.container.IContainerDelta;
-import org.eclipse.net4j.util.container.IContainerEvent;
-
-/**
- * An event that is fired by an {@link IAcceptor} to indicate that its set of
- * accepted {@link IConnector}s has changed.
- * <p>
- * The information about added and removed connectors is provided by a set of
- * {@link IContainerDelta}s.
- *
- * @author Eike Stepper
- * @since 0.8.0
- */
-public interface IAcceptorEvent extends IContainerEvent<IConnector>
-{
- /**
- * The {@link IAcceptor} that sent this event.
- *
- * @see IContainerEvent#getContainer()
- */
- public IAcceptor getAcceptor();
-
- /**
- * The {@link IConnector} of the first {@link IContainerDelta} of this event.
- *
- * @see IContainerEvent#getDeltaElement()
- */
- public IConnector getConnector();
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnectorChannelsEvent.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnectorChannelsEvent.java
deleted file mode 100644
index 8e40ed8..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnectorChannelsEvent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 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.util.container.IContainerDelta;
-import org.eclipse.net4j.util.container.IContainerEvent;
-
-/**
- * An event that is fired by an {@link IConnector} to indicate that its set of
- * opened {@link IChannel}s has changed.
- * <p>
- * The information about opened and closed channels is provided by a set of
- * {@link IContainerDelta}s.
- *
- * @author Eike Stepper
- * @since 0.8.0
- */
-public interface IConnectorChannelsEvent extends IConnectorEvent, IContainerEvent<IChannel>
-{
- /**
- * The {@link IChannel} of the first {@link IContainerDelta} of this event.
- *
- * @see IContainerEvent#getDeltaElement()
- */
- public IChannel getChannel();
-}