hammant 2003/09/04 14:36:47
Modified: server/impl project.xml
Added: server/impl/src/java/org/apache/altrmi/server/impl/callback
CallbackHostContext.java
CallbackServerClassFactory.java
server/impl/src/java/org/apache/altrmi/server/impl/callback/socket
CallbackEnabledSocketCustomStreamServer.java
CallbackServerClientReadWriter.java
PartialCallbackEnabledSocketCustomStreamServer.java
server/impl/src/java/org/apache/altrmi/server/impl/callback/stream
CallbackEnabledCustomStreamReadWriter.java
CallbackStreamInvocationHandler.java
server/impl/src/java/org/apache/altrmi/server/impl/direct
DirectMarshalledServer.java DirectServer.java
Log:
Added back other half of direct and callback
Revision Changes Path
1.2 +10 -0 incubator-altrmi/server/impl/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-altrmi/server/impl/project.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.xml 28 Aug 2003 18:37:37 -0000 1.1
+++ project.xml 4 Sep 2003 21:36:47 -0000 1.2
@@ -22,7 +22,17 @@
</dependency>
<dependency>
<groupId>altrmi</groupId>
+ <artifactId>altrmi-client-api</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>altrmi</groupId>
<artifactId>altrmi-server-api</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>altrmi</groupId>
+ <artifactId>altrmi-client-impl</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
<dependency>
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/CallbackHostContext.java
Index: CallbackHostContext.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback;
import org.apache.altrmi.client.impl.AbstractHostContext;
import
org.apache.altrmi.client.impl.stream.AbstractStreamClientInvocationHandler;
/**
* Class CallbackHostContext wraps a AbstractStreamClientInvocationHandler
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision: 1.1 $
*/
public class CallbackHostContext extends AbstractHostContext
{
/**
* Construct a CallbackHostContext.
* @param streamInvocationHandler The invocation handler.
*/
public CallbackHostContext( AbstractStreamClientInvocationHandler
streamInvocationHandler )
{
super( streamInvocationHandler );
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/CallbackServerClassFactory.java
Index: CallbackServerClassFactory.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback;
import org.apache.altrmi.client.HostContext;
import org.apache.altrmi.client.impl.DefaultProxyHelper;
import org.apache.altrmi.client.impl.ServerSideClassFactory;
import org.apache.altrmi.common.Authentication;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ExceptionReply;
import org.apache.altrmi.common.LookupReply;
import org.apache.altrmi.common.LookupRequest;
import org.apache.altrmi.common.NotPublishedReply;
import org.apache.altrmi.common.OpenConnectionReply;
import org.apache.altrmi.common.OpenConnectionRequest;
import org.apache.altrmi.common.Reply;
import org.apache.altrmi.common.ReplyConstants;
/**
* Class CallbackServerClassFactory :
* Provides a hook for setting the hostContext
* for the Factory WITHOUT having to exchange
* OpenConnectionRequestMessage &
* also to provides the hacks the lookup() mechanism by modifying
* PublishedName during this part of the protocol.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision: 1.1 $
*/
public class CallbackServerClassFactory extends ServerSideClassFactory
{
public CallbackServerClassFactory(HostContext hostContext, boolean
allowOptimize) throws ConnectionException
{
super(hostContext, allowOptimize);
}
//hack method to influence OpenConnectionRequest/reply sequence
/**
* Method lookup
* PublishedName is modified during the lookup so that
* the client-side Server doesNOT have to generate stubs
* for each and every such PublishedName
*
*
* @param publishedServiceName The published service name
* @param authentication An Authentication
* @return The object
* @throws ConnectionException if a proble during connection
*/
public Object lookup( String publishedServiceName, Authentication
authentication )
throws ConnectionException
{
if (m_session == null) {
OpenConnectionReply reply = (OpenConnectionReply)
m_hostContext.getInvocationHandler()
.handleInvocation( new OpenConnectionRequest() );
m_session= reply.getSession();
}
String modifiedPublishedName =
publishedServiceName.substring( 0,
publishedServiceName.lastIndexOf( "_" ) );
Reply ar =
m_hostContext.getInvocationHandler()
.handleInvocation( new LookupRequest( modifiedPublishedName,
authentication,
m_session ) );
if( ar.getReplyCode() >= ReplyConstants.PROBLEMREPLY )
{
if( ar instanceof NotPublishedReply )
{
throw new ConnectionException( "Service " +
publishedServiceName
+ " not published" );
}
else if( ar instanceof ExceptionReply )
{
ExceptionReply er = (ExceptionReply)ar;
throw (ConnectionException)er.getReplyException();
}
else
{
throw new ConnectionException( "Problem doing lookup on
service" );
}
}
LookupReply lr = (LookupReply)ar;
DefaultProxyHelper baseObj = new DefaultProxyHelper(
this, m_hostContext.getInvocationHandler(),
publishedServiceName, "Main",
lr.getReferenceID(), m_session );
Object retVal = getInstance( modifiedPublishedName, "Main", baseObj);
baseObj.registerImplObject( retVal );
return retVal;
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/socket/CallbackEnabledSocketCustomStreamServer.java
Index: CallbackEnabledSocketCustomStreamServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback.socket;
import org.apache.altrmi.common.DefaultThreadPool;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.Authenticator;
import org.apache.altrmi.server.ClassRetriever;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.DefaultServerSideClientContextFactory;
import org.apache.altrmi.server.impl.NullServerMonitor;
import org.apache.altrmi.server.impl.DefaultAuthenticator;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import
org.apache.altrmi.server.impl.callback.stream.CallbackEnabledCustomStreamReadWriter;
import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
import
org.apache.altrmi.server.impl.socket.AbstractCompleteSocketStreamServer;
/**
* Class CallbackEnabledSocketCustomStreamServer
*
[EMAIL PROTECTED] <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision: 1.1 $
*/
public class CallbackEnabledSocketCustomStreamServer extends
AbstractCompleteSocketStreamServer
{
/*
* @see
AbstractCompleteSocketStreamServer#AbstractCompleteSocketStreamServer(int)
*/
/**
* Constructor CallbackEnabledSocketCustomStreamServer
*
* @param classRetriever
* @param authenticator
* @param serverMonitor
* @param threadPool
* @param contextFactory
* @param port
*/
public CallbackEnabledSocketCustomStreamServer(
ClassRetriever classRetriever,
Authenticator authenticator,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory,
int port)
{
super(new InvocationHandlerAdapter(
classRetriever,
authenticator,
serverMonitor,
contextFactory
), serverMonitor, threadPool, contextFactory, port);
}
public static class WithSimpleDefaults extends
CallbackEnabledSocketCustomStreamServer
{
public WithSimpleDefaults(int port)
{
super(
new NoClassRetriever(),
new DefaultAuthenticator(),
new NullServerMonitor(),
new DefaultThreadPool(),
new DefaultServerSideClientContextFactory(),
port);
}
}
/*
* @see AbstractCompleteSocketStreamServer#createServerStreamReadWriter()
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
return new CallbackEnabledCustomStreamReadWriter(m_serverMonitor,
m_threadPool);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/socket/CallbackServerClientReadWriter.java
Index: CallbackServerClientReadWriter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback.socket;
import java.io.IOException;
import org.apache.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.altrmi.common.Reply;
import org.apache.altrmi.common.Request;
import
org.apache.altrmi.server.impl.callback.stream.CallbackEnabledCustomStreamReadWriter;
/**
* Class CallbackServerClientReadWriter
* forwards the postRequest made on it to the
* CallbackEnabledSocketStreamReadWriter
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision: 1.1 $
*/
public class CallbackServerClientReadWriter implements ClientStreamReadWriter
{
private CallbackEnabledCustomStreamReadWriter
m_callbackEnabledCustomSocketStreamReadWriter;
/**
* Constructor CallbackServerClientReadWriter
*
*
* @param callbackEnabledCustomSocketStreamReadWriter
*
*/
public CallbackServerClientReadWriter(
CallbackEnabledCustomStreamReadWriter
callbackEnabledCustomSocketStreamReadWriter )
{
this.m_callbackEnabledCustomSocketStreamReadWriter =
callbackEnabledCustomSocketStreamReadWriter;
}
public Reply postRequest( Request request )
throws IOException, ClassNotFoundException
{
Reply reply =
m_callbackEnabledCustomSocketStreamReadWriter.postRequest(
request );
return reply;
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/socket/PartialCallbackEnabledSocketCustomStreamServer.java
Index: PartialCallbackEnabledSocketCustomStreamServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback.socket;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import
org.apache.altrmi.server.impl.callback.stream.CallbackEnabledCustomStreamReadWriter;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.impl.socket.AbstractPartialSocketStreamServer;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.common.ThreadPool;
/**
* Class CallbackEnabledSocketCustomStreamServer
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @author Peter Royal
* @version $Revision: 1.1 $
*/
public class PartialCallbackEnabledSocketCustomStreamServer
extends AbstractPartialSocketStreamServer
{
/**
* Constructor PartialCallbackEnabledSocketCustomStreamServer
*
*
* @param invocationHandlerAdapter
* @param serverMonitor
*
*/
public
PartialCallbackEnabledSocketCustomStreamServer(InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor
serverMonitor, ThreadPool threadPool,
ServerSideClientContextFactory contextFactory)
{
super(invocationHandlerAdapter, serverMonitor, threadPool,
contextFactory);
}
/*
* @see
AbstractPartialSocketStreamServer#createServerStreamReadWriter()
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
return new CallbackEnabledCustomStreamReadWriter(m_serverMonitor,
m_threadPool);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/stream/CallbackEnabledCustomStreamReadWriter.java
Index: CallbackEnabledCustomStreamReadWriter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback.stream;
import org.apache.altrmi.client.ConnectionClosedException;
import org.apache.altrmi.client.impl.DumbClientMonitor;
import org.apache.altrmi.client.impl.NeverConnectionPinger;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ExposedObjectProxy;
import org.apache.altrmi.common.InvocationExceptionReply;
import org.apache.altrmi.common.MethodRequest;
import org.apache.altrmi.common.Reply;
import org.apache.altrmi.common.ReqRepBytes;
import org.apache.altrmi.common.Request;
import org.apache.altrmi.common.SerializationHelper;
import org.apache.altrmi.common.ThreadContext;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.callback.CallbackHostContext;
import org.apache.altrmi.server.impl.callback.CallbackServerClassFactory;
import
org.apache.altrmi.server.impl.callback.socket.CallbackServerClientReadWriter;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.net.SocketException;
/**
* CallbackEnabledCustomStreamReadWriter
* This StreamReadWriter is responsible for unmarshalling
* exposedClient objects too and devliering it to the Remote Object.
* The calls made for the exposed Client Object is also marshalled
* out here with the aid of the internal InvocationHandler.
* The callbacks are multiplexed over the same connection and thus
* there are no extra network connections needed to enable callbacks.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class CallbackEnabledCustomStreamReadWriter extends
AbstractServerStreamReadWriter
implements Runnable
{
private DataInputStream m_dataInputStream;
private DataOutputStream m_dataOutputStream;
private ThreadContext m_messageLoopThread = null;
private boolean m_isStopped = false;
private Object m_requestLock = new Object();
private Object m_replyLock = new Object();
private Request m_request = null;
private Reply m_reply = null;
private CallbackServerClientReadWriter m_callbackServerClientReadWriter;
private CallbackStreamInvocationHandler m_callbackStreamInvocationHandler;
private CallbackHostContext m_callbackHostContext;
private CallbackServerClassFactory m_factory;
public CallbackEnabledCustomStreamReadWriter(ServerMonitor serverMonitor,
ThreadPool threadPool)
{
super(serverMonitor, threadPool);
}
/*
* @see AbstractServerStreamReadWriter#initialize()
*/
protected void initialize() throws IOException
{
m_dataInputStream = new DataInputStream(getInputStream());
m_dataOutputStream = new DataOutputStream(new
BufferedOutputStream(getOutputStream()));
//start the receiving message loop
m_messageLoopThread = m_threadPool.getThreadContext(this);
m_messageLoopThread.start();
}
/**
* Message Loop .
* Notifies the Reply or Request monitor depending upon the type of
message.
* @see java.lang.Runnable#run()
*/
public void run()
{
m_callbackServerClientReadWriter = new
CallbackServerClientReadWriter(this);
m_callbackStreamInvocationHandler =
new CallbackStreamInvocationHandler(m_threadPool, new
DumbClientMonitor(), new NeverConnectionPinger(),
this.getClass().getClassLoader());
m_callbackStreamInvocationHandler.setObjectReadWriter(m_callbackServerClientReadWriter);
m_callbackHostContext = new
CallbackHostContext(m_callbackStreamInvocationHandler);
try
{
m_factory = new CallbackServerClassFactory(m_callbackHostContext,
false);
}
catch (ConnectionException e)
{
m_serverMonitor.unexpectedException(this.getClass(), "Connection
Exception in CallbackEnabledCustomStreamReadWriter", e);
m_request = null;
m_isStopped = true;
return;
}
while (!m_isStopped)
{
ReqRepBytes reqRepBytes =
ReqRepBytes.getRequestReplyBytesFromDataStream(m_dataInputStream);
if (reqRepBytes.getIOException() != null)
{
IOException ioe = reqRepBytes.getIOException();
if (ioe != null)
{
if ((ioe instanceof EOFException &&
reqRepBytes.ioeDuringReadInt())
|| ioe instanceof SocketException)
{
m_serverMonitor.closeError(this.getClass(), "Close
During callback operation", ioe);
m_isStopped = true;
notifyBoth();
// restart ?
return;
}
}
m_serverMonitor.unexpectedException(this.getClass(), "Problem
during reading of bytes", ioe);
}
//interpret it as a request or reply & notify the corresponding
listeners
// SHLD we need a queue here to hold the arriving packets
// TODO:WORKAROUND: Dont receive until the data is handled some
way
if (reqRepBytes.isRequest())
{
try
{
Object obj =
SerializationHelper.getInstanceFromBytes(reqRepBytes.getBytes());
m_request = (Request) obj;
}
catch (ClassNotFoundException e)
{
m_serverMonitor.classNotFound(this.getClass(), e);
m_request = null;
m_isStopped = true;
return;
}
synchronized (m_requestLock)
{
m_requestLock.notify();
}
}
else // Reply.
{
try
{
Object obj =
SerializationHelper.getInstanceFromBytes(reqRepBytes.getBytes());
m_reply = (Reply) obj;
}
catch (ClassNotFoundException e)
{
m_serverMonitor.classNotFound(this.getClass(), e);
m_reply = new
InvocationExceptionReply("ClassNotFoundException " + e.getMessage());
}
synchronized (m_replyLock)
{
m_replyLock.notify();
}
}
}
}
private void notifyBoth()
{
m_isStopped = true;
synchronized (m_requestLock)
{
m_requestLock.notify();
}
synchronized (m_replyLock)
{
m_replyLock.notify();
}
}
/**
* Method getRequestFromMessageLoop.
* @return Request
*/
private Request getRequestFromMessageLoop()
{
//if(_replyQueue.size()==0)
if (m_request == null)
{
synchronized (m_requestLock)
{
try
{
m_requestLock.wait();
}
catch (InterruptedException e)
{
m_serverMonitor.unexpectedException(this.getClass(),
"Wait issue", e);
}
}
}
return m_request;
}
/**
* Method getReplyFromMessageLoop.
* @return Reply
*/
private Reply getReplyFromMessageLoop()
{
if (m_reply == null)
{
synchronized (m_replyLock)
{
try
{
m_replyLock.wait();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
return m_reply;
}
/*
* @see AbstractServerStreamReadWriter#writeReplyAndGetRequest(Reply)
*/
protected Request writeReplyAndGetRequest(Reply reply)
throws IOException, ClassNotFoundException
{
if (reply != null)
{
writeReply(reply);
}
Request req = readRequest();
m_request = null;
return req;
}
/**
* Method writeReply.
* @param reply
* @throws java.io.IOException
*/
private void writeReply(Reply reply) throws IOException
{
byte[] aBytes = SerializationHelper.getBytesFromInstance(reply);
m_dataOutputStream.writeInt(aBytes.length);
m_dataOutputStream.writeBoolean(false);
m_dataOutputStream.write(aBytes);
m_dataOutputStream.flush();
}
/**
* Method readRequest.
* @return Request
*/
private Request readRequest()
{
Request request = getRequestFromMessageLoop();
if (request instanceof MethodRequest)
{
correctArgs(((MethodRequest) request).getArgs());
}
return request;
}
//client side
/**
* Method postRequest.
* @param request
* @return Reply
* @throws java.io.IOException
* @throws java.lang.ClassNotFoundException
*/
public Reply postRequest(Request request)
throws IOException, ClassNotFoundException
{
if (m_isStopped)
{
throw new ConnectionClosedException("Client Closed Connection");
}
writeRequest(request);
Reply r = getReplyFromMessageLoop();
if (r == null)
{
throw new java.io.InterruptedIOException("Client Connection
Closed");
}
m_reply = null;
return r;
}
/**
* Method writeRequest.
* @param request
* @throws java.io.IOException
*/
private void writeRequest(Request request) throws IOException
{
byte[] aBytes = SerializationHelper.getBytesFromInstance(request);
m_dataOutputStream.writeInt(aBytes.length);
m_dataOutputStream.writeBoolean(true);
m_dataOutputStream.write(aBytes);
m_dataOutputStream.flush();
}
/**
* Method correctArgs.
* UnMarshall the arguments .
* @param args
*/
public void correctArgs(Object[] args)
{
for (int i = 0; i < args.length; i++)
{
if (args[i] instanceof ExposedObjectProxy)
{
ExposedObjectProxy exposedObjectProxy = (ExposedObjectProxy)
args[i];
try
{
//lookup the client-side exported object.
Object obj =
m_factory.lookup(exposedObjectProxy.getPublishedName());
args[i] = obj;
}
catch (ConnectionException connectionException)
{
m_serverMonitor.unexpectedException(this.getClass(),
"Connection issue on lookup", connectionException);
}
}
}
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/callback/stream/CallbackStreamInvocationHandler.java
Index: CallbackStreamInvocationHandler.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.callback.stream;
import org.apache.altrmi.client.impl.ClientStreamReadWriter;
import
org.apache.altrmi.client.impl.stream.AbstractStreamClientInvocationHandler;
import org.apache.altrmi.client.ConnectionPinger;
import org.apache.altrmi.client.ClientMonitor;
import org.apache.altrmi.common.ThreadPool;
/**
* Class CallbackStreamInvocationHandler
* provides public access to the setObjectReadWriter function
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision: 1.1 $
*/
public class CallbackStreamInvocationHandler extends
AbstractStreamClientInvocationHandler
{
/*
* @see
AbstractStreamClientInvocationHandler#AbstractStreamClientInvocationHandler(ClassLoader)
*/
/**
* Constructor CallbackStreamInvocationHandler
*
*
* @param interfacesClassLoader
*
*/
public CallbackStreamInvocationHandler( ThreadPool threadPool,
ClientMonitor clientMonitor,
ConnectionPinger
connectionPinger, ClassLoader interfacesClassLoader )
{
super(threadPool, clientMonitor, connectionPinger,
interfacesClassLoader );
}
/*
* @see AbstractClientInvocationHandler#tryReconnect()
*/
/**
* Method tryReconnect
*
*
* @return
*
*/
public boolean tryReconnect()
{
return true;
}
/*
* @see
AbstractStreamClientInvocationHandler#setObjectReadWriter(ClientStreamReadWriter)
*/
/**
* Method setObjectReadWriter
*
*
* @param clientStreamReadWriter
*
*/
public void setObjectReadWriter( ClientStreamReadWriter
clientStreamReadWriter )
{
super.setObjectReadWriter( clientStreamReadWriter );
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/direct/DirectMarshalledServer.java
Index: DirectMarshalledServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.direct;
import org.apache.altrmi.common.DefaultThreadPool;
import org.apache.altrmi.common.InvocationExceptionReply;
import org.apache.altrmi.common.Reply;
import org.apache.altrmi.common.Request;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.Authenticator;
import org.apache.altrmi.server.ClassRetriever;
import org.apache.altrmi.server.ServerMarshalledInvocationHandler;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.impl.AbstractServer;
import org.apache.altrmi.server.impl.DefaultServerSideClientContextFactory;
import org.apache.altrmi.server.impl.NullServerMonitor;
import org.apache.altrmi.server.impl.DefaultAuthenticator;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import
org.apache.altrmi.server.impl.adapters.MarshalledInvocationHandlerAdapter;
import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
/**
* Class DirectMarshalledServer
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class DirectMarshalledServer extends AbstractServer
implements ServerMarshalledInvocationHandler {
private final MarshalledInvocationHandlerAdapter
m_marshalledInvocationHandlerAdapter;
/**
* Constructor DirectMarshalledServer for use with pre-exiting
InvocationHandlerAdapter and MarshalledInvocationHandler
*
* @param invocationHandlerAdapter
* @param serverMonitor
* @param threadPool
* @param contextFactory
* @param m_marshalledInvocationHandlerAdapter
*/
public DirectMarshalledServer(
InvocationHandlerAdapter invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory,
MarshalledInvocationHandlerAdapter
m_marshalledInvocationHandlerAdapter) {
super(
invocationHandlerAdapter,
serverMonitor,
threadPool,
contextFactory);
this.m_marshalledInvocationHandlerAdapter =
m_marshalledInvocationHandlerAdapter;
}
public static class WithMarshalledInvocationHandlerAdapter extends
DirectMarshalledServer {
public WithMarshalledInvocationHandlerAdapter(
InvocationHandlerAdapter invocationHandlerAdapter,
MarshalledInvocationHandlerAdapter
marshalledInvocationHandlerAdapter) {
super(
invocationHandlerAdapter,
new NullServerMonitor(),
new DefaultThreadPool(),
new DefaultServerSideClientContextFactory(),
marshalledInvocationHandlerAdapter
);
}
}
public static class WithInvocationHandlerAdapter extends
WithMarshalledInvocationHandlerAdapter {
public WithInvocationHandlerAdapter(InvocationHandlerAdapter
invocationHandlerAdapter) {
super(
invocationHandlerAdapter,
new
MarshalledInvocationHandlerAdapter(invocationHandlerAdapter)
);
}
}
// public DirectMarshalledServer(
//
// ClassRetriever classRetriever,
// Authenticator authenticator,
// ServerMonitor serverMonitor,
// ThreadPool threadPool,
// ServerSideClientContextFactory contextFactory,
// MarshalledInvocationHandlerAdapter
marshalledInvocationHandlerAdapter)
// {
// super(
// new InvocationHandlerAdapter(
// classRetriever,
// authenticator,
// serverMonitor,
// contextFactory),
// serverMonitor, threadPool, contextFactory);
// m_marshalledInvocationHandlerAdapter =
marshalledInvocationHandlerAdapter;
// }
public static class WithSimpleDefaults extends
WithInvocationHandlerAdapter {
public WithSimpleDefaults() {
super(
new InvocationHandlerAdapter(
new NoClassRetriever(),
new DefaultAuthenticator(),
new NullServerMonitor(),
new DefaultServerSideClientContextFactory())
);
}
}
/**
* Method start
*
*/
public void start() {
setState(STARTED);
}
/**
* Method stop
*
*/
public void stop() {
setState(SHUTTINGDOWN);
killAllConnections();
setState(STOPPED);
}
/**
* Method handleInvocation
*
*
* @param request
*
* @return
*
*/
public byte[] handleInvocation(byte[] request, Object connectionDetails) {
return m_marshalledInvocationHandlerAdapter.handleInvocation(request,
connectionDetails);
}
/**
* Method handleInvocation
*
*
* @param request
*
* @return
*
*/
public Reply handleInvocation(Request request, Object connectionDetails) {
if (getState() == STARTED) {
return super.handleInvocation(request, connectionDetails);
} else {
return new InvocationExceptionReply("Service is not started");
}
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/direct/DirectServer.java
Index: DirectServer.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.server.impl.direct;
import org.apache.altrmi.common.DefaultThreadPool;
import org.apache.altrmi.common.InvocationExceptionReply;
import org.apache.altrmi.common.Reply;
import org.apache.altrmi.common.Request;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.Authenticator;
import org.apache.altrmi.server.ClassRetriever;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.impl.AbstractServer;
import org.apache.altrmi.server.impl.DefaultServerSideClientContextFactory;
import org.apache.altrmi.server.impl.NullServerMonitor;
import org.apache.altrmi.server.impl.DefaultAuthenticator;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
/**
* Class DirectServer
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class DirectServer extends AbstractServer
{
/**
* Constructor DirectServer for use with pre-exiting
InvocationHandlerAdapter.
*
* @param classRetriever
* @param authenticator
* @param serverMonitor
* @param threadPool
* @param contextFactory
*/
public DirectServer(
ClassRetriever classRetriever,
Authenticator authenticator,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory)
{
super(new InvocationHandlerAdapter(
classRetriever,
authenticator,
serverMonitor,
contextFactory
), serverMonitor, threadPool, contextFactory);
}
public static class WithSimpleDefaults extends DirectServer
{
public WithSimpleDefaults()
{
super(
new NoClassRetriever(),
new DefaultAuthenticator(),
new NullServerMonitor(),
new DefaultThreadPool(),
new DefaultServerSideClientContextFactory());
}
}
/**
* Method start
*
*/
public void start()
{
setState(STARTED);
}
/**
* Method stop
*
*/
public void stop()
{
setState(SHUTTINGDOWN);
killAllConnections();
setState(STOPPED);
}
/**
* Method handleInvocation
*
*
* @param request
*
* @return
*
*/
public Reply handleInvocation( Request request )
{
if( getState() == STARTED )
{
return super.handleInvocation( request, "" );
}
else
{
return new InvocationExceptionReply( "Service is not started" );
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]