Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2537/components/http/impl/src/java/org/jicarilla/net
Modified Files:
SocketServerConfig.java SocketServerImpl.java
Log Message:
Ran some code analysis tools on the code and changed approximately 200 small things based on that. Nothing shocking (I hope!)
Index: SocketServerConfig.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/net/SocketServerConfig.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SocketServerConfig.java 4 Jan 2004 16:10:18 -0000 1.2
+++ SocketServerConfig.java 26 Feb 2004 16:51:55 -0000 1.3
@@ -40,7 +40,7 @@
protected int m_numberOfThreads;
- public SocketServerConfig( String address, int port, int backlog, int threads )
+ public SocketServerConfig( final String address, final int port, final int backlog, final int threads )
{
m_port = port;
m_backlog = backlog;
Index: SocketServerImpl.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/net/SocketServerImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- SocketServerImpl.java 20 Jan 2004 00:37:44 -0000 1.4
+++ SocketServerImpl.java 26 Feb 2004 16:51:55 -0000 1.5
@@ -66,6 +66,9 @@
*/
public class SocketServerImpl extends AbstractActive implements SocketServer
{
+ public final static int SLEEP_DURING_DISPOSE = 2000;
+ public final static int MAXIMUM_PORT_NUMBER=65536;
+
// ----------------------------------------------------------------------
// Properties
// ----------------------------------------------------------------------
@@ -83,16 +86,14 @@
protected PooledExecutor m_threadPool;
protected StoppableRunnable[] m_runners;
- protected boolean m_running = false;
- protected boolean m_stopped = false;
// ----------------------------------------------------------------------
// Constructor
// ----------------------------------------------------------------------
- public SocketServerImpl( SocketServerConfig config,
- ExceptionListener exceptionListener,
- ObjectPool eventPool, ObjectPool handlerPool, Sink errorHandler,
- PooledExecutor threadPool )
+ public SocketServerImpl( final SocketServerConfig config,
+ final ExceptionListener exceptionListener,
+ final ObjectPool eventPool, final ObjectPool handlerPool, final Sink errorHandler,
+ final PooledExecutor threadPool )
throws IOException
{
// configuration
@@ -108,8 +109,8 @@
setThreadPool( threadPool );
setExceptionListener( exceptionListener );
- ServerSocketChannel channel = ServerSocketChannel.open();
- SocketAddress address = new InetSocketAddress( getAddress(), getPort() );
+ final ServerSocketChannel channel = ServerSocketChannel.open();
+ final SocketAddress address = new InetSocketAddress( getAddress(), getPort() );
channel.socket().bind( address, getBacklog() );
setChannel( channel );
}
@@ -141,7 +142,7 @@
m_runners[i].stop();
// give runners 2 seconds to finish pending requests...
- Thread.sleep( 2000 );
+ Thread.sleep( SLEEP_DURING_DISPOSE );
getChannel().close();
getSocket().close();
@@ -149,7 +150,7 @@
m_channel = null;
}
- public void finalize() throws Throwable { dispose(); }
+ public void finalize() throws Throwable { dispose(); super.finalize(); }
// ----------------------------------------------------------------------
// Getters/Setters
@@ -159,11 +160,11 @@
return m_port;
}
- protected void setPort( int port )
+ protected void setPort( final int port )
{
Assert.assertTrue(
"port must be between 0 and 65536",
- port >= 0 && port <= 65536 );
+ port >= 0 && port <= MAXIMUM_PORT_NUMBER );
m_port = port;
}
@@ -172,7 +173,7 @@
return m_address;
}
- protected void setAddress( InetAddress address )
+ protected void setAddress( final InetAddress address )
{
Assert.assertNotNull( "address argument may not be null", address );
m_address = address;
@@ -183,7 +184,7 @@
return m_rootDirectory;
}
- protected void setRootDirectory( String rootDirectory )
+ protected void setRootDirectory( final String rootDirectory )
{
Assert.assertNotNull( "rootDirectory argument may not be null",
rootDirectory );
@@ -195,7 +196,7 @@
return m_exceptionListener;
}
- protected void setExceptionListener( ExceptionListener exceptionListener )
+ protected void setExceptionListener( final ExceptionListener exceptionListener )
{
Assert.assertNotNull( "exceptionListener argument may not be null",
exceptionListener );
@@ -208,7 +209,7 @@
//return m_socket;
}
- protected void setSocket( ServerSocket socket )
+ protected void setSocket( final ServerSocket socket )
{
Assert.assertNotNull( "socket argument may not be null", socket );
//m_socket = socket;
@@ -220,7 +221,7 @@
return m_channel;
}
- protected void setChannel( ServerSocketChannel channel )
+ protected void setChannel( final ServerSocketChannel channel )
{
Assert.assertNotNull( "channel argument may not be null", channel );
m_channel = channel;
@@ -231,7 +232,7 @@
return m_backlog;
}
- protected void setBacklog( int backlog )
+ protected void setBacklog( final int backlog )
{
Assert.assertTrue( "backlog argument must be 0 or bigger",
backlog >= 0 );
@@ -243,7 +244,7 @@
return m_numThreads;
}
- protected void setNumThreads( int numThreads )
+ protected void setNumThreads( final int numThreads )
{
Assert.assertTrue( "numThreads argument must be 1 or bigger",
numThreads > 0 );
@@ -255,7 +256,7 @@
return m_eventPool;
}
- protected void setEventPool( ObjectPool eventPool )
+ protected void setEventPool( final ObjectPool eventPool )
{
Assert.assertNotNull( "eventPool argument may not be null", eventPool );
m_eventPool = eventPool;
@@ -266,7 +267,7 @@
return m_handlerPool;
}
- protected void setHandlerPool( ObjectPool handlerPool )
+ protected void setHandlerPool( final ObjectPool handlerPool )
{
Assert.assertNotNull( "handlerPool argument may not be null",
handlerPool );
@@ -278,7 +279,7 @@
return m_errorHandler;
}
- protected void setErrorHandler( Sink errorHandler )
+ protected void setErrorHandler( final Sink errorHandler )
{
Assert.assertNotNull( "errorHandler argument may not be null",
errorHandler );
@@ -290,7 +291,7 @@
return m_threadPool;
}
- protected void setThreadPool( PooledExecutor threadPool )
+ protected void setThreadPool( final PooledExecutor threadPool )
{
Assert.assertNotNull( "threadPool argument may not be null",
threadPool );
@@ -311,7 +312,7 @@
return new RequestHandlingWorker( server );
}
- protected void executeRunner( Runnable r ) throws Throwable
+ protected void executeRunner( final Runnable r ) throws Throwable
{
try
{
@@ -356,12 +357,12 @@
*
* @param channel the channel to get a request from
*/
- protected void handleRequest( SocketChannel channel )
+ protected void handleRequest( final SocketChannel channel )
throws InterruptedException,
SocketServerException
{
- Event event = borrowEvent();
- Channel handler = borrowChannel();
+ final Event event = borrowEvent();
+ final Channel handler = borrowChannel();
event.setChannel( channel );
@@ -388,7 +389,7 @@
);
}
- protected void handleRequestException( SocketChannel channel, Exception ex )
+ protected void handleRequestException( final SocketChannel channel, final Exception ex )
{
try
{
@@ -424,7 +425,7 @@
protected interface StoppableRunnable extends Runnable
{
- public void stop();
+ void stop();
}
// ----------------------------------------------------------------------
@@ -436,7 +437,7 @@
protected boolean m_running = true;
private final SocketServerImpl m_server;
- public RequestHandlingWorker( SocketServerImpl server )
+ protected RequestHandlingWorker( final SocketServerImpl server )
{
m_server = server;
}
@@ -471,21 +472,21 @@
{
protected final Channel m_handler;
- public PoolReturningSinkSink( Channel handler )
+ protected PoolReturningSinkSink( final Channel handler )
{
m_handler = handler;
}
- public void put( Object o )
+ public void put( final Object o )
{
try { getHandlerPool().returnObject( m_handler ); }
- catch( Exception e ) {};
+ catch( Exception e ) {}
try { getEventPool().returnObject( o ); }
- catch( Exception e ) {};
+ catch( Exception e ) {}
}
- public boolean offer( Object o, long l )
+ public boolean offer( final Object o, final long l )
{
put( o );
return true;
@@ -502,7 +503,7 @@
protected final Sink m_sink;
protected final Event m_event;
- public PoolReturningWorker( Channel handler, Sink sink, Event event )
+ protected PoolReturningWorker( final Channel handler, final Sink sink, final Event event )
{
m_handler = handler;
m_sink = sink;
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.