You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2006/09/04 05:12:44 UTC
svn commit: r439913 - in /directory/trunks/mina:
core/src/main/java/org/apache/mina/common/
core/src/main/java/org/apache/mina/common/support/
core/src/main/java/org/apache/mina/filter/codec/
core/src/main/java/org/apache/mina/filter/codec/demux/ core/...
Author: trustin
Date: Sun Sep 3 20:12:43 2006
New Revision: 439913
URL: http://svn.apache.org/viewvc?view=rev&rev=439913
Log:
Replaced tabs with spaces
Modified:
directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java
directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBufferProxy.java
directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseByteBuffer.java
directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/SynchronizedProtocolDecoder.java
directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/textline/TextLineDecoder.java
directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
directory/trunks/mina/core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerFactory.java
directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionConfigImpl.java
directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java
directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
directory/trunks/mina/core/src/main/java/org/apache/mina/util/AnonymousSocketAddress.java
directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/ssl/BogusSSLContextFactory.java
directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyCodecFactory.java
directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyDecoder.java
directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyEncoder.java
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java Sun Sep 3 20:12:43 2006
@@ -438,7 +438,7 @@
*/
public int remaining()
{
- return limit() - position();
+ return limit() - position();
}
/**
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBufferProxy.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBufferProxy.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBufferProxy.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBufferProxy.java Sun Sep 3 20:12:43 2006
@@ -637,17 +637,17 @@
public ByteBuffer capacity( int newCapacity )
{
- buf.capacity( newCapacity );
- return this;
+ buf.capacity( newCapacity );
+ return this;
}
public boolean isReadOnly()
{
- return buf.isReadOnly();
+ return buf.isReadOnly();
}
public int markValue()
{
- return buf.markValue();
+ return buf.markValue();
}
}
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java Sun Sep 3 20:12:43 2006
@@ -66,23 +66,23 @@
*/
public static PooledThreadModel getInstance( String serviceName )
{
- if( serviceName == null )
- {
- throw new NullPointerException( "serviceName" );
- }
+ if( serviceName == null )
+ {
+ throw new NullPointerException( "serviceName" );
+ }
- PooledThreadModel model;
- synchronized( service2model )
- {
- model = ( PooledThreadModel ) service2model.get( serviceName );
- if( model == null )
- {
- model = new PooledThreadModel( serviceName );
- service2model.put( serviceName, model );
- }
- }
-
- return model;
+ PooledThreadModel model;
+ synchronized( service2model )
+ {
+ model = ( PooledThreadModel ) service2model.get( serviceName );
+ if( model == null )
+ {
+ model = new PooledThreadModel( serviceName );
+ service2model.put( serviceName, model );
+ }
+ }
+
+ return model;
}
private final ThreadPoolFilter filter = new ThreadPoolFilter();
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseByteBuffer.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseByteBuffer.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseByteBuffer.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseByteBuffer.java Sun Sep 3 20:12:43 2006
@@ -57,40 +57,40 @@
public boolean isDirect()
{
- return buf().isDirect();
+ return buf().isDirect();
}
public boolean isReadOnly()
{
- return buf().isReadOnly();
+ return buf().isReadOnly();
}
public int capacity()
{
- return buf().capacity();
+ return buf().capacity();
}
public ByteBuffer capacity( int newCapacity )
{
- if( newCapacity > capacity() )
- {
- // Allocate a new buffer and transfer all settings to it.
- int pos = position();
- int limit = limit();
- ByteOrder bo = order();
-
- capacity0( newCapacity );
- buf().limit( limit );
- if( mark >= 0 )
- {
- buf().position( mark );
- buf().mark();
- }
- buf().position( pos );
- buf().order( bo );
- }
-
- return this;
+ if( newCapacity > capacity() )
+ {
+ // Allocate a new buffer and transfer all settings to it.
+ int pos = position();
+ int limit = limit();
+ ByteOrder bo = order();
+
+ capacity0( newCapacity );
+ buf().limit( limit );
+ if( mark >= 0 )
+ {
+ buf().position( mark );
+ buf().mark();
+ }
+ buf().position( pos );
+ buf().order( bo );
+ }
+
+ return this;
}
/**
@@ -101,41 +101,41 @@
public boolean isAutoExpand()
{
- return autoExpand;
+ return autoExpand;
}
public ByteBuffer setAutoExpand( boolean autoExpand )
{
- this.autoExpand = autoExpand;
- return this;
+ this.autoExpand = autoExpand;
+ return this;
}
public ByteBuffer expand( int pos, int expectedRemaining )
{
- int end = pos + expectedRemaining;
- if( end > capacity() )
- {
- // The buffer needs expansion.
- capacity( end );
- }
-
- if( end > limit() )
- {
- // We call limit() directly to prevent StackOverflowError
- buf().limit( end );
- }
- return this;
+ int end = pos + expectedRemaining;
+ if( end > capacity() )
+ {
+ // The buffer needs expansion.
+ capacity( end );
+ }
+
+ if( end > limit() )
+ {
+ // We call limit() directly to prevent StackOverflowError
+ buf().limit( end );
+ }
+ return this;
}
public int position()
{
- return buf().position();
+ return buf().position();
}
public ByteBuffer position( int newPosition )
{
autoExpand( newPosition, 0 );
- buf().position( newPosition );
+ buf().position( newPosition );
if( mark > newPosition )
{
mark = -1;
@@ -145,13 +145,13 @@
public int limit()
{
- return buf().limit();
+ return buf().limit();
}
public ByteBuffer limit( int newLimit )
{
autoExpand( newLimit, 0 );
- buf().limit( newLimit );
+ buf().limit( newLimit );
if( mark > newLimit )
{
mark = -1;
@@ -161,276 +161,276 @@
public ByteBuffer mark()
{
- buf().mark();
+ buf().mark();
mark = position();
return this;
}
public int markValue()
{
- return mark;
+ return mark;
}
public ByteBuffer reset()
{
- buf().reset();
- return this;
+ buf().reset();
+ return this;
}
public ByteBuffer clear()
{
- buf().clear();
- mark = -1;
- return this;
+ buf().clear();
+ mark = -1;
+ return this;
}
public ByteBuffer flip()
{
- buf().flip();
- mark = -1;
- return this;
+ buf().flip();
+ mark = -1;
+ return this;
}
public ByteBuffer rewind()
{
- buf().rewind();
- mark = -1;
- return this;
+ buf().rewind();
+ mark = -1;
+ return this;
}
public byte get()
{
- return buf().get();
+ return buf().get();
}
public ByteBuffer put( byte b )
{
autoExpand( 1 );
- buf().put( b );
- return this;
+ buf().put( b );
+ return this;
}
public byte get( int index )
{
- return buf().get( index );
+ return buf().get( index );
}
public ByteBuffer put( int index, byte b )
{
autoExpand( index, 1 );
- buf().put( index, b );
- return this;
+ buf().put( index, b );
+ return this;
}
public ByteBuffer get( byte[] dst, int offset, int length )
{
- buf().get( dst, offset, length );
- return this;
+ buf().get( dst, offset, length );
+ return this;
}
public ByteBuffer put( java.nio.ByteBuffer src )
{
autoExpand( src.remaining() );
- buf().put( src );
- return this;
+ buf().put( src );
+ return this;
}
public ByteBuffer put( byte[] src, int offset, int length )
{
autoExpand( length );
- buf().put( src, offset, length );
- return this;
+ buf().put( src, offset, length );
+ return this;
}
public ByteBuffer compact()
{
- buf().compact();
- mark = -1;
- return this;
+ buf().compact();
+ mark = -1;
+ return this;
}
public ByteOrder order()
{
- return buf().order();
+ return buf().order();
}
public ByteBuffer order( ByteOrder bo )
{
- buf().order( bo );
- return this;
+ buf().order( bo );
+ return this;
}
public char getChar()
{
- return buf().getChar();
+ return buf().getChar();
}
public ByteBuffer putChar( char value )
{
autoExpand( 2 );
- buf().putChar( value );
- return this;
+ buf().putChar( value );
+ return this;
}
public char getChar( int index )
{
- return buf().getChar( index );
+ return buf().getChar( index );
}
public ByteBuffer putChar( int index, char value )
{
autoExpand( index, 2 );
- buf().putChar( index, value );
- return this;
+ buf().putChar( index, value );
+ return this;
}
public CharBuffer asCharBuffer()
{
- return buf().asCharBuffer();
+ return buf().asCharBuffer();
}
public short getShort()
{
- return buf().getShort();
+ return buf().getShort();
}
public ByteBuffer putShort( short value )
{
autoExpand( 2 );
- buf().putShort( value );
- return this;
+ buf().putShort( value );
+ return this;
}
public short getShort( int index )
{
- return buf().getShort( index );
+ return buf().getShort( index );
}
public ByteBuffer putShort( int index, short value )
{
autoExpand( index, 2 );
- buf().putShort( index, value );
- return this;
+ buf().putShort( index, value );
+ return this;
}
public ShortBuffer asShortBuffer()
{
- return buf().asShortBuffer();
+ return buf().asShortBuffer();
}
public int getInt()
{
- return buf().getInt();
+ return buf().getInt();
}
public ByteBuffer putInt( int value )
{
autoExpand( 4 );
- buf().putInt( value );
- return this;
+ buf().putInt( value );
+ return this;
}
public int getInt( int index )
{
- return buf().getInt( index );
+ return buf().getInt( index );
}
public ByteBuffer putInt( int index, int value )
{
autoExpand( index, 4 );
- buf().putInt( index, value );
- return this;
+ buf().putInt( index, value );
+ return this;
}
public IntBuffer asIntBuffer()
{
- return buf().asIntBuffer();
+ return buf().asIntBuffer();
}
public long getLong()
{
- return buf().getLong();
+ return buf().getLong();
}
public ByteBuffer putLong( long value )
{
autoExpand( 8 );
- buf().putLong( value );
- return this;
+ buf().putLong( value );
+ return this;
}
public long getLong( int index )
{
- return buf().getLong( index );
+ return buf().getLong( index );
}
public ByteBuffer putLong( int index, long value )
{
autoExpand( index, 8 );
- buf().putLong( index, value );
- return this;
+ buf().putLong( index, value );
+ return this;
}
public LongBuffer asLongBuffer()
{
- return buf().asLongBuffer();
+ return buf().asLongBuffer();
}
public float getFloat()
{
- return buf().getFloat();
+ return buf().getFloat();
}
public ByteBuffer putFloat( float value )
{
autoExpand( 4 );
- buf().putFloat( value );
- return this;
+ buf().putFloat( value );
+ return this;
}
public float getFloat( int index )
{
- return buf().getFloat( index );
+ return buf().getFloat( index );
}
public ByteBuffer putFloat( int index, float value )
{
autoExpand( index, 4 );
- buf().putFloat( index, value );
- return this;
+ buf().putFloat( index, value );
+ return this;
}
public FloatBuffer asFloatBuffer()
{
- return buf().asFloatBuffer();
+ return buf().asFloatBuffer();
}
public double getDouble()
{
- return buf().getDouble();
+ return buf().getDouble();
}
public ByteBuffer putDouble( double value )
{
autoExpand( 8 );
- buf().putDouble( value );
- return this;
+ buf().putDouble( value );
+ return this;
}
public double getDouble( int index )
{
- return buf().getDouble( index );
+ return buf().getDouble( index );
}
public ByteBuffer putDouble( int index, double value )
{
autoExpand( index, 8 );
- buf().putDouble( index, value );
- return this;
+ buf().putDouble( index, value );
+ return this;
}
public DoubleBuffer asDoubleBuffer()
{
- return buf().asDoubleBuffer();
+ return buf().asDoubleBuffer();
}
}
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java Sun Sep 3 20:12:43 2006
@@ -249,8 +249,8 @@
public void sessionClosed( NextFilter nextFilter, IoSession session ) throws Exception
{
- // Call finishDecode() first when a connection is closed.
- ProtocolDecoder decoder = getDecoder( session );
+ // Call finishDecode() first when a connection is closed.
+ ProtocolDecoder decoder = getDecoder( session );
ProtocolDecoderOutput decoderOut = getDecoderOut( session, nextFilter );
try
{
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/SynchronizedProtocolDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/SynchronizedProtocolDecoder.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/SynchronizedProtocolDecoder.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/SynchronizedProtocolDecoder.java Sun Sep 3 20:12:43 2006
@@ -65,10 +65,10 @@
public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
{
- synchronized( decoder )
- {
- decoder.finishDecode( session, out );
- }
+ synchronized( decoder )
+ {
+ decoder.finishDecode( session, out );
+ }
}
public void dispose( IoSession session ) throws Exception
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java Sun Sep 3 20:12:43 2006
@@ -60,7 +60,8 @@
* @see MessageEncoder
* @see MessageDecoder
*/
-public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory {
+public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory
+{
private MessageDecoderFactory[] decoderFactories = new MessageDecoderFactory[0];
private MessageEncoderFactory[] encoderFactories = new MessageEncoderFactory[0];
@@ -142,11 +143,13 @@
this.decoderFactories = newDecoderFactories;
}
- public ProtocolEncoder getEncoder() throws Exception {
+ public ProtocolEncoder getEncoder() throws Exception
+ {
return new ProtocolEncoderImpl();
}
- public ProtocolDecoder getDecoder() throws Exception {
+ public ProtocolDecoder getDecoder() throws Exception
+ {
return new ProtocolDecoderImpl();
}
@@ -337,13 +340,13 @@
{
if( currentDecoder == null )
{
- return;
+ return;
}
currentDecoder.finishDecode( session, out );
- }
+ }
- public void dispose( IoSession session ) throws Exception
+ public void dispose( IoSession session ) throws Exception
{
super.dispose( session );
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/textline/TextLineDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/textline/TextLineDecoder.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/textline/TextLineDecoder.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/textline/TextLineDecoder.java Sun Sep 3 20:12:43 2006
@@ -138,14 +138,14 @@
}
private Context getContext(IoSession session) {
- Context ctx;
- ctx = ( Context ) session.getAttribute( CONTEXT );
+ Context ctx;
+ ctx = ( Context ) session.getAttribute( CONTEXT );
if( ctx == null )
{
ctx = new Context();
session.setAttribute( CONTEXT, ctx );
}
- return ctx;
+ return ctx;
}
public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java Sun Sep 3 20:12:43 2006
@@ -46,8 +46,8 @@
*/
public class ThreadPoolFilter extends IoFilterAdapter
{
- private static final Logger logger = LoggerFactory.getLogger( ThreadPoolFilter.class.getName() );
- private final ThreadPool threadPool;
+ private static final Logger logger = LoggerFactory.getLogger( ThreadPoolFilter.class.getName() );
+ private final ThreadPool threadPool;
/**
* Creates a new instace with the default thread pool implementation
@@ -61,25 +61,25 @@
/**
* Creates a new instance with the specified <tt>threadPool</tt>.
*/
- public ThreadPoolFilter( ThreadPool threadPool )
- {
+ public ThreadPoolFilter( ThreadPool threadPool )
+ {
if( threadPool == null )
{
throw new NullPointerException( "threadPool" );
}
- this.threadPool = threadPool;
- }
+ this.threadPool = threadPool;
+ }
- public void init()
- {
- threadPool.init();
- }
-
- public void destroy()
- {
- threadPool.destroy();
- }
+ public void init()
+ {
+ threadPool.init();
+ }
+
+ public void destroy()
+ {
+ threadPool.destroy();
+ }
public void onPreAdd( IoFilterChain parent, String name, NextFilter nextFilter )
throws Exception
@@ -98,230 +98,230 @@
return threadPool;
}
- private void fireEvent( NextFilter nextFilter, IoSession session,
- EventType type, Object data )
- {
- Event event = new Event( type, nextFilter, data );
- SessionBuffer buf = SessionBuffer.getSessionBuffer( session );
-
- synchronized( buf.eventQueue )
- {
- buf.eventQueue.add( event );
- if( buf.processingCompleted )
- {
- buf.processingCompleted = false;
- if ( logger.isDebugEnabled() ) {
- logger.debug( "Launching thread for " + session.getRemoteAddress() );
- }
+ private void fireEvent( NextFilter nextFilter, IoSession session,
+ EventType type, Object data )
+ {
+ Event event = new Event( type, nextFilter, data );
+ SessionBuffer buf = SessionBuffer.getSessionBuffer( session );
+
+ synchronized( buf.eventQueue )
+ {
+ buf.eventQueue.add( event );
+ if( buf.processingCompleted )
+ {
+ buf.processingCompleted = false;
+ if ( logger.isDebugEnabled() ) {
+ logger.debug( "Launching thread for " + session.getRemoteAddress() );
+ }
threadPool.submit( new ProcessEventsRunnable( buf ) );
- }
- }
- }
-
- private static class SessionBuffer
- {
- private static final String KEY = SessionBuffer.class.getName() + ".KEY";
-
- private static SessionBuffer getSessionBuffer( IoSession session )
- {
- synchronized( session )
- {
- SessionBuffer buf = (SessionBuffer)session.getAttribute( KEY );
- if( buf == null )
- {
- buf = new SessionBuffer( session );
- session.setAttribute( KEY, buf );
- }
- return buf;
- }
- }
-
- private final IoSession session;
- private final List eventQueue = new ArrayList();
- private boolean processingCompleted = true;
-
- private SessionBuffer( IoSession session )
- {
- this.session = session;
- }
- }
-
- protected static class EventType
- {
- public static final EventType OPENED = new EventType( "OPENED" );
-
- public static final EventType CLOSED = new EventType( "CLOSED" );
-
- public static final EventType READ = new EventType( "READ" );
-
- public static final EventType WRITTEN = new EventType( "WRITTEN" );
-
- public static final EventType RECEIVED = new EventType( "RECEIVED" );
-
- public static final EventType SENT = new EventType( "SENT" );
-
- public static final EventType IDLE = new EventType( "IDLE" );
-
- public static final EventType EXCEPTION = new EventType( "EXCEPTION" );
-
- private final String value;
-
- private EventType( String value )
- {
- this.value = value;
- }
-
- public String toString()
- {
- return value;
- }
- }
-
- protected static class Event
- {
- private final EventType type;
- private final NextFilter nextFilter;
- private final Object data;
-
- Event( EventType type, NextFilter nextFilter, Object data )
- {
- this.type = type;
- this.nextFilter = nextFilter;
- this.data = data;
- }
-
- public Object getData()
- {
- return data;
- }
-
- public NextFilter getNextFilter()
- {
- return nextFilter;
- }
-
- public EventType getType()
- {
- return type;
- }
- }
-
- public void sessionCreated( NextFilter nextFilter, IoSession session )
- {
- nextFilter.sessionCreated( session );
- }
-
- public void sessionOpened( NextFilter nextFilter,
- IoSession session )
- {
- fireEvent( nextFilter, session, EventType.OPENED, null );
- }
-
- public void sessionClosed( NextFilter nextFilter,
- IoSession session )
- {
- fireEvent( nextFilter, session, EventType.CLOSED, null );
- }
-
- public void sessionIdle( NextFilter nextFilter,
- IoSession session, IdleStatus status )
- {
- fireEvent( nextFilter, session, EventType.IDLE, status );
- }
-
- public void exceptionCaught( NextFilter nextFilter,
- IoSession session, Throwable cause )
- {
- fireEvent( nextFilter, session, EventType.EXCEPTION, cause );
- }
-
- public void messageReceived( NextFilter nextFilter,
- IoSession session, Object message )
- {
- ByteBufferUtil.acquireIfPossible( message );
- fireEvent( nextFilter, session, EventType.RECEIVED, message );
- }
-
- public void messageSent( NextFilter nextFilter,
- IoSession session, Object message )
- {
- ByteBufferUtil.acquireIfPossible( message );
- fireEvent( nextFilter, session, EventType.SENT, message );
- }
-
- protected void processEvent( NextFilter nextFilter, IoSession session, EventType type, Object data )
- {
- if( type == EventType.RECEIVED )
- {
- nextFilter.messageReceived( session, data );
- ByteBufferUtil.releaseIfPossible( data );
- }
- else if( type == EventType.SENT )
- {
- nextFilter.messageSent( session, data );
- ByteBufferUtil.releaseIfPossible( data );
- }
- else if( type == EventType.EXCEPTION )
- {
- nextFilter.exceptionCaught( session, (Throwable)data );
- }
- else if( type == EventType.IDLE )
- {
- nextFilter.sessionIdle( session, (IdleStatus)data );
- }
- else if( type == EventType.OPENED )
- {
- nextFilter.sessionOpened( session );
- }
- else if( type == EventType.CLOSED )
- {
- nextFilter.sessionClosed( session );
- }
- }
-
- public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest )
- {
- nextFilter.filterWrite( session, writeRequest );
- }
-
- public void filterClose( NextFilter nextFilter, IoSession session ) throws Exception
- {
- nextFilter.filterClose( session );
- }
-
- private class ProcessEventsRunnable implements Runnable
- {
- private final SessionBuffer buffer;
-
- ProcessEventsRunnable( SessionBuffer buffer )
- {
- this.buffer = buffer;
- }
-
- public void run()
- {
- while( true )
- {
- Event event;
-
- synchronized( buffer.eventQueue )
- {
- if( buffer.eventQueue.isEmpty() )
- {
- buffer.processingCompleted = true;
- break;
- }
-
- event = ( Event ) buffer.eventQueue.remove( 0 );
- }
-
- processEvent( event.getNextFilter(), buffer.session, event.getType(), event.getData() );
- }
-
- if ( logger.isDebugEnabled() ) {
- logger.debug( "Exiting since queue is empty for " + buffer.session.getRemoteAddress() );
- }
- }
- }
+ }
+ }
+ }
+
+ private static class SessionBuffer
+ {
+ private static final String KEY = SessionBuffer.class.getName() + ".KEY";
+
+ private static SessionBuffer getSessionBuffer( IoSession session )
+ {
+ synchronized( session )
+ {
+ SessionBuffer buf = (SessionBuffer)session.getAttribute( KEY );
+ if( buf == null )
+ {
+ buf = new SessionBuffer( session );
+ session.setAttribute( KEY, buf );
+ }
+ return buf;
+ }
+ }
+
+ private final IoSession session;
+ private final List eventQueue = new ArrayList();
+ private boolean processingCompleted = true;
+
+ private SessionBuffer( IoSession session )
+ {
+ this.session = session;
+ }
+ }
+
+ protected static class EventType
+ {
+ public static final EventType OPENED = new EventType( "OPENED" );
+
+ public static final EventType CLOSED = new EventType( "CLOSED" );
+
+ public static final EventType READ = new EventType( "READ" );
+
+ public static final EventType WRITTEN = new EventType( "WRITTEN" );
+
+ public static final EventType RECEIVED = new EventType( "RECEIVED" );
+
+ public static final EventType SENT = new EventType( "SENT" );
+
+ public static final EventType IDLE = new EventType( "IDLE" );
+
+ public static final EventType EXCEPTION = new EventType( "EXCEPTION" );
+
+ private final String value;
+
+ private EventType( String value )
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+ }
+
+ protected static class Event
+ {
+ private final EventType type;
+ private final NextFilter nextFilter;
+ private final Object data;
+
+ Event( EventType type, NextFilter nextFilter, Object data )
+ {
+ this.type = type;
+ this.nextFilter = nextFilter;
+ this.data = data;
+ }
+
+ public Object getData()
+ {
+ return data;
+ }
+
+ public NextFilter getNextFilter()
+ {
+ return nextFilter;
+ }
+
+ public EventType getType()
+ {
+ return type;
+ }
+ }
+
+ public void sessionCreated( NextFilter nextFilter, IoSession session )
+ {
+ nextFilter.sessionCreated( session );
+ }
+
+ public void sessionOpened( NextFilter nextFilter,
+ IoSession session )
+ {
+ fireEvent( nextFilter, session, EventType.OPENED, null );
+ }
+
+ public void sessionClosed( NextFilter nextFilter,
+ IoSession session )
+ {
+ fireEvent( nextFilter, session, EventType.CLOSED, null );
+ }
+
+ public void sessionIdle( NextFilter nextFilter,
+ IoSession session, IdleStatus status )
+ {
+ fireEvent( nextFilter, session, EventType.IDLE, status );
+ }
+
+ public void exceptionCaught( NextFilter nextFilter,
+ IoSession session, Throwable cause )
+ {
+ fireEvent( nextFilter, session, EventType.EXCEPTION, cause );
+ }
+
+ public void messageReceived( NextFilter nextFilter,
+ IoSession session, Object message )
+ {
+ ByteBufferUtil.acquireIfPossible( message );
+ fireEvent( nextFilter, session, EventType.RECEIVED, message );
+ }
+
+ public void messageSent( NextFilter nextFilter,
+ IoSession session, Object message )
+ {
+ ByteBufferUtil.acquireIfPossible( message );
+ fireEvent( nextFilter, session, EventType.SENT, message );
+ }
+
+ protected void processEvent( NextFilter nextFilter, IoSession session, EventType type, Object data )
+ {
+ if( type == EventType.RECEIVED )
+ {
+ nextFilter.messageReceived( session, data );
+ ByteBufferUtil.releaseIfPossible( data );
+ }
+ else if( type == EventType.SENT )
+ {
+ nextFilter.messageSent( session, data );
+ ByteBufferUtil.releaseIfPossible( data );
+ }
+ else if( type == EventType.EXCEPTION )
+ {
+ nextFilter.exceptionCaught( session, (Throwable)data );
+ }
+ else if( type == EventType.IDLE )
+ {
+ nextFilter.sessionIdle( session, (IdleStatus)data );
+ }
+ else if( type == EventType.OPENED )
+ {
+ nextFilter.sessionOpened( session );
+ }
+ else if( type == EventType.CLOSED )
+ {
+ nextFilter.sessionClosed( session );
+ }
+ }
+
+ public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest )
+ {
+ nextFilter.filterWrite( session, writeRequest );
+ }
+
+ public void filterClose( NextFilter nextFilter, IoSession session ) throws Exception
+ {
+ nextFilter.filterClose( session );
+ }
+
+ private class ProcessEventsRunnable implements Runnable
+ {
+ private final SessionBuffer buffer;
+
+ ProcessEventsRunnable( SessionBuffer buffer )
+ {
+ this.buffer = buffer;
+ }
+
+ public void run()
+ {
+ while( true )
+ {
+ Event event;
+
+ synchronized( buffer.eventQueue )
+ {
+ if( buffer.eventQueue.isEmpty() )
+ {
+ buffer.processingCompleted = true;
+ break;
+ }
+
+ event = ( Event ) buffer.eventQueue.remove( 0 );
+ }
+
+ processEvent( event.getNextFilter(), buffer.session, event.getType(), event.getData() );
+ }
+
+ if ( logger.isDebugEnabled() ) {
+ logger.debug( "Exiting since queue is empty for " + buffer.session.getRemoteAddress() );
+ }
+ }
+ }
}
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerFactory.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerFactory.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerFactory.java Sun Sep 3 20:12:43 2006
@@ -31,11 +31,11 @@
* @version $Rev$, $Date$
*/
public interface SingleSessionIoHandlerFactory {
-
- /**
- * Returns a {@link SingleSessionIoHandler} for the given session.
- *
- * @param session the session for which a handler is requested
- */
- SingleSessionIoHandler getHandler(IoSession session);
+
+ /**
+ * Returns a {@link SingleSessionIoHandler} for the given session.
+ *
+ * @param session the session for which a handler is requested
+ */
+ SingleSessionIoHandler getHandler(IoSession session);
}
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionConfigImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionConfigImpl.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionConfigImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionConfigImpl.java Sun Sep 3 20:12:43 2006
@@ -35,12 +35,12 @@
*/
public class SocketSessionConfigImpl extends BaseIoSessionConfig implements SocketSessionConfig
{
- private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
- private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;
- private static boolean GET_TRAFFIC_CLASS_AVAILABLE = false;
- private static boolean SET_TRAFFIC_CLASS_AVAILABLE = false;
+ private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
+ private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;
+ private static boolean GET_TRAFFIC_CLASS_AVAILABLE = false;
+ private static boolean SET_TRAFFIC_CLASS_AVAILABLE = false;
- private static boolean DEFAULT_REUSE_ADDRESS;
+ private static boolean DEFAULT_REUSE_ADDRESS;
private static int DEFAULT_RECEIVE_BUFFER_SIZE;
private static int DEFAULT_SEND_BUFFER_SIZE;
private static int DEFAULT_TRAFFIC_CLASS;
@@ -51,95 +51,95 @@
static
{
- initialize();
+ initialize();
}
private static void initialize()
{
- Socket socket = null;
-
- socket = new Socket();
+ Socket socket = null;
+
+ socket = new Socket();
- try
- {
- DEFAULT_REUSE_ADDRESS = socket.getReuseAddress();
- DEFAULT_RECEIVE_BUFFER_SIZE = socket.getReceiveBufferSize();
- DEFAULT_SEND_BUFFER_SIZE = socket.getSendBufferSize();
- DEFAULT_KEEP_ALIVE = socket.getKeepAlive();
- DEFAULT_OOB_INLINE = socket.getOOBInline();
- DEFAULT_SO_LINGER = socket.getSoLinger();
- DEFAULT_TCP_NO_DELAY = socket.getTcpNoDelay();
-
- // Check if setReceiveBufferSize is supported.
- try
- {
- socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
- SET_RECEIVE_BUFFER_SIZE_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
- }
-
- // Check if setSendBufferSize is supported.
- try
- {
- socket.setSendBufferSize(DEFAULT_SEND_BUFFER_SIZE);
- SET_SEND_BUFFER_SIZE_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- SET_SEND_BUFFER_SIZE_AVAILABLE = false;
- }
+ try
+ {
+ DEFAULT_REUSE_ADDRESS = socket.getReuseAddress();
+ DEFAULT_RECEIVE_BUFFER_SIZE = socket.getReceiveBufferSize();
+ DEFAULT_SEND_BUFFER_SIZE = socket.getSendBufferSize();
+ DEFAULT_KEEP_ALIVE = socket.getKeepAlive();
+ DEFAULT_OOB_INLINE = socket.getOOBInline();
+ DEFAULT_SO_LINGER = socket.getSoLinger();
+ DEFAULT_TCP_NO_DELAY = socket.getTcpNoDelay();
+
+ // Check if setReceiveBufferSize is supported.
+ try
+ {
+ socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
+ SET_RECEIVE_BUFFER_SIZE_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
+ }
+
+ // Check if setSendBufferSize is supported.
+ try
+ {
+ socket.setSendBufferSize(DEFAULT_SEND_BUFFER_SIZE);
+ SET_SEND_BUFFER_SIZE_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ SET_SEND_BUFFER_SIZE_AVAILABLE = false;
+ }
- // Check if getTrafficClass is supported.
- try
- {
- DEFAULT_TRAFFIC_CLASS = socket.getTrafficClass();
- GET_TRAFFIC_CLASS_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- GET_TRAFFIC_CLASS_AVAILABLE = false;
- DEFAULT_TRAFFIC_CLASS = 0;
- }
- }
+ // Check if getTrafficClass is supported.
+ try
+ {
+ DEFAULT_TRAFFIC_CLASS = socket.getTrafficClass();
+ GET_TRAFFIC_CLASS_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ GET_TRAFFIC_CLASS_AVAILABLE = false;
+ DEFAULT_TRAFFIC_CLASS = 0;
+ }
+ }
catch( SocketException e )
{
- throw new ExceptionInInitializerError(e);
- }
- finally
+ throw new ExceptionInInitializerError(e);
+ }
+ finally
{
- if( socket != null )
- {
- try
- {
- socket.close();
- }
- catch( IOException e )
- {
- ExceptionMonitor.getInstance().exceptionCaught(e);
- }
- }
- }
+ if( socket != null )
+ {
+ try
+ {
+ socket.close();
+ }
+ catch( IOException e )
+ {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
+ }
+ }
+ }
}
public static boolean isSetReceiveBufferSizeAvailable() {
- return SET_RECEIVE_BUFFER_SIZE_AVAILABLE;
+ return SET_RECEIVE_BUFFER_SIZE_AVAILABLE;
}
-
+
public static boolean isSetSendBufferSizeAvailable() {
- return SET_SEND_BUFFER_SIZE_AVAILABLE;
+ return SET_SEND_BUFFER_SIZE_AVAILABLE;
}
-
+
public static boolean isGetTrafficClassAvailable() {
- return GET_TRAFFIC_CLASS_AVAILABLE;
+ return GET_TRAFFIC_CLASS_AVAILABLE;
}
-
+
public static boolean isSetTrafficClassAvailable() {
- return SET_TRAFFIC_CLASS_AVAILABLE;
+ return SET_TRAFFIC_CLASS_AVAILABLE;
}
-
+
private boolean reuseAddress = DEFAULT_REUSE_ADDRESS;
private int receiveBufferSize = DEFAULT_RECEIVE_BUFFER_SIZE;
private int sendBufferSize = DEFAULT_SEND_BUFFER_SIZE;
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java Sun Sep 3 20:12:43 2006
@@ -32,92 +32,92 @@
*/
public class DatagramSessionConfigImpl extends BaseIoSessionConfig implements DatagramSessionConfig
{
- private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
- private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;
- private static boolean GET_TRAFFIC_CLASS_AVAILABLE = false;
- private static boolean SET_TRAFFIC_CLASS_AVAILABLE = false;
+ private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
+ private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;
+ private static boolean GET_TRAFFIC_CLASS_AVAILABLE = false;
+ private static boolean SET_TRAFFIC_CLASS_AVAILABLE = false;
- private static boolean DEFAULT_BROADCAST;
- private static boolean DEFAULT_REUSE_ADDRESS;
+ private static boolean DEFAULT_BROADCAST;
+ private static boolean DEFAULT_REUSE_ADDRESS;
private static int DEFAULT_RECEIVE_BUFFER_SIZE;
private static int DEFAULT_SEND_BUFFER_SIZE;
private static int DEFAULT_TRAFFIC_CLASS;
static
{
- initialize();
+ initialize();
}
private static void initialize()
{
- DatagramSocket socket = null;
+ DatagramSocket socket = null;
- try
- {
- socket = new DatagramSocket();
- DEFAULT_BROADCAST = socket.getBroadcast();
- DEFAULT_REUSE_ADDRESS = socket.getReuseAddress();
- DEFAULT_RECEIVE_BUFFER_SIZE = socket.getReceiveBufferSize();
- DEFAULT_SEND_BUFFER_SIZE = socket.getSendBufferSize();
-
- // Check if setReceiveBufferSize is supported.
- try
- {
- socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
- SET_RECEIVE_BUFFER_SIZE_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
- }
-
- // Check if setSendBufferSize is supported.
- try
- {
- socket.setSendBufferSize(DEFAULT_SEND_BUFFER_SIZE);
- SET_SEND_BUFFER_SIZE_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- SET_SEND_BUFFER_SIZE_AVAILABLE = false;
- }
-
- // Check if getTrafficClass is supported.
- try
- {
- DEFAULT_TRAFFIC_CLASS = socket.getTrafficClass();
- GET_TRAFFIC_CLASS_AVAILABLE = true;
- }
- catch( SocketException e )
- {
- GET_TRAFFIC_CLASS_AVAILABLE = false;
- DEFAULT_TRAFFIC_CLASS = 0;
- }
- } catch (SocketException e) {
- throw new ExceptionInInitializerError(e);
- }
- finally {
- if( socket != null )
- {
- socket.close();
- }
- }
+ try
+ {
+ socket = new DatagramSocket();
+ DEFAULT_BROADCAST = socket.getBroadcast();
+ DEFAULT_REUSE_ADDRESS = socket.getReuseAddress();
+ DEFAULT_RECEIVE_BUFFER_SIZE = socket.getReceiveBufferSize();
+ DEFAULT_SEND_BUFFER_SIZE = socket.getSendBufferSize();
+
+ // Check if setReceiveBufferSize is supported.
+ try
+ {
+ socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
+ SET_RECEIVE_BUFFER_SIZE_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
+ }
+
+ // Check if setSendBufferSize is supported.
+ try
+ {
+ socket.setSendBufferSize(DEFAULT_SEND_BUFFER_SIZE);
+ SET_SEND_BUFFER_SIZE_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ SET_SEND_BUFFER_SIZE_AVAILABLE = false;
+ }
+
+ // Check if getTrafficClass is supported.
+ try
+ {
+ DEFAULT_TRAFFIC_CLASS = socket.getTrafficClass();
+ GET_TRAFFIC_CLASS_AVAILABLE = true;
+ }
+ catch( SocketException e )
+ {
+ GET_TRAFFIC_CLASS_AVAILABLE = false;
+ DEFAULT_TRAFFIC_CLASS = 0;
+ }
+ } catch (SocketException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ finally {
+ if( socket != null )
+ {
+ socket.close();
+ }
+ }
}
public static boolean isSetReceiveBufferSizeAvailable() {
- return SET_RECEIVE_BUFFER_SIZE_AVAILABLE;
+ return SET_RECEIVE_BUFFER_SIZE_AVAILABLE;
}
-
+
public static boolean isSetSendBufferSizeAvailable() {
- return SET_SEND_BUFFER_SIZE_AVAILABLE;
+ return SET_SEND_BUFFER_SIZE_AVAILABLE;
}
-
+
public static boolean isGetTrafficClassAvailable() {
- return GET_TRAFFIC_CLASS_AVAILABLE;
+ return GET_TRAFFIC_CLASS_AVAILABLE;
}
-
+
public static boolean isSetTrafficClassAvailable() {
- return SET_TRAFFIC_CLASS_AVAILABLE;
+ return SET_TRAFFIC_CLASS_AVAILABLE;
}
private boolean broadcast = DEFAULT_BROADCAST;
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java Sun Sep 3 20:12:43 2006
@@ -228,18 +228,18 @@
public void setReceiveBufferSize( int receiveBufferSize )
{
- if( DatagramSessionConfigImpl.isSetReceiveBufferSizeAvailable() )
- {
- try
- {
- ch.socket().setReceiveBufferSize( receiveBufferSize );
- DatagramSessionImpl.this.readBufferSize = receiveBufferSize;
- }
- catch( SocketException e )
- {
- throw new RuntimeIOException( e );
- }
- }
+ if( DatagramSessionConfigImpl.isSetReceiveBufferSizeAvailable() )
+ {
+ try
+ {
+ ch.socket().setReceiveBufferSize( receiveBufferSize );
+ DatagramSessionImpl.this.readBufferSize = receiveBufferSize;
+ }
+ catch( SocketException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+ }
}
public boolean isBroadcast()
@@ -280,17 +280,17 @@
public void setSendBufferSize( int sendBufferSize )
{
- if( DatagramSessionConfigImpl.isSetSendBufferSizeAvailable() )
- {
- try
- {
- ch.socket().setSendBufferSize( sendBufferSize );
- }
- catch( SocketException e )
- {
- throw new RuntimeIOException( e );
- }
- }
+ if( DatagramSessionConfigImpl.isSetSendBufferSizeAvailable() )
+ {
+ try
+ {
+ ch.socket().setSendBufferSize( sendBufferSize );
+ }
+ catch( SocketException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+ }
}
public boolean isReuseAddress()
@@ -319,36 +319,36 @@
public int getTrafficClass()
{
- if( DatagramSessionConfigImpl.isGetTrafficClassAvailable() )
- {
- try
- {
- return ch.socket().getTrafficClass();
- }
- catch( SocketException e )
- {
- throw new RuntimeIOException( e );
- }
- }
- else
- {
- return 0;
- }
+ if( DatagramSessionConfigImpl.isGetTrafficClassAvailable() )
+ {
+ try
+ {
+ return ch.socket().getTrafficClass();
+ }
+ catch( SocketException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+ }
+ else
+ {
+ return 0;
+ }
}
public void setTrafficClass( int trafficClass )
{
- if( DatagramSessionConfigImpl.isSetTrafficClassAvailable() )
- {
- try
- {
- ch.socket().setTrafficClass( trafficClass );
- }
- catch( SocketException e )
- {
- throw new RuntimeIOException( e );
- }
- }
+ if( DatagramSessionConfigImpl.isSetTrafficClassAvailable() )
+ {
+ try
+ {
+ ch.socket().setTrafficClass( trafficClass );
+ }
+ catch( SocketException e )
+ {
+ throw new RuntimeIOException( e );
+ }
+ }
}
}
}
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/util/AnonymousSocketAddress.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/util/AnonymousSocketAddress.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/util/AnonymousSocketAddress.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/util/AnonymousSocketAddress.java Sun Sep 3 20:12:43 2006
@@ -45,7 +45,7 @@
public boolean equals( Object o )
{
- return this == o;
+ return this == o;
}
public int compareTo( Object o )
Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java Sun Sep 3 20:12:43 2006
@@ -156,22 +156,22 @@
public void testAutoExpandMark() throws Exception
{
- ByteBuffer buf = ByteBuffer.allocate( 4 ).setAutoExpand( true );
+ ByteBuffer buf = ByteBuffer.allocate( 4 ).setAutoExpand( true );
- buf.put( ( byte ) 0 );
- buf.put( ( byte ) 0 );
- buf.put( ( byte ) 0 );
+ buf.put( ( byte ) 0 );
+ buf.put( ( byte ) 0 );
+ buf.put( ( byte ) 0 );
- // Position should be 3 when we reset this buffer.
- buf.mark();
+ // Position should be 3 when we reset this buffer.
+ buf.mark();
- // Overflow it
- buf.put( ( byte ) 0 );
- buf.put( ( byte ) 0 );
-
- Assert.assertEquals( 5, buf.position() );
- buf.reset();
- Assert.assertEquals( 3, buf.position() );
+ // Overflow it
+ buf.put( ( byte ) 0 );
+ buf.put( ( byte ) 0 );
+
+ Assert.assertEquals( 5, buf.position() );
+ buf.reset();
+ Assert.assertEquals( 3, buf.position() );
}
public void testPooledProperty() throws Exception
Modified: directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/ssl/BogusSSLContextFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/ssl/BogusSSLContextFactory.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/ssl/BogusSSLContextFactory.java (original)
+++ directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/echoserver/ssl/BogusSSLContextFactory.java Sun Sep 3 20:12:43 2006
@@ -45,13 +45,13 @@
private static final String KEY_MANAGER_FACTORY_ALGORITHM;
static {
- String algorithm = Security.getProperty( "ssl.KeyManagerFactory.algorithm" );
- if( algorithm == null )
- {
- algorithm = "SunX509";
- }
-
- KEY_MANAGER_FACTORY_ALGORITHM = algorithm;
+ String algorithm = Security.getProperty( "ssl.KeyManagerFactory.algorithm" );
+ if( algorithm == null )
+ {
+ algorithm = "SunX509";
+ }
+
+ KEY_MANAGER_FACTORY_ALGORITHM = algorithm;
}
/**
Modified: directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyCodecFactory.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyCodecFactory.java (original)
+++ directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyCodecFactory.java Sun Sep 3 20:12:43 2006
@@ -22,6 +22,8 @@
import net.gleamynode.netty2.Message;
import net.gleamynode.netty2.MessageRecognizer;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+
/**
* A MINA <tt>ProtocolCodecFactory</tt> that provides encoder and decoder
* for Netty2 {@link Message}s and {@link MessageRecognizer}s.
@@ -33,22 +35,25 @@
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$,
*/
-public class NettyCodecFactory implements org.apache.mina.filter.codec.ProtocolCodecFactory {
-
+public class NettyCodecFactory implements ProtocolCodecFactory
+{
private static final NettyEncoder ENCODER = new NettyEncoder();
private final MessageRecognizer recognizer;
- public NettyCodecFactory(MessageRecognizer recognizer) {
+ public NettyCodecFactory(MessageRecognizer recognizer)
+ {
this.recognizer = recognizer;
}
- public org.apache.mina.filter.codec.ProtocolEncoder getEncoder() {
- return ENCODER;
- }
+ public org.apache.mina.filter.codec.ProtocolEncoder getEncoder()
+ {
+ return ENCODER;
+ }
- public org.apache.mina.filter.codec.ProtocolDecoder getDecoder() {
- return new NettyDecoder(recognizer);
- }
+ public org.apache.mina.filter.codec.ProtocolDecoder getDecoder()
+ {
+ return new NettyDecoder(recognizer);
+ }
}
Modified: directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyDecoder.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyDecoder.java (original)
+++ directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyDecoder.java Sun Sep 3 20:12:43 2006
@@ -105,15 +105,15 @@
{
if( m == null )
{
- readBuf.limit( readBuf.capacity() );
- readBuf.position( limit );
- break; // finish decoding
+ readBuf.limit( readBuf.capacity() );
+ readBuf.position( limit );
+ break; // finish decoding
}
else
{
- // reset buffer for read
- readBuf.limit( limit );
- readBuf.position( 0 );
+ // reset buffer for read
+ readBuf.limit( limit );
+ readBuf.position( 0 );
}
}
}
@@ -123,25 +123,25 @@
{
try
{
- if( m.read( readBuf ) )
- {
- out.write( m );
- m = null;
- } else {
- break;
- }
+ if( m.read( readBuf ) )
+ {
+ out.write( m );
+ m = null;
+ } else {
+ break;
+ }
}
finally
{
- if( readBuf.hasRemaining() )
- {
- readBuf.compact();
- }
- else
- {
- readBuf.clear();
- break;
- }
+ if( readBuf.hasRemaining() )
+ {
+ readBuf.compact();
+ }
+ else
+ {
+ readBuf.clear();
+ break;
+ }
}
}
}
@@ -154,6 +154,6 @@
finally
{
readingMessage = m;
- }
+ }
}
}
Modified: directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyEncoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyEncoder.java?view=diff&rev=439913&r1=439912&r2=439913
==============================================================================
--- directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyEncoder.java (original)
+++ directory/trunks/mina/filter-codec-netty/src/main/java/org/apache/mina/filter/codec/netty/NettyEncoder.java Sun Sep 3 20:12:43 2006
@@ -23,6 +23,7 @@
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderException;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
@@ -33,7 +34,7 @@
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$,
*/
-public class NettyEncoder implements org.apache.mina.filter.codec.ProtocolEncoder
+public class NettyEncoder implements ProtocolEncoder
{
/**
* Creates a new instance.
@@ -42,39 +43,41 @@
{
}
- public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
- if( ! ( message instanceof Message ) )
- {
- throw new ProtocolEncoderException("This encoder can decode only Netty Messages." );
- }
+ public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception
+ {
+ if( !( message instanceof Message ) )
+ {
+ throw new ProtocolEncoderException(
+ "This encoder can decode only Netty Messages." );
+ }
- for( ;; )
- {
- ByteBuffer buf = ByteBuffer.allocate( 8192 );
- Message m = ( Message ) message;
- try
- {
- if( m.write( buf.buf() ) )
- {
- break;
- }
- }
- finally
- {
- buf.flip();
- if( buf.hasRemaining() )
- {
- out.write( buf );
- }
- else
- {
- buf.release();
- }
- }
- }
- }
+ for( ;; )
+ {
+ ByteBuffer buf = ByteBuffer.allocate( 8192 );
+ Message m = ( Message ) message;
+ try
+ {
+ if( m.write( buf.buf() ) )
+ {
+ break;
+ }
+ }
+ finally
+ {
+ buf.flip();
+ if( buf.hasRemaining() )
+ {
+ out.write( buf );
+ }
+ else
+ {
+ buf.release();
+ }
+ }
+ }
+ }
- public void dispose(IoSession session) throws Exception {
-
- }
-}
\ No newline at end of file
+ public void dispose( IoSession session ) throws Exception
+ {
+ }
+}