Author: david.lloyd(a)jboss.com
Date: 2008-03-25 17:09:44 -0400 (Tue, 25 Mar 2008)
New Revision: 3754
Modified:
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java
Log:
Connects.... again.... sort of
Modified:
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java
===================================================================
---
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java 2008-03-25
20:37:25 UTC (rev 3753)
+++
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java 2008-03-25
21:09:44 UTC (rev 3754)
@@ -106,8 +106,10 @@
}
private enum State implements org.jboss.cx.remoting.util.State<State> {
- /** Initial state - unconnected */
+ /** Initial state - unconnected and uninitialized */
NEW,
+ /** Initial state - unconnected but initialized */
+ INITIALIZED,
/** Client side, waiting to receive protocol version info */
AWAITING_SERVER_VERSION,
/** Server side, waiting to receive protocol version info */
@@ -141,18 +143,14 @@
protocolHandler = new RemotingProtocolHandler();
}
- public void initializeClient(final IoSession ioSession, final ProtocolContext
protocolContext) {
+ public void initializeClient(final IoSession ioSession) {
if (ioSession == null) {
throw new NullPointerException("ioSession is null");
}
- if (protocolContext == null) {
- throw new NullPointerException("protocolContext is null");
- }
- state.transitionExclusive(State.NEW, State.AWAITING_SERVER_VERSION);
+ state.transitionExclusive(State.NEW, State.INITIALIZED);
try {
ioSession.setAttribute(JRPP_CONNECTION, this);
this.ioSession = ioSession;
- this.protocolContext = protocolContext;
client = true;
remoteRootContextIdentifier = new JrppContextIdentifier(false, 0);
localRootContextIdentifier = new JrppContextIdentifier(true, 0);
@@ -161,18 +159,14 @@
}
}
- public void initializeServer(final IoSession ioSession, final ProtocolContext
protocolContext) {
+ public void initializeServer(final IoSession ioSession) {
if (ioSession == null) {
throw new NullPointerException("ioSession is null");
}
- if (protocolContext == null) {
- throw new NullPointerException("protocolContext is null");
- }
- state.transitionExclusive(State.NEW, State.AWAITING_CLIENT_VERSION);
+ state.transitionExclusive(State.NEW, State.INITIALIZED);
try {
ioSession.setAttribute(JRPP_CONNECTION, this);
this.ioSession = ioSession;
- this.protocolContext = protocolContext;
client = false;
remoteRootContextIdentifier = new JrppContextIdentifier(true, 0);
localRootContextIdentifier = new JrppContextIdentifier(false, 0);
@@ -181,6 +175,15 @@
}
}
+ public void start(final ProtocolContext protocolContext) {
+ if (protocolContext == null) {
+ throw new NullPointerException("protocolContext is null");
+ }
+ state.requireTransitionExclusive(State.INITIALIZED, client ?
State.AWAITING_SERVER_VERSION : State.AWAITING_CLIENT_VERSION);
+ this.protocolContext = protocolContext;
+ state.releaseExclusive();
+ }
+
private String getNegotiatedMechanism(final String[] clientMechs, final
Set<String> serverMechs) throws SaslException {
for (String name : clientMechs) {
if (serverMechs.contains(name)) {
Modified:
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java
===================================================================
---
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java 2008-03-25
20:37:25 UTC (rev 3753)
+++
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java 2008-03-25
21:09:44 UTC (rev 3754)
@@ -135,7 +135,8 @@
final SocketAddress serverAddress = getSocketAddressFromUri(remoteUri);
final ConnectFuture future = connector.connect(serverAddress, new
IoSessionInitializer<ConnectFuture>() {
public void initializeSession(final IoSession ioSession, final
ConnectFuture connectFuture) {
- jrppConnection.initializeClient(ioSession, context);
+ jrppConnection.initializeClient(ioSession);
+ jrppConnection.start(context);
}
});
future.awaitUninterruptibly();
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java
===================================================================
---
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java 2008-03-25
20:37:25 UTC (rev 3753)
+++
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java 2008-03-25
21:09:44 UTC (rev 3754)
@@ -17,9 +17,8 @@
import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.jrpp.mina.FramingIoFilter;
import org.jboss.cx.remoting.Endpoint;
+import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
-import com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl;
-
/**
*
*/
@@ -118,7 +117,9 @@
private final class ServerSessionHandlerFactory implements
SingleSessionIoHandlerFactory {
public SingleSessionIoHandler getHandler(IoSession ioSession) throws IOException
{
final JrppConnection connection = new JrppConnection(attributeMap);
- endpoint.openIncomingSession(connection.getProtocolHandler());
+ connection.initializeServer(ioSession);
+ final ProtocolContext protocolContext =
endpoint.openIncomingSession(connection.getProtocolHandler());
+ connection.start(protocolContext);
return connection.getIoHandler();
}
}
Show replies by date