summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-27 08:16:20 (EDT)
committerEike Stepper2007-08-27 08:16:20 (EDT)
commitbd5f9cdc7fb5c41d2294cfc0ee7d2f02720eacb0 (patch)
treecf3823b7bfec8771ce31672c61258a585cfbd61e
parent35641c723ea18581b1985cbc342b4104bdc6012a (diff)
downloadcdo-bd5f9cdc7fb5c41d2294cfc0ee7d2f02720eacb0.zip
cdo-bd5f9cdc7fb5c41d2294cfc0ee7d2f02720eacb0.tar.gz
cdo-bd5f9cdc7fb5c41d2294cfc0ee7d2f02720eacb0.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java49
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java4
-rw-r--r--plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/JMSAdmin.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java13
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java2
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java13
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java28
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java37
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java11
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java26
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java15
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocol.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java11
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java52
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java25
42 files changed, 283 insertions, 151 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
index f0fa322..41faede 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
@@ -20,15 +20,12 @@ import org.eclipse.net4j.signal.SignalReactor;
/**
* @author Eike Stepper
*/
-public class CDOServerProtocol extends SignalProtocol
+public class CDOServerProtocol extends SignalProtocol<IRepositoryProvider>
{
- private IRepositoryProvider repositoryProvider;
-
private Session session;
- public CDOServerProtocol(IRepositoryProvider repositoryProvider)
+ public CDOServerProtocol()
{
- this.repositoryProvider = repositoryProvider;
}
public String getType()
@@ -36,11 +33,6 @@ public class CDOServerProtocol extends SignalProtocol
return CDOProtocolConstants.PROTOCOL_NAME;
}
- public IRepositoryProvider getRepositoryProvider()
- {
- return repositoryProvider;
- }
-
public Session getSession()
{
return session;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
index 61fb88b..1ee7a21 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
@@ -29,7 +29,9 @@ public class CDOServerProtocolFactory extends ServerProtocolFactory<CDOServerPro
public CDOServerProtocol create(String description)
{
- return new CDOServerProtocol(repositoryProvider);
+ CDOServerProtocol serverProtocol = new CDOServerProtocol();
+ serverProtocol.setInfraStructure(repositoryProvider);
+ return serverProtocol;
}
public static CDOServerProtocol get(IManagedContainer container, String description)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 69bcd5d..b88607d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -100,7 +100,7 @@ public class OpenSessionIndication extends IndicationWithResponse
private Repository getRepository()
{
CDOServerProtocol protocol = (CDOServerProtocol)getProtocol();
- IRepositoryProvider repositoryProvider = protocol.getRepositoryProvider();
+ IRepositoryProvider repositoryProvider = protocol.getInfraStructure();
return (Repository)repositoryProvider.getRepository(repositoryName);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
index 3275acb..e5b691b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
@@ -181,11 +181,22 @@ public final class EMFUtil
// TODO Make configurable via ExtPoint
if (feature == EcorePackage.eINSTANCE.getEClass_ESuperTypes())
{
+ // See
+ // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
continue;
}
if (feature == EcorePackage.eINSTANCE.getETypedElement_EType())
{
+ // See
+ // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
+ continue;
+ }
+
+ if (feature == EcorePackage.eINSTANCE.getEOperation_EExceptions())
+ {
+ // See
+ // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
continue;
}
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 5438bfe..a51029b 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
@@ -23,7 +23,6 @@ import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
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.Container;
@@ -45,7 +44,6 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionRequest;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionResult;
import org.eclipse.emf.internal.cdo.protocol.ViewsChangedNotification;
@@ -74,6 +72,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
private int sessionID;
+ private IConnector connector;
+
private IChannel channel;
private String repositoryName;
@@ -119,20 +119,12 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
public IConnector getConnector()
{
- if (channel == null)
- {
- return null;
- }
-
- return channel.getConnector();
+ return connector;
}
- public void setConnector(IConnector connector) throws ConnectorException
+ public void setConnector(IConnector connector)
{
- CDOClientProtocol protocol = new CDOClientProtocol();
- protocol.setSession(this);
- channel = connector.openChannel(protocol);
- EventUtil.addListener(channel, channelListener);
+ this.connector = connector;
}
public IChannel getChannel()
@@ -343,6 +335,26 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
idToMetaInstanceMap.put(id, metaInstance);
metaInstanceToIDMap.put(metaInstance, id);
+ // EClass eClass = metaInstance.eClass();
+ // for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ // {
+ // Object value = metaInstance.eGet(feature);
+ // if (value instanceof InternalEObject)
+ // {
+ // metaInstance.eResolveProxy((InternalEObject)value);
+ // }
+ // else if (value instanceof Collection)
+ // {
+ // for (Object element : (Collection)value)
+ // {
+ // if (element instanceof InternalEObject)
+ // {
+ // metaInstance.eResolveProxy((InternalEObject)element);
+ // }
+ // }
+ // }
+ // }
+
long step = id.isTemporary() ? -2L : 2L;
long count = 1L;
for (EObject content : metaInstance.eContents())
@@ -420,9 +432,9 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- if (channel == null)
+ if (channel == null && connector == null)
{
- throw new IllegalStateException("channel == null");
+ throw new IllegalStateException("channel == null && connector == null");
}
if (repositoryName == null)
@@ -435,6 +447,13 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
protected void doActivate() throws Exception
{
super.doActivate();
+ if (channel == null)
+ {
+ channel = connector.openChannel(CDOProtocolConstants.PROTOCOL_NAME, this);
+ }
+
+ EventUtil.addListener(channel, channelListener);
+
OpenSessionRequest request = new OpenSessionRequest(channel, repositoryName);
OpenSessionResult result = request.send();
sessionID = result.getSessionID();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
index e316d72..9d63845 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
@@ -20,10 +20,8 @@ import org.eclipse.emf.internal.cdo.CDOSessionImpl;
/**
* @author Eike Stepper
*/
-public class CDOClientProtocol extends SignalProtocol
+public class CDOClientProtocol extends SignalProtocol<CDOSessionImpl>
{
- private CDOSessionImpl session;
-
public CDOClientProtocol()
{
}
@@ -33,16 +31,6 @@ public class CDOClientProtocol extends SignalProtocol
return CDOProtocolConstants.PROTOCOL_NAME;
}
- public CDOSessionImpl getSession()
- {
- return session;
- }
-
- public void setSession(CDOSessionImpl session)
- {
- this.session = session;
- }
-
@Override
protected SignalReactor doCreateSignalReactor(short signalID)
{
@@ -59,7 +47,7 @@ public class CDOClientProtocol extends SignalProtocol
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- if (session == null)
+ if (getInfraStructure() == null)
{
throw new IllegalStateException("session == null");
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java
index 6859a8b..db0bda1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java
@@ -43,9 +43,10 @@ public abstract class CDOClientRequest<RESULT> extends RequestWithConfirmation<R
protected CDOSessionImpl getSession()
{
- return getProtocol().getSession();
+ return getProtocol().getInfraStructure();
}
+ @Override
protected CDOClientProtocol getProtocol()
{
return (CDOClientProtocol)super.getProtocol();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
index 98ad34a..866dc12 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
@@ -67,8 +67,14 @@ public class InvalidationIndication extends Indication
getSession().notifyInvalidation(timeStamp, dirtyOIDs, null);
}
- private CDOSessionImpl getSession()
+ protected CDOSessionImpl getSession()
{
- return ((CDOClientProtocol)getProtocol()).getSession();
+ return getProtocol().getInfraStructure();
+ }
+
+ @Override
+ protected CDOClientProtocol getProtocol()
+ {
+ return (CDOClientProtocol)super.getProtocol();
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index b79a2c4..92c2a4a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -75,7 +75,7 @@ public final class FSMUtil
if (eObject.eIsProxy())
{
- EcoreUtil.resolve(eObject, view.getResourceSet());
+ eObject = (InternalEObject)EcoreUtil.resolve(eObject, view.getResourceSet());
}
CDOID id = ((CDOViewImpl)view).getSession().lookupMetaInstanceID(eObject);
@@ -94,6 +94,11 @@ public final class FSMUtil
if (callback == null)
{
InternalEObject instance = (InternalEObject)aware;
+ if (instance.eIsProxy())
+ {
+ instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
+ }
+
callback = new CDOCallbackImpl(instance);
aware.setCDOCallback(callback);
instance.eAdapters().add(callback);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
index b3953f7..c8fef9b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
@@ -125,6 +125,10 @@ public final class ModelUtil
return cdoClass.lookupFeature(eFeature.getFeatureID());
}
+ /**
+ * @see EMFUtil#getPersistentFeatures(org.eclipse.emf.common.util.EList)
+ * @see http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
+ */
private static CDOPackageImpl createCDOPackage(EPackage ePackage, CDOSessionPackageManager packageManager)
{
String packageURI = ePackage.getNsURI();
diff --git a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/JMSAdmin.java b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/JMSAdmin.java
index dfe11f7..d1ff54a 100644
--- a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/JMSAdmin.java
+++ b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/JMSAdmin.java
@@ -26,7 +26,7 @@ public class JMSAdmin implements IJMSAdmin
public JMSAdmin(IConnector connector)
{
- channel = connector.openChannel(JMSAdminProtocolConstants.PROTOCOL_NAME);
+ channel = connector.openChannel(JMSAdminProtocolConstants.PROTOCOL_NAME, this);
}
public void close()
diff --git a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocol.java b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocol.java
index 77dc0be..a7ecbe5 100644
--- a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocol.java
+++ b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSAdminProtocol.java
@@ -11,13 +11,14 @@
package org.eclipse.net4j.jms.internal.admin.protocol;
import org.eclipse.net4j.jms.JMSAdminProtocolConstants;
+import org.eclipse.net4j.jms.internal.admin.JMSAdmin;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
/**
* @author Eike Stepper
*/
-public class JMSAdminProtocol extends SignalProtocol
+public class JMSAdminProtocol extends SignalProtocol<JMSAdmin>
{
public JMSAdminProtocol()
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
index eb40d13..de57a2d 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
@@ -40,7 +40,7 @@ public class JMSAcknowledgeIndication extends Indication
int sessionID = in.readInt();
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.getSession(sessionID);
if (session == null)
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
index 21bbb5a..b5875cd 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
@@ -43,7 +43,7 @@ public class JMSClientMessageIndication extends IndicationWithResponse
{
MessageImpl[] messages = { MessageUtil.read(in) };
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
Server server = connection.getServer();
String[] ids = server.handleClientMessages(messages);
if (ids != null && ids.length != 0)
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
index 0f43e8e..b69cfe2 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
@@ -51,7 +51,7 @@ public class JMSCommitIndication extends IndicationWithResponse
}
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.getSession(sessionID);
if (session == null)
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
index 92c32eb..3663004 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
@@ -51,7 +51,7 @@ public class JMSLogonIndication extends IndicationWithResponse
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
connection.setProtocol(protocol);
- protocol.setConnection(connection);
+ protocol.setInfraStructure(connection);
ok = true;
}
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
index afb19df..13ebc35 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
@@ -41,7 +41,7 @@ public class JMSOpenSessionIndication extends IndicationWithResponse
{
int sessionID = in.readInt();
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.openSession(sessionID);
if (session != null)
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
index 016e86f..39662be 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
@@ -40,7 +40,7 @@ public class JMSRecoverIndication extends IndicationWithResponse
{
int sessionID = in.readInt();
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.getSession(sessionID);
if (session == null)
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
index d8458a8..4a67b87 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
@@ -47,7 +47,7 @@ public class JMSRegisterConsumerIndication extends IndicationWithResponse
boolean noLocal = in.readBoolean();
boolean durable = in.readBoolean();
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.getSession(sessionID);
consumerID = session.registerConsumer(destination, messageSelector, noLocal, durable);
}
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
index 69d5ca4..fec3dc0 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
@@ -40,7 +40,7 @@ public class JMSRollbackIndication extends IndicationWithResponse
{
int sessionID = in.readInt();
JMSServerProtocol protocol = (JMSServerProtocol)getProtocol();
- ServerConnection connection = protocol.getConnection();
+ ServerConnection connection = protocol.getInfraStructure();
ServerSession session = connection.getSession(sessionID);
if (session == null)
{
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java
index ada9339..4e8e58f 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java
@@ -18,9 +18,8 @@ import org.eclipse.net4j.signal.SignalReactor;
/**
* @author Eike Stepper
*/
-public class JMSServerProtocol extends SignalProtocol
+public class JMSServerProtocol extends SignalProtocol<ServerConnection>
{
- private ServerConnection connection;
public JMSServerProtocol()
{
@@ -31,16 +30,6 @@ public class JMSServerProtocol extends SignalProtocol
return JMSProtocolConstants.PROTOCOL_NAME;
}
- public ServerConnection getConnection()
- {
- return connection;
- }
-
- public void setConnection(ServerConnection connection)
- {
- this.connection = connection;
- }
-
@Override
protected SignalReactor doCreateSignalReactor(short signalID)
{
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 05521e6..6947449 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
@@ -110,7 +110,7 @@ public class ConnectionImpl extends Container<Session> implements Connection
IConnector connector = Net4jUtil.getConnector(transportContainer, connectorType, connectorDescription);
JMSClientProtocol protocol = new JMSClientProtocol();
- protocol.setConnection(this);
+ protocol.setInfraStructure(this);
channel = connector.openChannel(protocol);
channel.addListener(channelListener);
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java
index 589eb86..68c8a57 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java
@@ -18,9 +18,8 @@ import org.eclipse.net4j.signal.SignalReactor;
/**
* @author Eike Stepper
*/
-public class JMSClientProtocol extends SignalProtocol
+public class JMSClientProtocol extends SignalProtocol<ConnectionImpl>
{
- private ConnectionImpl connection;
public JMSClientProtocol()
{
@@ -31,16 +30,6 @@ public class JMSClientProtocol extends SignalProtocol
return JMSProtocolConstants.PROTOCOL_NAME;
}
- public ConnectionImpl getConnection()
- {
- return connection;
- }
-
- public void setConnection(ConnectionImpl connection)
- {
- this.connection = connection;
- }
-
@Override
protected SignalReactor doCreateSignalReactor(short signalID)
{
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
index 6187c53..065fd8a 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
@@ -41,7 +41,7 @@ public class JMSServerMessageIndication extends Indication
long consumerID = in.readLong();
MessageImpl message = MessageUtil.read(in);
JMSClientProtocol protocol = (JMSClientProtocol)getProtocol();
- ConnectionImpl connection = protocol.getConnection();
+ ConnectionImpl connection = protocol.getInfraStructure();
connection.handleMessageFromSignal(sessionID, consumerID, message);
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index ddc0840..31bc4e8 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -35,7 +35,7 @@ public class SignalTest extends AbstractTransportTest
public void testInteger() throws Exception
{
startTransport();
- IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME);
+ IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME, null);
int data = 0x0a;
int result = new Request1(channel, data).send();
assertEquals(data, result);
@@ -44,7 +44,7 @@ public class SignalTest extends AbstractTransportTest
public void testArray() throws Exception
{
startTransport();
- IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME);
+ IChannel channel = getConnector().openChannel(TestSignalProtocol.PROTOCOL_NAME, null);
byte[] data = TinyData.getBytes();
byte[] result = new Request2(channel, data).send();
assertTrue(Arrays.equals(data, result));
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 28daa7a..b125101 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
@@ -80,7 +80,7 @@ public class TCPTransportTest extends AbstractTransportTest
container.registerFactory(new ClientTestProtocolFactory());
startTransport();
- IChannel channel = getConnector().openChannel(ClientTestProtocolFactory.TYPE);
+ IChannel channel = getConnector().openChannel(ClientTestProtocolFactory.TYPE, null);
for (int i = 0; i < COUNT; i++)
{
IBuffer buffer = provideBuffer();
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
index af34af4..e47de39 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
@@ -9,13 +9,11 @@ import java.util.concurrent.CountDownLatch;
/**
* @author Eike Stepper
*/
-public final class TestProtocol extends Protocol
+public final class TestProtocol extends Protocol<CountDownLatch>
{
- private CountDownLatch counter;
-
public TestProtocol(CountDownLatch counter)
{
- this.counter = counter;
+ setInfraStructure(counter);
}
public String getType()
@@ -27,9 +25,9 @@ public final class TestProtocol extends Protocol
{
System.out.println("BUFFER ARRIVED");
buffer.release();
- if (counter != null)
+ if (getInfraStructure() != null)
{
- counter.countDown();
+ getInfraStructure().countDown();
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java
index d0789b4..2bb142e 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java
@@ -47,8 +47,8 @@ public class Lifecycle extends Notifier implements ILifecycle.Introspection
}
lifecycleState = ILifecycleState.ACTIVATING;
- doBeforeActivate();
fireEvent(new LifecycleEvent(this, ILifecycleEvent.Kind.ABOUT_TO_ACTIVATE));
+ doBeforeActivate();
dump();
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java
index 41b2272..415c3ca 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java
@@ -10,13 +10,15 @@
**************************************************************************/
package org.eclipse.net4j.util.io;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Eike Stepper
*/
-public abstract class DelegatingStreamWrapper implements IStreamWrapper
+public abstract class DelegatingStreamWrapper<IN extends InputStream, OUT extends OutputStream> implements
+ IStreamWrapper<IN, OUT>
{
private IStreamWrapper delegate;
@@ -30,17 +32,33 @@ public abstract class DelegatingStreamWrapper implements IStreamWrapper
return delegate;
}
- public InputStream wrapInputStream(InputStream in)
+ public IN wrapInputStream(InputStream in) throws IOException
{
return doWrapInputStream(delegate.wrapInputStream(in));
}
- public OutputStream wrapOutputStream(OutputStream out)
+ public OUT wrapOutputStream(OutputStream out) throws IOException
{
return doWrapOutputStream(delegate.wrapOutputStream(out));
}
- protected abstract InputStream doWrapInputStream(InputStream in);
+ public void finishInputStream(IN in) throws IOException
+ {
+ delegate.finishInputStream(in);
+ doFinishInputStream(in);
+ }
+
+ public void finishOutputStream(OUT out) throws IOException
+ {
+ delegate.finishOutputStream(out);
+ doFinishOutputStream(out);
+ }
+
+ protected abstract IN doWrapInputStream(InputStream in) throws IOException;
+
+ protected abstract OUT doWrapOutputStream(OutputStream out) throws IOException;
+
+ protected abstract void doFinishInputStream(IN in) throws IOException;
- protected abstract OutputStream doWrapOutputStream(OutputStream out);
+ protected abstract void doFinishOutputStream(OUT out) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
index 3a51c01..83e7bc1 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
@@ -19,43 +19,38 @@ import java.util.zip.GZIPOutputStream;
/**
* @author Eike Stepper
*/
-public class GZIPStreamWrapper implements IStreamWrapper
+public class GZIPStreamWrapper implements IStreamWrapper<GZIPInputStream, GZIPOutputStream>
{
public GZIPStreamWrapper()
{
}
- public InputStream wrapInputStream(InputStream in)
+ public GZIPInputStream wrapInputStream(InputStream in) throws IOException
{
if (in instanceof GZIPInputStream)
{
- return in;
+ return (GZIPInputStream)in;
}
- try
- {
- return new GZIPInputStream(in);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
+ return new GZIPInputStream(in);
}
- public OutputStream wrapOutputStream(OutputStream out)
+ public GZIPOutputStream wrapOutputStream(OutputStream out) throws IOException
{
if (out instanceof GZIPOutputStream)
{
- return out;
+ return (GZIPOutputStream)out;
}
- try
- {
- return new GZIPOutputStream(out);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
+ return new GZIPOutputStream(out);
+ }
+
+ public void finishInputStream(GZIPInputStream in) throws IOException
+ {
+ }
+
+ public void finishOutputStream(GZIPOutputStream out) throws IOException
+ {
+ out.finish();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
index 9688fd6..9c01c19 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
@@ -10,15 +10,20 @@
**************************************************************************/
package org.eclipse.net4j.util.io;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Eike Stepper
*/
-public interface IStreamWrapper
+public interface IStreamWrapper<IN extends InputStream, OUT extends OutputStream>
{
- public InputStream wrapInputStream(InputStream in);
+ public IN wrapInputStream(InputStream in) throws IOException;
- public OutputStream wrapOutputStream(OutputStream out);
+ public OUT wrapOutputStream(OutputStream out) throws IOException;
+
+ public void finishInputStream(IN in) throws IOException;
+
+ public void finishOutputStream(OUT out) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java
index 74d3541..5db5432 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java
@@ -10,36 +10,50 @@
**************************************************************************/
package org.eclipse.net4j.util.io;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Eike Stepper
*/
-public class StreamWrapperChain extends DelegatingStreamWrapper
+public class StreamWrapperChain<IN extends InputStream, OUT extends OutputStream> extends
+ DelegatingStreamWrapper<IN, OUT>
{
- private IStreamWrapper head;
+ private IStreamWrapper<IN, OUT> head;
- public StreamWrapperChain(IStreamWrapper head, IStreamWrapper delegate)
+ public StreamWrapperChain(IStreamWrapper<IN, OUT> head, IStreamWrapper delegate)
{
super(delegate);
this.head = head;
}
- public IStreamWrapper getHead()
+ public IStreamWrapper<IN, OUT> getHead()
{
return head;
}
@Override
- protected InputStream doWrapInputStream(InputStream in)
+ protected IN doWrapInputStream(InputStream in) throws IOException
{
return head.wrapInputStream(in);
}
@Override
- protected OutputStream doWrapOutputStream(OutputStream out)
+ protected OUT doWrapOutputStream(OutputStream out) throws IOException
{
return head.wrapOutputStream(out);
}
+
+ @Override
+ protected void doFinishInputStream(IN in) throws IOException
+ {
+ head.finishInputStream(in);
+ }
+
+ @Override
+ protected void doFinishOutputStream(OUT out) throws IOException
+ {
+ head.finishOutputStream(out);
+ }
}
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 944c66f..4a4d2a1 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
@@ -338,9 +338,9 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
return openChannel((IProtocol)null);
}
- public IChannel openChannel(String protocolID) throws ConnectorException
+ public IChannel openChannel(String protocolID, Object infraStructure) throws ConnectorException
{
- IProtocol protocol = createProtocol(protocolID);
+ IProtocol protocol = createProtocol(protocolID, infraStructure);
if (protocol == null)
{
throw new IllegalArgumentException("Unknown protocolID: " + protocolID);
@@ -374,7 +374,7 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
public Channel createChannel(short channelIndex, String protocolID)
{
- IProtocol protocol = createProtocol(protocolID);
+ IProtocol protocol = createProtocol(protocolID, null);
return createChannel(channelIndex, protocol);
}
@@ -568,8 +568,10 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
* so that the post processors can reach them. The protocol description can be
* used to store unique protocol IDs so that always new protocols are created
* in the container.
+ *
+ * @param infraStructure
*/
- protected IProtocol createProtocol(String type)
+ protected IProtocol createProtocol(String type, Object infraStructure)
{
IRegistry<IFactoryKey, IFactory> registry = getProtocolFactoryRegistry();
if (StringUtil.isEmpty(type) || registry == null)
@@ -593,6 +595,10 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
// Create protocol
String description = null;
IProtocol protocol = factory.create(description);
+ if (infraStructure != null)
+ {
+ protocol.setInfraStructure(infraStructure);
+ }
// Post process protocol
List<IElementProcessor> processors = getProtocolPostProcessors();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java
index 342be62..f3c5c4c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Protocol.java
@@ -20,10 +20,13 @@ import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
/**
* @author Eike Stepper
*/
-public abstract class Protocol extends Lifecycle implements IProtocol, IBufferProvider
+public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IProtocol<INFRA_STRUCTURE>,
+ IBufferProvider
{
private Channel channel;
+ private INFRA_STRUCTURE infraStructure;
+
public Protocol()
{
}
@@ -38,6 +41,16 @@ public abstract class Protocol extends Lifecycle implements IProtocol, IBufferPr
this.channel = (Channel)channel;
}
+ public INFRA_STRUCTURE getInfraStructure()
+ {
+ return infraStructure;
+ }
+
+ public void setInfraStructure(INFRA_STRUCTURE infraStructure)
+ {
+ this.infraStructure = infraStructure;
+ }
+
public short getBufferCapacity()
{
return Net4jUtil.getBufferProvider(channel).getBufferCapacity();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
index f0ef342..2d22fa9 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
@@ -181,7 +181,7 @@ public interface IConnector extends IContainer<IChannel>
* @see #openChannel()
* @see #openChannel(IProtocol)
*/
- public IChannel openChannel(String protocolID) throws ConnectorException;
+ public IChannel openChannel(String protocolID, Object infraStructure) throws ConnectorException;
/**
* Synchronous request to open a new {@link IChannel} with the given channel
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocol.java
index ebbe985..be7b3c8 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocol.java
@@ -14,11 +14,15 @@ package org.eclipse.net4j;
* @author Eike Stepper
* @since 0.8.0
*/
-public interface IProtocol extends IBufferHandler
+public interface IProtocol<INFRA_STRUCTURE> extends IBufferHandler
{
public String getType();
public IChannel getChannel();
public void setChannel(IChannel channel);
+
+ public INFRA_STRUCTURE getInfraStructure();
+
+ public void setInfraStructure(INFRA_STRUCTURE infraStructure);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
index b8266b5..243411e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
@@ -19,6 +19,7 @@ import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.internal.net4j.bundle.OM;
import java.io.IOException;
+import java.io.InputStream;
/**
* @author Eike Stepper
@@ -39,7 +40,9 @@ public abstract class Indication extends SignalReactor
TRACER.trace("================ Indicating " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- indicating(wrapInputStream(in));
+ InputStream wrappedInputStream = wrapInputStream(in);
+ indicating(ExtendedDataInputStream.wrap(wrappedInputStream));
+ finishInputStream(wrappedInputStream);
}
protected abstract void indicating(ExtendedDataInputStream in) throws IOException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
index 6777fee..e149cbc 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
@@ -20,6 +20,8 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.internal.net4j.bundle.OM;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* @author Eike Stepper
@@ -40,13 +42,17 @@ public abstract class IndicationWithResponse extends SignalReactor
TRACER.trace("================ Indicating " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- indicating(wrapInputStream(in));
+ InputStream wrappedInputStream = wrapInputStream(in);
+ indicating(ExtendedDataInputStream.wrap(wrappedInputStream));
+ finishInputStream(wrappedInputStream);
if (TRACER.isEnabled())
{
TRACER.trace("================ Responding " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- responding(wrapOutputStream(out));
+ OutputStream wrappedOutputStream = wrapOutputStream(out);
+ responding(ExtendedDataOutputStream.wrap(wrappedOutputStream));
+ finishOutputStream(wrappedOutputStream);
out.flush();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
index 50c8884..66bfe54 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
@@ -20,6 +20,7 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.internal.net4j.bundle.OM;
import java.io.IOException;
+import java.io.OutputStream;
/**
* @author Eike Stepper
@@ -41,7 +42,9 @@ public abstract class Request extends SignalActor
TRACER.trace("================ Requesting " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- requesting(wrapOutputStream(out));
+ OutputStream wrappedOutputStream = wrapOutputStream(out);
+ requesting(ExtendedDataOutputStream.wrap(wrappedOutputStream));
+ finishOutputStream(wrappedOutputStream);
out.flush();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
index e96c95a..4caabda 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
@@ -21,6 +21,8 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.internal.net4j.bundle.OM;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* @author Eike Stepper
@@ -42,14 +44,19 @@ public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT
TRACER.trace("================ Requesting " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- requesting(wrapOutputStream(out));
+ OutputStream wrappedOutputStream = wrapOutputStream(out);
+ requesting(ExtendedDataOutputStream.wrap(wrappedOutputStream));
+ finishOutputStream(wrappedOutputStream);
out.flush();
if (TRACER.isEnabled())
{
TRACER.trace("================ Confirming " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
}
- setResult(confirming(wrapInputStream(in)));
+ InputStream wrappedInputStream = wrapInputStream(in);
+ RESULT result = confirming(ExtendedDataInputStream.wrap(wrappedInputStream));
+ finishInputStream(wrappedInputStream);
+ setResult(result);
}
protected abstract void requesting(ExtendedDataOutputStream out) throws IOException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
index f6483a4..4d508ea 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
@@ -13,12 +13,12 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.stream.BufferInputStream;
import org.eclipse.net4j.stream.BufferOutputStream;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.internal.net4j.bundle.OM;
import java.io.EOFException;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.TimeoutException;
@@ -63,16 +63,52 @@ public abstract class Signal implements Runnable
return bufferOutputStream;
}
- protected ExtendedDataInputStream wrapInputStream(InputStream in)
+ protected InputStream wrapInputStream(InputStream in)
{
- in = protocol.wrapInputStream(in);
- return ExtendedDataInputStream.wrap(in);
+ try
+ {
+ return protocol.wrapInputStream(in);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+
+ protected OutputStream wrapOutputStream(OutputStream out)
+ {
+ try
+ {
+ return protocol.wrapOutputStream(out);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
}
- protected ExtendedDataOutputStream wrapOutputStream(OutputStream out)
+ protected void finishInputStream(InputStream in)
{
- out = protocol.wrapOutputStream(out);
- return ExtendedDataOutputStream.wrap(out);
+ try
+ {
+ protocol.finishInputStream(in);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+
+ protected void finishOutputStream(OutputStream out)
+ {
+ try
+ {
+ protocol.finishOutputStream(out);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
}
public final void run()
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 3c55721..c0a7499 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.io.StreamWrapperChain;
import org.eclipse.internal.net4j.Protocol;
import org.eclipse.internal.net4j.bundle.OM;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
@@ -32,7 +33,7 @@ import java.util.concurrent.ExecutorService;
/**
* @author Eike Stepper
*/
-public abstract class SignalProtocol extends Protocol implements IStreamWrapper
+public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> implements IStreamWrapper
{
public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
@@ -42,7 +43,7 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, SignalProtocol.class);
- private static final ContextTracer STREAM_TRACER = new ContextTracer(OM.DEBUG_BUFFER_STREAM, SignalOutputStream.class);
+ private static final ContextTracer STREAM_TRACER = new ContextTracer(OM.DEBUG_BUFFER_STREAM, SignalProtocol.class);
private IStreamWrapper streamWrapper;
@@ -101,7 +102,7 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
return true;
}
- public InputStream wrapInputStream(InputStream in)
+ public InputStream wrapInputStream(InputStream in) throws IOException
{
if (streamWrapper != null)
{
@@ -111,7 +112,7 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
return in;
}
- public OutputStream wrapOutputStream(OutputStream out)
+ public OutputStream wrapOutputStream(OutputStream out) throws IOException
{
if (streamWrapper != null)
{
@@ -121,6 +122,22 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
return out;
}
+ public void finishInputStream(InputStream in) throws IOException
+ {
+ if (streamWrapper != null)
+ {
+ streamWrapper.finishInputStream(in);
+ }
+ }
+
+ public void finishOutputStream(OutputStream out) throws IOException
+ {
+ if (streamWrapper != null)
+ {
+ streamWrapper.finishOutputStream(out);
+ }
+ }
+
public void handleBuffer(IBuffer buffer)
{
ByteBuffer byteBuffer = buffer.getByteBuffer();