You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/09/21 17:52:57 UTC
cvs commit: jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket AbstractCompleteSocketStreamServer.java AbstractPartialSocketStreamServer.java CompleteSocketCustomStreamServer.java CompleteSocketObjectStreamServer.java PartialSocketCustomStreamServer.java PartialSocketObjectStreamServer.java SocketStreamServerConnection.java
hammant 2002/09/21 08:52:57
Modified: altrmi build.xml
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream
CallbackEnabledClientCustomStreamReadWriter.java
altrmi/src/java/org/apache/excalibur/altrmi/server
AltrmiPublisher.java AltrmiServer.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl
AbstractServer.java AltrmiSession.java
DefaultAuthenticator.java
DefaultMethodInvocationHandler.java
ServerCustomStreamReadWriter.java
ServerObjectStreamReadWriter.java
ServerStreamReadWriter.java
StreamServerConnection.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters
PublicationAdapter.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket
CallbackEnabledSocketCustomStreamReadWriter.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/direct
DirectMarshalledServer.java DirectServer.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/piped
AbstractPipedServer.java
PipedStreamServerConnection.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/rmi
RmiInovcationAdapter.java RmiServer.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket
AbstractCompleteSocketStreamServer.java
AbstractPartialSocketStreamServer.java
CompleteSocketCustomStreamServer.java
CompleteSocketObjectStreamServer.java
PartialSocketCustomStreamServer.java
PartialSocketObjectStreamServer.java
SocketStreamServerConnection.java
Log:
More checkstyle conformance
Revision Changes Path
1.38 +4 -2 jakarta-avalon-excalibur/altrmi/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/build.xml,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- build.xml 26 Aug 2002 21:53:48 -0000 1.37
+++ build.xml 21 Sep 2002 15:52:56 -0000 1.38
@@ -319,9 +319,11 @@
<fileset dir="${java.dir}">
<include name="org/apache/excalibur/altrmi/common/*.java"/>
<include name="org/apache/excalibur/altrmi/generator/*.java"/>
- <include name="org/apache/excalibur/altrmi/server/impl/classretrievers/*.java"/>
<include name="org/apache/excalibur/altrmi/server/*.java"/>
- <include name="org/apache/excalibur/altrmi/server/rmi/*.java"/>
+ <include name="org/apache/excalibur/altrmi/server/impl/*.java"/>
+ <include name="org/apache/excalibur/altrmi/server/impl/classretrievers/*.java"/>
+ <include name="org/apache/excalibur/altrmi/server/impl/rmi/*.java"/>
+ <include name="org/apache/excalibur/altrmi/server/impl/socket/*.java"/>
</fileset>
<formatter type="plain"/>
<formatter type="xml" toFile="${build.dir}/checkstyle-results.xml"/>
1.6 +49 -49 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java
Index: CallbackEnabledClientCustomStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CallbackEnabledClientCustomStreamReadWriter.java 25 Aug 2002 22:43:11 -0000 1.5
+++ CallbackEnabledClientCustomStreamReadWriter.java 21 Sep 2002 15:52:56 -0000 1.6
@@ -39,43 +39,43 @@
implements Runnable
{
//Mutex to block the client till a reply reaches back from server
- private Object mReplyLock = new Object();
- private AltrmiReply mReply = null;
- private Thread mMessageLoopThread = null;
- private boolean mIsStopped = false;
- private DataInputStream mDataInputStream;
- private DataOutputStream mDataOutputStream;
- private ClassLoader mInterfacesClassLoader;
- private HashMap mExposedObjPublishNameHash_ = new HashMap();
- private AltrmiServer mClientServerHostingExposedObjects = new DirectServer();
- private static int mRandom__ = 0;
+ private Object m_replyLock = new Object();
+ private AltrmiReply m_reply = null;
+ private Thread m_messageLoopThread = null;
+ private boolean m_isStopped = false;
+ private DataInputStream m_dataInputStream;
+ private DataOutputStream m_dataOutputStream;
+ private ClassLoader m_interfacesClassLoader;
+ private HashMap m_exposedObjPublishNameHash_ = new HashMap();
+ private AltrmiServer m_clientServerHostingExposedObjects = new DirectServer();
+ private static int m_random = 0;
/**
* Constructor ClientCustomStreamReadWriter
*
*
- * @param inputStream
- * @param outputStream
+ * @param inputStream The input stream
+ * @param outputStream The output stream
*
- * @throws IOException
+ * @throws IOException The IO Exception
*
*/
public CallbackEnabledClientCustomStreamReadWriter( InputStream inputStream, OutputStream outputStream, ClassLoader interfacesClassLoader )
throws IOException
{
- mDataOutputStream = new DataOutputStream( new BufferedOutputStream( outputStream ) );
- mDataInputStream = new DataInputStream( inputStream );
+ m_dataOutputStream = new DataOutputStream( new BufferedOutputStream( outputStream ) );
+ m_dataInputStream = new DataInputStream( inputStream );
- mInterfacesClassLoader = interfacesClassLoader;
+ m_interfacesClassLoader = interfacesClassLoader;
//This thread recv's all the messages sent from the server
- mMessageLoopThread = new Thread( this,"CallbackEnabledClientStream Thread" );
- mMessageLoopThread.start();
+ m_messageLoopThread = new Thread( this,"CallbackEnabledClientStream Thread" );
+ m_messageLoopThread.start();
//start the internal AltrmiServer which holds the exposed Objects
// for the server to make callbacks upon.
try
{
- mClientServerHostingExposedObjects.start();
- mClientServerHostingExposedObjects.setClassRetriever( new PlainClassRetriever() );
+ m_clientServerHostingExposedObjects.start();
+ m_clientServerHostingExposedObjects.setClassRetriever( new PlainClassRetriever() );
}
catch( Exception e )
{
@@ -89,32 +89,32 @@
public void run()
{
boolean readingInt = false;
- while( !mIsStopped )
+ while( !m_isStopped )
{
try
{
readingInt = true;
- int byteArraySize = (int)mDataInputStream.readInt();
+ int byteArraySize = (int)m_dataInputStream.readInt();
readingInt = false;
byte[] byteArray = new byte[ byteArraySize ];
- mDataInputStream.read( byteArray );
+ m_dataInputStream.read( byteArray );
- //_replyQueue.addFirst(SerializationHelper.getInstanceFromBytes(byteArray, mInterfacesClassLoader));
- Object obj = SerializationHelper.getInstanceFromBytes( byteArray, mInterfacesClassLoader );
+ //_replyQueue.addFirst(SerializationHelper.getInstanceFromBytes(byteArray, m_interfacesClassLoader));
+ Object obj = SerializationHelper.getInstanceFromBytes( byteArray, m_interfacesClassLoader );
if( obj instanceof AltrmiReply )
{
- mReply = (AltrmiReply)obj;
- synchronized( mReplyLock )
+ m_reply = (AltrmiReply)obj;
+ synchronized( m_replyLock )
{
- mReplyLock.notify();
+ m_replyLock.notify();
}
}
else if( obj instanceof AltrmiRequest )
{
- AltrmiReply altrmiReply = mClientServerHostingExposedObjects.handleInvocation( (AltrmiRequest)obj );
+ AltrmiReply altrmiReply = m_clientServerHostingExposedObjects.handleInvocation( (AltrmiRequest)obj );
postReply( altrmiReply );
}
else
@@ -136,7 +136,7 @@
continue;
e.printStackTrace();
}
- mIsStopped = true;
+ m_isStopped = true;
return;
}
catch( ClassNotFoundException e )
@@ -154,13 +154,13 @@
*/
public AltrmiReply getReplyFromMessageLoop()
{
- if( mReply == null )
+ if( m_reply == null )
{
- synchronized( mReplyLock )
+ synchronized( m_replyLock )
{
try
{
- mReplyLock.wait();
+ m_replyLock.wait();
}
catch( InterruptedException e )
{
@@ -168,7 +168,7 @@
}
}
}
- return mReply;
+ return m_reply;
}
/*
@@ -177,11 +177,11 @@
protected AltrmiReply postRequest( AltrmiRequest altrmiRequest )
throws IOException, ClassNotFoundException
{
- if( mIsStopped )
+ if( m_isStopped )
throw new IOException( "Server Stoppped" );
writeRequest( altrmiRequest );
AltrmiReply r = readReply();
- mReply = null;
+ m_reply = null;
return r;
}
@@ -195,9 +195,9 @@
byte[] aBytes = SerializationHelper.getBytesFromInstance( altrmiRequest );
- mDataOutputStream.writeInt( aBytes.length );
- mDataOutputStream.write( aBytes );
- mDataOutputStream.flush();
+ m_dataOutputStream.writeInt( aBytes.length );
+ m_dataOutputStream.write( aBytes );
+ m_dataOutputStream.flush();
}
/**
@@ -222,9 +222,9 @@
{
byte[] aBytes = SerializationHelper.getBytesFromInstance( altrmiReply );
- mDataOutputStream.writeInt( aBytes.length );
- mDataOutputStream.write( aBytes );
- mDataOutputStream.flush();
+ m_dataOutputStream.writeInt( aBytes.length );
+ m_dataOutputStream.write( aBytes );
+ m_dataOutputStream.flush();
}
/**
@@ -238,13 +238,13 @@
*/
public boolean exposeObject( Object tobeExposedObject, Class tobeExposedInterface ) throws AltrmiCallbackException
{
- if( mExposedObjPublishNameHash_.get( tobeExposedObject ) != null )
+ if( m_exposedObjPublishNameHash_.get( tobeExposedObject ) != null )
return false;
String _uniquePublishedName = getUniqueNameForExposedObject( tobeExposedObject );
- mExposedObjPublishNameHash_.put( tobeExposedObject, _uniquePublishedName );
+ m_exposedObjPublishNameHash_.put( tobeExposedObject, _uniquePublishedName );
try
{
- mClientServerHostingExposedObjects.publish( tobeExposedObject, _uniquePublishedName, tobeExposedInterface );
+ m_clientServerHostingExposedObjects.publish( tobeExposedObject, _uniquePublishedName, tobeExposedInterface );
}
catch( PublicationException pce )
{
@@ -262,8 +262,8 @@
*/
private String getUniqueNameForExposedObject( Object tobeExposedObject )
{
- mRandom__++;
- return tobeExposedObject.getClass().getName().substring( tobeExposedObject.getClass().getName().lastIndexOf( "." ) + 1 ) + "_" + mRandom__;
+ m_random++;
+ return tobeExposedObject.getClass().getName().substring( tobeExposedObject.getClass().getName().lastIndexOf( "." ) + 1 ) + "_" + m_random;
}
/**
@@ -275,7 +275,7 @@
*/
public String getPublishedName( Object tobeExposedObject )
{
- return (String)mExposedObjPublishNameHash_.get( tobeExposedObject );
+ return (String)m_exposedObjPublishNameHash_.get( tobeExposedObject );
}
}
1.4 +5 -5 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/AltrmiPublisher.java
Index: AltrmiPublisher.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/AltrmiPublisher.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AltrmiPublisher.java 24 Aug 2002 11:39:05 -0000 1.3
+++ AltrmiPublisher.java 21 Sep 2002 15:52:56 -0000 1.4
@@ -51,23 +51,23 @@
*
*
* @param impl the object implementing the principle interface.
- * @param asName the lookup name of the published object
+ * @param publishedName the lookup name of the published object
* @throws PublicationException if there is a problem publishing
*
*/
- void unPublish( Object impl, String asName ) throws PublicationException;
+ void unPublish( Object impl, String publishedName ) throws PublicationException;
/**
* Replace Published object with another.
*
*
* @param oldImpl the old object implementing the principle interface.
- * @param asName the lookup name of the published object
+ * @param publishedName the lookup name of the published object
* @param withImpl the new object implementing the principle interface.
* @throws PublicationException if there is a problem publishing
*
*/
- void replacePublished( Object oldImpl, String asName, Object withImpl )
+ void replacePublished( Object oldImpl, String publishedName, Object withImpl )
throws PublicationException;
/**
1.4 +27 -1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/AltrmiServer.java
Index: AltrmiServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/AltrmiServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AltrmiServer.java 24 Aug 2002 11:39:05 -0000 1.3
+++ AltrmiServer.java 21 Sep 2002 15:52:56 -0000 1.4
@@ -20,6 +20,32 @@
{
/**
+ * The state of the system while shutting down.
+ */
+ int SHUTTINGDOWN = 101;
+
+ /**
+ * The state of the starting system.
+ */
+ int STARTING = 202;
+
+ /**
+ * The state of the starting system.
+ */
+ int STARTED = 303;
+
+ /**
+ * The state of the system when stopped
+ */
+ int STOPPED = 404;
+
+ /**
+ * The state of the un started system.
+ */
+ int UNSTARTED = 505;
+
+
+ /**
* Set a ClassRetriever for the server. Overides default.
*
*
1.7 +110 -72 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AbstractServer.java
Index: AbstractServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AbstractServer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractServer.java 24 Aug 2002 11:39:06 -0000 1.6
+++ AbstractServer.java 21 Sep 2002 15:52:56 -0000 1.7
@@ -7,7 +7,6 @@
*/
package org.apache.excalibur.altrmi.server.impl;
-import java.util.Iterator;
import java.util.Vector;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
@@ -37,149 +36,165 @@
implements AltrmiServer, LogEnabled
{
- private Vector mConnections = new Vector();
- protected InvocationHandlerAdapter mInovcationHandlerAdapter;
- private Logger mLogger;
- protected static final int SHUTTINGDOWN = 11;
- protected static final int STARTED = 22;
- protected static final int STOPPED = 33;
- protected static final int UNSTARTED = 44;
- protected int mState = UNSTARTED;
+ /**
+ * A vector of connections
+ */
+ private Vector m_connections = new Vector();
/**
- * Constructor AbstractServer
- *
+ * The invocation handler
+ */
+ private InvocationHandlerAdapter m_inovcationHandlerAdapter;
+
+ /**
+ * The logger
+ */
+ private Logger m_logger;
+
+ /**
+ * The state of the system.
+ */
+ private int m_state = UNSTARTED;
+
+ /**
+ * Construct an AbstractServer
*
*/
public AbstractServer()
{
- mInovcationHandlerAdapter = new InvocationHandlerAdapter();
+ m_inovcationHandlerAdapter = new InvocationHandlerAdapter();
}
/**
- * Constructor AbstractServer
+ * Construct a AbstractServer
*
*
- * @param inovcationHandlerAdapter
+ * @param inovcationHandlerAdapter The invocation handler adapter to use.
*
*/
public AbstractServer( InvocationHandlerAdapter inovcationHandlerAdapter )
{
- mInovcationHandlerAdapter = inovcationHandlerAdapter;
+ m_inovcationHandlerAdapter = inovcationHandlerAdapter;
}
/**
- * Method enableLogging
+ * Enable Logging
*
*
- * @param logger
+ * @param logger The logger.
*
*/
public void enableLogging( Logger logger )
{
- mLogger = logger;
+ m_logger = logger;
}
/**
* Method getLogger
*
*
- * @return
+ * @return The logger.
*
*/
public synchronized Logger getLogger()
{
- if( mLogger == null )
+ // Default if not logger assigned.
+ if( m_logger == null )
{
- mLogger = new ConsoleLogger();
+ m_logger = new ConsoleLogger();
}
- return mLogger;
+ return m_logger;
}
/**
- * Method setClassRetriever
+ * Set a ClassRetriever to use.
*
*
- * @param classRetriever
+ * @param classRetriever The class retriever.
*
*
*/
public final void setClassRetriever( ClassRetriever classRetriever )
{
- mInovcationHandlerAdapter.setClassRetriever( classRetriever );
+ m_inovcationHandlerAdapter.setClassRetriever( classRetriever );
}
/**
- * Method setAuthenticator
+ * Set an Authenticator
*
*
- * @param altrmiAuthenticator
+ * @param altrmiAuthenticator The authenticator to use.
*
*
*/
public final void setAuthenticator( AltrmiAuthenticator altrmiAuthenticator )
{
- mInovcationHandlerAdapter.setAuthenticator( altrmiAuthenticator );
+ m_inovcationHandlerAdapter.setAuthenticator( altrmiAuthenticator );
}
/**
- * Method handleInvocation
+ * Handle an Invocation
*
*
- * @param request
+ * @param request The request of the invocation.
*
- * @return
+ * @return An suitable reply.
*
*/
public AltrmiReply handleInvocation( AltrmiRequest request )
{
- return mInovcationHandlerAdapter.handleInvocation( request );
+ return m_inovcationHandlerAdapter.handleInvocation( request );
}
/**
- * Method suspend
+ * Suspend the server with open connections.
*
*/
public void suspend()
{
- mInovcationHandlerAdapter.suspend();
+ m_inovcationHandlerAdapter.suspend();
}
/**
- * Method resume
+ * Resume a server with open connections.
*
*/
public void resume()
{
- mInovcationHandlerAdapter.resume();
+ m_inovcationHandlerAdapter.resume();
}
/**
- * Method connectionStart
+ * Strart a connection
+ * @param altrmiConnection The connection
*
*/
protected void connectionStart( AltrmiServerConnection altrmiConnection )
{
- mConnections.add( altrmiConnection );
+ m_connections.add( altrmiConnection );
}
/**
- * Method connectionCompleted
+ * Complete a connection.
+ * @param altrmiConnection The connection
*
*/
protected void connectionCompleted( AltrmiServerConnection altrmiConnection )
{
- mConnections.remove( altrmiConnection );
+ m_connections.remove( altrmiConnection );
}
+ /**
+ * Kill connections.
+ */
protected void killAllConnections()
{
// Copy the connections into an array to avoid ConcurrentModificationExceptions
// as the connections are closed.
AltrmiServerConnection[] connections =
- (AltrmiServerConnection[])mConnections.toArray( new AltrmiServerConnection[0] );
+ (AltrmiServerConnection[])m_connections.toArray( new AltrmiServerConnection[0] );
for ( int i = 0; i < connections.length; i++ )
{
connections[i].endConnection();
@@ -187,89 +202,112 @@
}
/**
- * Method publish
+ * Publish an object via its interface
*
*
- * @param impl
- * @param asName
- * @param interfaceToExpose
+ * @param impl The implementation
+ * @param asName as this name.
+ * @param interfaceToExpose The interface to expose.
+ * @throws PublicationException if an error during publication.
*
*/
public void publish( Object impl, String asName, Class interfaceToExpose )
throws PublicationException
{
- mInovcationHandlerAdapter.publish( impl, asName, interfaceToExpose );
+ m_inovcationHandlerAdapter.publish( impl, asName, interfaceToExpose );
}
/**
- * Method publish
+ * Publish an object via its publication description
*
*
- * @param impl
- * @param asName
- * @param publicationDescription
+ * @param impl The implementation
+ * @param asName as this name.
+ * @param publicationDescription The publication description.
+ * @throws PublicationException if an error during publication.
*
*/
public void publish( Object impl, String asName, PublicationDescription publicationDescription )
throws PublicationException
{
- mInovcationHandlerAdapter.publish( impl, asName, publicationDescription );
+ m_inovcationHandlerAdapter.publish( impl, asName, publicationDescription );
}
/**
- * Method unPublish
+ * UnPublish an object.
*
*
- * @param impl
- * @param asName
+ * @param impl The implementation
+ * @param asName as this name.
+ * @throws PublicationException if an error during publication.
*
*/
public void unPublish( Object impl, String asName ) throws PublicationException
{
- mInovcationHandlerAdapter.unPublish( impl, asName );
+ m_inovcationHandlerAdapter.unPublish( impl, asName );
}
/**
- * Method replacePublished
+ * Replace the server side instance of a published object
*
*
- * @param oldImpl
- * @param asName
- * @param withImpl
+ * @param oldImpl The previous implementation.
+ * @param publishedName The name it is published as.
+ * @param withImpl The impl to superceed.
+ * @throws PublicationException if an error during publication.
*
*/
- public void replacePublished( Object oldImpl, String asName, Object withImpl )
+ public void replacePublished( Object oldImpl, String publishedName, Object withImpl )
throws PublicationException
{
- mInovcationHandlerAdapter.replacePublished( oldImpl, asName, withImpl );
+ m_inovcationHandlerAdapter.replacePublished( oldImpl, publishedName, withImpl );
}
/**
- * Method getMethodInvocationHandler
+ * Get the Method Invocation Handler for a particular request.
*
*
- * @param mr
- * @param objectName
+ * @param methodRequest The method request
+ * @param objectName The object Name.
*
- * @return
+ * @return The Method invocation handler
*
*/
- public MethodInvocationHandler getMethodInvocationHandler( MethodRequest mr, String objectName )
+ public MethodInvocationHandler getMethodInvocationHandler( MethodRequest methodRequest,
+ String objectName )
{
- return mInovcationHandlerAdapter.getMethodInvocationHandler( mr, objectName );
+ return m_inovcationHandlerAdapter.getMethodInvocationHandler( methodRequest, objectName );
}
/**
- * Method getMethodInvocationHandler
+ * Get the MethodInvocationHandler for a prticular published name.
*
*
- * @param publishedName
+ * @param publishedName The published name.
*
- * @return
+ * @return The Method invocation handler
*
*/
public MethodInvocationHandler getMethodInvocationHandler( String publishedName )
{
- return mInovcationHandlerAdapter.getMethodInvocationHandler( publishedName );
+ return m_inovcationHandlerAdapter.getMethodInvocationHandler( publishedName );
+ }
+
+ /**
+ * Set the state for the server
+ * @param state The state
+ */
+ protected void setState(int state)
+ {
+ m_state = state;
+ }
+
+ /**
+ * Get the state for teh server.
+ * @return the state.
+ */
+ protected int getState()
+ {
+ return m_state;
}
}
1.4 +23 -16 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AltrmiSession.java
Index: AltrmiSession.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AltrmiSession.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AltrmiSession.java 24 Apr 2002 12:43:01 -0000 1.3
+++ AltrmiSession.java 21 Sep 2002 15:52:56 -0000 1.4
@@ -19,55 +19,62 @@
public class AltrmiSession
{
- private Long mSession;
- private HashMap mBeansInUse = new HashMap();
+ /**
+ * Session ID
+ */
+ private Long m_session;
+
+ /**
+ * A map of in-use beans
+ */
+ private HashMap m_beansInUse = new HashMap();
/**
- * Constructor AltrmiSession
+ * Construct an AltrmiSession with a session ID
*
*
- * @param session
+ * @param session the session ID
*
*/
public AltrmiSession( Long session )
{
- mSession = session;
+ m_session = session;
}
/**
- * Method getSession
+ * Get the Session ID
*
*
- * @return
+ * @return The session ID
*
*/
public Long getSession()
{
- return mSession;
+ return m_session;
}
/**
- * Method addBeanInUse
+ * Add a bean in use.
*
*
- * @param referenceID
- * @param bean
+ * @param referenceID The reference ID
+ * @param bean The bean to use.
*
*/
public void addBeanInUse( Long referenceID, Object bean )
{
- mBeansInUse.put( referenceID, bean );
+ m_beansInUse.put( referenceID, bean );
}
/**
- * Method removeBeanInUse
+ * Remove a bean in use
*
*
- * @param referenceID
+ * @param referenceID The reference ID.
*
*/
public void removeBeanInUse( Long referenceID )
{
- mBeansInUse.remove( referenceID );
+ m_beansInUse.remove( referenceID );
}
}
1.4 +8 -11 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultAuthenticator.java
Index: DefaultAuthenticator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultAuthenticator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultAuthenticator.java 24 Apr 2002 12:43:01 -0000 1.3
+++ DefaultAuthenticator.java 21 Sep 2002 15:52:56 -0000 1.4
@@ -8,11 +8,10 @@
package org.apache.excalibur.altrmi.server.impl;
import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
-import org.apache.excalibur.altrmi.common.AltrmiAuthenticationException;
import org.apache.excalibur.altrmi.server.AltrmiAuthenticator;
/**
- * Class DefaultAuthenticator
+ * Check the Authority of a client to a service.
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
@@ -22,26 +21,24 @@
{
/**
- * Method checkAuthority
+ * Check the Authority of a client to a service.
*
*
- * @param auth
- * @param publishedService
+ * @param altrmiAuthentication The Authentication object
+ * @param publishedService the publishes server to authenticate against
*
*
- * @throws AltrmiAuthenticationException
*
*/
- public void checkAuthority( AltrmiAuthentication auth, String publishedService )
- throws AltrmiAuthenticationException
+ public void checkAuthority( AltrmiAuthentication altrmiAuthentication, String publishedService )
{
}
/**
- * Method getTextToSign
+ * Get text to sign for a request.
*
*
- * @return
+ * @return The text to sign.
*
*/
public String getTextToSign()
1.7 +91 -55 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultMethodInvocationHandler.java
Index: DefaultMethodInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/DefaultMethodInvocationHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultMethodInvocationHandler.java 24 Aug 2002 11:39:06 -0000 1.6
+++ DefaultMethodInvocationHandler.java 21 Sep 2002 15:52:56 -0000 1.7
@@ -35,24 +35,55 @@
public class DefaultMethodInvocationHandler implements MethodInvocationHandler
{
- private WeakHashMap mRefBeans = new WeakHashMap();
- private WeakHashMap mBeanRefs = new WeakHashMap();
- private HashMap mMethodMap;
+ /**
+ * Beans for references
+ */
+ private WeakHashMap m_refBeans = new WeakHashMap();
+
+ /**
+ * References for beans.
+ */
+ private WeakHashMap m_beanRefs = new WeakHashMap();
+
+ /**
+ * Method map
+ */
+ private HashMap m_methodMap;
+
+ /**
+ * Next reference
+ */
private static int NEXT_REFERENCE = 1;
- private AltrmiPublisher mAltrmiPublisher;
- private String mPublishedThing;
- private Object mBeanImpl;
- private final PublicationDescription mPublicationDescription;
+
+ /**
+ * The altrmi publisher
+ */
+ private AltrmiPublisher m_altrmiPublisher;
+
+ /**
+ * published thing
+ */
+ private String m_publishedThing;
+
+ /**
+ * The bean implementation
+ */
+ private Object m_beanImpl;
+
+ /**
+ * The publication description.
+ */
+ private final PublicationDescription m_publicationDescription;
/**
* Constructor DefaultMethodInvocationHandler
*
*
*
- * @param altrmiPublisher
- * @param publishedThing
- * @param methodMap
- * @param publicationDescription
+ * @param altrmiPublisher The publisher
+ * @param publishedThing The published Thing
+ * @param methodMap The method map
+ * @param publicationDescription The publication description
*
*/
public DefaultMethodInvocationHandler( AltrmiPublisher altrmiPublisher, String publishedThing,
@@ -60,30 +91,30 @@
PublicationDescription publicationDescription )
{
- mAltrmiPublisher = altrmiPublisher;
- mPublishedThing = publishedThing;
- mMethodMap = methodMap;
- mPublicationDescription = publicationDescription;
+ m_altrmiPublisher = altrmiPublisher;
+ m_publishedThing = publishedThing;
+ m_methodMap = methodMap;
+ m_publicationDescription = publicationDescription;
}
/**
* Method toString
*
*
- * @return
+ * @return a string.
*
*/
public String toString()
{
- return "DMIH:" + mPublishedThing;
+ return "DMIH:" + m_publishedThing;
}
/**
- * Method addImplementationBean
+ * Add an Implementation Bean
*
*
- * @param referenceID
- * @param beanImpl
+ * @param referenceID The reference ID
+ * @param beanImpl The bean implementaion
*
*/
public void addImplementationBean( Long referenceID, Object beanImpl )
@@ -91,47 +122,47 @@
if( referenceID.equals( new Long( 0 ) ) )
{
- mBeanImpl = beanImpl;
+ m_beanImpl = beanImpl;
}
- mRefBeans.put( referenceID, new WeakReference( beanImpl ) );
- mBeanRefs.put( beanImpl, referenceID );
+ m_refBeans.put( referenceID, new WeakReference( beanImpl ) );
+ m_beanRefs.put( beanImpl, referenceID );
}
/**
* Method replaceImplementationBean
*
*
- * @param implBean
- * @param withImplBean
+ * @param implBean The bean implementaion
+ * @param withImplBean The new bean implementaion.
*
*/
public void replaceImplementationBean( Object implBean, Object withImplBean )
{
- Long ref = (Long)mBeanRefs.get( implBean );
+ Long ref = (Long)m_beanRefs.get( implBean );
- mRefBeans.put( ref, new WeakReference( withImplBean ) );
- mBeanRefs.remove( implBean );
- mBeanRefs.put( withImplBean, ref );
+ m_refBeans.put( ref, new WeakReference( withImplBean ) );
+ m_beanRefs.remove( implBean );
+ m_beanRefs.put( withImplBean, ref );
- if( mBeanImpl == implBean )
+ if( m_beanImpl == implBean )
{
- mBeanImpl = withImplBean;
+ m_beanImpl = withImplBean;
}
}
/**
- * Method getOrMakeReferenceIDForBean
+ * Get or make a reference ID for a bean
*
- *
- * @param implBean
+ * @param implBean The bean implementaion
+ * @return A reference ID
*
*/
public Long getOrMakeReferenceIDForBean( Object implBean )
{
- Long ref = (Long)mBeanRefs.get( implBean );
+ Long ref = (Long)m_beanRefs.get( implBean );
if( ref == null )
{
@@ -140,8 +171,8 @@
// + (long) Math.round(Math.random()));
ref = new Long( NEXT_REFERENCE++ );
- //mBeanRefs.put(implBean, ref);
- //mRefBeans.put(ref, implBean);
+ //m_beanRefs.put(implBean, ref);
+ //m_refBeans.put(ref, implBean);
addImplementationBean( ref, implBean );
}
@@ -149,12 +180,12 @@
}
/**
- * Method handleMethodInvocation
+ * Handle a method invocation
*
*
- * @param request
+ * @param request The emthod request
*
- * @return
+ * @return The reply.
*
*/
public AltrmiReply handleMethodInvocation( MethodRequest request )
@@ -162,22 +193,22 @@
String methodSignature = request.getMethodSignature();
- if( !mMethodMap.containsKey( methodSignature ) )
+ if( !m_methodMap.containsKey( methodSignature ) )
{
return new ExceptionReply(
new AltrmiInvocationException( "Method not present in impl" ) );
}
- Method method = (Method)mMethodMap.get( methodSignature );
+ Method method = (Method)m_methodMap.get( methodSignature );
try
{
- WeakReference wr = (WeakReference)mRefBeans.get( request.getReferenceID() );
+ WeakReference wr = (WeakReference)m_refBeans.get( request.getReferenceID() );
if( wr == null )
{
System.out.println( "missing weak reference for referenceID - "
- + request.getReferenceID() + " pub " + mPublishedThing );
+ + request.getReferenceID() + " pub " + m_publishedThing );
return new NoSuchReferenceReply( request.getReferenceID() );
}
@@ -224,7 +255,12 @@
}
}
- private void correctArgs( MethodRequest mr, Object[] args )
+ /**
+ * Correct the arguments for a request (seme are 'additional facades' and can;t be serialized).
+ * @param methodRequest The method request
+ * @param args The arguments to correct
+ */
+ private void correctArgs( MethodRequest methodRequest, Object[] args )
{
for( int i = 0; i < args.length; i++ )
@@ -235,10 +271,10 @@
{
FacadeRefHolder frh = (FacadeRefHolder)args[ i ];
DefaultMethodInvocationHandler methodInvocationHandler =
- (DefaultMethodInvocationHandler)mAltrmiPublisher
+ (DefaultMethodInvocationHandler)m_altrmiPublisher
.getMethodInvocationHandler( frh.getObjectName() );
WeakReference wr =
- (WeakReference)methodInvocationHandler.mRefBeans.get( frh.getReferenceID() );
+ (WeakReference)methodInvocationHandler.m_refBeans.get( frh.getReferenceID() );
args[ i ] = wr.get();
}
@@ -262,26 +298,26 @@
}
/**
- * Method getMostDerivedType
+ * Get the most derived type.
*
*
- * @param beanImpl
+ * @param beanImpl The bean implementaion
*
- * @return
+ * @return The class
*
*/
public Class getMostDerivedType( Object beanImpl )
{
- return mPublicationDescription.getMostDerivedType( beanImpl );
+ return m_publicationDescription.getMostDerivedType( beanImpl );
}
/**
- * Method encodeClassName
+ * Encode a class name
*
*
- * @param className
+ * @param className The class name
*
- * @return
+ * @return the enoded class name.
*
*/
public String encodeClassName( String className )
1.5 +21 -10 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerCustomStreamReadWriter.java
Index: ServerCustomStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerCustomStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerCustomStreamReadWriter.java 24 Apr 2002 12:43:01 -0000 1.4
+++ ServerCustomStreamReadWriter.java 21 Sep 2002 15:52:56 -0000 1.5
@@ -25,15 +25,26 @@
public class ServerCustomStreamReadWriter extends ServerStreamReadWriter
{
- private DataInputStream mDataInputStream;
- private DataOutputStream mDataOutputStream;
+ private DataInputStream m_dataInputStream;
+ private DataOutputStream m_dataOutputStream;
+ /**
+ * Initialize
+ * @throws IOException if an IO Excpetion
+ */
protected void initialize() throws IOException
{
- mDataInputStream = new DataInputStream( mInputStream );
- mDataOutputStream = new DataOutputStream( new BufferedOutputStream( mOutputStream ) );
+ m_dataInputStream = new DataInputStream( getInputStream() );
+ m_dataOutputStream = new DataOutputStream( new BufferedOutputStream( getOutputStream() ) );
}
+ /**
+ * Write a reply, and wait for a request
+ * @param altrmiReply The reply to send
+ * @return The new request
+ * @throws IOException In an IO Exception
+ * @throws ClassNotFoundException If a class not found during deserialization.
+ */
protected synchronized AltrmiRequest writeReplyAndGetRequest( AltrmiReply altrmiReply )
throws IOException, ClassNotFoundException
{
@@ -51,15 +62,15 @@
byte[] aBytes = SerializationHelper.getBytesFromInstance( altrmiReply );
- mDataOutputStream.writeInt( aBytes.length );
- mDataOutputStream.write( aBytes );
- mDataOutputStream.flush();
+ m_dataOutputStream.writeInt( aBytes.length );
+ m_dataOutputStream.write( aBytes );
+ m_dataOutputStream.flush();
}
private AltrmiRequest readRequest() throws IOException, ClassNotFoundException
{
- int byteArraySize = mDataInputStream.readInt();
+ int byteArraySize = m_dataInputStream.readInt();
byte[] byteArray = new byte[ byteArraySize ];
int pos = 0;
int cnt = 0;
@@ -67,7 +78,7 @@
// Loop here until the entire array has been read in.
while( pos < byteArraySize )
{
- int read = mDataInputStream.read( byteArray, pos, byteArraySize - pos );
+ int read = m_dataInputStream.read( byteArray, pos, byteArraySize - pos );
pos += read;
1.5 +58 -20 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerObjectStreamReadWriter.java
Index: ServerObjectStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerObjectStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerObjectStreamReadWriter.java 5 Sep 2002 22:22:37 -0000 1.4
+++ ServerObjectStreamReadWriter.java 21 Sep 2002 15:52:56 -0000 1.5
@@ -26,10 +26,25 @@
public class ServerObjectStreamReadWriter extends ServerStreamReadWriter
{
- private ObjectInputStream mObjectInputStream;
- private ObjectOutputStream mObjectOutputStream;
- private String mObjectOutputStreamClassName = "java.io.ObjectOutputStream";
- private String mObjectInputStreamClassName = "java.io.ObjectInputStream";
+ /**
+ * The Object Input Stream
+ */
+ private ObjectInputStream m_objectInputStream;
+
+ /**
+ * The Object Output Stream
+ */
+ private ObjectOutputStream m_objectOutputStream;
+
+ /**
+ * The Object Output Stream Class name
+ */
+ private String m_objectOutputStreamClassName = "java.io.ObjectOutputStream";
+
+ /**
+ * The Object Input Stream Class name
+ */
+ private String m_objectInputStreamClassName = "java.io.ObjectInputStream";
/**
* Constructor ServerObjectStreamReadWriter
@@ -41,34 +56,39 @@
}
/**
- * Constructor ServerObjectStreamReadWriter
+ * Construct a ServerObjectStreamReadWriter
*
*
- * @param objectOutputStreamClassName
- * @param objectInputStreamClassName
+ * @param objectOutputStreamClassName The Object Output Stream Class name
+ * @param objectInputStreamClassName The Object Input Stream Class name
*
*/
public ServerObjectStreamReadWriter( String objectOutputStreamClassName,
String objectInputStreamClassName )
{
- mObjectOutputStreamClassName = objectOutputStreamClassName;
- mObjectInputStreamClassName = objectInputStreamClassName;
+ m_objectOutputStreamClassName = objectOutputStreamClassName;
+ m_objectInputStreamClassName = objectInputStreamClassName;
}
+ /**
+ * Initialize
+ * @throws IOException if an IO Excpetion
+ */
protected void initialize() throws IOException
{
try
{
- Class clazz = this.getClass().getClassLoader().loadClass( mObjectInputStreamClassName );
+ Class clazz =
+ this.getClass().getClassLoader().loadClass( m_objectInputStreamClassName );
Constructor con = clazz.getConstructor( new Class[]{InputStream.class} );
- mObjectInputStream = (ObjectInputStream)con.newInstance( new Object[]{
- mInputStream} );
- clazz = this.getClass().getClassLoader().loadClass( mObjectOutputStreamClassName );
+ m_objectInputStream = (ObjectInputStream)con.newInstance( new Object[]{
+ getInputStream()} );
+ clazz = this.getClass().getClassLoader().loadClass( m_objectOutputStreamClassName );
con = clazz.getConstructor( new Class[]{OutputStream.class} );
- mObjectOutputStream = (ObjectOutputStream)con.newInstance( new Object[]{
- mOutputStream} );
+ m_objectOutputStream = (ObjectOutputStream)con.newInstance( new Object[]{
+ getOutputStream()} );
}
catch( Exception e )
{
@@ -79,6 +99,13 @@
}
}
+ /**
+ * Write a reply, and wait for a request
+ * @param altrmiReply The reply to send
+ * @return The new request
+ * @throws IOException In an IO Exception
+ * @throws ClassNotFoundException If a class not found during deserialization.
+ */
protected synchronized AltrmiRequest writeReplyAndGetRequest( AltrmiReply altrmiReply )
throws IOException, ClassNotFoundException
{
@@ -91,17 +118,28 @@
return readRequest();
}
+ /**
+ * Write a rpely.
+ * @param altrmiReply The reply to write
+ * @throws IOException If and IO Exception
+ */
private void writeReply( AltrmiReply altrmiReply ) throws IOException
{
- mObjectOutputStream.writeObject( altrmiReply );
- mObjectOutputStream.flush();
+ m_objectOutputStream.writeObject( altrmiReply );
+ m_objectOutputStream.flush();
- //mObjectOutputStream.reset();
+ //m_objectOutputStream.reset();
}
+ /**
+ * Read a request
+ * @return The request
+ * @throws IOException If an IO Exception
+ * @throws ClassNotFoundException If a class not found during deserialization.
+ */
private AltrmiRequest readRequest() throws IOException, ClassNotFoundException
{
- return (AltrmiRequest)mObjectInputStream.readObject();
+ return (AltrmiRequest)m_objectInputStream.readObject();
}
}
1.5 +53 -18 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerStreamReadWriter.java
Index: ServerStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/ServerStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerStreamReadWriter.java 19 Aug 2002 03:06:07 -0000 1.4
+++ ServerStreamReadWriter.java 21 Sep 2002 15:52:56 -0000 1.5
@@ -12,6 +12,7 @@
import java.io.OutputStream;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
* Class ServerStreamReadWriter
@@ -20,54 +21,88 @@
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision$
*/
-public abstract class ServerStreamReadWriter
+public abstract class ServerStreamReadWriter extends AbstractLogEnabled
{
- protected InputStream mInputStream;
- protected OutputStream mOutputStream;
+ /**
+ * The input stream
+ */
+ private InputStream m_inputStream;
+
+ /**
+ * The output stream
+ */
+ private OutputStream m_outputStream;
/**
* Method setStreams
*
*
- * @param inputStream
- * @param outputStream
- *
- *
- * @throws ClassCastException
- * @throws IOException
+ * @param inputStream The input stream
+ * @param outputStream the outpur stream
*
*/
public final void setStreams( InputStream inputStream, OutputStream outputStream )
- throws IOException, ClassCastException
{
- mInputStream = inputStream;
- mOutputStream = outputStream;
+ m_inputStream = inputStream;
+ m_outputStream = outputStream;
}
+ /**
+ * Initialize the Read Writer.
+ * @throws IOException if a problem during initialization.
+ */
protected abstract void initialize() throws IOException;
+ /**
+ * Write a Reply, then Get a new Request over the stream.
+ * @param altrmiReply The reply to pass back to the client
+ * @return The Request that is new and incoming
+ * @throws IOException if a problem during write & read.
+ * @throws ClassNotFoundException If a Class is not found during serialization.
+ */
protected abstract AltrmiRequest writeReplyAndGetRequest( AltrmiReply altrmiReply )
throws IOException, ClassNotFoundException;
-
+
+ /**
+ * Close the stream.
+ */
protected void close()
{
try
{
- mInputStream.close();
+ m_inputStream.close();
}
catch ( IOException e )
{
- System.out.println( "Failed closing an Altrmi connection input stream: " + e );
+ getLogger().error( "Failed closing an Altrmi connection input stream: ", e);
}
try
{
- mOutputStream.close();
+ m_outputStream.close();
}
catch ( IOException e )
{
- System.out.println( "Failed closing an Altrmi connection output stream: " + e );
+ getLogger().error( "Failed closing an Altrmi connection output stream: ", e);
}
+ }
+
+ /**
+ * Get the Input stream
+ * @return The input stream
+ */
+ protected InputStream getInputStream()
+ {
+ return m_inputStream;
+ }
+
+ /**
+ * Get the Output stream
+ * @return The Output stream
+ */
+ protected OutputStream getOutputStream()
+ {
+ return m_outputStream;
}
}
1.6 +36 -39 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java
Index: StreamServerConnection.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamServerConnection.java 19 Aug 2002 03:06:07 -0000 1.5
+++ StreamServerConnection.java 21 Sep 2002 15:52:56 -0000 1.6
@@ -11,8 +11,7 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketException;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
import org.apache.excalibur.altrmi.common.EndConnectionReply;
@@ -25,40 +24,38 @@
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision$
*/
-public abstract class StreamServerConnection
- implements Runnable, AltrmiServerConnection, LogEnabled
+public abstract class StreamServerConnection extends AbstractLogEnabled
+ implements Runnable, AltrmiServerConnection
{
- private AbstractServer mAbstractServer;
- private boolean mEndConnection = false;
- private ServerStreamReadWriter mReadWriter;
- private Logger mLogger;
+ /**
+ * The Abstract Server
+ */
+ private AbstractServer m_abstractServer;
/**
- * Constructor StreamServerConnection
- *
- *
- * @param abstractServer
- * @param readWriter
- *
+ * End connections
*/
- public StreamServerConnection( AbstractServer abstractServer,
- ServerStreamReadWriter readWriter )
- {
- mAbstractServer = abstractServer;
- mReadWriter = readWriter;
- }
+ private boolean m_endConnection = false;
+
+ /**
+ * The Sever Stream Read Writer.
+ */
+ private ServerStreamReadWriter m_readWriter;
/**
- * Method enableLogging
+ * Construct a StreamServerConnection
*
*
- * @param logger
+ * @param abstractServer The Abstract Server handling requests
+ * @param readWriter The Read Writer.
*
*/
- public void enableLogging( Logger logger )
+ public StreamServerConnection( AbstractServer abstractServer,
+ ServerStreamReadWriter readWriter )
{
- mLogger = logger;
+ m_abstractServer = abstractServer;
+ m_readWriter = readWriter;
}
/**
@@ -69,11 +66,11 @@
public void run()
{
- mAbstractServer.connectionStart( this );
+ m_abstractServer.connectionStart( this );
try
{
- mReadWriter.initialize();
+ m_readWriter.initialize();
boolean more = true;
AltrmiRequest request = null;
@@ -85,15 +82,15 @@
{
if( request != null )
{
- reply = mAbstractServer.handleInvocation( request );
+ reply = m_abstractServer.handleInvocation( request );
}
- request = mReadWriter.writeReplyAndGetRequest( reply );
+ request = m_readWriter.writeReplyAndGetRequest( reply );
// http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
// halves the performance though.
//oOS.reset();
- if( mEndConnection )
+ if( m_endConnection )
{
reply = new EndConnectionReply();
more = false;
@@ -105,7 +102,7 @@
if( ioe instanceof EOFException )
{
- mLogger.info( "One Connection closed. (EOF)" );
+ getLogger().info( "One Connection closed. (EOF)" );
}
else if( ( ioe instanceof SocketException )
|| ioe.getClass().getName().equals( "java.net.SocketTimeoutException" )
@@ -116,36 +113,35 @@
{
// TODO implement implementation indepandant logger
- mLogger.info( "One Connection closed." );
+ getLogger().info( "One Connection closed." );
}
else
{
- mLogger.error( "Unexpected IOE in StreamServerConnection #1", ioe );
+ getLogger().error( "Unexpected IOE in StreamServerConnection #1", ioe );
}
}
}
}
catch( IOException e )
{
- mLogger.error( "Unexpected IOE in StreamServerConnection #2", e );
+ getLogger().error( "Unexpected IOE in StreamServerConnection #2", e );
}
catch( ClassNotFoundException e )
{
- mLogger.error( "Unexpected ClassNotFoundException in StreamServerConnection", e );
+ getLogger().error( "Unexpected ClassNotFoundException in StreamServerConnection", e );
}
- mAbstractServer.connectionCompleted( this );
+ m_abstractServer.connectionCompleted( this );
}
/**
* Method endConnection
*
- *
*/
public void endConnection()
{
- mEndConnection = true;
- mReadWriter.close();
+ m_endConnection = true;
+ m_readWriter.close();
}
/**
@@ -154,4 +150,5 @@
*
*/
protected abstract void killConnection();
+
}
1.4 +11 -11 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java
Index: PublicationAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PublicationAdapter.java 24 Apr 2002 12:43:01 -0000 1.3
+++ PublicationAdapter.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -129,18 +129,18 @@
*
*
* @param impl
- * @param asName
+ * @param publishedName
*
*/
- public void unPublish( Object impl, String asName ) throws PublicationException
+ public void unPublish( Object impl, String publishedName ) throws PublicationException
{
- if( !mPublishedObjects.containsKey( asName + "_Main" ) )
+ if( !mPublishedObjects.containsKey( publishedName + "_Main" ) )
{
- throw new PublicationException( "Service '" + asName + "' not published" );
+ throw new PublicationException( "Service '" + publishedName + "' not published" );
}
- mPublishedObjects.remove( asName + "_Main" );
+ mPublishedObjects.remove( publishedName + "_Main" );
}
/**
@@ -148,20 +148,20 @@
*
*
* @param oldImpl
- * @param asName
+ * @param publishedName
* @param withImpl
*
*/
- public void replacePublished( Object oldImpl, String asName, Object withImpl )
+ public void replacePublished( Object oldImpl, String publishedName, Object withImpl )
throws PublicationException
{
- if( !mPublishedObjects.containsKey( asName + "_Main" ) )
+ if( !mPublishedObjects.containsKey( publishedName + "_Main" ) )
{
- throw new PublicationException( "Service '" + asName + "' not published" );
+ throw new PublicationException( "Service '" + publishedName + "' not published" );
}
- MethodInvocationHandler asih = (MethodInvocationHandler)mPublishedObjects.get( asName
+ MethodInvocationHandler asih = (MethodInvocationHandler)mPublishedObjects.get( publishedName
+ "_Main" );
asih.replaceImplementationBean( oldImpl, withImpl );
1.5 +57 -57 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket/CallbackEnabledSocketCustomStreamReadWriter.java
Index: CallbackEnabledSocketCustomStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket/CallbackEnabledSocketCustomStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CallbackEnabledSocketCustomStreamReadWriter.java 23 Jun 2002 17:03:32 -0000 1.4
+++ CallbackEnabledSocketCustomStreamReadWriter.java 21 Sep 2002 15:52:57 -0000 1.5
@@ -38,18 +38,18 @@
implements Runnable
{
- private DataInputStream mDataInputStream;
- private DataOutputStream mDataOutputStream;
- private Thread mMessageLoopThread = null;
- private boolean mIsStopped = false;
- private Object mRequestLock = new Object();
- private Object mReplyLock = new Object();
- private AltrmiRequest mRequest = null;
- private AltrmiReply mReply = null;
- private CallbackServerClientReadWriter mCallbackServerClientReadWriter;
- private CallbackStreamInvocationHandler mCallbackStreamInvocationHandler;
- private CallbackHostContext mCallbackHostContext;
- private CallbackServerClassAltrmiFactory mAltrmiFactory;
+ private DataInputStream m_dataInputStream;
+ private DataOutputStream m_dataOutputStream;
+ private Thread m_messageLoopThread = null;
+ private boolean m_isStopped = false;
+ private Object m_requestLock = new Object();
+ private Object m_replyLock = new Object();
+ private AltrmiRequest m_request = null;
+ private AltrmiReply m_reply = null;
+ private CallbackServerClientReadWriter m_callbackServerClientReadWriter;
+ private CallbackStreamInvocationHandler m_callbackStreamInvocationHandler;
+ private CallbackHostContext m_callbackHostContext;
+ private CallbackServerClassAltrmiFactory m_altrmiFactory;
/*
* @see ServerStreamReadWriter#initialize()
@@ -57,13 +57,13 @@
protected void initialize() throws IOException
{
- mDataInputStream = new DataInputStream( mInputStream );
- mDataOutputStream = new DataOutputStream( new BufferedOutputStream( mOutputStream ) );
+ m_dataInputStream = new DataInputStream( getInputStream() );
+ m_dataOutputStream = new DataOutputStream( new BufferedOutputStream( getOutputStream() ) );
//start the receiving message loop
- mMessageLoopThread = new Thread( this ,"CallbackEnabledServer Thread");
+ m_messageLoopThread = new Thread( this ,"CallbackEnabledServer Thread");
- mMessageLoopThread.start();
+ m_messageLoopThread.start();
}
/**
@@ -74,27 +74,27 @@
public void run()
{
- mCallbackServerClientReadWriter = new CallbackServerClientReadWriter( this );
- mCallbackStreamInvocationHandler =
+ m_callbackServerClientReadWriter = new CallbackServerClientReadWriter( this );
+ m_callbackStreamInvocationHandler =
new CallbackStreamInvocationHandler( this.getClass().getClassLoader() );
- mCallbackStreamInvocationHandler.setObjectReadWriter( mCallbackServerClientReadWriter );
+ m_callbackStreamInvocationHandler.setObjectReadWriter( m_callbackServerClientReadWriter );
- mCallbackHostContext = new CallbackHostContext( mCallbackStreamInvocationHandler );
- mAltrmiFactory = new CallbackServerClassAltrmiFactory( false );
+ m_callbackHostContext = new CallbackHostContext( m_callbackStreamInvocationHandler );
+ m_altrmiFactory = new CallbackServerClassAltrmiFactory( false );
- mAltrmiFactory.setInitializedHostContext( mCallbackHostContext );
+ m_altrmiFactory.setInitializedHostContext( m_callbackHostContext );
- while( !mIsStopped )
+ while( !m_isStopped )
{
try
{
//recv packets from the client
- int byteArraySize = (int)mDataInputStream.readInt();
+ int byteArraySize = (int)m_dataInputStream.readInt();
byte[] byteArray = new byte[ byteArraySize ];
- mDataInputStream.read( byteArray );
+ m_dataInputStream.read( byteArray );
Object obj = SerializationHelper.getInstanceFromBytes( byteArray );
@@ -103,20 +103,20 @@
// TODO:WORKAROUND: Dont receive until the data is handled some way
if( obj instanceof AltrmiRequest )
{
- mRequest = (AltrmiRequest)obj;
+ m_request = (AltrmiRequest)obj;
- synchronized( mRequestLock )
+ synchronized( m_requestLock )
{
- mRequestLock.notify();
+ m_requestLock.notify();
}
}
else if( obj instanceof AltrmiReply )
{
- mReply = (AltrmiReply)obj;
+ m_reply = (AltrmiReply)obj;
- synchronized( mReplyLock )
+ synchronized( m_replyLock )
{
- mReplyLock.notify();
+ m_replyLock.notify();
}
}
else
@@ -127,16 +127,16 @@
}
catch( java.net.SocketException se )
{
- mIsStopped = true;
+ m_isStopped = true;
- synchronized( mRequestLock )
+ synchronized( m_requestLock )
{
- mRequestLock.notify();
+ m_requestLock.notify();
}
- synchronized( mReplyLock )
+ synchronized( m_replyLock )
{
- mReplyLock.notify();
+ m_replyLock.notify();
}
return;
@@ -145,7 +145,7 @@
{
e.printStackTrace();
- mIsStopped = true;
+ m_isStopped = true;
return;
}
@@ -153,7 +153,7 @@
{
ce.printStackTrace();
- mIsStopped = true;
+ m_isStopped = true;
return;
}
@@ -168,13 +168,13 @@
{
//if(_replyQueue.size()==0)
- if( mRequest == null )
+ if( m_request == null )
{
- synchronized( mRequestLock )
+ synchronized( m_requestLock )
{
try
{
- mRequestLock.wait();
+ m_requestLock.wait();
}
catch( InterruptedException e )
{
@@ -183,7 +183,7 @@
}
}
- return mRequest;
+ return m_request;
}
/**
@@ -194,13 +194,13 @@
{
//if(_replyQueue.size()==0)
- if( mReply == null )
+ if( m_reply == null )
{
- synchronized( mReplyLock )
+ synchronized( m_replyLock )
{
try
{
- mReplyLock.wait();
+ m_replyLock.wait();
}
catch( InterruptedException e )
{
@@ -209,7 +209,7 @@
}
}
- return mReply;
+ return m_reply;
}
/*
@@ -226,7 +226,7 @@
AltrmiRequest req = readRequest();
- mRequest = null;
+ m_request = null;
return req;
}
@@ -241,9 +241,9 @@
byte[] aBytes = SerializationHelper.getBytesFromInstance( altrmiReply );
- mDataOutputStream.writeInt( aBytes.length );
- mDataOutputStream.write( aBytes );
- mDataOutputStream.flush();
+ m_dataOutputStream.writeInt( aBytes.length );
+ m_dataOutputStream.write( aBytes );
+ m_dataOutputStream.flush();
}
/**
@@ -278,7 +278,7 @@
throws IOException, ClassNotFoundException
{
- if( mIsStopped )
+ if( m_isStopped )
{
throw new AltrmiConnectionClosedException( "Client Closed Connection" );
}
@@ -292,7 +292,7 @@
throw new java.io.InterruptedIOException( "Client Connection Closed" );
}
- mReply = null;
+ m_reply = null;
return r;
}
@@ -307,9 +307,9 @@
byte[] aBytes = SerializationHelper.getBytesFromInstance( altrmiRequest );
- mDataOutputStream.writeInt( aBytes.length );
- mDataOutputStream.write( aBytes );
- mDataOutputStream.flush();
+ m_dataOutputStream.writeInt( aBytes.length );
+ m_dataOutputStream.write( aBytes );
+ m_dataOutputStream.flush();
}
/**
@@ -341,7 +341,7 @@
{
//lookup the client-side exported object.
- Object obj = mAltrmiFactory.lookup( exposedObjectProxy.getPublishedName() );
+ Object obj = m_altrmiFactory.lookup( exposedObjectProxy.getPublishedName() );
args[ i ] = obj;
}
1.3 +5 -5 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/direct/DirectMarshalledServer.java
Index: DirectMarshalledServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/direct/DirectMarshalledServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirectMarshalledServer.java 24 Apr 2002 12:43:02 -0000 1.2
+++ DirectMarshalledServer.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -77,7 +77,7 @@
*/
public void start()
{
- mState = STARTED;
+ setState(STARTED);
}
/**
@@ -87,11 +87,11 @@
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
killAllConnections();
- mState = STOPPED;
+ setState(STOPPED);
}
/**
@@ -120,7 +120,7 @@
public AltrmiReply handleInvocation( AltrmiRequest request )
{
- if( mState == STARTED )
+ if( getState() == STARTED )
{
return super.handleInvocation( request );
}
1.3 +5 -5 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/direct/DirectServer.java
Index: DirectServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/direct/DirectServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirectServer.java 24 Apr 2002 12:43:02 -0000 1.2
+++ DirectServer.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -50,7 +50,7 @@
*/
public void start()
{
- mState = STARTED;
+ setState(STARTED);
}
/**
@@ -60,11 +60,11 @@
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
killAllConnections();
- mState = STOPPED;
+ setState(STOPPED);
}
/**
@@ -79,7 +79,7 @@
public AltrmiReply handleInvocation( AltrmiRequest request )
{
- if( mState == STARTED )
+ if( getState() == STARTED )
{
return super.handleInvocation( request );
}
1.4 +7 -6 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/piped/AbstractPipedServer.java
Index: AbstractPipedServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/piped/AbstractPipedServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractPipedServer.java 23 Jun 2002 17:03:24 -0000 1.3
+++ AbstractPipedServer.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -41,11 +41,11 @@
throws AltrmiConnectionException
{
- if( mState == UNSTARTED )
+ if( getState() == UNSTARTED | getState() == STARTING)
{
throw new AltrmiConnectionException( "Server not started yet" );
}
- else if( mState == SHUTTINGDOWN )
+ else if( getState() == SHUTTINGDOWN )
{
throw new AltrmiConnectionException( "Server is Shutting down" );
}
@@ -64,6 +64,7 @@
PipedStreamServerConnection pssc = new PipedStreamServerConnection( this, pIS, pOS,
ssrw );
+ pssc.enableLogging(getLogger());
pssc.enableLogging( getLogger() );
@@ -84,7 +85,7 @@
*/
public void start()
{
- mState = STARTED;
+ setState(STARTED);
}
/**
@@ -94,11 +95,11 @@
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
killAllConnections();
- mState = STOPPED;
+ setState(STOPPED);
}
protected abstract ServerStreamReadWriter createServerStreamReadWriter();
1.3 +25 -8 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/piped/PipedStreamServerConnection.java
Index: PipedStreamServerConnection.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/piped/PipedStreamServerConnection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PipedStreamServerConnection.java 24 Apr 2002 12:43:02 -0000 1.2
+++ PipedStreamServerConnection.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -24,24 +24,29 @@
public class PipedStreamServerConnection extends StreamServerConnection
{
+ /**
+ * The piped input stream.
+ */
private PipedInputStream mPipedIn;
+
+ /**
+ * The piped output stream.
+ */
private PipedOutputStream mPipedOut;
/**
- * Constructor PipedStreamServerConnection
+ * Construct a PipedStreamServerConnection
*
*
- * @param abstractServer
- * @param pipedIn
- * @param pipedOut
- * @param readWriter
+ * @param abstractServer The asbtract server than handles requests
+ * @param pipedIn The piped Input Stream
+ * @param pipedOut The piped Output Stream
+ * @param readWriter The read writer.
*
- * @throws IOException
*
*/
public PipedStreamServerConnection(
AbstractServer abstractServer, PipedInputStream pipedIn, PipedOutputStream pipedOut, ServerStreamReadWriter readWriter )
- throws IOException
{
super( abstractServer, readWriter );
@@ -50,16 +55,28 @@
mPipedOut = pipedOut;
}
+ /**
+ * Kill connections
+ */
protected void killConnection()
{
try
{
mPipedIn.close();
+ }
+ catch( IOException e )
+ {
+ getLogger().error("Some problem during closing of Input Stream", e);
+ }
+
+ try
+ {
mPipedOut.close();
}
catch( IOException e )
{
+ getLogger().error("Some problem during closing of Output Stream", e);
}
}
}
1.3 +14 -12 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/rmi/RmiInovcationAdapter.java
Index: RmiInovcationAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/rmi/RmiInovcationAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RmiInovcationAdapter.java 24 Apr 2002 12:43:02 -0000 1.2
+++ RmiInovcationAdapter.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -14,7 +14,7 @@
import org.apache.excalibur.altrmi.server.impl.AbstractServer;
/**
- * Class RmiInovcationAdapter
+ * Class RmiInovcationAdapter for AltRMI over RMI invocation adaptation.
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
@@ -22,34 +22,36 @@
*/
public class RmiInovcationAdapter implements RmiAltrmiInvocationHandler
{
-
- private AbstractServer mAbstractServer;
+ /**
+ * The abstract server
+ */
+ private AbstractServer m_abstractServer;
/**
- * Constructor RmiInovcationAdapter
+ * Constructor a RmiInovcationAdapter with an abstract server.
*
*
- * @param abstractServer
+ * @param abstractServer The abstract server
*
*/
public RmiInovcationAdapter( AbstractServer abstractServer )
{
- mAbstractServer = abstractServer;
+ m_abstractServer = abstractServer;
}
/**
- * Method handleInvocation
+ * Handle an Invocation
*
*
- * @param request
+ * @param request The request
*
- * @return
+ * @return an AltRMI reply object
*
- * @throws RemoteException
+ * @throws RemoteException if a problem during processing
*
*/
public AltrmiReply handleInvocation( AltrmiRequest request ) throws RemoteException
{
- return mAbstractServer.handleInvocation( request );
+ return m_abstractServer.handleInvocation( request );
}
}
1.4 +47 -38 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/rmi/RmiServer.java
Index: RmiServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/rmi/RmiServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RmiServer.java 4 May 2002 15:48:31 -0000 1.3
+++ RmiServer.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -18,7 +18,7 @@
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
/**
- * Class RmiServer
+ * Class RmiServer for serving of AltRMI over RMI
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
@@ -27,96 +27,105 @@
public class RmiServer extends AbstractServer
{
- private RmiInovcationAdapter mRmiAltrmiInovcationAdapter;
- private String mHost;
- private int mPort;
- private Registry mRegistry;
+ /**
+ * The invocation adapter
+ */
+ private RmiInovcationAdapter m_rmiAltrmiInovcationAdapter;
+ /**
+ * The host
+ */
+ private String m_host;
+ /**
+ * The port
+ */
+ private int m_port;
+ /**
+ * The registry
+ */
+ private Registry m_registry;
/**
- * Constructor RmiServer
- *
+ * Constructor a RmiServer.
*
- * @param host
- * @param port
*
- * @throws AltrmiServerException
+ * @param host the host to connect to (unused presently)
+ * @param port the port to connect to.
*
*/
- public RmiServer( String host, int port ) throws AltrmiServerException
+ public RmiServer( String host, int port )
{
- mHost = host;
- mPort = port;
+ m_host = host;
+ m_port = port;
}
/**
- * Constructor RmiServer
- *
+ * Constructor a RmiServer with a preexiting invocation handler.
*
- * @param invocationHandlerAdapter
- * @param host
- * @param port
*
- * @throws AltrmiServerException
+ * @param invocationHandlerAdapter for piping of invocations.
+ * @param host the host to connect to (unused presently)
+ * @param port the port to connect to.
*
*/
- public RmiServer( InvocationHandlerAdapter invocationHandlerAdapter, String host, int port ) throws AltrmiServerException
+ public RmiServer( InvocationHandlerAdapter invocationHandlerAdapter, String host, int port )
{
super(invocationHandlerAdapter);
- mHost = host;
- mPort = port;
+ m_host = host;
+ m_port = port;
}
/**
- * Method start
+ * Start the server.
*
+ * @throws AltrmiServerException if an exception during starting.
*/
public void start() throws AltrmiServerException
{
-
- mState = STARTED;
-
+ setState(STARTING);
try
{
- mRmiAltrmiInovcationAdapter = new RmiInovcationAdapter( this );
+ m_rmiAltrmiInovcationAdapter = new RmiInovcationAdapter( this );
- UnicastRemoteObject.exportObject( mRmiAltrmiInovcationAdapter );
+ UnicastRemoteObject.exportObject( m_rmiAltrmiInovcationAdapter );
- mRegistry = LocateRegistry.createRegistry( mPort );
+ m_registry = LocateRegistry.createRegistry( m_port );
- mRegistry.rebind( RmiAltrmiInvocationHandler.class.getName(),
- mRmiAltrmiInovcationAdapter );
+ m_registry.rebind( RmiAltrmiInvocationHandler.class.getName(),
+ m_rmiAltrmiInovcationAdapter );
+ setState(STARTED);
}
catch( RemoteException re )
{
+ getLogger().error("Error starting RMI server",re);
throw new AltrmiServerException( "Some problem setting up server : "
+ re.getMessage() );
}
}
/**
- * Method stop
+ * Stop the server.
*
*/
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
killAllConnections();
try
{
- mRegistry.unbind( RmiAltrmiInvocationHandler.class.getName() );
+ m_registry.unbind( RmiAltrmiInvocationHandler.class.getName() );
}
catch( RemoteException re )
{
+ getLogger().error("Error stopping RMI server",re);
}
catch( NotBoundException nbe )
{
-
- //TODO ?
+ getLogger().error("Error stopping RMI server",nbe);
}
- mState = STOPPED;
+ setState(STOPPED);
}
}
1.6 +45 -29 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java
Index: AbstractCompleteSocketStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractCompleteSocketStreamServer.java 18 Aug 2002 12:04:49 -0000 1.5
+++ AbstractCompleteSocketStreamServer.java 21 Sep 2002 15:52:57 -0000 1.6
@@ -26,16 +26,23 @@
implements Runnable
{
- private ServerSocket mServerSocket;
- private Thread mThread;
+ /**
+ * The server socket.
+ */
+ private ServerSocket m_serverSocket;
+
+ /**
+ * The thread handling the listening
+ */
+ private Thread m_thread;
/**
- * Constructor CompleteSocketObjectStreamServer
+ * Construct a CompleteSocketObjectStreamServer
*
*
- * @param port
+ * @param port The port to use
*
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem during instantiation.
*
*/
public AbstractCompleteSocketStreamServer( int port ) throws AltrmiServerException
@@ -43,7 +50,7 @@
try
{
- mServerSocket = new ServerSocket( port );
+ m_serverSocket = new ServerSocket( port );
}
catch( IOException ioe )
{
@@ -53,13 +60,13 @@
}
/**
- * Constructor AbstractCompleteSocketStreamServer
+ * Construct a AbstractCompleteSocketStreamServer
*
*
- * @param invocationHandlerAdapter
- * @param port
+ * @param invocationHandlerAdapter The invocation handler adapter to use.
+ * @param port The port to use
*
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem during instantiation.
*
*/
public AbstractCompleteSocketStreamServer(
@@ -71,7 +78,7 @@
try
{
- mServerSocket = new ServerSocket( port );
+ m_serverSocket = new ServerSocket( port );
}
catch( IOException ioe )
{
@@ -91,11 +98,11 @@
boolean accepting = false;
try
{
- while( mState == STARTED )
+ while( getState() == STARTED )
{
accepting = true;
- Socket sock = mServerSocket.accept();
+ Socket sock = m_serverSocket.accept();
accepting = false;
// see http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
@@ -105,9 +112,8 @@
ssrw.setStreams( sock.getInputStream(), sock.getOutputStream() );
- SocketStreamServerConnection sssc = new SocketStreamServerConnection( this, sock,
- sock.getInputStream(),
- sock.getOutputStream(), ssrw );
+ SocketStreamServerConnection sssc =
+ new SocketStreamServerConnection( this, sock, ssrw );
sssc.enableLogging( getLogger() );
@@ -124,8 +130,7 @@
}
else
{
- System.err.println( "Some problem connecting client via sockets: " + ioe.getMessage());
- ioe.printStackTrace();
+ getLogger().error("Some problem connecting client via sockets: ", ioe);
}
}
}
@@ -137,9 +142,10 @@
public void start()
{
- mState = STARTED;
-
+ setState(STARTING);
getThread().start();
+ setState(STARTED);
+
}
/**
@@ -149,32 +155,42 @@
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
try
{
- mServerSocket.close();
+ m_serverSocket.close();
}
- catch ( IOException e )
+ catch ( IOException ioe )
{
- System.out.println( "Unable to close the server socket." );
+ getLogger().error("Error stopping Complete Socket server", ioe);
+ throw new RuntimeException("Error stopping Complete Socket server :"
+ + ioe.getMessage());
}
killAllConnections();
getThread().interrupt();
- mState = STOPPED;
+ setState(STOPPED);
}
+ /**
+ * Get the thread used for connection processing
+ * @return
+ */
private Thread getThread()
{
- if( mThread == null )
+ if( m_thread == null )
{
- mThread = new Thread( this, "AltrmiSocketStreamServer" );
+ m_thread = new Thread( this, "AltrmiSocketStreamServer" );
}
- return mThread;
+ return m_thread;
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected abstract ServerStreamReadWriter createServerStreamReadWriter();
}
1.4 +25 -17 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractPartialSocketStreamServer.java
Index: AbstractPartialSocketStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractPartialSocketStreamServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractPartialSocketStreamServer.java 18 Aug 2002 12:04:49 -0000 1.3
+++ AbstractPartialSocketStreamServer.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -13,57 +13,65 @@
*/
public abstract class AbstractPartialSocketStreamServer extends AbstractServer
{
+ /**
+ * Construct an AbstractPartialSocketStreamServer
+ */
public AbstractPartialSocketStreamServer()
{
}
+ /**
+ * Construct a AbstractPartialSocketStreamServer
+ * @param inovcationHandlerAdapter Use this invocation handler adapter.
+ */
public AbstractPartialSocketStreamServer( InvocationHandlerAdapter inovcationHandlerAdapter )
{
super( inovcationHandlerAdapter );
}
/**
- * Method handleConnection
+ * Handle a connection.
*
- * @param sock
+ * @param socket The socket for the connection
*
*/
- public void handleConnection( final Socket sock )
+ public void handleConnection( final Socket socket )
{
// see http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
try
{
- sock.setSoTimeout( 36000 );
+ socket.setSoTimeout( 36000 );
}
catch( SocketException se )
{
- se.printStackTrace();
+ getLogger().error("Some error during socket handling", se);
}
try
{
- if( mState == STARTED )
+ if( getState() == STARTED )
{
ServerStreamReadWriter ssrw = createServerStreamReadWriter();
- ssrw.setStreams( sock.getInputStream(), sock.getOutputStream() );
-
- SocketStreamServerConnection sssc = new SocketStreamServerConnection( this, sock,
- sock.getInputStream(),
- sock.getOutputStream(), ssrw );
+ ssrw.setStreams( socket.getInputStream(), socket.getOutputStream() );
+ SocketStreamServerConnection sssc =
+ new SocketStreamServerConnection( this, socket, ssrw );
sssc.enableLogging( getLogger() );
sssc.run();
}
}
catch( IOException ioe )
{
- System.err.println( "Some problem connecting client via sockets: " + ioe.getMessage());
- ioe.printStackTrace();
+ getLogger().error("Some problem connecting client via sockets: ", ioe);
}
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected abstract ServerStreamReadWriter createServerStreamReadWriter();
/**
@@ -72,7 +80,7 @@
*/
public void start()
{
- mState = STARTED;
+ setState(STARTED);
}
/**
@@ -82,10 +90,10 @@
public void stop()
{
- mState = SHUTTINGDOWN;
+ setState(SHUTTINGDOWN);
killAllConnections();
- mState = STOPPED;
+ setState(STOPPED);
}
}
1.3 +12 -9 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/CompleteSocketCustomStreamServer.java
Index: CompleteSocketCustomStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/CompleteSocketCustomStreamServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CompleteSocketCustomStreamServer.java 24 Apr 2002 12:43:02 -0000 1.2
+++ CompleteSocketCustomStreamServer.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -23,12 +23,12 @@
{
/**
- * Constructor CompleteSocketObjectStreamServer
+ * Construct a CompleteSocketObjectStreamServer
*
*
- * @param port
+ * @param port The port to use
*
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem instantiating.
*
*/
public CompleteSocketCustomStreamServer( int port ) throws AltrmiServerException
@@ -37,13 +37,12 @@
}
/**
- * Constructor CompleteSocketCustomStreamServer
+ * Construct a CompleteSocketCustomStreamServer
*
+ * @param invocationHandlerAdapter The invocation handler to use.
+ * @param port The port to use
*
- * @param invocationHandlerAdapter
- * @param port
- *
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem instantiating.
*
*/
public CompleteSocketCustomStreamServer(
@@ -53,6 +52,10 @@
super( invocationHandlerAdapter, port );
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected ServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerCustomStreamReadWriter();
1.3 +25 -15 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java
Index: CompleteSocketObjectStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CompleteSocketObjectStreamServer.java 24 Apr 2002 12:43:02 -0000 1.2
+++ CompleteSocketObjectStreamServer.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -21,16 +21,22 @@
public class CompleteSocketObjectStreamServer extends AbstractCompleteSocketStreamServer
{
- private String mObjectOutputStreamClassName = "java.io.ObjectOutputStream";
- private String mObjectInputStreamClassName = "java.io.ObjectInputStream";
+ /**
+ * The object output stream class name
+ */
+ private String m_objectOutputStreamClassName = "java.io.ObjectOutputStream";
+ /**
+ * The object input stream class name
+ */
+ private String m_objectInputStreamClassName = "java.io.ObjectInputStream";
/**
- * Constructor CompleteSocketObjectStreamServer
+ * Construct a CompleteSocketObjectStreamServer
*
*
- * @param port
+ * @param port The port to use.
*
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem instantiating.
*
*/
public CompleteSocketObjectStreamServer( int port ) throws AltrmiServerException
@@ -39,14 +45,14 @@
}
/**
- * Constructor CompleteSocketObjectStreamServer
+ * Construct a CompleteSocketObjectStreamServer
*
*
- * @param port
- * @param objectInputStreamClassName
- * @param objectOutputStreamClassName
+ * @param port The port to use
+ * @param objectInputStreamClassName The overriding class to use for InputStreams
+ * @param objectOutputStreamClassName The overriding class to use for OutputStreams
*
- * @throws AltrmiServerException
+ * @throws AltrmiServerException If a problem instantiating.
*
*/
public CompleteSocketObjectStreamServer(
@@ -56,13 +62,17 @@
super( port );
- mObjectInputStreamClassName = objectInputStreamClassName;
- mObjectOutputStreamClassName = objectOutputStreamClassName;
+ m_objectInputStreamClassName = objectInputStreamClassName;
+ m_objectOutputStreamClassName = objectOutputStreamClassName;
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected ServerStreamReadWriter createServerStreamReadWriter()
{
- return new ServerObjectStreamReadWriter( mObjectOutputStreamClassName,
- mObjectInputStreamClassName );
+ return new ServerObjectStreamReadWriter( m_objectOutputStreamClassName,
+ m_objectInputStreamClassName );
}
}
1.4 +9 -9 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/PartialSocketCustomStreamServer.java
Index: PartialSocketCustomStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/PartialSocketCustomStreamServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PartialSocketCustomStreamServer.java 24 Apr 2002 12:43:02 -0000 1.3
+++ PartialSocketCustomStreamServer.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -7,7 +7,6 @@
*/
package org.apache.excalibur.altrmi.server.impl.socket;
-import org.apache.excalibur.altrmi.server.AltrmiServerException;
import org.apache.excalibur.altrmi.server.impl.ServerCustomStreamReadWriter;
import org.apache.excalibur.altrmi.server.impl.ServerStreamReadWriter;
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
@@ -24,31 +23,32 @@
{
/**
- * Constructor PartialSocketCustomStreamServer
+ * Construct a PartialSocketCustomStreamServer
*
*
- * @throws AltrmiServerException
*
*/
- public PartialSocketCustomStreamServer() throws AltrmiServerException
+ public PartialSocketCustomStreamServer()
{
}
/**
- * Constructor PartialSocketCustomStreamServer
+ * Construct a PartialSocketCustomStreamServer
*
*
- * @param invocationHandlerAdapter
+ * @param invocationHandlerAdapter The invocation handler to use insteado of creating one.
*
- * @throws AltrmiServerException
*
*/
public PartialSocketCustomStreamServer( InvocationHandlerAdapter invocationHandlerAdapter )
- throws AltrmiServerException
{
super( invocationHandlerAdapter );
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected ServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerCustomStreamReadWriter();
1.4 +9 -11 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/PartialSocketObjectStreamServer.java
Index: PartialSocketObjectStreamServer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/PartialSocketObjectStreamServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PartialSocketObjectStreamServer.java 24 Apr 2002 12:43:02 -0000 1.3
+++ PartialSocketObjectStreamServer.java 21 Sep 2002 15:52:57 -0000 1.4
@@ -7,7 +7,6 @@
*/
package org.apache.excalibur.altrmi.server.impl.socket;
-import org.apache.excalibur.altrmi.server.AltrmiServerException;
import org.apache.excalibur.altrmi.server.impl.ServerObjectStreamReadWriter;
import org.apache.excalibur.altrmi.server.impl.ServerStreamReadWriter;
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
@@ -24,31 +23,30 @@
{
/**
- * Constructor PartialSocketObjectStreamServer
- *
- *
- * @throws AltrmiServerException
+ * Construct a PartialSocketObjectStreamServer
*
*/
- public PartialSocketObjectStreamServer() throws AltrmiServerException
+ public PartialSocketObjectStreamServer()
{
}
/**
- * Constructor PartialSocketObjectStreamServer
+ * Construct a PartialSocketObjectStreamServer
*
*
- * @param invocationHandlerAdapter
+ * @param invocationHandlerAdapter The invocation handler to use insteado of creating one.
*
- * @throws AltrmiServerException
*
*/
public PartialSocketObjectStreamServer( InvocationHandlerAdapter invocationHandlerAdapter )
- throws AltrmiServerException
{
super( invocationHandlerAdapter );
}
+ /**
+ * Create a Server Stream Read Writer.
+ * @return The Server Stream Read Writer.
+ */
protected ServerStreamReadWriter createServerStreamReadWriter()
{
return new ServerObjectStreamReadWriter();
1.3 +16 -20 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/SocketStreamServerConnection.java
Index: SocketStreamServerConnection.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/SocketStreamServerConnection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SocketStreamServerConnection.java 24 Apr 2002 12:43:02 -0000 1.2
+++ SocketStreamServerConnection.java 21 Sep 2002 15:52:57 -0000 1.3
@@ -8,8 +8,6 @@
package org.apache.excalibur.altrmi.server.impl.socket;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.Socket;
import org.apache.excalibur.altrmi.server.impl.AbstractServer;
import org.apache.excalibur.altrmi.server.impl.ServerStreamReadWriter;
@@ -25,40 +23,38 @@
public class SocketStreamServerConnection extends StreamServerConnection
{
- private Socket mSocket;
+ /**
+ * The socket for the connection
+ */
+ private Socket m_socket;
/**
- * Constructor SocketStreamServerConnection
- *
- *
- * @param abstractServer
- * @param socket
- * @param inStream
- * @param outStream
- * @param readWriter
- *
- * @throws IOException
- *
+ * 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, InputStream inStream, OutputStream outStream, ServerStreamReadWriter readWriter )
- throws IOException
+ final AbstractServer abstractServer, final Socket socket,ServerStreamReadWriter readWriter )
{
super( abstractServer, readWriter );
-
- mSocket = socket;
+ m_socket = socket;
}
+ /**
+ * Kill connections
+ */
protected void killConnection()
{
try
{
- mSocket.close();
+ m_socket.close();
}
catch( IOException e )
{
+ getLogger().error("Error closing Connection",e);
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>