vinayc 2003/08/28 11:34:20
Added: server/impl/src/java/org/apache/altrmi/server/impl/socket
AbstractCompleteSocketStreamServer.java
AbstractPartialSocketStreamServer.java
CompleteCustomStreamPipedServer.java
CompleteSocketCustomStreamPipedBinder.java
CompleteSocketCustomStreamPipedConnection.java
CompleteSocketCustomStreamServer.java
CompleteSocketObjectStreamPipedBinder.java
CompleteSocketObjectStreamPipedConnection.java
CompleteSocketObjectStreamServer.java
PartialSocketCustomStreamServer.java
PartialSocketObjectStreamServer.java
SocketStreamServerConnection.java
Log:
Refactorize (includes modularize,mavenize & rest of the nice's)
Revision Changes Path
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java
Index: AbstractCompleteSocketStreamServer.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.socket;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import org.apache.altrmi.server.ServerException;
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.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.common.AltrmiRuntimeException;
import org.apache.altrmi.common.ThreadContext;
import org.apache.altrmi.common.ThreadPool;
import javax.swing.*;
/**
* Class CompleteSocketObjectStreamServer
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public abstract class AbstractCompleteSocketStreamServer extends
AbstractServer
implements Runnable
{
/**
* The server socket.
*/
private ServerSocket m_serverSocket;
/**
* The thread handling the listening
*/
private ThreadContext m_threadContext;
private int m_port;
/**
* Construct a AbstractCompleteSocketStreamServer
*
*
* @param invocationHandlerAdapter The invocation handler adapter to use.
* @param port The port to use
* @param serverMonitor
*
*
*/
public AbstractCompleteSocketStreamServer(
InvocationHandlerAdapter invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory,
int port )
{
super( invocationHandlerAdapter, serverMonitor, threadPool,
contextFactory );
m_port = port;
}
/**
* Method run
*
*
*/
public void run()
{
boolean accepting = false;
try
{
while( getState() == STARTED )
{
accepting = true;
Socket sock = m_serverSocket.accept();
accepting = false;
// see
http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
sock.setSoTimeout( 36000 );
AbstractServerStreamReadWriter ssrw =
createServerStreamReadWriter();
ssrw.setStreams( sock.getInputStream(),
sock.getOutputStream(), sock );
SocketStreamServerConnection sssc =
new SocketStreamServerConnection( this, sock, ssrw,
m_serverMonitor );
//TODO ? Two of these getThreadContexts? PH
ThreadContext threadContext =
getThreadPool().getThreadContext(sssc);
threadContext.start();
}
}
catch( IOException ioe )
{
if (accepting & ioe.getMessage().equals("socket closed"))
{
// do nothing, server shut down during accept();
}
else
{
m_serverMonitor.unexpectedException(this.getClass(),
"AbstractCompleteSocketStreamServer.run(): Some problem connecting client " +
"via sockets: ", ioe);
}
}
}
/**
* Method start
*
*/
public void start() throws ServerException
{
setState(STARTING);
try
{
m_serverSocket = new ServerSocket( m_port );
}
catch( IOException ioe )
{
throw new ServerException( "Could not bind to a socket when
setting up the server", ioe);
}
setState(STARTED);
getThreadContext().start();
}
/**
* Method stop
*
*/
public void stop()
{
if (getState() != STARTED) {
throw new AltrmiRuntimeException("Server Not Started at time of
stop");
}
setState(SHUTTINGDOWN);
try
{
m_serverSocket.close();
}
catch ( IOException ioe )
{
throw new AltrmiRuntimeException("Error stopping Complete Socket
server", ioe);
}
killAllConnections();
getThreadContext().interrupt();
setState(STOPPED);
}
/**
* Get the thread used for connection processing
* @return
*/
private ThreadContext getThreadContext()
{
if( m_threadContext == null )
{
m_threadContext = getThreadPool().getThreadContext(this);
}
return m_threadContext;
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected abstract AbstractServerStreamReadWriter
createServerStreamReadWriter();
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/AbstractPartialSocketStreamServer.java
Index: AbstractPartialSocketStreamServer.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.socket;
import java.io.IOException;
import java.net.Socket;
import java.net.SocketException;
import org.apache.altrmi.server.impl.AbstractServer;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.common.ThreadPool;
/**
* @author Peter Royal
* @version $Revision: 1.1 $
*/
public abstract class AbstractPartialSocketStreamServer extends AbstractServer
{
/**
* Construct a AbstractPartialSocketStreamServer
* @param invocationHandlerAdapter Use this invocation handler adapter.
* @param serverMonitor The server Monitor
*/
public AbstractPartialSocketStreamServer( InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool, ServerSideClientContextFactory contextFactory )
{
super( invocationHandlerAdapter, serverMonitor, threadPool,
contextFactory);
}
/**
* Handle a connection.
*
* @param socket The socket for the connection
*
*/
public void handleConnection( final Socket socket )
{
// see
http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
try
{
socket.setSoTimeout( 36000 );
}
catch( SocketException se )
{
m_serverMonitor.unexpectedException(this.getClass(),
"AbstractPartialSocketStreamServer.handleConnection(): Some error during " +
"socket handling", se);
}
try
{
if( getState() == STARTED )
{
AbstractServerStreamReadWriter ssrw =
createServerStreamReadWriter();
ssrw.setStreams( socket.getInputStream(),
socket.getOutputStream(), socket );
SocketStreamServerConnection sssc =
new SocketStreamServerConnection( this, socket, ssrw,
m_serverMonitor );
sssc.run();
}
}
catch( IOException ioe )
{
m_serverMonitor.unexpectedException(this.getClass(),
"AbstractPartialSocketStreamServer.handleConnection(): Some problem connecting
" +
"client via sockets: ", ioe);
}
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected abstract AbstractServerStreamReadWriter
createServerStreamReadWriter();
/**
* Method start
*
*/
public void start()
{
setState(STARTED);
}
/**
* Method stop
*
*/
public void stop()
{
setState(SHUTTINGDOWN);
killAllConnections();
setState(STOPPED);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteCustomStreamPipedServer.java
Index: CompleteCustomStreamPipedServer.java
===================================================================
package org.apache.altrmi.server.impl.socket;
import org.apache.altrmi.server.impl.piped.PipedCustomStreamServer;
import org.apache.altrmi.server.impl.piped.AbstractPipedServer;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.ServerCustomStreamReadWriter;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.common.ThreadPool;
public class CompleteCustomStreamPipedServer extends AbstractPipedServer
{
public CompleteCustomStreamPipedServer(InvocationHandlerAdapter
invocationHandlerAdapter, ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory)
{
super(invocationHandlerAdapter,serverMonitor,threadPool,contextFactory);
}
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerCustomStreamReadWriter(m_serverMonitor,
m_threadPool);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketCustomStreamPipedBinder.java
Index: CompleteSocketCustomStreamPipedBinder.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.socket;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.registry.Binder;
import org.apache.altrmi.registry.BindException;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ThreadPool;
import java.util.Vector;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
* A Complete Socket Custom Stream Piped Binder
* @author Paul Hammant
*/
public class CompleteSocketCustomStreamPipedBinder implements Binder
{
private InvocationHandlerAdapter m_invocationHandlerAdapter;
private final ServerMonitor m_serverMonitor;
private final ThreadPool m_threadPool;
private final ServerSideClientContextFactory m_contextFactory;
private Vector m_connections = new Vector();
/**
* Construuct a Piped Binder
* @param invocationHandlerAdapter An invocation handler adapter to
handle requests
*/
public CompleteSocketCustomStreamPipedBinder(InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory)
{
m_invocationHandlerAdapter = invocationHandlerAdapter;
m_serverMonitor = serverMonitor;
m_threadPool = threadPool;
m_contextFactory = contextFactory;
}
/**
* Bind to an piped stream
* @param bindParms the piped input stream and piped output stream
* @return thebound object
* @throws BindException if a problem
*/
public Object bind(Object[] bindParms) throws BindException
{
PipedInputStream inputStream = (PipedInputStream) bindParms[0];
PipedOutputStream outputStream = (PipedOutputStream) bindParms[1];
try
{
Object connection =
new
CompleteSocketCustomStreamPipedConnection(m_invocationHandlerAdapter,
this, inputStream, outputStream, m_threadPool,
m_contextFactory, m_serverMonitor);
m_connections.add(connection);
return connection;
}
catch (ConnectionException e)
{
throw new BindException("Problem binding: " + e.getMessage());
}
}
/**
* Stop the server
*/
public void stop()
{
for (int i = 0; i < m_connections.size(); i++)
{
CompleteSocketCustomStreamPipedConnection
completeSocketCustomStreamPipedConnection =
(CompleteSocketCustomStreamPipedConnection)
m_connections.elementAt(i);
completeSocketCustomStreamPipedConnection.stop();
}
}
/**
* End a connection
* @param connection the connection
*/
void endConnection(CompleteSocketCustomStreamPipedConnection connection)
{
for (int i = 0; i < m_connections.size(); i++)
{
CompleteSocketCustomStreamPipedConnection
completeSocketCustomStreamPipedConnection =
(CompleteSocketCustomStreamPipedConnection)
m_connections.elementAt(i);
if (connection == completeSocketCustomStreamPipedConnection)
{
connection.stop();
}
}
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketCustomStreamPipedConnection.java
Index: CompleteSocketCustomStreamPipedConnection.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.socket;
import org.apache.altrmi.server.impl.piped.PipedCustomStreamServer;
import org.apache.altrmi.server.impl.piped.AbstractPipedServer;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.ClassRetriever;
import org.apache.altrmi.server.Authenticator;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ThreadPool;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
* A Complete Sockect Custom Stream Piped Instance.
* @author Paul Hammant
*/
public class CompleteSocketCustomStreamPipedConnection
{
private CompleteCustomStreamPipedServer m_pipedCustomStreamServer;
private CompleteSocketCustomStreamPipedBinder
m_completeSocketCustomStreamPipedBinder;
/**
* Create a Complete Socket CustomStream Piped Connection
* @param invocationHandlerAdapter the invocation adapter from the
SocketCustomStream
* @param completeSocketCustomStreamPipedBinder The binder that controls
this connection
* @param inputStream the piped input stream
* @param outputStream the piped output stream
* @throws ConnectionException if a problem
*/
public CompleteSocketCustomStreamPipedConnection
(
InvocationHandlerAdapter invocationHandlerAdapter,
CompleteSocketCustomStreamPipedBinder
completeSocketCustomStreamPipedBinder,
PipedInputStream inputStream,
PipedOutputStream outputStream,
ThreadPool threadPool, ServerSideClientContextFactory
contextFactory,
ServerMonitor serverMonitor) throws ConnectionException
{
m_pipedCustomStreamServer = new
CompleteCustomStreamPipedServer(invocationHandlerAdapter,serverMonitor,
threadPool,contextFactory);
m_pipedCustomStreamServer.start();
m_completeSocketCustomStreamPipedBinder =
completeSocketCustomStreamPipedBinder;
m_pipedCustomStreamServer.makeNewConnection(inputStream,
outputStream);
}
/**
* Close the connection
*/
public void close()
{
m_completeSocketCustomStreamPipedBinder.endConnection(this);
}
/**
* Stop the server.
*/
protected void stop()
{
m_pipedCustomStreamServer.stop();
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketCustomStreamServer.java
Index: CompleteSocketCustomStreamServer.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.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.ServerCustomStreamReadWriter;
import org.apache.altrmi.server.impl.DefaultAuthenticator;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
/**
* Class CompleteSocketObjectStreamServer
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class CompleteSocketCustomStreamServer extends
AbstractCompleteSocketStreamServer
{
/**
* Construct a CompleteSocketCustomStreamServer
*
* @param classRetriever
* @param authenticator
* @param serverMonitor
* @param threadPool
* @param contextFactory
* @param port
*/
public CompleteSocketCustomStreamServer(
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
CompleteSocketCustomStreamServer
{
public WithSimpleDefaults(int port)
{
super(
new NoClassRetriever(),
new DefaultAuthenticator(),
new NullServerMonitor(),
new DefaultThreadPool(),
new DefaultServerSideClientContextFactory(),
port);
}
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
ServerCustomStreamReadWriter rw = new
ServerCustomStreamReadWriter(m_serverMonitor, m_threadPool);
return rw;
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketObjectStreamPipedBinder.java
Index: CompleteSocketObjectStreamPipedBinder.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.socket;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.registry.Binder;
import org.apache.altrmi.registry.BindException;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ThreadPool;
import java.util.Vector;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
* A Complete Socket Object Stream Piped Binder
* @author Paul Hammant
*/
public class CompleteSocketObjectStreamPipedBinder implements Binder
{
private InvocationHandlerAdapter m_invocationHandlerAdapter;
private final ServerMonitor m_serverMonitor;
private final ThreadPool m_threadPool;
private final ServerSideClientContextFactory m_contextFactory;
private Vector m_connections = new Vector();
/**
* Construuct a Piped Binder
* @param invocationHandlerAdapter An invocation handler adapter to
handle requests
*/
public CompleteSocketObjectStreamPipedBinder(InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory)
{
m_invocationHandlerAdapter = invocationHandlerAdapter;
this.m_serverMonitor = serverMonitor;
m_threadPool = threadPool;
m_contextFactory = contextFactory;
}
/**
* Bind to an piped stream
* @param bindParms the piped input stream and piped output stream
* @return thebound object
* @throws BindException if a problem
*/
public Object bind(Object[] bindParms) throws BindException
{
PipedInputStream inputStream = (PipedInputStream) bindParms[0];
PipedOutputStream outputStream = (PipedOutputStream) bindParms[1];
try
{
Object connection =
new
CompleteSocketObjectStreamPipedConnection(m_invocationHandlerAdapter,
this, m_serverMonitor, m_threadPool, m_contextFactory,
inputStream, outputStream);
m_connections.add(connection);
return connection;
}
catch (ConnectionException e)
{
throw new BindException("Problem binding: " + e.getMessage());
}
}
/**
* Stop the server
*/
public void stop()
{
for (int i = 0; i < m_connections.size(); i++)
{
CompleteSocketObjectStreamPipedConnection
completeSocketObjectStreamPipedConnection =
(CompleteSocketObjectStreamPipedConnection)
m_connections.elementAt(i);
completeSocketObjectStreamPipedConnection.stop();
}
}
/**
* End a connection
* @param connection the connection
*/
void endConnection(CompleteSocketObjectStreamPipedConnection connection)
{
for (int i = 0; i < m_connections.size(); i++)
{
CompleteSocketObjectStreamPipedConnection
completeSocketObjectStreamPipedConnection =
(CompleteSocketObjectStreamPipedConnection)
m_connections.elementAt(i);
if (connection == completeSocketObjectStreamPipedConnection)
{
connection.stop();
}
}
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketObjectStreamPipedConnection.java
Index: CompleteSocketObjectStreamPipedConnection.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.socket;
import org.apache.altrmi.common.ConnectionException;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
* A Complete Sockect Object Stream Piped Connection.
* @author Paul Hammant
*/
public class CompleteSocketObjectStreamPipedConnection
{
private CompleteCustomStreamPipedServer m_completeCustomStreamPipedServer;
private CompleteSocketObjectStreamPipedBinder
m_completeSocketObjectStreamPipedBinder;
/**
* Create a Complete Socket ObjectStream Piped Connection
* @param invocationHandlerAdapter the invocation adapter from the
SocketObjectStream
* @param completeSocketObjectStreamPipedBinder The binder that controls
this connection
* @param inputStream the piped input stream
* @param outputStream the piped output stream
* @throws ConnectionException if a problem
*/
public CompleteSocketObjectStreamPipedConnection
(
InvocationHandlerAdapter invocationHandlerAdapter,
CompleteSocketObjectStreamPipedBinder
completeSocketObjectStreamPipedBinder,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory contextFactory,
PipedInputStream inputStream,
PipedOutputStream outputStream) throws ConnectionException
{
m_completeCustomStreamPipedServer = new
CompleteCustomStreamPipedServer(invocationHandlerAdapter, serverMonitor,
threadPool, contextFactory);
m_completeSocketObjectStreamPipedBinder =
completeSocketObjectStreamPipedBinder;
m_completeCustomStreamPipedServer.makeNewConnection(inputStream,
outputStream);
m_completeCustomStreamPipedServer.start();
}
/**
* Close the connection
*/
public void close()
{
m_completeSocketObjectStreamPipedBinder.endConnection(this);
}
/**
* Stop the server.
*/
protected void stop()
{
m_completeCustomStreamPipedServer.stop();
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java
Index: CompleteSocketObjectStreamServer.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.socket;
import org.apache.altrmi.common.DefaultThreadPool;
import org.apache.altrmi.common.ThreadPool;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.server.ClassRetriever;
import org.apache.altrmi.server.Authenticator;
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.ServerObjectStreamReadWriter;
import org.apache.altrmi.server.impl.DefaultAuthenticator;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
/**
* Class CompleteSocketObjectStreamServer
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class CompleteSocketObjectStreamServer extends
AbstractCompleteSocketStreamServer
{
/**
* Construct a CompleteSocketObjectStreamServer
*
*
* @param port The port to use.
*
*
*/
public CompleteSocketObjectStreamServer(
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
CompleteSocketObjectStreamServer
{
public WithSimpleDefaults(int port)
{
super(
new NoClassRetriever(),
new DefaultAuthenticator(),
new NullServerMonitor(),
new DefaultThreadPool(),
new DefaultServerSideClientContextFactory(),
port);
}
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
ServerObjectStreamReadWriter rw = new
ServerObjectStreamReadWriter(m_serverMonitor, m_threadPool);
return rw;
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/PartialSocketCustomStreamServer.java
Index: PartialSocketCustomStreamServer.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.socket;
import org.apache.altrmi.server.impl.ServerCustomStreamReadWriter;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.altrmi.server.ServerException;
import org.apache.altrmi.server.ServerMonitor;
import org.apache.altrmi.server.ServerSideClientContextFactory;
import org.apache.altrmi.common.RegistryHelper;
import org.apache.altrmi.common.ThreadPool;
/**
* Class PartialSocketCustomStreamServer
*
*
* @author Paul Hammant
* @author Peter Royal
* @version $Revision: 1.1 $
*/
public class PartialSocketCustomStreamServer extends
AbstractPartialSocketStreamServer
{
private CompleteSocketCustomStreamPipedBinder
m_completeSocketCustomStreamPipedBinder;
/**
* Construct a PartialSocketCustomStreamServer
*
* @param invocationHandlerAdapter the handler
* @param serverMonitor the monitor
* @param port ther port
*/
public PartialSocketCustomStreamServer(InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory
contextFactory, int port)
{
super(invocationHandlerAdapter, serverMonitor, threadPool,
contextFactory);
m_completeSocketCustomStreamPipedBinder =
new
CompleteSocketCustomStreamPipedBinder(super.getInovcationHandlerAdapter(),
serverMonitor,
threadPool, contextFactory);
new RegistryHelper().put("/.altrmi/optimizations/port="
+ port, m_completeSocketCustomStreamPipedBinder);
}
/**
* Stop
*/
public void stop()
{
super.stop();
m_completeSocketCustomStreamPipedBinder.stop();
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerCustomStreamReadWriter(m_serverMonitor,
m_threadPool);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/PartialSocketObjectStreamServer.java
Index: PartialSocketObjectStreamServer.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.socket;
import org.apache.altrmi.common.RegistryHelper;
import org.apache.altrmi.common.ThreadPool;
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.ServerObjectStreamReadWriter;
import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
/**
* Class PartialSocketObjectStreamServer
*
*
* @author Paul Hammant
* @author Peter Royal
* @version $Revision: 1.1 $
*/
public class PartialSocketObjectStreamServer extends
AbstractPartialSocketStreamServer
{
private CompleteSocketObjectStreamPipedBinder
m_completeSocketObjectStreamPipedBinder;
/*
* Construct a PartialSocketObjectStreamServer
*
* @param invocationHandlerAdapter the handler
* @param serverMonitor the monitor
* @param port ther port
*/
public PartialSocketObjectStreamServer(InvocationHandlerAdapter
invocationHandlerAdapter,
ServerMonitor serverMonitor,
ThreadPool threadPool,
ServerSideClientContextFactory
contextFactory,
int port)
{
super(invocationHandlerAdapter, serverMonitor, threadPool,
contextFactory);
m_completeSocketObjectStreamPipedBinder =
new
CompleteSocketObjectStreamPipedBinder(super.getInovcationHandlerAdapter(),
serverMonitor, threadPool, contextFactory);
new RegistryHelper().put("/.altrmi/optimizations/port="
+ port, m_completeSocketObjectStreamPipedBinder);
}
/**
* Stop
*/
public void stop()
{
super.stop();
m_completeSocketObjectStreamPipedBinder.stop();
}
/**
* Create a Server Stream Read Writer.
* @return The Server Stream Read Writer.
*/
protected AbstractServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerObjectStreamReadWriter(m_serverMonitor,
m_threadPool);
}
}
1.1
incubator-altrmi/server/impl/src/java/org/apache/altrmi/server/impl/socket/SocketStreamServerConnection.java
Index: SocketStreamServerConnection.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.socket;
import java.io.IOException;
import java.net.Socket;
import org.apache.altrmi.server.impl.AbstractServer;
import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
import org.apache.altrmi.server.impl.AbstractStreamServerConnection;
import org.apache.altrmi.server.ServerMonitor;
/**
* Class SocketStreamServerConnection
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class SocketStreamServerConnection extends
AbstractStreamServerConnection
{
/**
* The socket for the connection
*/
private Socket m_socket;
/**
* Construct a Socket Stream Server Connection
* @param abstractServer The Abstract Server that will process
invocations and requests
* @param socket The Socket
* @param readWriter The readWriter for the transport type
*/
public SocketStreamServerConnection(
final AbstractServer abstractServer, final Socket
socket,AbstractServerStreamReadWriter readWriter,
ServerMonitor serverMonitor )
{
super( abstractServer, readWriter, serverMonitor );
m_socket = socket;
}
/**
* Kill connections
*/
protected void killConnection()
{
try
{
m_socket.close();
}
catch( IOException e )
{
m_serverMonitor.closeError(this.getClass(),
"SocketStreamServerConnection.killConnection(): Error closing Connection",e);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]