>
> Oleksiy Stashok wrote:
>> Hi,
>> +1
>> (though I'd prefer http-utils'es package to be renamed to
>> com.sun.grizzly.http.utils, but we really have a lot of
>> dependencies on it)
>
> One alternative would consist of moving the grizzly/
> com.sun.grizzly.util classes under the http-util package, and add
> that small dependencies to the grizzly modules. This way no package
> change.
>
> In short:
>
> + move util from grizzly to http-util (we can eventually rename that
> module)
> + change the build order (first build http-util, then framework)
> + The maven bundle plugs in can filter the extra classes so the
> framework module stay small
>
> What do you think? That way no backward compatibility issues.
Ok, I agree. But for sure we have to rename http-utils in that case.
WBR,
Alexey.
>
>
> A+
>
> -- Jeanfrancois
>
>
>> Thanks.
>> WBR,
>> Alexey.
>> On Dec 19, 2008, at 5:51 , Jeanfrancois Arcand wrote:
>>> Hi,
>>>
>>> we currently have a split package that prevent us supporting OSGi
>>> properly (we know that for awhile, but thanks to Hubert, it very
>>> simple test case helped me isolating the issue).
>>>
>>> Mainly, module grizzly has:
>>>
>>> com.sun.grizzly.util
>>>
>>>
>>> module http-util has:
>>>
>>> com.sun.grizzly.util
>>>
>>> Since http-util is, IMO, more used that other, I would like to
>>> propose we rename the package in trunk/modules/grizzly to:
>>>
>>> com.sun.grizzly.misc
>>>
>>> (or any better name)
>>>
>>> With that changes, OSGi works like a charm. I'm attaching the diff.
>>>
>>> That will breaks backward compatibility, but I guess we don't have
>>> choice.
>>>
>>> A+
>>>
>>> -- Jeanfrancois
>>> Index: modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EchoStreamAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EchoStreamAlgorithm.java (revision 2047)
>>> +++ modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EchoStreamAlgorithm.java (working copy)
>>> @@ -40,8 +40,8 @@
>>>
>>> import com.sun.grizzly.http.SelectorThread;
>>> import com.sun.grizzly.standalone.StaticStreamAlgorithm;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.util.logging.Level;
>>> Index: modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EmptyHttpStreamAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EmptyHttpStreamAlgorithm.java (revision 2047)
>>> +++ modules/http/src/test/java/com/sun/grizzly/http/utils/
>>> EmptyHttpStreamAlgorithm.java (working copy)
>>> @@ -40,8 +40,8 @@
>>>
>>> import com.sun.grizzly.http.SelectorThread;
>>> import com.sun.grizzly.standalone.StaticStreamAlgorithm;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.util.concurrent.atomic.AtomicInteger;
>>> Index: modules/http/src/test/java/com/sun/grizzly/http/
>>> ArpSSLTest.java
>>> ===================================================================
>>> --- modules/http/src/test/java/com/sun/grizzly/http/
>>> ArpSSLTest.java (revision 2047)
>>> +++ modules/http/src/test/java/com/sun/grizzly/http/
>>> ArpSSLTest.java (working copy)
>>> @@ -48,7 +48,7 @@
>>> import com.sun.grizzly.tcp.OutputBuffer;
>>> import com.sun.grizzly.tcp.Request;
>>> import com.sun.grizzly.tcp.Response;
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> import com.sun.grizzly.util.buf.ByteChunk;
>>> import com.sun.grizzly.util.net.jsse.JSSEImplementation;
>>> import java.io.DataInputStream;
>>> Index: modules/http/src/test/java/com/sun/grizzly/http/
>>> SelectorThreadStatsTest.java
>>> ===================================================================
>>> --- modules/http/src/test/java/com/sun/grizzly/http/
>>> SelectorThreadStatsTest.java (revision 2047)
>>> +++ modules/http/src/test/java/com/sun/grizzly/http/
>>> SelectorThreadStatsTest.java (working copy)
>>> @@ -43,7 +43,7 @@
>>> import com.sun.grizzly.tcp.OutputBuffer;
>>> import com.sun.grizzly.tcp.Request;
>>> import com.sun.grizzly.tcp.Response;
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> import com.sun.grizzly.util.buf.ByteChunk;
>>> import java.io.BufferedReader;
>>> import java.io.DataInputStream;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpWorkerThread.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpWorkerThread.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpWorkerThread.java (working copy)
>>> @@ -38,10 +38,10 @@
>>>
>>> package com.sun.grizzly.http;
>>>
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.WorkerThreadImpl;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.WorkerThreadImpl;
>>>
>>> -import com.sun.grizzly.util.StreamAlgorithm;
>>> +import com.sun.grizzly.misc.StreamAlgorithm;
>>>
>>> /**
>>> * Specialized WorkerThread.
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> ProcessorTask.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> ProcessorTask.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> ProcessorTask.java (working copy)
>>> @@ -42,7 +42,7 @@
>>> import java.io.OutputStream;
>>> import java.net.Socket;
>>>
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>>
>>> /**
>>> * Process HTTP request.
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> FileCache.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> FileCache.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> FileCache.java (working copy)
>>> @@ -38,8 +38,8 @@
>>>
>>> package com.sun.grizzly.http;
>>>
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.WorkerThreadImpl;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.WorkerThreadImpl;
>>> import java.io.File;
>>> import java.io.FileInputStream;
>>> import java.io.IOException;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpProtocolChain.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpProtocolChain.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> HttpProtocolChain.java (working copy)
>>> @@ -40,7 +40,7 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.DefaultProtocolChain;
>>> import com.sun.grizzly.rcm.ResourceAllocationFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.nio.ByteBuffer;
>>>
>>> /**
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadHandler.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadHandler.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadHandler.java (working copy)
>>> @@ -38,7 +38,7 @@
>>> package com.sun.grizzly.http;
>>>
>>> import com.sun.grizzly.TCPSelectorHandler;
>>> -import com.sun.grizzly.util.Copyable;
>>> +import com.sun.grizzly.misc.Copyable;
>>> import java.io.IOException;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProcessorTask.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProcessorTask.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProcessorTask.java (working copy)
>>> @@ -84,10 +84,10 @@
>>> import com.sun.grizzly.tcp.http11.filters.VoidInputFilter;
>>> import com.sun.grizzly.tcp.http11.filters.VoidOutputFilter;
>>> import com.sun.grizzly.tcp.http11.filters.BufferedInputFilter;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.Interceptor;
>>>
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.util.buf.Ascii;
>>> import com.sun.grizzly.util.buf.ByteChunk;
>>> import com.sun.grizzly.util.buf.HexUtils;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThread.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThread.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThread.java (working copy)
>>> @@ -53,7 +53,7 @@
>>> import com.sun.grizzly.portunif.ProtocolFinder;
>>> import com.sun.grizzly.portunif.ProtocolHandler;
>>> import com.sun.grizzly.rcm.ResourceAllocationFilter;
>>> -import com.sun.grizzly.util.SelectorFactory;
>>> +import com.sun.grizzly.misc.SelectorFactory;
>>>
>>> import java.io.IOException;
>>> import java.net.InetAddress;
>>> @@ -70,7 +70,7 @@
>>> import com.sun.grizzly.tcp.Adapter;
>>> import com.sun.grizzly.tcp.RequestGroupInfo;
>>> import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> import com.sun.grizzly.util.IntrospectionUtils;
>>>
>>> import com.sun.grizzly.util.LoggerUtils;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProtocolFilter.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProtocolFilter.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> DefaultProtocolFilter.java (working copy)
>>> @@ -43,9 +43,9 @@
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.http.algorithms.NoParsingAlgorithm;
>>> import com.sun.grizzly.rcm.ResourceAllocationFilter;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.Interceptor;
>>> -import com.sun.grizzly.util.StreamAlgorithm;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> +import com.sun.grizzly.misc.StreamAlgorithm;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadKeyHandler.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadKeyHandler.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadKeyHandler.java (working copy)
>>> @@ -41,9 +41,9 @@
>>> import com.sun.grizzly.DefaultSelectionKeyHandler;
>>> import com.sun.grizzly.tcp.Response;
>>> import com.sun.grizzly.tcp.Response.ResponseAttachment;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> import java.nio.channels.SelectionKey;
>>> import java.util.Iterator;
>>> import java.util.concurrent.ConcurrentLinkedQueue;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> StatsThreadPool.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> StatsThreadPool.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> StatsThreadPool.java (working copy)
>>> @@ -37,7 +37,7 @@
>>> */
>>> package com.sun.grizzly.http;
>>>
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> import java.util.concurrent.ThreadFactory;
>>> import java.util.concurrent.TimeUnit;
>>>
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpProtocolHandler.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpProtocolHandler.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpProtocolHandler.java (working copy)
>>> @@ -41,7 +41,7 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.portunif.PUProtocolRequest;
>>> import com.sun.grizzly.portunif.ProtocolHandler;
>>> -import com.sun.grizzly.util.Utils;
>>> +import com.sun.grizzly.misc.Utils;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpRedirector.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpRedirector.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/portunif/
>>> HttpRedirector.java (working copy)
>>> @@ -41,8 +41,8 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.portunif.PUProtocolRequest;
>>> import com.sun.grizzly.ssl.SSLSelectorThread;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import com.sun.grizzly.util.buf.Ascii;
>>> import java.io.IOException;
>>> import java.net.InetAddress;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> ContentLengthAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> ContentLengthAlgorithm.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> ContentLengthAlgorithm.java (working copy)
>>> @@ -54,7 +54,7 @@
>>> package com.sun.grizzly.http.algorithms;
>>>
>>> import com.sun.grizzly.http.Constants;
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.http.SelectorThread;
>>>
>>> import java.nio.ByteBuffer;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> NoParsingAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> NoParsingAlgorithm.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> NoParsingAlgorithm.java (working copy)
>>> @@ -38,7 +38,7 @@
>>>
>>> package com.sun.grizzly.http.algorithms;
>>>
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import java.nio.ByteBuffer;
>>>
>>>
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StateMachineAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StateMachineAlgorithm.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StateMachineAlgorithm.java (working copy)
>>> @@ -37,7 +37,7 @@
>>> */
>>> package com.sun.grizzly.http.algorithms;
>>>
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.http.SelectorThread;
>>>
>>> import java.nio.ByteBuffer;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StreamAlgorithmBase.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StreamAlgorithmBase.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/algorithms/
>>> StreamAlgorithmBase.java (working copy)
>>> @@ -38,9 +38,9 @@
>>>
>>> package com.sun.grizzly.http.algorithms;
>>>
>>> -import com.sun.grizzly.util.Interceptor;
>>> -import com.sun.grizzly.util.StreamAlgorithm;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> +import com.sun.grizzly.misc.StreamAlgorithm;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> import java.io.IOException;
>>>
>>> import java.nio.ByteBuffer;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> ThreadPoolStatistic.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> ThreadPoolStatistic.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> ThreadPoolStatistic.java (working copy)
>>> @@ -38,8 +38,8 @@
>>>
>>> package com.sun.grizzly.http;
>>>
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> -import com.sun.grizzly.util.WorkerThreadImpl;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.WorkerThreadImpl;
>>> import java.util.concurrent.ConcurrentHashMap;
>>> import java.util.concurrent.ExecutorService;
>>> import java.util.concurrent.Future;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> SocketChannelOutputBuffer.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> SocketChannelOutputBuffer.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> SocketChannelOutputBuffer.java (working copy)
>>> @@ -48,10 +48,10 @@
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.FileChannel;
>>> import java.nio.channels.SocketChannel;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> import com.sun.grizzly.tcp.Response;
>>> import com.sun.grizzly.tcp.http11.InternalOutputBuffer;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> import java.nio.channels.Channel;
>>> import java.nio.channels.SelectionKey;
>>> import java.nio.channels.WritableByteChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/TaskBase.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> TaskBase.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> TaskBase.java (working copy)
>>> @@ -46,7 +46,7 @@
>>> import java.util.logging.Level;
>>>
>>> import com.sun.grizzly.tcp.RequestGroupInfo;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> import java.util.concurrent.ExecutorService;
>>>
>>> /**
>>> Index: modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadConfig.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadConfig.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/http/
>>> SelectorThreadConfig.java (working copy)
>>> @@ -39,10 +39,10 @@
>>>
>>> import com.sun.grizzly.arp.AsyncHandler;
>>> import com.sun.grizzly.util.ClassLoaderUtil;
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SelectorFactory;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SelectorFactory;
>>> import com.sun.grizzly.util.res.StringManager;
>>> import java.io.IOException;
>>> import java.util.StringTokenizer;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncProtocolFilter.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncProtocolFilter.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncProtocolFilter.java (working copy)
>>> @@ -42,9 +42,9 @@
>>> import com.sun.grizzly.arp.AsyncProtocolFilter;
>>> import com.sun.grizzly.http.HttpWorkerThread;
>>> import com.sun.grizzly.http.ProcessorTask;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.util.net.SSLImplementation;
>>> import com.sun.grizzly.util.net.SSLSupport;
>>> import java.io.InputStream;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLSelectorThreadHandler.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLSelectorThreadHandler.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLSelectorThreadHandler.java (working copy)
>>> @@ -40,8 +40,8 @@
>>> import com.sun.grizzly.SSLSelectorHandler;
>>> import com.sun.grizzly.http.SelectorThread;
>>> import java.nio.channels.SelectionKey;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyOP;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyOP;
>>> import java.nio.channels.ClosedChannelException;
>>>
>>> /**
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncOutputBuffer.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncOutputBuffer.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncOutputBuffer.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.http.SocketChannelOutputBuffer;
>>> import com.sun.grizzly.tcp.Response;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncStream.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncStream.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLAsyncStream.java (working copy)
>>> @@ -38,8 +38,8 @@
>>>
>>> package com.sun.grizzly.ssl;
>>>
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.SSLUtils;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.SSLUtils;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLOutputBuffer.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLOutputBuffer.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLOutputBuffer.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.http.SocketChannelOutputBuffer;
>>> import com.sun.grizzly.tcp.Response;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLFileCacheFactory.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLFileCacheFactory.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLFileCacheFactory.java (working copy)
>>> @@ -41,7 +41,7 @@
>>> import com.sun.grizzly.http.FileCache;
>>> import com.sun.grizzly.http.FileCacheFactory;
>>> import com.sun.grizzly.http.FileCache.FileCacheEntry;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLDefaultProtocolFilter.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLDefaultProtocolFilter.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/ssl/
>>> SSLDefaultProtocolFilter.java (working copy)
>>> @@ -41,7 +41,7 @@
>>> import com.sun.grizzly.http.DefaultProtocolFilter;
>>> import com.sun.grizzly.http.HttpWorkerThread;
>>> import com.sun.grizzly.http.ProcessorTask;
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.util.net.SSLImplementation;
>>> import com.sun.grizzly.util.net.SSLSupport;
>>>
>>> Index: modules/http/src/main/java/com/sun/grizzly/arp/
>>> AsyncProtocolFilter.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/arp/
>>> AsyncProtocolFilter.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/arp/
>>> AsyncProtocolFilter.java (working copy)
>>> @@ -44,13 +44,13 @@
>>> import com.sun.grizzly.http.HttpWorkerThread;
>>> import com.sun.grizzly.http.ProcessorTask;
>>> import com.sun.grizzly.http.SelectorThread;
>>> -import com.sun.grizzly.util.Interceptor;
>>> -import com.sun.grizzly.util.StreamAlgorithm;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> +import com.sun.grizzly.misc.StreamAlgorithm;
>>> import com.sun.grizzly.http.TaskEvent;
>>> import com.sun.grizzly.http.TaskListener;
>>> import com.sun.grizzly.http.algorithms.NoParsingAlgorithm;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> -import com.sun.grizzly.util.InputReader;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.InputReader;
>>> import java.io.IOException;
>>> import java.io.InputStream;
>>> import java.nio.ByteBuffer;
>>> Index: modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticHandler.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticHandler.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticHandler.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.http.Constants;
>>> import com.sun.grizzly.http.FileCacheFactory;
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.http.FileCache;
>>> import com.sun.grizzly.http.SelectorThread;
>>> import java.io.IOException;
>>> Index: modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticStreamAlgorithm.java
>>> ===================================================================
>>> --- modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticStreamAlgorithm.java (revision 2047)
>>> +++ modules/http/src/main/java/com/sun/grizzly/standalone/
>>> StaticStreamAlgorithm.java (working copy)
>>> @@ -38,7 +38,7 @@
>>>
>>> package com.sun.grizzly.standalone;
>>>
>>> -import com.sun.grizzly.util.Interceptor;
>>> +import com.sun.grizzly.misc.Interceptor;
>>> import com.sun.grizzly.http.algorithms.StreamAlgorithmBase;
>>> import java.nio.ByteBuffer;
>>>
>>> Index: modules/rcm/src/test/java/com/sun/grizzly/rcm/RCMTest.java
>>> ===================================================================
>>> --- modules/rcm/src/test/java/com/sun/grizzly/rcm/RCMTest.java
>>> (revision 2047)
>>> +++ modules/rcm/src/test/java/com/sun/grizzly/rcm/RCMTest.java
>>> (working copy)
>>> @@ -46,9 +46,9 @@
>>> import com.sun.grizzly.ProtocolChain;
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.TCPSelectorHandler;
>>> -import com.sun.grizzly.util.ByteBufferInputStream;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.ByteBufferInputStream;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.BufferedReader;
>>> import java.io.InputStream;
>>> import java.io.InputStreamReader;
>>> Index: modules/rcm/src/main/java/com/sun/grizzly/rcm/
>>> ResourceAllocationFilter.java
>>> ===================================================================
>>> --- modules/rcm/src/main/java/com/sun/grizzly/rcm/
>>> ResourceAllocationFilter.java (revision 2047)
>>> +++ modules/rcm/src/main/java/com/sun/grizzly/rcm/
>>> ResourceAllocationFilter.java (working copy)
>>> @@ -44,12 +44,12 @@
>>> import com.sun.grizzly.ProtocolChainContextTask;
>>> import com.sun.grizzly.ProtocolParser;
>>> import com.sun.grizzly.filter.ParserProtocolFilter;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> -import com.sun.grizzly.util.ByteBufferInputStream;
>>> -import com.sun.grizzly.util.Cloner;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> -import com.sun.grizzly.util.ExtendedThreadPool;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.ByteBufferInputStream;
>>> +import com.sun.grizzly.misc.Cloner;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.ExtendedThreadPool;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.BufferUnderflowException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/portunif/src/test/java/com/sun/grizzly/portunif/
>>> SimpleProtocolHandler.java
>>> ===================================================================
>>> --- modules/portunif/src/test/java/com/sun/grizzly/portunif/
>>> SimpleProtocolHandler.java (revision 2047)
>>> +++ modules/portunif/src/test/java/com/sun/grizzly/portunif/
>>> SimpleProtocolHandler.java (working copy)
>>> @@ -40,11 +40,11 @@
>>>
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.Controller;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.Utils;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.Utils;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> PUReadFilter.java
>>> ===================================================================
>>> --- modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> PUReadFilter.java (revision 2047)
>>> +++ modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> PUReadFilter.java (working copy)
>>> @@ -42,7 +42,7 @@
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.Utils;
>>> +import com.sun.grizzly.misc.Utils;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> SSLFilterChainProtocolHandler.java
>>> ===================================================================
>>> --- modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> SSLFilterChainProtocolHandler.java (revision 2047)
>>> +++ modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> SSLFilterChainProtocolHandler.java (working copy)
>>> @@ -38,7 +38,7 @@
>>>
>>> package com.sun.grizzly.portunif;
>>>
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.nio.ByteBuffer;
>>>
>>> /**
>>> Index: modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> ProtocolRequestWorkerThreadAdapter.java
>>> ===================================================================
>>> --- modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> ProtocolRequestWorkerThreadAdapter.java (revision 2047)
>>> +++ modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> ProtocolRequestWorkerThreadAdapter.java (working copy)
>>> @@ -39,7 +39,7 @@
>>> package com.sun.grizzly.portunif;
>>>
>>> import com.sun.grizzly.Context;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> TLSPUPreProcessor.java
>>> ===================================================================
>>> --- modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> TLSPUPreProcessor.java (revision 2047)
>>> +++ modules/portunif/src/main/java/com/sun/grizzly/portunif/
>>> TLSPUPreProcessor.java (working copy)
>>> @@ -41,11 +41,11 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.SSLConfig;
>>> -import com.sun.grizzly.util.SSLUtils;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.SSLUtils;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment.Mode;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.EOFException;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometInputStream.java
>>> ===================================================================
>>> --- modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometInputStream.java (revision 2047)
>>> +++ modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometInputStream.java (working copy)
>>> @@ -38,7 +38,7 @@
>>>
>>> package com.sun.grizzly.comet;
>>>
>>> -import com.sun.grizzly.util.InputReader;
>>> +import com.sun.grizzly.misc.InputReader;
>>> import java.nio.ByteBuffer;
>>>
>>> /**
>>> Index: modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometWriter.java
>>> ===================================================================
>>> --- modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometWriter.java (revision 2047)
>>> +++ modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometWriter.java (working copy)
>>> @@ -37,7 +37,7 @@
>>> */
>>> package com.sun.grizzly.comet;
>>>
>>> -import com.sun.grizzly.util.OutputWriter;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometTask.java
>>> ===================================================================
>>> --- modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometTask.java (revision 2047)
>>> +++ modules/comet/src/main/java/com/sun/grizzly/comet/
>>> CometTask.java (working copy)
>>> @@ -43,9 +43,9 @@
>>> import com.sun.grizzly.NIOContext;
>>> import com.sun.grizzly.ProtocolChain;
>>> import com.sun.grizzly.http.SelectorThread;
>>> -import com.sun.grizzly.util.InputReader;
>>> +import com.sun.grizzly.misc.InputReader;
>>> import com.sun.grizzly.http.TaskBase;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> SSLAsyncQueueWriterTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> SSLAsyncQueueWriterTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> SSLAsyncQueueWriterTest.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.filter.SSLEchoAsyncWriteQueueFilter;
>>> import com.sun.grizzly.filter.SSLReadFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import java.io.File;
>>> import java.io.IOException;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueReaderTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueReaderTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueReaderTest.java (working copy)
>>> @@ -42,7 +42,7 @@
>>> import com.sun.grizzly.async.AsyncQueueReadUnit;
>>> import com.sun.grizzly.filter.EchoAsyncWriteQueueFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import java.io.IOException;
>>> import java.net.InetSocketAddress;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> StateHolderTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> StateHolderTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> StateHolderTest.java (working copy)
>>> @@ -38,9 +38,9 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.State;
>>> -import com.sun.grizzly.util.StateHolder;
>>> -import com.sun.grizzly.util.StateHolder.ConditionListener;
>>> +import com.sun.grizzly.misc.State;
>>> +import com.sun.grizzly.misc.StateHolder;
>>> +import com.sun.grizzly.misc.StateHolder.ConditionListener;
>>> import java.util.Arrays;
>>> import java.util.List;
>>> import java.util.Random;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueReaderTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueReaderTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueReaderTest.java (working copy)
>>> @@ -45,7 +45,7 @@
>>> import com.sun.grizzly.async.AsyncQueueReadUnit;
>>> import com.sun.grizzly.filter.EchoAsyncWriteQueueFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import java.io.IOException;
>>> import java.net.InetSocketAddress;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> RoundRobinSelectorHandlerTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> RoundRobinSelectorHandlerTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> RoundRobinSelectorHandlerTest.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.filter.ReadFilter;
>>> import com.sun.grizzly.filter.EchoFilter;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import com.sun.grizzly.utils.TCPIOClient;
>>> import java.io.IOException;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueWriterTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueWriterTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> TCPAsyncQueueWriterTest.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.filter.EchoAsyncWriteQueueFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import java.io.IOException;
>>> import java.net.InetSocketAddress;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> BaseSelectionKeyHandlerTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> BaseSelectionKeyHandlerTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> BaseSelectionKeyHandlerTest.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.filter.EchoFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import com.sun.grizzly.utils.TCPIOClient;
>>> import java.io.IOException;
>>> Index: modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueWriterTest.java
>>> ===================================================================
>>> --- modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueWriterTest.java (revision 2047)
>>> +++ modules/grizzly/src/test/java/com/sun/grizzly/
>>> UDPAsyncQueueWriterTest.java (working copy)
>>> @@ -40,7 +40,7 @@
>>>
>>> import com.sun.grizzly.filter.EchoAsyncWriteQueueFilter;
>>> import com.sun.grizzly.filter.ReadFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import com.sun.grizzly.utils.ControllerUtils;
>>> import java.io.IOException;
>>> import java.net.InetSocketAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPConnectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPConnectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPConnectorHandler.java (working copy)
>>> @@ -46,9 +46,9 @@
>>> import com.sun.grizzly.async.AsyncQueueWritable;
>>> import com.sun.grizzly.async.AsyncQueueWriteUnit;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> import java.io.IOException;
>>> import java.net.Socket;
>>> import java.net.SocketAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> ContextTask.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> ContextTask.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> ContextTask.java (working copy)
>>> @@ -38,7 +38,7 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.ConcurrentLinkedQueuePool;
>>> +import com.sun.grizzly.misc.ConcurrentLinkedQueuePool;
>>> import java.util.concurrent.Callable;
>>>
>>> /**
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandlerRunner.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandlerRunner.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandlerRunner.java (working copy)
>>> @@ -38,9 +38,9 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.State;
>>> -import com.sun.grizzly.util.StateHolder;
>>> -import com.sun.grizzly.util.StateHolder.ConditionListener;
>>> +import com.sun.grizzly.misc.State;
>>> +import com.sun.grizzly.misc.StateHolder;
>>> +import com.sun.grizzly.misc.StateHolder.ConditionListener;
>>> import java.util.concurrent.CountDownLatch;
>>> import java.util.concurrent.TimeUnit;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> RoundRobinSelectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> RoundRobinSelectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> RoundRobinSelectorHandler.java (working copy)
>>> @@ -39,7 +39,7 @@
>>> package com.sun.grizzly;
>>>
>>> import com.sun.grizzly.Controller.Protocol;
>>> -import com.sun.grizzly.util.Copyable;
>>> +import com.sun.grizzly.misc.Copyable;
>>> import java.io.IOException;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableFilter.java (working copy)
>>> @@ -44,10 +44,10 @@
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.DefaultProtocolChain;
>>> import com.sun.grizzly.SelectorHandler;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> -import com.sun.grizzly.util.Utils;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment.Mode;
>>> +import com.sun.grizzly.misc.Utils;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableContextTask.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableContextTask.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/suspendable/
>>> SuspendableContextTask.java (working copy)
>>> @@ -39,8 +39,8 @@
>>>
>>> import com.sun.grizzly.DefaultProtocolChain;
>>> import com.sun.grizzly.SelectionKeyContextTask;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>>
>>> /**
>>> * Simple ContextTask used to resume a {_at_link ProtocolChain}
>>> execution
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPSelectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPSelectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPSelectorHandler.java (working copy)
>>> @@ -40,10 +40,10 @@
>>>
>>> import com.sun.grizzly.async.UDPAsyncQueueReader;
>>> import com.sun.grizzly.async.UDPAsyncQueueWriter;
>>> -import com.sun.grizzly.util.CallbackHandlerSelectionKeyAttachment;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyOP;
>>> -import com.sun.grizzly.util.State;
>>> +import com.sun.grizzly.misc.CallbackHandlerSelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyOP;
>>> +import com.sun.grizzly.misc.State;
>>> import java.io.IOException;
>>> import java.net.BindException;
>>> import java.net.DatagramSocket;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectionKeyHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectionKeyHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectionKeyHandler.java (working copy)
>>> @@ -37,7 +37,7 @@
>>> */
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.Copyable;
>>> +import com.sun.grizzly.misc.Copyable;
>>> import java.nio.channels.ClosedChannelException;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPConnectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPConnectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> UDPConnectorHandler.java (working copy)
>>> @@ -47,8 +47,8 @@
>>> import com.sun.grizzly.async.AsyncReadCallbackHandler;
>>> import com.sun.grizzly.async.AsyncReadCondition;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> -import com.sun.grizzly.util.InputReader;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.InputReader;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> DefaultSelectionKeyHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> DefaultSelectionKeyHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> DefaultSelectionKeyHandler.java (working copy)
>>> @@ -38,8 +38,8 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> import java.nio.channels.ClosedChannelException;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> connectioncache/server/CacheableSelectionKeyHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/connectioncache/
>>> server/CacheableSelectionKeyHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/connectioncache/
>>> server/CacheableSelectionKeyHandler.java (working copy)
>>> @@ -41,7 +41,7 @@
>>> import com.sun.grizzly.DefaultSelectionKeyHandler;
>>> import
>>> com
>>> .sun.grizzly.connectioncache.spi.transport.ConnectionCacheFactory;
>>> import
>>> com
>>> .sun.grizzly.connectioncache.spi.transport.InboundConnectionCache;
>>> -import com.sun.grizzly.util.Copyable;
>>> +import com.sun.grizzly.misc.Copyable;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ReadFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ReadFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ReadFilter.java (working copy)
>>> @@ -42,7 +42,7 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.net.SocketAddress;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoAsyncWriteQueueFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoAsyncWriteQueueFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoAsyncWriteQueueFilter.java (working copy)
>>> @@ -42,8 +42,8 @@
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLReadFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLReadFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLReadFilter.java (working copy)
>>> @@ -42,11 +42,11 @@
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.SSLConfig;
>>> -import com.sun.grizzly.util.InputReader;
>>> -import com.sun.grizzly.util.SSLUtils;
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.InputReader;
>>> +import com.sun.grizzly.misc.SSLUtils;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment.Mode;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.EOFException;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoAsyncWriteQueueFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoAsyncWriteQueueFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoAsyncWriteQueueFilter.java (working copy)
>>> @@ -42,9 +42,9 @@
>>> import com.sun.grizzly.ProtocolFilter;
>>> import com.sun.grizzly.async.AsyncQueueDataProcessor;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.ByteBufferFactory;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.ByteBufferFactory;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import javax.net.ssl.SSLEngine;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ParserProtocolFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ParserProtocolFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> ParserProtocolFilter.java (working copy)
>>> @@ -43,14 +43,14 @@
>>> import com.sun.grizzly.ProtocolChainInstruction;
>>> import com.sun.grizzly.ProtocolParser;
>>> import com.sun.grizzly.SSLConfig;
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>>
>>> -import com.sun.grizzly.util.ThreadAttachment;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> +import com.sun.grizzly.misc.ThreadAttachment;
>>> +import com.sun.grizzly.misc.ThreadAttachment.Mode;
>>>
>>> /**
>>> * Simple ProtocolFilter implementation which read the available
>>> bytes
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> EchoFilter.java (working copy)
>>> @@ -41,8 +41,8 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> SSLEchoFilter.java (working copy)
>>> @@ -40,8 +40,8 @@
>>>
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.ProtocolFilter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectableChannel;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> LogFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> LogFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> LogFilter.java (working copy)
>>> @@ -39,7 +39,7 @@
>>>
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.ProtocolFilter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPWriteFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPWriteFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPWriteFilter.java (working copy)
>>> @@ -41,8 +41,8 @@
>>> import com.sun.grizzly.Context;
>>> import com.sun.grizzly.Controller;
>>> import com.sun.grizzly.ProtocolFilter;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPReadFilter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPReadFilter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/filter/
>>> UDPReadFilter.java (working copy)
>>> @@ -39,7 +39,7 @@
>>> package com.sun.grizzly.filter;
>>>
>>> import com.sun.grizzly.Context;
>>> -import com.sun.grizzly.util.WorkerThread;
>>> +import com.sun.grizzly.misc.WorkerThread;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> SSLConnectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> SSLConnectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> SSLConnectorHandler.java (working copy)
>>> @@ -46,10 +46,10 @@
>>> import com.sun.grizzly.async.AsyncReadCondition;
>>> import com.sun.grizzly.async.AsyncWriteCallbackHandler;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> -import com.sun.grizzly.util.OutputWriter;
>>> -import com.sun.grizzly.util.SSLOutputWriter;
>>> -import com.sun.grizzly.util.SSLUtils;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.OutputWriter;
>>> +import com.sun.grizzly.misc.SSLOutputWriter;
>>> +import com.sun.grizzly.misc.SSLUtils;
>>> import java.io.EOFException;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ObjectPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ObjectPool.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ObjectPool.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> /**
>>> * Basic interface for object pool implementations
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/Utils.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Utils.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Utils.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThread.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThread.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThread.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.ByteBuffer;
>>> import javax.net.ssl.SSLEngine;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> AttributeHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> AttributeHolder.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> AttributeHolder.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.util.Map;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StreamAlgorithm.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StreamAlgorithm.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StreamAlgorithm.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SocketChannel;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachment.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachment.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.channels.SelectionKey;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConcurrentLinkedQueuePool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConcurrentLinkedQueuePool.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConcurrentLinkedQueuePool.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.util.concurrent.ConcurrentLinkedQueue;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SupportStateHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SupportStateHolder.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SupportStateHolder.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> /**
>>> * Interface implementors support {_at_link StateHolder} for state
>>> control
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLOutputWriter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLOutputWriter.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLOutputWriter.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.IOException;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ThreadAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ThreadAttachment.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ThreadAttachment.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.ByteBuffer;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLUtils.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLUtils.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SSLUtils.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Controller;
>>> import java.io.ByteArrayInputStream;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> CallbackHandlerSelectionKeyAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> CallbackHandlerSelectionKeyAttachment.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> CallbackHandlerSelectionKeyAttachment.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.CallbackHandler;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ExtendedThreadPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ExtendedThreadPool.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ExtendedThreadPool.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.util.concurrent.BlockingQueue;
>>> import java.util.concurrent.TimeUnit;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConnectionCloseHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConnectionCloseHandler.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ConnectionCloseHandler.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Handler;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferFactory.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferFactory.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.ByteBuffer;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyOP.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyOP.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyOP.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.CallbackHandler;
>>> import java.net.SocketAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Copyable.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Copyable.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Copyable.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> /**
>>> * Copyable objects are able to copy their content to
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Interceptor.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Interceptor.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Interceptor.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.IOException;
>>> import java.nio.channels.Channel;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyActionAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyActionAttachment.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyActionAttachment.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.channels.SelectionKey;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> DefaultThreadPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> DefaultThreadPool.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> DefaultThreadPool.java (working copy)
>>> @@ -36,10 +36,10 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Controller;
>>> -import com.sun.grizzly.util.ByteBufferFactory.ByteBufferType;
>>> +import com.sun.grizzly.misc.ByteBufferFactory.ByteBufferType;
>>> import java.util.concurrent.ExecutorService;
>>> import java.util.concurrent.LinkedBlockingQueue;
>>> import java.util.concurrent.ThreadFactory;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectorFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectorFactory.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectorFactory.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Controller;
>>> import java.io.IOException;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachmentWrapper.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachmentWrapper.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> SelectionKeyAttachmentWrapper.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.nio.channels.SelectionKey;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> LoggingFormatter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> LoggingFormatter.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> LoggingFormatter.java (working copy)
>>> @@ -33,7 +33,7 @@
>>> * only if the new code is made subject to such option by the
>>> copyright
>>> * holder.
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.PrintWriter;
>>> import java.io.StringWriter;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StateHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StateHolder.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> StateHolder.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Controller;
>>> import java.util.Iterator;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/State.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> State.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> State.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> /**
>>> * State enum
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Cloner.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Cloner.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> Cloner.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import com.sun.grizzly.Controller;
>>> import java.lang.reflect.Constructor;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> InputReader.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> InputReader.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> InputReader.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.InputStream;
>>> import java.io.IOException;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadImpl.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadImpl.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadImpl.java (working copy)
>>> @@ -35,11 +35,11 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.util.concurrent.Callable;
>>> -import com.sun.grizzly.util.ByteBufferFactory.ByteBufferType;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> +import com.sun.grizzly.misc.ByteBufferFactory.ByteBufferType;
>>> +import com.sun.grizzly.misc.ThreadAttachment.Mode;
>>>
>>> /**
>>> * Simple worker thread used for processing HTTP requests. All
>>> threads are
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferInputStream.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferInputStream.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> ByteBufferInputStream.java (working copy)
>>> @@ -35,7 +35,7 @@
>>> * holder.
>>> *
>>> */
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> /**
>>> * This class implement IO stream operations on top of a {_at_link
>>> ByteBuffer}.
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadFactory.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> WorkerThreadFactory.java (working copy)
>>> @@ -21,7 +21,7 @@
>>> * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.util.concurrent.ThreadFactory;
>>>
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> OutputWriter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> OutputWriter.java (revision 0)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/misc/
>>> OutputWriter.java (working copy)
>>> @@ -36,7 +36,7 @@
>>> *
>>> */
>>>
>>> -package com.sun.grizzly.util;
>>> +package com.sun.grizzly.misc;
>>>
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> SelectorHandler.java (working copy)
>>> @@ -39,10 +39,10 @@
>>>
>>> import com.sun.grizzly.async.AsyncQueueReader;
>>> import com.sun.grizzly.async.AsyncQueueWriter;
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.State;
>>> -import com.sun.grizzly.util.SupportStateHolder;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.State;
>>> +import com.sun.grizzly.misc.SupportStateHolder;
>>> import java.io.IOException;
>>> import java.nio.channels.SelectableChannel;
>>> import java.nio.channels.SelectionKey;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/Controller.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> Controller.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> Controller.java (working copy)
>>> @@ -38,14 +38,14 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.Cloner;
>>> -import com.sun.grizzly.util.ConcurrentLinkedQueuePool;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.DefaultThreadPool;
>>> -import com.sun.grizzly.util.State;
>>> -import com.sun.grizzly.util.StateHolder;
>>> -import com.sun.grizzly.util.SupportStateHolder;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.Cloner;
>>> +import com.sun.grizzly.misc.ConcurrentLinkedQueuePool;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.DefaultThreadPool;
>>> +import com.sun.grizzly.misc.State;
>>> +import com.sun.grizzly.misc.StateHolder;
>>> +import com.sun.grizzly.misc.SupportStateHolder;
>>> import java.io.IOException;
>>> import java.nio.channels.ClosedChannelException;
>>> import java.nio.channels.ClosedSelectorException;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/Context.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/Context.java
>>> (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/Context.java
>>> (working copy)
>>> @@ -40,8 +40,8 @@
>>>
>>> import com.sun.grizzly.async.AsyncQueueReader;
>>> import com.sun.grizzly.async.AsyncQueueWritable;
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.Copyable;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.Copyable;
>>> import java.nio.channels.SelectionKey;
>>> import java.util.Map;
>>> import java.util.concurrent.ExecutorService;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPSelectorHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPSelectorHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> TCPSelectorHandler.java (working copy)
>>> @@ -44,14 +44,14 @@
>>> import com.sun.grizzly.async.TCPAsyncQueueWriter;
>>> import com.sun.grizzly.async.AsyncQueueWriterContextTask;
>>> import com.sun.grizzly.async.TCPAsyncQueueReader;
>>> -import com.sun.grizzly.util.CallbackHandlerSelectionKeyAttachment;
>>> -import com.sun.grizzly.util.Cloner;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> -import com.sun.grizzly.util.SelectionKeyOP;
>>> -import com.sun.grizzly.util.SelectionKeyOP.ConnectSelectionKeyOP;
>>> -import com.sun.grizzly.util.State;
>>> -import com.sun.grizzly.util.StateHolder;
>>> +import com.sun.grizzly.misc.CallbackHandlerSelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.Cloner;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.SelectionKeyOP;
>>> +import com.sun.grizzly.misc.SelectionKeyOP.ConnectSelectionKeyOP;
>>> +import com.sun.grizzly.misc.State;
>>> +import com.sun.grizzly.misc.StateHolder;
>>> import java.io.IOException;
>>> import java.net.BindException;
>>> import java.net.InetAddress;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/
>>> BaseSelectionKeyHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> BaseSelectionKeyHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> BaseSelectionKeyHandler.java (working copy)
>>> @@ -38,10 +38,10 @@
>>>
>>> package com.sun.grizzly;
>>>
>>> -import com.sun.grizzly.util.ConnectionCloseHandler;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyActionAttachment;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.ConnectionCloseHandler;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyActionAttachment;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> import java.io.IOException;
>>> import java.net.Socket;
>>> import java.nio.channels.ClosedChannelException;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/NIOContext.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/
>>> NIOContext.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/
>>> NIOContext.java (working copy)
>>> @@ -48,9 +48,9 @@
>>> import com.sun.grizzly.async.AsyncWriteCallbackHandler;
>>> import com.sun.grizzly.async.AsyncQueueWriteUnit;
>>> import com.sun.grizzly.async.ByteBufferCloner;
>>> -import com.sun.grizzly.util.AttributeHolder;
>>> -import com.sun.grizzly.util.Copyable;
>>> -import com.sun.grizzly.util.SelectionKeyAttachment;
>>> +import com.sun.grizzly.misc.AttributeHolder;
>>> +import com.sun.grizzly.misc.Copyable;
>>> +import com.sun.grizzly.misc.SelectionKeyAttachment;
>>> import java.io.IOException;
>>> import java.net.SocketAddress;
>>> import java.nio.ByteBuffer;
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/Utils.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Utils.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Utils.java (working copy)
>>> @@ -1,248 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.IOException;
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.ReadableByteChannel;
>>> -import java.nio.channels.SelectableChannel;
>>> -import java.nio.channels.SelectionKey;
>>> -import java.nio.channels.Selector;
>>> -
>>> -/**
>>> - * Class contains set of useful operations commonly used in the
>>> framework
>>> - *
>>> - * @author Alexey Stashok
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public class Utils {
>>> - /**
>>> - * Character translation tables.
>>> - */
>>> - private static final byte[] toLower = new byte[256];
>>> -
>>> - /**
>>> - * Initialize character translation and type tables.
>>> - */
>>> - static {
>>> - for (int i = 0; i < 256; i++) {
>>> - toLower[i] = (byte)i;
>>> - }
>>> -
>>> - for (int lc = 'a'; lc <= 'z'; lc++) {
>>> - int uc = lc + 'A' - 'a';
>>> - toLower[uc] = (byte)lc;
>>> - }
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Method reads data from {_at_link SelectableChannel} to
>>> - * {_at_link ByteBuffer}. If data is not immediately available -
>>> channel
>>> - * will be reregistered on temporary {_at_link Selector} and
>>> wait maximum
>>> - * readTimeout milliseconds for data.
>>> - *
>>> - * @param channel {_at_link SelectableChannel} to read data from
>>> - * @param byteBuffer {_at_link ByteBuffer} to store read data to
>>> - * @param readTimeout maximum time in millis operation will
>>> wait for
>>> - * incoming data
>>> - *
>>> - * @return number of bytes were read
>>> - * @throws <code>IOException</code> if any error was occured
>>> during read
>>> - */
>>> - public static int readWithTemporarySelector(SelectableChannel
>>> channel,
>>> - ByteBuffer byteBuffer, long readTimeout) throws
>>> IOException {
>>> - int count = 1;
>>> - int byteRead = 0;
>>> - int preReadInputBBPos = byteBuffer.position();
>>> - Selector readSelector = null;
>>> - SelectionKey tmpKey = null;
>>> -
>>> - try {
>>> - ReadableByteChannel readableChannel =
>>> (ReadableByteChannel) channel;
>>> - while (count > 0){
>>> - count = readableChannel.read(byteBuffer);
>>> - if ( count > -1 )
>>> - byteRead += count;
>>> - else
>>> - byteRead = count;
>>> - }
>>> -
>>> - if (byteRead == 0 && byteBuffer.position() ==
>>> preReadInputBBPos) {
>>> - readSelector = SelectorFactory.getSelector();
>>> -
>>> - if ( readSelector == null ){
>>> - return 0;
>>> - }
>>> - count = 1;
>>> -
>>> - tmpKey = channel.register(readSelector,
>>> SelectionKey.OP_READ);
>>> - tmpKey.interestOps(tmpKey.interestOps() |
>>> SelectionKey.OP_READ);
>>> - int code = readSelector.select(readTimeout);
>>> - tmpKey.interestOps(
>>> - tmpKey.interestOps() &
>>> (~SelectionKey.OP_READ));
>>> -
>>> - if ( code == 0 ){
>>> - return 0; // Return on the main Selector and
>>> try again.
>>> - }
>>> -
>>> - while (count > 0){
>>> - count = readableChannel.read(byteBuffer);
>>> - if ( count > -1 )
>>> - byteRead += count;
>>> - else
>>> - byteRead = count;
>>> - }
>>> - } else if (byteRead == 0 && byteBuffer.position() !=
>>> preReadInputBBPos) {
>>> - byteRead += (byteBuffer.position() -
>>> preReadInputBBPos);
>>> - }
>>> - } finally {
>>> - if (tmpKey != null)
>>> - tmpKey.cancel();
>>> -
>>> - if ( readSelector != null) {
>>> - // Bug 6403933
>>> -
>>> SelectorFactory.selectNowAndReturnSelector(readSelector);
>>> - }
>>> - }
>>> -
>>> - return byteRead;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the bytes contained between the startByte and the
>>> endByte. The ByteBuffer
>>> - * will be left in the state it was before invoking that
>>> method, meaning
>>> - * its position and limit will be the same.
>>> - *
>>> - * @param byteBuffer The bytes.
>>> - * @param startByte the first byte to look for
>>> - * @param endByte the second byte to look for
>>> - * @return The byte[] contained between startByte and endByte
>>> - */
>>> - public static byte[] extractBytes(ByteBuffer byteBuffer,
>>> - byte startByte, byte endByte) throws IOException{
>>> -
>>> - int curPosition = byteBuffer.position();
>>> - int curLimit = byteBuffer.limit();
>>> -
>>> - if (byteBuffer.position() == 0){
>>> - throw new IllegalStateException("Invalid state");
>>> - }
>>> -
>>> - byteBuffer.position(0);
>>> - byteBuffer.limit(curPosition);
>>> - int state =0;
>>> - int start =0;
>>> - int end = 0;
>>> - try {
>>> - byte c;
>>> -
>>> - // Rule b - try to determine the context-root
>>> - while(byteBuffer.hasRemaining()) {
>>> - c = byteBuffer.get();
>>> - switch(state) {
>>> - case 0: // Search for first ' '
>>> - if (c == startByte){
>>> - state = 1;
>>> - start = byteBuffer.position();
>>> - }
>>> - break;
>>> - case 1:
>>> - if (c == endByte){
>>> - end = byteBuffer.position();
>>> - byte[] bytes = new byte[end - start];
>>> - byteBuffer.position(start);
>>> - byteBuffer.limit(end);
>>> - byteBuffer.get(bytes);
>>> - return bytes;
>>> - }
>>> - break;
>>> - default:
>>> - throw new
>>> IllegalArgumentException("Unexpected state");
>>> - }
>>> - }
>>> - throw new IllegalStateException("Unexpected state");
>>> - } finally {
>>> - byteBuffer.limit(curLimit);
>>> - byteBuffer.position(curPosition);
>>> - }
>>> - }
>>> -
>>> -
>>> -
>>> - /**
>>> - * Specialized utility method: find a sequence of lower case
>>> bytes inside
>>> - * a ByteBuffer.
>>> - */
>>> - public static int findBytes(ByteBuffer byteBuffer, byte[] b) {
>>> - int curPosition = byteBuffer.position();
>>> - int curLimit = byteBuffer.limit();
>>> -
>>> - if (byteBuffer.position() == 0){
>>> - throw new IllegalStateException("Invalid state");
>>> - }
>>> -
>>> - byteBuffer.position(0);
>>> - byteBuffer.limit(curPosition);
>>> - try {
>>> - byte first = b[0];
>>> - int start = 0;
>>> - int end = curPosition;
>>> -
>>> - // Look for first char
>>> - int srcEnd = b.length;
>>> -
>>> - for (int i = start; i <= (end - srcEnd); i++) {
>>> - if ((toLower[byteBuffer.get(i) & 0xff] & 0xff) !=
>>> first) continue;
>>> - // found first char, now look for a match
>>> - int myPos = i+1;
>>> - for (int srcPos = 1; srcPos < srcEnd; ) {
>>> - if ((toLower[byteBuffer.get(myPos++) &
>>> 0xff] & 0xff) != b[srcPos++])
>>> - break;
>>> - if (srcPos == srcEnd) return i -
>>> start; // found it
>>> - }
>>> - }
>>> - return -1;
>>> - } finally {
>>> - byteBuffer.limit(curLimit);
>>> - byteBuffer.position(curPosition);
>>> - }
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ObjectPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ObjectPool.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ObjectPool.java (working copy)
>>> @@ -1,50 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -/**
>>> - * Basic interface for object pool implementations
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public interface ObjectPool<E> {
>>> - public E poll();
>>> -
>>> - public void offer(E object);
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThread.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThread.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThread.java (working copy)
>>> @@ -1,223 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.ByteBuffer;
>>> -import javax.net.ssl.SSLEngine;
>>> -
>>> -/**
>>> - * Simple interface to allow the addition of <code>Thread</code>
>>> attributes.
>>> - *
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public abstract class WorkerThread extends Thread {
>>> -
>>> -
>>> - /**
>>> - * The {_at_link ByteBuffer} used when {_at_link Task} are executed.
>>> - */
>>> - protected ByteBuffer byteBuffer;
>>> -
>>> -
>>> - /**
>>> - * The encrypted ByteBuffer used for handshaking and reading
>>> request bytes.
>>> - */
>>> - protected ByteBuffer inputBB;
>>> -
>>> -
>>> - /**
>>> - * The encrypted ByteBuffer used for handshaking and writing
>>> response bytes.
>>> - */
>>> - protected ByteBuffer outputBB;
>>> -
>>> -
>>> - /**
>>> - * The{_at_link SSLEngine} used to manage the SSL over NIO
>>> request.
>>> - */
>>> - protected SSLEngine sslEngine;
>>> -
>>> - public WorkerThread() {
>>> - }
>>> -
>>> - public WorkerThread(String name) {
>>> - super(name);
>>> - }
>>> -
>>> - public WorkerThread(Runnable target) {
>>> - super(target);
>>> - }
>>> -
>>> - public WorkerThread(Runnable target, String name) {
>>> - super(target, name);
>>> - }
>>> -
>>> - public WorkerThread(ThreadGroup group, String name) {
>>> - super(group, name);
>>> - }
>>> -
>>> - public WorkerThread(ThreadGroup group, Runnable target) {
>>> - super(group, target);
>>> - }
>>> -
>>> - public WorkerThread(ThreadGroup group, Runnable target,
>>> String name) {
>>> - super(group, target, name);
>>> - }
>>> -
>>> - public WorkerThread(ThreadGroup group, Runnable target,
>>> String name, long stackSize) {
>>> - super(group, target, name, stackSize);
>>> - }
>>> -
>>> - /**
>>> - * Set the {_at_link ByteBuffer} shared this thread
>>> - */
>>> - public void setByteBuffer(ByteBuffer byteBuffer){
>>> - this.byteBuffer = byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the {_at_link ByteBuffer} shared this thread
>>> - */
>>> - public ByteBuffer getByteBuffer(){
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the encrypted {_at_link ByteBuffer} used to handle
>>> request.
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer getInputBB(){
>>> - return inputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the encrypted {_at_link ByteBuffer} used to handle request.
>>> - * @param inputBB {_at_link ByteBuffer}
>>> - */
>>> - public void setInputBB(ByteBuffer inputBB){
>>> - this.inputBB = inputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the encrypted {_at_link ByteBuffer} used to handle
>>> response.
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer getOutputBB(){
>>> - return outputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the encrypted {_at_link ByteBuffer} used to handle
>>> response.
>>> - * @param outputBB {_at_link ByteBuffer}
>>> - */
>>> - public void setOutputBB(ByteBuffer outputBB){
>>> - this.outputBB = outputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the{_at_link SSLEngine}.
>>> - * @return{_at_link SSLEngine}
>>> - */
>>> - public SSLEngine getSSLEngine() {
>>> - return sslEngine;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Get the{_at_link SSLEngine}.
>>> - * @param sslEngine{_at_link SSLEngine}
>>> - */
>>> - public void setSSLEngine(SSLEngine sslEngine) {
>>> - this.sslEngine = sslEngine;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Updates Thread associated attachment according to the
>>> passed mode.
>>> - *
>>> - * @return updated ThreadAttachment
>>> - */
>>> - public abstract ThreadAttachment updateAttachment(int mode);
>>> -
>>> -
>>> - /**
>>> - * Get the current set of attributes (state) associated with
>>> this instance.
>>> - * Unlike detach(), this method doesn't clear the
>>> WorkerThread attributes.
>>> - *
>>> - * @return the Thread associated ThreadAttachment
>>> - */
>>> - public abstract ThreadAttachment getAttachment();
>>> -
>>> -
>>> - /**
>>> - * Detach the current set of attributes (state) associated
>>> with this instance.
>>> - * Method will re-create all the ByteBuffers associated with
>>> this thread.
>>> - *
>>> - * @return a new ThreadAttachment
>>> - */
>>> - public abstract ThreadAttachment detach();
>>> -
>>> -
>>> - /**
>>> - * Attach the ThreadAttachment to this instance. This will
>>> configure this
>>> - * Thread attributes like ByteBuffer, SSLEngine, etc.
>>> - * @param ThreadAttachment the attachment.
>>> - */
>>> - public abstract void attach(ThreadAttachment threadAttachment);
>>> -
>>> - protected void reset() {
>>> - if (byteBuffer != null) {
>>> - byteBuffer.clear();
>>> - }
>>> -
>>> - if (inputBB != null) {
>>> - inputBB.clear();
>>> - }
>>> -
>>> - if (outputBB != null) {
>>> - outputBB.clear();
>>> - }
>>> -
>>> - sslEngine = null;
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> AttributeHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> AttributeHolder.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> AttributeHolder.java (working copy)
>>> @@ -1,94 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.util.Map;
>>> -
>>> -/**
>>> - * Interface declares common functionality for objects, which
>>> could have
>>> - * associated attributes.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public interface AttributeHolder {
>>> - /**
>>> - * Remove a name/value object.
>>> - * @param name - name of an attribute
>>> - * @return attribute which has been removed
>>> - */
>>> - public Object removeAttribute(String name);
>>> -
>>> -
>>> - /**
>>> - * Set a name/value object.
>>> - * @param name - name of an attribute
>>> - * @param value - value of named attribute
>>> - */
>>> - public void setAttribute(String name, Object value);
>>> -
>>> -
>>> - /**
>>> - * Set a {_at_link Map} of attribute name/value pairs.
>>> - * Old {_at_link AttributeHolder} values will not be available.
>>> - * Later changes of this {_at_link Map} will lead to changes to
>>> the current
>>> - * {_at_link AttributeHolder}.
>>> - *
>>> - * @param attributes - map of name/value pairs
>>> - */
>>> - public void setAttributes(Map<String, Object> attributes);
>>> -
>>> -
>>> - /**
>>> - * Return an object based on a name.
>>> - * @param name - name of an attribute
>>> - * @return - attribute value for the <tt>name</tt>, null if
>>> <tt>name</tt>
>>> - * does not exist in <tt>attributes</tt>
>>> - */
>>> - public Object getAttribute(String name);
>>> -
>>> -
>>> - /**
>>> - * Return a {_at_link Map} of attribute name/value pairs.
>>> - * Updates, performed on the returned {_at_link Map} will be
>>> reflected in
>>> - * this {_at_link AttributeHolder}
>>> - *
>>> - * @return - {_at_link Map} of attribute name/value pairs
>>> - */
>>> - public Map<String, Object> getAttributes();
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StreamAlgorithm.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StreamAlgorithm.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StreamAlgorithm.java (working copy)
>>> @@ -1,147 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.SocketChannel;
>>> -/**
>>> - * Generic parsing interface that can be used to implement protocol
>>> - * specific logic parsing.
>>> - *
>>> - * @deprecated Use the ProtocolParser instead.
>>> - *
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public interface StreamAlgorithm<E>{
>>> -
>>> -
>>> - /**
>>> - * Return the stream content-length. If the content-length
>>> wasn't parsed,
>>> - * return -1.
>>> - * @return content length or -1 if content length was not
>>> parsed
>>> - */
>>> - public int contentLength();
>>> -
>>> -
>>> - /**
>>> - * Return the stream header length. The header length is the
>>> length between
>>> - * the start of the stream and the first occurance of
>>> character '\r\n' .
>>> - * @return header length
>>> - */
>>> - public int headerLength();
>>> -
>>> -
>>> - /**
>>> - * Allocate a {_at_link ByteBuffer}
>>> - * @param useDirect allocate a direct {_at_link ByteBuffer}.
>>> - * @param useView allocate a view {_at_link ByteBuffer}.
>>> - * @param size the size of the newly created {_at_link
>>> ByteBuffer}.
>>> - * @return a new {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer allocate(boolean useDirect, boolean
>>> useView, int size);
>>> -
>>> -
>>> - /**
>>> - * Before parsing the bytes, initialize and prepare the
>>> algorithm.
>>> - * @param byteBuffer the {_at_link ByteBuffer} used by this
>>> algorithm
>>> - * @return {_at_link ByteBuffer} used by this algorithm
>>> - */
>>> - public ByteBuffer preParse(ByteBuffer byteBuffer);
>>> -
>>> -
>>> - /**
>>> - * Parse the {_at_link ByteBuffer} and try to determine if the
>>> bytes
>>> - * stream has been fully read from the {_at_link SocketChannel}.
>>> - * @param byteBuffer the bytes read.
>>> - * @return true if the algorithm determines the end of the
>>> stream.
>>> - */
>>> - public boolean parse(ByteBuffer byteBuffer);
>>> -
>>> -
>>> - /**
>>> - * After parsing the bytes, post process the {_at_link ByteBuffer}
>>> - * @param byteBuffer the {_at_link ByteBuffer} used by this
>>> algorithm
>>> - * @return {_at_link ByteBuffer} used by this algorithm
>>> - */
>>> - public ByteBuffer postParse(ByteBuffer byteBuffer);
>>> -
>>> -
>>> - /**
>>> - * Recycle the algorithm.
>>> - */
>>> - public void recycle();
>>> -
>>> -
>>> - /**
>>> - * Rollback the {_at_link ByteBuffer} to its previous state in
>>> case
>>> - * an error as occured.
>>> - * @param byteBuffer
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer rollbackParseState(ByteBuffer byteBuffer);
>>> -
>>> -
>>> - /**
>>> - * The {_at_link Interceptor} associated with this algorithm.
>>> - * @return {_at_link Interceptor}
>>> - */
>>> - public Interceptor getHandler();
>>> -
>>> -
>>> - /**
>>> - * Set the {_at_link Channel} used by this algorithm
>>> - * @param channek set {_at_link Channel}
>>> - */
>>> - public void setChannel(E channel);
>>> -
>>> -
>>> - /**
>>> - * Set the <code>port</code> this algorithm is used.
>>> - * @param port port number
>>> - */
>>> - public void setPort(int port);
>>> -
>>> -
>>> - /**
>>> - * Return the port
>>> - * @return port number being used
>>> - */
>>> - public int getPort();
>>> -
>>> -}
>>> -
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachment.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachment.java (working copy)
>>> @@ -1,72 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.channels.SelectionKey;
>>> -
>>> -/**
>>> - * Basic class for all SelectionKey attachments.
>>> - * Custom attachments should be inherited from it.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public abstract class SelectionKeyAttachment {
>>> - private Long timeout;
>>> -
>>> - public static Object getAttachment(SelectionKey key) {
>>> - Object attachment = key.attachment();
>>> - if (attachment instanceof SelectionKeyAttachmentWrapper) {
>>> - return ((SelectionKeyAttachmentWrapper)
>>> attachment).getAttachment();
>>> - }
>>> -
>>> - return attachment;
>>> - }
>>> -
>>> - public Long getTimeout() {
>>> - return timeout;
>>> - }
>>> -
>>> - public void setTimeout(Long timeout) {
>>> - this.timeout = timeout;
>>> - }
>>> -
>>> - public void release(SelectionKey selectionKey) {
>>> - timeout = null;
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConcurrentLinkedQueuePool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConcurrentLinkedQueuePool.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConcurrentLinkedQueuePool.java (working copy)
>>> @@ -1,75 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.util.concurrent.ConcurrentLinkedQueue;
>>> -
>>> -/**
>>> - * <code>ObjectPool</code> implementation based on {_at_link
>>> ConcurrentLinkedQueue}
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public abstract class ConcurrentLinkedQueuePool<E> implements
>>> ObjectPool<E> {
>>> - private volatile ConcurrentLinkedQueue<E> pool;
>>> -
>>> - public abstract E newInstance();
>>> -
>>> - public E poll() {
>>> - if (pool == null) {
>>> - synchronized(this) {
>>> - if (pool == null) {
>>> - pool = new ConcurrentLinkedQueue<E>();
>>> - }
>>> - }
>>> - }
>>> -
>>> - E object = pool.poll();
>>> - if (object == null) {
>>> - object = newInstance();
>>> - }
>>> -
>>> - return object;
>>> - }
>>> -
>>> - public void offer(E object) {
>>> - if (pool != null) {
>>> - pool.offer(object);
>>> - }
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SupportStateHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SupportStateHolder.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SupportStateHolder.java (working copy)
>>> @@ -1,52 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -/**
>>> - * Interface implementors support {_at_link StateHolder} for state
>>> control
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public interface SupportStateHolder<E> {
>>> - /**
>>> - * Gets {_at_link StateHolder} for this object
>>> - * @return {_at_link StateHolder}
>>> - */
>>> - public StateHolder<E> getStateHolder();
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLOutputWriter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLOutputWriter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLOutputWriter.java (working copy)
>>> @@ -1,106 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.IOException;
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.SelectableChannel;
>>> -import javax.net.ssl.SSLEngine;
>>> -import javax.net.ssl.SSLEngineResult;
>>> -import javax.net.ssl.SSLEngineResult.HandshakeStatus;
>>> -
>>> -/**
>>> - * SSL over NIO utility to encrypt {_at_link ByteBuffer} and flush
>>> them.
>>> - * All the SSLEngine operations are delegated to class {_at_link
>>> SSLUtils}
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public final class SSLOutputWriter{
>>> -
>>> - /**
>>> - * Encrypt the response and flush it using {_at_link OutputWriter}
>>> - * @param channel {_at_link SelectableChannel} to flush
>>> - * @param bb {_at_link ByteBuffer}
>>> - * @return number of bytes written
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SelectableChannel channel,
>>> ByteBuffer bb)
>>> - throws IOException{
>>> -
>>> - WorkerThread workerThread =
>>> (WorkerThread)Thread.currentThread();
>>> - SSLEngine sslEngine = workerThread.getSSLEngine();
>>> - ByteBuffer outputBB = workerThread.getOutputBB();
>>> - return flushChannel(channel,bb,outputBB,sslEngine);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Encrypt the response and flush it using {_at_link OutputWriter}
>>> - * @param channel {_at_link SelectableChannel} to flush
>>> - * @param bb input {_at_link ByteBuffer}
>>> - * @param outputBB output {_at_link ByteBuffer}
>>> - * @param sslEngine {_at_link SSLEngine}
>>> - * @return number of bytes written
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SelectableChannel channel,
>>> ByteBuffer bb,
>>> - ByteBuffer outputBB, SSLEngine sslEngine) throws
>>> IOException{
>>> -
>>> - long nWrite = 0;
>>> - while (bb.hasRemaining()) {
>>> - SSLEngineResult result =
>>> SSLUtils.wrap(bb,outputBB,sslEngine);
>>> - switch (result.getStatus()) {
>>> - case OK:
>>> - if (result.getHandshakeStatus() ==
>>> HandshakeStatus.NEED_TASK) {
>>> - SSLUtils.executeDelegatedTask(sslEngine);
>>> - }
>>> - break;
>>> -
>>> - default:
>>> - throw new IOException("SSLOutputWriter: " +
>>> result.getStatus());
>>> - }
>>> -
>>> - if (outputBB.hasRemaining()) {
>>> - nWrite +=
>>> OutputWriter.flushChannel(channel,outputBB);
>>> - }
>>> - }
>>> - outputBB.clear();
>>> - return nWrite;
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ThreadAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ThreadAttachment.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ThreadAttachment.java (working copy)
>>> @@ -1,286 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.SelectionKey;
>>> -import java.util.HashMap;
>>> -import java.util.Map;
>>> -import java.util.concurrent.locks.ReentrantLock;
>>> -import javax.net.ssl.SSLEngine;
>>> -
>>> -/**
>>> - * This object represent the state of a {_at_link WorkerThread}.
>>> This include
>>> - * the ByteBuffer binded to the WorkerThread, application data etc.
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - * @author Alexey Stashok
>>> - */
>>> -public class ThreadAttachment extends SelectionKeyActionAttachment
>>> - implements AttributeHolder {
>>> -
>>> - public static class Mode {
>>> - public static int ATTRIBUTES_ONLY = 0;
>>> - public static int BYTE_BUFFER = 2;
>>> - public static int INPUT_BB = 4;
>>> - public static int OUTPUT_BB = 8;
>>> - public static int SECURE_BUFFERS = 12;
>>> - public static int SSL_ENGINE = 16;
>>> - public static int SSL_ARTIFACTS = 28;
>>> - public static int STORE_ALL = 31;
>>> - };
>>> -
>>> - private ReentrantLock threadLock = new ReentrantLock();
>>> -
>>> - private String threadId;
>>> -
>>> -
>>> - private Map<String, Object> attributes;
>>> -
>>> -
>>> - private ByteBuffer byteBuffer;
>>> -
>>> -
>>> - /**
>>> - * The encrypted ByteBuffer used for handshaking and reading
>>> request bytes.
>>> - */
>>> - private ByteBuffer inputBB;
>>> -
>>> -
>>> - /**
>>> - * The encrypted ByteBuffer used for handshaking and writing
>>> response bytes.
>>> - */
>>> - private ByteBuffer outputBB;
>>> -
>>> -
>>> - /**
>>> - * The{_at_link SSLEngine} used to manage the SSL over NIO
>>> request.
>>> - */
>>> - private SSLEngine sslEngine;
>>> -
>>> - /**
>>> - * ThreadAttachment store mode
>>> - */
>>> - private int mode;
>>> -
>>> -
>>> - public ThreadAttachment(){
>>> - attributes = new HashMap<String,Object>();
>>> - }
>>> -
>>> - public int getMode() {
>>> - return mode;
>>> - }
>>> -
>>> - public void setMode(int mode) {
>>> - this.mode = mode;
>>> - }
>>> -
>>> -
>>> - public void setAttribute(String key, Object value){
>>> - attributes.put(key,value);
>>> - }
>>> -
>>> -
>>> - public Object getAttribute(String key){
>>> - return attributes.get(key);
>>> - }
>>> -
>>> -
>>> - public Object removeAttribute(String key){
>>> - return attributes.remove(key);
>>> - }
>>> -
>>> - public void setAttributes(Map<String, Object> attributes) {
>>> - this.attributes = attributes;
>>> - }
>>> -
>>> - public Map<String, Object> getAttributes() {
>>> - return attributes;
>>> - }
>>> -
>>> - /**
>>> - * Set the {_at_link ByteBuffer} shared this thread
>>> - */
>>> - public void setByteBuffer(ByteBuffer byteBuffer){
>>> - this.byteBuffer = byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the {_at_link ByteBuffer} shared this thread
>>> - */
>>> - public ByteBuffer getByteBuffer(){
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the encrypted {_at_link ByteBuffer} used to handle
>>> request.
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer getInputBB(){
>>> - return inputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the encrypted {_at_link ByteBuffer} used to handle request.
>>> - * @param inputBB {_at_link ByteBuffer}
>>> - */
>>> - public void setInputBB(ByteBuffer inputBB){
>>> - this.inputBB = inputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the encrypted {_at_link ByteBuffer} used to handle
>>> response.
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer getOutputBB(){
>>> - return outputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the encrypted {_at_link ByteBuffer} used to handle
>>> response.
>>> - * @param outputBB {_at_link ByteBuffer}
>>> - */
>>> - public void setOutputBB(ByteBuffer outputBB){
>>> - this.outputBB = outputBB;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the{_at_link SSLEngine}.
>>> - * @return{_at_link SSLEngine}
>>> - */
>>> - public SSLEngine getSSLEngine() {
>>> - return sslEngine;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Get the{_at_link SSLEngine}.
>>> - * @param sslEngine{_at_link SSLEngine}
>>> - */
>>> - public void setSSLEngine(SSLEngine sslEngine) {
>>> - this.sslEngine = sslEngine;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the name of the Thread on which this instance is
>>> binded.
>>> - */
>>> - public String getThreadId() {
>>> - return threadId;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the Thread's name on which this instance is binded.
>>> - */
>>> - public void setThreadId(String threadId) {
>>> - this.threadId = threadId;
>>> - }
>>> -
>>> - /**
>>> - * Associates ThreadAttachment with the current thread
>>> - */
>>> - public void associate() {
>>> - if (!threadLock.isHeldByCurrentThread()) {
>>> - threadLock.lock();
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Releases ThreadAttachment association with the current
>>> thread
>>> - */
>>> - public void deassociate() {
>>> - if (threadLock.isHeldByCurrentThread()) {
>>> - threadLock.unlock();
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * SelectionKey attachment processing
>>> - * @param selectionKey
>>> - */
>>> - public void process(SelectionKey selectionKey) {
>>> - ((WorkerThread) Thread.currentThread()).attach(this);
>>> - }
>>> -
>>> - /**
>>> - * SelectionKey attachment postProcessing
>>> - * @param selectionKey
>>> - */
>>> - public void postProcess(SelectionKey selectionKey) {
>>> - ((WorkerThread) Thread.currentThread()).detach();
>>> - }
>>> -
>>> - public void reset() {
>>> - mode = Mode.ATTRIBUTES_ONLY;
>>> - byteBuffer = null;
>>> - sslEngine = null;
>>> - inputBB = null;
>>> - outputBB = null;
>>> - }
>>> -
>>> - @Override
>>> - public void release(SelectionKey selectionKey) {
>>> - attributes.clear();
>>> - reset();
>>> -
>>> - deassociate();
>>> - super.release(selectionKey);
>>> - }
>>> -
>>> - @Override
>>> - public String toString() {
>>> - StringBuilder sb = new StringBuilder(256);
>>> - sb.append("ThreadAttachment[mode=").append(mode);
>>> - sb.append(", threadId=").append(threadId);
>>> - sb.append(", byteBuffer=").append(byteBuffer);
>>> - sb.append(", sslEngine=").append(sslEngine);
>>> - sb.append(", inputBB=").append(inputBB);
>>> - sb.append(", outputBB=").append(outputBB);
>>> - sb.append(", attributes=").append(attributes);
>>> - sb.append(']');
>>> - return sb.toString();
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ExtendedThreadPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ExtendedThreadPool.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ExtendedThreadPool.java (working copy)
>>> @@ -1,189 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.util.concurrent.BlockingQueue;
>>> -import java.util.concurrent.TimeUnit;
>>> -
>>> -/**
>>> - * Thread pool, from which it's possible to gather statistics
>>> information,
>>> - * and finer control its execution.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public interface ExtendedThreadPool {
>>> -
>>> - /**
>>> - * Returns the approximate number of threads that are actively
>>> - * executing tasks.
>>> - *
>>> - * @return the number of threads
>>> - */
>>> - public int getActiveCount();
>>> -
>>> -
>>> - /**
>>> - * Returns the approximate total number of tasks that have been
>>> - * scheduled for execution. Because the states of tasks and
>>> - * threads may change dynamically during computation, the
>>> returned
>>> - * value is only an approximation, but one that does not ever
>>> - * decrease across successive calls.
>>> - *
>>> - * @return the number of tasks
>>> - */
>>> - public long getTaskCount();
>>> -
>>> - /**
>>> - * Returns the approximate total number of tasks that have
>>> - * completed execution. Because the states of tasks and threads
>>> - * may change dynamically during computation, the returned
>>> value
>>> - * is only an approximation, but one that does not ever
>>> decrease
>>> - * across successive calls.
>>> - *
>>> - * @return the number of tasks
>>> - */
>>> - public long getCompletedTaskCount();
>>> -
>>> - /**
>>> - * Returns the core number of threads.
>>> - *
>>> - * @return the core number of threads
>>> - * @see #setCorePoolSize
>>> - */
>>> - public int getCorePoolSize();
>>> -
>>> - /**
>>> - * Sets the core number of threads. This overrides any value
>>> set
>>> - * in the constructor. If the new value is smaller than the
>>> - * current value, excess existing threads will be terminated
>>> when
>>> - * they next become idle. If larger, new threads will, if
>>> needed,
>>> - * be started to execute any queued tasks.
>>> - *
>>> - * @param corePoolSize the new core size
>>> - * @throws IllegalArgumentException if <tt>corePoolSize</tt>
>>> - * less than zero
>>> - * @see #getCorePoolSize
>>> - */
>>> - public void setCorePoolSize(int corePoolSize);
>>> -
>>> - /**
>>> - * Returns the largest number of threads that have ever
>>> - * simultaneously been in the pool.
>>> - *
>>> - * @return the number of threads
>>> - */
>>> - public int getLargestPoolSize();
>>> -
>>> - /**
>>> - * Returns the current number of threads in the pool.
>>> - *
>>> - * @return the number of threads
>>> - */
>>> - public int getPoolSize();
>>> -
>>> - /**
>>> - * Returns the task queue used by this executor. Access to the
>>> - * task queue is intended primarily for debugging and
>>> monitoring.
>>> - * This queue may be in active use. Retrieving the task queue
>>> - * does not prevent queued tasks from executing.
>>> - *
>>> - * @return the task queue
>>> - */
>>> - public BlockingQueue<Runnable> getQueue();
>>> -
>>> - /**
>>> - * Returns the number of tasks, which are currently waiting
>>> in the queue.
>>> - *
>>> - * @return the number of tasks, which are currently waiting
>>> in the queue.
>>> - */
>>> - public int getQueueSize();
>>> -
>>> - /**
>>> - * Returns the thread keep-alive time, which is the amount of
>>> time
>>> - * which threads in excess of the core pool size may remain
>>> - * idle before being terminated.
>>> - *
>>> - * @param unit the desired time unit of the result
>>> - * @return the time limit
>>> - * @see #setKeepAliveTime
>>> - */
>>> - public long getKeepAliveTime(TimeUnit unit);
>>> -
>>> - /**
>>> - * Sets the time limit for which threads may remain idle before
>>> - * being terminated. If there are more than the core number of
>>> - * threads currently in the pool, after waiting this amount of
>>> - * time without processing a task, excess threads will be
>>> - * terminated. This overrides any value set in the
>>> constructor.
>>> - * @param time the time to wait. A time value of zero will
>>> cause
>>> - * excess threads to terminate immediately after executing
>>> tasks.
>>> - * @param unit the time unit of the time argument
>>> - * @throws IllegalArgumentException if time less than zero
>>> - * @see #getKeepAliveTime
>>> - */
>>> - public void setKeepAliveTime(long time, TimeUnit unit);
>>> -
>>> - /**
>>> - * Returns the maximum allowed number of threads.
>>> - *
>>> - * @return the maximum allowed number of threads
>>> - * @see #setMaximumPoolSize
>>> - */
>>> - public int getMaximumPoolSize();
>>> -
>>> - /**
>>> - * Sets the maximum allowed number of threads. This overrides
>>> any
>>> - * value set in the constructor. If the new value is smaller
>>> than
>>> - * the current value, excess existing threads will be
>>> - * terminated when they next become idle.
>>> - *
>>> - * @param maximumPoolSize the new maximum
>>> - * @throws IllegalArgumentException if maximumPoolSize less
>>> than zero or
>>> - * the {_at_link #getCorePoolSize core pool size}
>>> - * @see #getMaximumPoolSize
>>> - */
>>> - public void setMaximumPoolSize(int maximumPoolSize);
>>> -
>>> - public int getMaxQueuedTasksCount();
>>> -
>>> - public void setMaxQueuedTasksCount(int maxTasksCount);
>>> -
>>> - public String getName();
>>> -
>>> - public void setName(String name);
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> CallbackHandlerSelectionKeyAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> CallbackHandlerSelectionKeyAttachment.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> CallbackHandlerSelectionKeyAttachment.java (working copy)
>>> @@ -1,101 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.CallbackHandler;
>>> -import java.nio.channels.SelectionKey;
>>> -import java.util.concurrent.atomic.AtomicReference;
>>> -
>>> -/**
>>> - * {_at_link SelectionKey} attachment, which wraps {_at_link
>>> CallbackHandler}
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class CallbackHandlerSelectionKeyAttachment extends
>>> SelectionKeyAttachmentWrapper<CallbackHandler> {
>>> - private static
>>> ConcurrentLinkedQueuePool<CallbackHandlerSelectionKeyAttachment>
>>> pool =
>>> - new
>>> ConcurrentLinkedQueuePool<CallbackHandlerSelectionKeyAttachment>() {
>>> -
>>> - @Override
>>> - public CallbackHandlerSelectionKeyAttachment
>>> newInstance() {
>>> - return new
>>> CallbackHandlerSelectionKeyAttachment();
>>> - }
>>> - };
>>> -
>>> - // Is used for key pooling
>>> - private AtomicReference<SelectionKey> associatedKey = new
>>> AtomicReference<SelectionKey>();
>>> -
>>> -
>>> - /**
>>> - * Creates the {_at_link CallbackHandler} to the {_at_link
>>> SelectionKey}
>>> - * CallbackHandler will not be attached directly, but wrapped
>>> with
>>> - * <code>CallbackHandlerSelectionKeyAttachment</code>
>>> - */
>>> - public static CallbackHandlerSelectionKeyAttachment create(
>>> - CallbackHandler callbackHandler) {
>>> - CallbackHandlerSelectionKeyAttachment attachment =
>>> pool.poll();
>>> -
>>> - attachment.setAttachment(callbackHandler);
>>> - return attachment;
>>> - }
>>> -
>>> - private CallbackHandlerSelectionKeyAttachment() {
>>> - }
>>> -
>>> - public void associateKey(SelectionKey selectionKey) {
>>> - associatedKey.set(selectionKey);
>>> - }
>>> -
>>> - @Override
>>> - public void release(SelectionKey selectionKey) {
>>> - if (associatedKey.getAndSet(null) == selectionKey) {
>>> - super.release(selectionKey);
>>> - pool.offer(this);
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Callback handler never should lead to the timeout situation,
>>> - * as connections could use it, but perform IO operations in
>>> sync. mode.
>>> - * @return null
>>> - */
>>> - @Override
>>> - public Long getTimeout() {
>>> - return null;
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLUtils.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLUtils.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SSLUtils.java (working copy)
>>> @@ -1,646 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Controller;
>>> -import java.io.ByteArrayInputStream;
>>> -import java.io.EOFException;
>>> -import java.io.IOException;
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.SelectableChannel;
>>> -import java.security.cert.Certificate;
>>> -import java.security.cert.CertificateFactory;
>>> -import java.security.cert.X509Certificate;
>>> -import java.util.logging.Level;
>>> -import java.util.logging.Logger;
>>> -import javax.net.ssl.SSLEngine;
>>> -import javax.net.ssl.SSLEngineResult;
>>> -import javax.net.ssl.SSLEngineResult.HandshakeStatus;
>>> -import javax.net.ssl.SSLEngineResult.Status;
>>> -
>>> -/**
>>> - * SSL over NIO utility class. The class handle the SSLEngine
>>> operations
>>> - * needed to support SSL over NIO.
>>> - *
>>> - * TODO: Create an object that Wrap SSLEngine and its associated
>>> buffers.
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public class SSLUtils {
>>> -
>>> - /**
>>> - * The maximum size a ByteBuffer can take.
>>> - */
>>> - public final static int MAX_BB_SIZE = 48 * 4096;
>>> -
>>> -
>>> - /*
>>> - * An empty ByteBuffer used for handshaking
>>> - */
>>> - protected final static ByteBuffer hsBB =
>>> ByteBuffer.allocate(0);
>>> -
>>> -
>>> - /**
>>> - * The time to wait before timing out when reading bytes
>>> - */
>>> - private static int readTimeout = 30000;
>>> -
>>> -
>>> - /**
>>> - * Read and decrypt bytes from the underlying SSL connections.
>>> - * @param socketChannel underlying socket channel
>>> - * @param sslEngine{_at_link SSLEngine}
>>> - * @param byteBuffer buffer for application decrypted data
>>> - * @param inputBB buffer for reading enrypted data from socket
>>> - * @return number of bytes read
>>> - * @throws java.io.IOException
>>> - */
>>> - public static int doSecureRead(SelectableChannel channel,
>>> SSLEngine sslEngine,
>>> - ByteBuffer byteBuffer, ByteBuffer inputBB) throws
>>> IOException {
>>> -
>>> - int initialPosition = byteBuffer.position();
>>> - int byteRead = 0;
>>> -
>>> - // We need to make sure the unwrap worked properly and we
>>> have all
>>> - // the packets properly read. If the SSLEngine fail to
>>> unwrap all the
>>> - // bytes, the byteBuffer will be empty event if some
>>> encrypted bytes
>>> - // are available.
>>> - while (byteBuffer.position() == initialPosition){
>>> - int currentRead = SSLUtils.doRead(channel, inputBB,
>>> - sslEngine,readTimeout);
>>> -
>>> - if (currentRead > 0) {
>>> - byteRead += currentRead;
>>> - }
>>> -
>>> - if (currentRead > 0 || inputBB.position() > 0) {
>>> - try{
>>> - byteBuffer = SSLUtils.unwrapAll(byteBuffer,
>>> - inputBB, sslEngine);
>>> -
>>> - if (currentRead == -1 &&
>>> - byteBuffer.position() ==
>>> initialPosition) {
>>> - // if last read was -1 and unwrap decoded
>>> nothing then return -1
>>> - byteRead = -1;
>>> - break;
>>> - }
>>> - } catch (IOException ex){
>>> - Logger logger = Controller.logger();
>>> - if ( logger.isLoggable(Level.FINE) )
>>> -
>>> logger.log(Level.FINE,"SSLUtils.unwrapAll",ex);
>>> - return -1;
>>> - }
>>> - } else if (currentRead == -1) {
>>> - byteRead = -1;
>>> - break;
>>> - } else {
>>> - break;
>>> - }
>>> - }
>>> -
>>> - return byteRead;
>>> - }
>>> -
>>> - /**
>>> - * Read encrypted bytes using an{_at_link SSLEngine}.
>>> - * @param channel The {_at_link SelectableChannel}
>>> - * @param inputBB The byteBuffer to store encrypted bytes
>>> - * @param sslEngine The{_at_link SSLEngine} uses to manage the
>>> - * SSL operations.
>>> - * @param timeout The Selector.select() timeout value. A
>>> value of 0 will
>>> - * be exectuted as a Selector.selectNow();
>>> - * @return the bytes read.
>>> - */
>>> - public static int doRead(SelectableChannel channel,
>>> ByteBuffer inputBB,
>>> - SSLEngine sslEngine, int timeout) {
>>> -
>>> - if (channel == null) return -1;
>>> -
>>> - try {
>>> - int bytesRead =
>>> Utils.readWithTemporarySelector(channel,
>>> - inputBB, timeout);
>>> -
>>> - if (bytesRead == -1) {
>>> - try {
>>> - sslEngine.closeInbound();
>>> - } catch (IOException ex) {
>>> - }
>>> - }
>>> -
>>> - return bytesRead;
>>> - } catch (Throwable t){
>>> - Logger logger = Controller.logger();
>>> - if ( logger.isLoggable(Level.FINEST) ){
>>> - logger.log(Level.FINEST,"doRead",t);
>>> - }
>>> - return -1;
>>> - }
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Unwrap all encrypted bytes from <code>inputBB</code> to
>>> - * {_at_link ByteBuffer} using the{_at_link SSLEngine}
>>> - * @param byteBuffer the decrypted ByteBuffer
>>> - * @param inputBB the encrypted ByteBuffer
>>> - * @param sslEngine The SSLEngine used to manage the SSL
>>> operations.
>>> - * @return the decrypted ByteBuffer
>>> - * @throws java.io.IOException
>>> - */
>>> - public static ByteBuffer unwrapAll(ByteBuffer byteBuffer,
>>> - ByteBuffer inputBB, SSLEngine sslEngine) throws
>>> IOException{
>>> -
>>> - SSLEngineResult result = null;
>>> - do{
>>> - try{
>>> - result = unwrap(byteBuffer,inputBB,sslEngine);
>>> - } catch (Throwable ex){
>>> - Logger logger = Controller.logger();
>>> - if ( logger.isLoggable(Level.FINE) ){
>>> - logger.log(Level.FINE,"unwrap",ex);
>>> - }
>>> - inputBB.compact();
>>> - }
>>> -
>>> - if (result != null){
>>> - switch (result.getStatus()) {
>>> -
>>> - case BUFFER_UNDERFLOW:
>>> - case CLOSED:
>>> - // Closed or need more data.
>>> - break;
>>> - case OK:
>>> - if (result.getHandshakeStatus()
>>> - == HandshakeStatus.NEED_TASK) {
>>> - executeDelegatedTask(sslEngine);
>>> - }
>>> - break;
>>> - case BUFFER_OVERFLOW:
>>> - byteBuffer = reallocate(byteBuffer);
>>> - break;
>>> - default:
>>> - throw new
>>> - IOException("Unwrap error: "+
>>> result.getStatus());
>>> - }
>>> - }
>>> - } while (inputBB.position() > 0 && result!= null &&
>>> - result.getStatus() != Status.BUFFER_UNDERFLOW);
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Unwrap available encrypted bytes from <code>inputBB</code>
>>> to
>>> - * {_at_link ByteBuffer} using the{_at_link SSLEngine}
>>> - * @param byteBuffer the decrypted ByteBuffer
>>> - * @param inputBB the encrypted ByteBuffer
>>> - * @param sslEngine The SSLEngine used to manage the SSL
>>> operations.
>>> - * @return SSLEngineResult of the SSLEngine.unwrap operation.
>>> - * @throws java.io.IOException
>>> - */
>>> - public static SSLEngineResult unwrap(ByteBuffer byteBuffer,
>>> - ByteBuffer inputBB, SSLEngine sslEngine) throws
>>> IOException{
>>> -
>>> - // Logging block
>>> - if (Controller.logger().isLoggable(Level.FINE)) {
>>> - Controller.logger().log(Level.FINE, "start unwrap.
>>> engine: " +
>>> - sslEngine + " buffer: " +
>>> - byteBuffer + " secured: " + inputBB);
>>> - if (Controller.logger().isLoggable(Level.FINER)) {
>>> - StackTraceElement[] stackTraceElements =
>>> Thread.currentThread().getStackTrace();
>>> - StringBuilder buffer = new StringBuilder();
>>> - for (StackTraceElement element :
>>> stackTraceElements) {
>>> - buffer.append('\n');
>>> - buffer.append(element);
>>> - }
>>> -
>>> - Controller.logger().log(Level.FINER,
>>> buffer.toString());
>>> - }
>>> - }
>>> -
>>> - inputBB.flip();
>>> - SSLEngineResult result = sslEngine.unwrap(inputBB,
>>> byteBuffer);
>>> - inputBB.compact();
>>> -
>>> - // Logging block
>>> - if (Controller.logger().isLoggable(Level.FINE)) {
>>> - int bytesProduced = result.bytesProduced();
>>> - Controller.logger().log(Level.FINE, "after unwrap.
>>> engine: " +
>>> - sslEngine + " buffer: " +
>>> - byteBuffer + " secured: " + inputBB + "
>>> consumed: " +
>>> - result.bytesConsumed() + " produced: " +
>>> bytesProduced +
>>> - " status: " + result.getStatus() +
>>> - " handshakeStatus: " +
>>> result.getHandshakeStatus());
>>> - if (bytesProduced > 0 &&
>>> Controller.logger().isLoggable(Level.FINER)) {
>>> - byteBuffer.position(byteBuffer.position() -
>>> bytesProduced);
>>> - byte[] producedBytes = new byte[bytesProduced];
>>> - byteBuffer.get(producedBytes);
>>> - Controller.logger().log(Level.FINER, new
>>> String(producedBytes));
>>> - }
>>> - }
>>> -
>>> - return result;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Encrypt bytes.
>>> - * @param byteBuffer the decrypted ByteBuffer
>>> - * @param outputBB the encrypted ByteBuffer
>>> - * @param sslEngine The SSLEngine used to manage the SSL
>>> operations.
>>> - * @return SSLEngineResult of the SSLEngine.wrap operation.
>>> - * @throws java.io.IOException
>>> - */
>>> - public static SSLEngineResult wrap(ByteBuffer byteBuffer,
>>> - ByteBuffer outputBB, SSLEngine sslEngine) throws
>>> IOException {
>>> -
>>> - outputBB.clear();
>>> - SSLEngineResult result = sslEngine.wrap(byteBuffer,
>>> outputBB);
>>> - outputBB.flip();
>>> - return result;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Resize a ByteBuffer.
>>> - * @param byteBuffer {_at_link ByteBuffer} to re-allocate
>>> - * @return {_at_link ByteBuffer} reallocted
>>> - * @throws java.io.IOException
>>> - */
>>> - private static ByteBuffer reallocate(ByteBuffer byteBuffer)
>>> - throws IOException{
>>> -
>>> - if (byteBuffer.capacity() > MAX_BB_SIZE){
>>> - throw new IOException("Unwrap error: BUFFER_OVERFLOW");
>>> - }
>>> - ByteBuffer tmp =
>>> ByteBuffer.allocate(byteBuffer.capacity() * 2);
>>> - byteBuffer.flip();
>>> - tmp.put(byteBuffer);
>>> - byteBuffer = tmp;
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Complete hanshakes operations.
>>> - * @param sslEngine The SSLEngine used to manage the SSL
>>> operations.
>>> - * @return SSLEngineResult.HandshakeStatus
>>> - */
>>> - public static SSLEngineResult.HandshakeStatus
>>> - executeDelegatedTask(SSLEngine sslEngine) {
>>> -
>>> - Runnable runnable;
>>> - while ((runnable = sslEngine.getDelegatedTask()) != null) {
>>> - runnable.run();
>>> - }
>>> - return sslEngine.getHandshakeStatus();
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Perform an SSL handshake using the SSLEngine.
>>> - * Note: If handshake was done successfully - outputBB will
>>> be cleared out,
>>> - * but this is *not* ready data to be written.
>>> - *
>>> - * @param channel the {_at_link SelectableChannel}
>>> - * @param byteBuffer The application {_at_link ByteBuffer}
>>> - * @param inputBB The encrypted input {_at_link ByteBuffer}
>>> - * @param outputBB The encrypted output {_at_link ByteBuffer}
>>> - * @param sslEngine The SSLEngine used.
>>> - * @param handshakeStatus The current handshake status
>>> - * @return byteBuffer the new ByteBuffer
>>> - * @throws java.io.IOException
>>> - * @throw IOException if the handshake fail.
>>> - */
>>> - public static ByteBuffer doHandshake(SelectableChannel channel,
>>> - ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer
>>> outputBB,
>>> - SSLEngine sslEngine, HandshakeStatus handshakeStatus)
>>> - throws IOException {
>>> - return doHandshake(channel, byteBuffer, inputBB, outputBB,
>>> - sslEngine, handshakeStatus, readTimeout);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Perform an SSL handshake using the SSLEngine.
>>> - * Note: If handshake was done successfully - outputBB will
>>> be cleared out,
>>> - * but this is *not* ready data to be written.
>>> - *
>>> - * @param channel the {_at_link SelectableChannel}
>>> - * @param byteBuffer The application {_at_link ByteBuffer}
>>> - * @param inputBB The encrypted input {_at_link ByteBuffer}
>>> - * @param outputBB The encrypted output {_at_link ByteBuffer}
>>> - * @param sslEngine The SSLEngine used.
>>> - * @param handshakeStatus The current handshake status
>>> - * @param timeout
>>> - * @return byteBuffer the new ByteBuffer
>>> - * @throws java.io.IOException
>>> - * @throws IOException if the handshake fail.
>>> - */
>>> - public static ByteBuffer doHandshake(SelectableChannel channel,
>>> - ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer
>>> outputBB,
>>> - SSLEngine sslEngine, HandshakeStatus
>>> handshakeStatus,int timeout)
>>> - throws IOException {
>>> - return doHandshake(channel, byteBuffer, inputBB, outputBB,
>>> - sslEngine, handshakeStatus, timeout,
>>> inputBB.position() > 0);
>>> - }
>>> -
>>> - /**
>>> - * Perform an SSL handshake using the SSLEngine.
>>> - * Note: If handshake was done successfully - outputBB will
>>> be cleared out,
>>> - * but this is *not* ready data to be written.
>>> - *
>>> - * @param channel the {_at_link SelectableChannel}
>>> - * @param byteBuffer The application {_at_link ByteBuffer}
>>> - * @param inputBB The encrypted input {_at_link ByteBuffer}
>>> - * @param outputBB The encrypted output {_at_link ByteBuffer}
>>> - * @param sslEngine The SSLEngine used.
>>> - * @param handshakeStatus The current handshake status
>>> - * @param timeout
>>> - * @param useReadyBuffer does method need to read data before
>>> UNWRAP or use
>>> - * a data from inputBB
>>> - * @return byteBuffer the new ByteBuffer
>>> - * @throws java.io.IOException
>>> - * @throws IOException if the handshake fail.
>>> - */
>>> - public static ByteBuffer doHandshake(SelectableChannel channel,
>>> - ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer
>>> outputBB,
>>> - SSLEngine sslEngine, HandshakeStatus handshakeStatus,
>>> - int timeout,boolean useReadyBuffer)
>>> - throws IOException {
>>> -
>>> - SSLEngineResult result;
>>> - int eof = timeout > 0 ? 0 : -1;
>>> - while (handshakeStatus != HandshakeStatus.FINISHED){
>>> - switch (handshakeStatus) {
>>> - case NEED_UNWRAP:
>>> - if (!useReadyBuffer) {
>>> - if (doRead(channel, inputBB, sslEngine,
>>> timeout) <= eof) {
>>> - try {
>>> - sslEngine.closeInbound();
>>> - } catch (IOException ex) {
>>> - Logger logger =
>>> Controller.logger();
>>> - if
>>> (logger.isLoggable(Level.FINE)) {
>>> - logger.log(Level.FINE,
>>> "closeInbound", ex);
>>> - }
>>> - }
>>> - throw new EOFException("Connection
>>> closed");
>>> - }
>>> - } else {
>>> - useReadyBuffer = false;
>>> - }
>>> -
>>> - while (handshakeStatus ==
>>> HandshakeStatus.NEED_UNWRAP) {
>>> - result =
>>> unwrap(byteBuffer,inputBB,sslEngine);
>>> - handshakeStatus =
>>> result.getHandshakeStatus();
>>> -
>>> - if (result.getStatus() ==
>>> Status.BUFFER_UNDERFLOW){
>>> - break;
>>> - }
>>> -
>>> - switch (result.getStatus()) {
>>> - case OK:
>>> - switch (handshakeStatus) {
>>> - case NOT_HANDSHAKING:
>>> - throw new IOException("No
>>> Hanshake");
>>> -
>>> - case NEED_TASK:
>>> - handshakeStatus =
>>> -
>>> executeDelegatedTask(sslEngine);
>>> - break;
>>> -
>>> - case FINISHED:
>>> - return byteBuffer;
>>> - }
>>> - break;
>>> - case BUFFER_OVERFLOW:
>>> - byteBuffer =
>>> reallocate(byteBuffer);
>>> - break;
>>> - default:
>>> - throw new IOException("Handshake
>>> exception: " +
>>> - result.getStatus());
>>> - }
>>> - }
>>> -
>>> - if (handshakeStatus !=
>>> HandshakeStatus.NEED_WRAP) {
>>> - break;
>>> - }
>>> - case NEED_WRAP:
>>> - result = wrap(hsBB,outputBB,sslEngine);
>>> - handshakeStatus = result.getHandshakeStatus();
>>> - switch (result.getStatus()) {
>>> - case OK:
>>> -
>>> - if (handshakeStatus ==
>>> HandshakeStatus.NEED_TASK) {
>>> - handshakeStatus =
>>> executeDelegatedTask(sslEngine);
>>> - }
>>> -
>>> - // Flush all Server bytes to the
>>> client.
>>> - if (channel != null) {
>>> - OutputWriter.flushChannel(
>>> - channel, outputBB);
>>> - outputBB.clear();
>>> - }
>>> - break;
>>> - default:
>>> - throw new IOException("Handshaking
>>> error: "
>>> - + result.getStatus());
>>> - }
>>> - break;
>>> - default:
>>> - throw new RuntimeException("Invalid
>>> Handshaking State" +
>>> - handshakeStatus);
>>> - }
>>> - }
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Get the peer certificate list by initiating a new handshake.
>>> - * @param channel {_at_link SelectableChannel}
>>> - * @param needClientAuth
>>> - * @return Object[] An array of X509Certificate.
>>> - * @throws java.io.IOException
>>> - */
>>> - public static Object[]
>>> doPeerCertificateChain(SelectableChannel channel,
>>> - ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer
>>> outputBB,
>>> - SSLEngine sslEngine, boolean needClientAuth, int
>>> timeout) throws IOException {
>>> -
>>> - Logger logger = Controller.logger();
>>> -
>>> - Certificate[] certs=null;
>>> - try {
>>> - certs = sslEngine.getSession().getPeerCertificates();
>>> - } catch( Throwable t ) {
>>> - if ( logger.isLoggable(Level.FINE))
>>> - logger.log(Level.FINE,"Error getting client
>>> certs",t);
>>> - }
>>> -
>>> - if (certs == null && needClientAuth){
>>> - sslEngine.getSession().invalidate();
>>> - sslEngine.setNeedClientAuth(true);
>>> - sslEngine.beginHandshake();
>>> -
>>> - ByteBuffer origBB = byteBuffer;
>>> - // In case the application hasn't read all the body
>>> bytes.
>>> - if ( origBB.position() != origBB.limit() ){
>>> - byteBuffer =
>>> ByteBuffer.allocate(origBB.capacity());
>>> - } else {
>>> - byteBuffer.clear();
>>> - }
>>> - outputBB.position(0);
>>> - outputBB.limit(0);
>>> -
>>> - // We invalidate ssl seesion, so no need for unwrap
>>> - try{
>>> - doHandshake(channel, byteBuffer, inputBB, outputBB,
>>> - sslEngine, HandshakeStatus.NEED_WRAP,
>>> timeout);
>>> - } catch (Throwable ex){
>>> - if ( logger.isLoggable(Level.FINE))
>>> - logger.log(Level.FINE,"Error during
>>> handshake",ex);
>>> - return null;
>>> - } finally {
>>> - byteBuffer = origBB;
>>> - byteBuffer.clear();
>>> - }
>>> -
>>> - try {
>>> - certs =
>>> sslEngine.getSession().getPeerCertificates();
>>> - } catch( Throwable t ) {
>>> - if ( logger.isLoggable(Level.FINE))
>>> - logger.log(Level.FINE,"Error getting client
>>> certs",t);
>>> - }
>>> - }
>>> -
>>> - if( certs==null ) return null;
>>> -
>>> - X509Certificate[] x509Certs = new
>>> X509Certificate[certs.length];
>>> - for(int i=0; i < certs.length; i++) {
>>> - if( certs[i] instanceof X509Certificate ) {
>>> - x509Certs[i] = (X509Certificate)certs[i];
>>> - } else {
>>> - try {
>>> - byte [] buffer = certs[i].getEncoded();
>>> - CertificateFactory cf =
>>> - CertificateFactory.getInstance("X.509");
>>> - ByteArrayInputStream stream = new
>>> ByteArrayInputStream(buffer);
>>> - x509Certs[i] = (X509Certificate)
>>> - cf.generateCertificate(stream);
>>> - } catch(Exception ex) {
>>> - logger.log(Level.INFO,"Error translating cert
>>> " + certs[i],
>>> - ex);
>>> - return null;
>>> - }
>>> - }
>>> -
>>> - if(logger.isLoggable(Level.FINE))
>>> - logger.log(Level.FINE,"Cert #" + i + " = " +
>>> x509Certs[i]);
>>> - }
>>> -
>>> - if(x509Certs.length < 1)
>>> - return null;
>>> -
>>> - return x509Certs;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Allocate themandatory {_at_link ByteBuffer}s. Since the
>>> ByteBuffer
>>> - * are maintaned on the {_at_link WorkerThread} lazily, this
>>> method
>>> - * makes sure the ByteBuffers are properly allocated and
>>> configured.
>>> - */
>>> - public static void allocateThreadBuffers(int
>>> defaultBufferSize) {
>>> - final WorkerThread workerThread =
>>> - (WorkerThread)Thread.currentThread();
>>> - ByteBuffer byteBuffer = workerThread.getByteBuffer();
>>> - ByteBuffer outputBB = workerThread.getOutputBB();
>>> - ByteBuffer inputBB = workerThread.getInputBB();
>>> -
>>> - int expectedSize = workerThread.getSSLEngine().getSession()
>>> - .getPacketBufferSize();
>>> - if (defaultBufferSize < expectedSize){
>>> - defaultBufferSize = expectedSize;
>>> - }
>>> -
>>> - if (inputBB != null && inputBB.capacity() <
>>> defaultBufferSize) {
>>> - ByteBuffer newBB =
>>> ByteBuffer.allocate(defaultBufferSize);
>>> - inputBB.flip();
>>> - newBB.put(inputBB);
>>> - inputBB = newBB;
>>> - } else if (inputBB == null){
>>> - inputBB = ByteBuffer.allocate(defaultBufferSize);
>>> - }
>>> -
>>> - if (outputBB == null) {
>>> - outputBB = ByteBuffer.allocate(defaultBufferSize);
>>> - }
>>> -
>>> - if (byteBuffer == null){
>>> - byteBuffer = ByteBuffer.allocate(defaultBufferSize *
>>> 2);
>>> - }
>>> -
>>> - expectedSize = workerThread.getSSLEngine().getSession()
>>> - .getApplicationBufferSize();
>>> - if ( expectedSize > byteBuffer.capacity() ) {
>>> - ByteBuffer newBB = ByteBuffer.allocate(expectedSize);
>>> - byteBuffer.flip();
>>> - newBB.put(byteBuffer);
>>> - byteBuffer = newBB;
>>> - }
>>> -
>>> - workerThread.setInputBB(inputBB);
>>> - workerThread.setOutputBB(outputBB);
>>> - workerThread.setByteBuffer(byteBuffer);
>>> -
>>> - outputBB.position(0);
>>> - outputBB.limit(0);
>>> - }
>>> -
>>> -
>>> - public static int getReadTimeout() {
>>> - return readTimeout;
>>> - }
>>> -
>>> -
>>> - public static void setReadTimeout(int aReadTimeout) {
>>> - readTimeout = aReadTimeout;
>>> - }
>>> -
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConnectionCloseHandler.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConnectionCloseHandler.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ConnectionCloseHandler.java (working copy)
>>> @@ -1,73 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Handler;
>>> -import java.nio.channels.SelectionKey;
>>> -
>>> -/**
>>> - * Simple listener to be used when an application needs to be
>>> notified when a
>>> - * a {_at_link SelectorHandler}, {_at_link ConnectionHandler} or {_at_link
>>> SelectionKeyHandler}
>>> - * close a connection ({_at_link
>>> ConnectionCloseHandler#locallyClosed}), or when a
>>> - * remote client close the connection ({_at_link
>>> ConnectionCloseHandler#remotlyClosed}).
>>> - *
>>> - * Note that when the connection is closed remotly, the ({_at_link
>>> ConnectionCloseHandler#remotlyClosed})
>>> - * will be invoked immediately followed by a ({_at_link
>>> ConnectionCloseHandler#locallyClosed}), as
>>> - * Grizzly will discard the server side dirty {_at_link SelectionKey}.
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public interface ConnectionCloseHandler extends Handler {
>>> -
>>> - /**
>>> - * Invoked when the a {_at_link SelectionKey} is cancelled
>>> locally, e.g. by
>>> - * one {_at_link SelectorHandler}, {_at_link ConnectionHandler} or
>>> {_at_link SelectionKeyHandler}
>>> - *
>>> - * @param key a {_at_link SelectionKey}
>>> - */
>>> - void locallyClosed(SelectionKey key);
>>> -
>>> -
>>> - /**
>>> - * Invoked when a remote connection is being closed.
>>> - *
>>> - * @param key a {_at_link SelectionKey}
>>> - */
>>> - void remotlyClosed(SelectionKey key);
>>> -
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferFactory.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferFactory.java (working copy)
>>> @@ -1,148 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.ByteBuffer;
>>> -
>>> -
>>> -/**
>>> - * Factory class used to create {_at_link ByteBuffer}.
>>> - *
>>> - * The ByteBuffer can by direct (ByteBufferType.DIRECT) or heap
>>> (ByteBufferType.HEAP)
>>> - * a view (ByteBufferType.DIRECT_VIEW) or ByteBufferType.HEAP_VIEW)
>>> - * or backed by an array (ByteBufferType.HEAP_ARRAY).
>>> - *
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public class ByteBufferFactory{
>>> -
>>> - /**
>>> - * An enumeration of all type of ByteBuffer this object can
>>> create.
>>> - */
>>> - public enum ByteBufferType { DIRECT, HEAP, DIRECT_VIEW,
>>> HEAP_VIEW, HEAP_ARRAY }
>>> -
>>> -
>>> - /**
>>> - * The default capacity of the default view of a {_at_link
>>> ByteBuffer}
>>> - */
>>> - public static int defaultCapacity = 8192;
>>> -
>>> -
>>> - /**
>>> - * The default capacity of the {_at_link ByteBuffer} from which
>>> views
>>> - * will be created.
>>> - */
>>> - public static int capacity = 4000000;
>>> -
>>> -
>>> - /**
>>> - * The {_at_link ByteBuffer} used to create direct byteBuffer
>>> view.
>>> - */
>>> - private static ByteBuffer directByteBuffer;
>>> -
>>> -
>>> - /**
>>> - * The {_at_link ByteBuffer} used to create direct byteBuffer
>>> view.
>>> - */
>>> - private static ByteBuffer heapByteBuffer;
>>> -
>>> -
>>> - /**
>>> - * Private constructor.
>>> - */
>>> - private ByteBufferFactory(){
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return a direct {_at_link ByteBuffer} view
>>> - * @param size the Size of the {_at_link ByteBuffer}
>>> - * @param direct - direct or non-direct buffer?
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public synchronized static ByteBuffer allocateView(int size,
>>> boolean direct){
>>> - if (direct && (directByteBuffer == null ||
>>> - (directByteBuffer.capacity() -
>>> directByteBuffer.limit() < size))){
>>> - directByteBuffer = ByteBuffer.allocateDirect(capacity);
>>> - } else if (heapByteBuffer == null ||
>>> - (heapByteBuffer.capacity() -
>>> heapByteBuffer.limit() < size)){
>>> - heapByteBuffer = ByteBuffer.allocate(capacity);
>>> - }
>>> - ByteBuffer byteBuffer = (direct ? directByteBuffer :
>>> heapByteBuffer);
>>> -
>>> - byteBuffer.limit(byteBuffer.position() + size);
>>> - ByteBuffer view = byteBuffer.slice();
>>> - byteBuffer.position(byteBuffer.limit());
>>> -
>>> - return view;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return a direct {_at_link ByteBuffer} view using the default
>>> size.
>>> - * @param direct - direct or non-direct buffer
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public synchronized static ByteBuffer allocateView(boolean
>>> direct){
>>> - return allocateView(defaultCapacity, direct);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return a new ByteBuffer based on the requested
>>> <code>ByteBufferType</code>
>>> - * @param type the requested <code>ByteBufferType</code>
>>> - * @param size the {_at_link ByteBuffer} size.
>>> - * @return a new ByteBuffer based on the requested
>>> <code>ByteBufferType</code>
>>> - */
>>> - public static ByteBuffer allocate(ByteBufferType type,int
>>> size){
>>> - if (type == ByteBufferType.HEAP){
>>> - return ByteBuffer.allocate(size);
>>> - } else if (type == ByteBufferType.HEAP_VIEW) {
>>> - return allocateView(size,false);
>>> - } else if (type == ByteBufferType.HEAP_ARRAY) {
>>> - return ByteBuffer.wrap(new byte[size]);
>>> - } else if (type == ByteBufferType.DIRECT){
>>> - return ByteBuffer.allocateDirect(size);
>>> - } else if (type == ByteBufferType.DIRECT_VIEW){
>>> - return allocateView(size,true);
>>> - } else {
>>> - throw new IllegalStateException("Invalid ByteBuffer
>>> Type");
>>> - }
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyOP.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyOP.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyOP.java (working copy)
>>> @@ -1,169 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.CallbackHandler;
>>> -import java.net.SocketAddress;
>>> -import java.nio.channels.SelectableChannel;
>>> -import java.nio.channels.SelectionKey;
>>> -
>>> -/**
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class SelectionKeyOP {
>>> - private int op;
>>> - private SelectionKey key;
>>> - private SelectableChannel channel;
>>> -
>>> - private static ConcurrentLinkedQueuePool<SelectionKeyOP>
>>> readWritePool =
>>> - new ConcurrentLinkedQueuePool<SelectionKeyOP>() {
>>> - @Override
>>> - public SelectionKeyOP newInstance() {
>>> - return new SelectionKeyOP();
>>> - }
>>> - };
>>> -
>>> - private static ConcurrentLinkedQueuePool<SelectionKeyOP>
>>> connectPool =
>>> - new ConcurrentLinkedQueuePool<SelectionKeyOP>() {
>>> - @Override
>>> - public SelectionKeyOP newInstance() {
>>> - return new ConnectSelectionKeyOP();
>>> - }
>>> - };
>>> -
>>> - public static SelectionKeyOP aquireSelectionKeyOP(int op) {
>>> - if (op == SelectionKey.OP_READ || op ==
>>> SelectionKey.OP_WRITE ||
>>> - op == (SelectionKey.OP_WRITE |
>>> SelectionKey.OP_READ)) {
>>> - SelectionKeyOP operation = readWritePool.poll();
>>> - return operation;
>>> - } else if (op == SelectionKey.OP_CONNECT) {
>>> - SelectionKeyOP operation = connectPool.poll();
>>> - return operation;
>>> - }
>>> -
>>> - throw new IllegalStateException("Unknown operation or
>>> operation is not supported");
>>> - }
>>> -
>>> - public static void releaseSelectionKeyOP(SelectionKeyOP
>>> operation) {
>>> - int op = operation.op;
>>> - operation.recycle();
>>> -
>>> - if (op == SelectionKey.OP_READ || op ==
>>> SelectionKey.OP_WRITE ||
>>> - op == (SelectionKey.OP_WRITE |
>>> SelectionKey.OP_READ)) {
>>> - readWritePool.offer(operation);
>>> - return;
>>> - } else if (op == SelectionKey.OP_CONNECT) {
>>> - connectPool.offer(operation);
>>> - return;
>>> - }
>>> -
>>> - throw new IllegalStateException("Unknown operation or
>>> operation is not supported");
>>> - }
>>> -
>>> - private SelectionKeyOP() {
>>> - }
>>> -
>>> - public int getOp() {
>>> - return op;
>>> - }
>>> -
>>> - public void setOp(int op) {
>>> - this.op = op;
>>> - }
>>> -
>>> - public SelectionKey getSelectionKey() {
>>> - return key;
>>> - }
>>> -
>>> - public void setSelectionKey(SelectionKey key) {
>>> - this.key = key;
>>> - }
>>> -
>>> - public SelectableChannel getChannel() {
>>> - return channel;
>>> - }
>>> -
>>> - public void setChannel(SelectableChannel channel) {
>>> - this.channel = channel;
>>> - }
>>> -
>>> - protected void recycle() {
>>> - op = 0;
>>> - key = null;
>>> - channel = null;
>>> - }
>>> -
>>> - public static class ConnectSelectionKeyOP extends
>>> SelectionKeyOP {
>>> - private SocketAddress localAddress;
>>> - private SocketAddress remoteAddress;
>>> - private CallbackHandler callbackHandler;
>>> -
>>> - public SocketAddress getLocalAddress() {
>>> - return localAddress;
>>> - }
>>> -
>>> - public void setLocalAddress(SocketAddress localAddress) {
>>> - this.localAddress = localAddress;
>>> - }
>>> -
>>> - public SocketAddress getRemoteAddress() {
>>> - return remoteAddress;
>>> - }
>>> -
>>> - public void setRemoteAddress(SocketAddress remoteAddress) {
>>> - this.remoteAddress = remoteAddress;
>>> - }
>>> -
>>> - public CallbackHandler getCallbackHandler() {
>>> - return callbackHandler;
>>> - }
>>> -
>>> - public void setCallbackHandler(CallbackHandler
>>> callbackHandler) {
>>> - this.callbackHandler = callbackHandler;
>>> - }
>>> -
>>> - @Override
>>> - protected void recycle() {
>>> - localAddress = null;
>>> - remoteAddress = null;
>>> - callbackHandler = null;
>>> - }
>>> - }
>>> -}
>>> \ No newline at end of file
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Copyable.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Copyable.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Copyable.java (working copy)
>>> @@ -1,54 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -/**
>>> - * Copyable objects are able to copy their content to
>>> - * other objects of the same type
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public interface Copyable {
>>> - /**
>>> - * Copies current object content to copy object
>>> - *
>>> - * @param copy represents target object, where current
>>> object's content will be copied
>>> - */
>>> - public void copyTo(Copyable copy);
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Interceptor.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Interceptor.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Interceptor.java (working copy)
>>> @@ -1,98 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.IOException;
>>> -import java.nio.channels.Channel;
>>> -
>>> -/**
>>> - * Simple interception hook used to trap events inside Grizzly
>>> core.
>>> - *
>>> - * @param E type of Interceptor handler
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public interface Interceptor<E,F extends Channel>{
>>> -
>>> - /**
>>> - * Continue the processing
>>> - */
>>> - public final static int CONTINUE = 0;
>>> -
>>> -
>>> - /**
>>> - * Do not continue the processing.
>>> - */
>>> - public final static int BREAK = 1;
>>> -
>>> -
>>> - /**
>>> - * The request line has been parsed
>>> - */
>>> - public final static int REQUEST_LINE_PARSED = 0;
>>> -
>>> -
>>> - /**
>>> - * The response has been proceeded.
>>> - */
>>> - public final static int RESPONSE_PROCEEDED = 1;
>>> -
>>> -
>>> - /**
>>> - * The request has been buffered.
>>> - */
>>> - public final static int REQUEST_BUFFERED = 2;
>>> -
>>> -
>>> - /**
>>> - * Handle <E> and the associated handler code.
>>> - * @param e
>>> - * @param handlerCode
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public int handle(E e, int handlerCode) throws IOException;
>>> -
>>> -
>>> - /**
>>> - * The {_at_link Channel} associated with this handler.
>>> - * @param socketChannel
>>> - */
>>> - public void attachChannel(F channel);
>>> -
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyActionAttachment.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyActionAttachment.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyActionAttachment.java (working copy)
>>> @@ -1,53 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.channels.SelectionKey;
>>> -
>>> -/**
>>> - * Class represents extended version of {_at_link
>>> SelectionKeyAttachment},
>>> - * and introduces process method, which will be called by
>>> framework once
>>> - * {_at_link SelectionKey} has some ready event, before actual event
>>> processing.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public abstract class SelectionKeyActionAttachment extends
>>> SelectionKeyAttachment {
>>> - public abstract void process(SelectionKey selectionKey);
>>> - public abstract void postProcess(SelectionKey selectionKey);
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> DefaultThreadPool.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> DefaultThreadPool.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> DefaultThreadPool.java (working copy)
>>> @@ -1,208 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Controller;
>>> -import com.sun.grizzly.util.ByteBufferFactory.ByteBufferType;
>>> -import java.util.concurrent.ExecutorService;
>>> -import java.util.concurrent.LinkedBlockingQueue;
>>> -import java.util.concurrent.ThreadFactory;
>>> -import java.util.concurrent.ThreadPoolExecutor;
>>> -import java.util.concurrent.TimeUnit;
>>> -import java.util.concurrent.atomic.AtomicInteger;
>>> -import java.util.logging.Level;
>>> -
>>> -/**
>>> - * Thread Pool implementation, based on {_at_link ThreadPoolExecutor}
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class DefaultThreadPool extends ThreadPoolExecutor
>>> - implements ExecutorService, ExtendedThreadPool,
>>> - Thread.UncaughtExceptionHandler {
>>> - // Min number of worker threads in a pool
>>> - public static int DEFAULT_MIN_THREAD_COUNT = 5;
>>> -
>>> - // Max number of worker threads in a pool
>>> - public static int DEFAULT_MAX_THREAD_COUNT = 5;
>>> -
>>> - // Max number of tasks thread pool can enqueue
>>> - public static int DEFAULT_MAX_TASKS_QUEUED = Integer.MAX_VALUE;
>>> -
>>> - // Timeout, after which idle thread will be stopped and
>>> excluded from pool
>>> - public static int DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT =
>>> 30000;
>>> -
>>> - protected String name = "Grizzly";
>>> -
>>> - protected int maxTasksCount;
>>> -
>>> - protected AtomicInteger workerThreadCounter = new
>>> AtomicInteger();
>>> -
>>> - /**
>>> - * Threads priority
>>> - */
>>> - protected int priority = Thread.NORM_PRIORITY;
>>> -
>>> - /**
>>> - * The initial ByteBuffer size for newly created WorkerThread
>>> instances
>>> - */
>>> - protected int initialByteBufferSize = 8192;
>>> -
>>> - /**
>>> - * The {_at_link ByteBufferType}
>>> - */
>>> - protected ByteBufferType byteBufferType =
>>> ByteBufferType.HEAP_VIEW;
>>> -
>>> - public DefaultThreadPool() {
>>> - this(DEFAULT_MIN_THREAD_COUNT, DEFAULT_MAX_THREAD_COUNT,
>>> - DEFAULT_MAX_TASKS_QUEUED,
>>> DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT,
>>> - TimeUnit.MILLISECONDS);
>>> - }
>>> -
>>> - public DefaultThreadPool(int corePoolSize, int maximumPoolSize,
>>> - int maxTasksCount, long keepAliveTime, TimeUnit unit) {
>>> - super(corePoolSize, maximumPoolSize, keepAliveTime, unit,
>>> - new LinkedBlockingQueue<Runnable>(maxTasksCount));
>>> - setThreadFactory(new DefaultWorkerThreadFactory());
>>> - this.maxTasksCount = maxTasksCount;
>>> - }
>>> -
>>> - public int getQueuedTasksCount() {
>>> - return getQueue().size();
>>> - }
>>> -
>>> - public int getMaxQueuedTasksCount() {
>>> - return maxTasksCount;
>>> - }
>>> -
>>> - public void setMaxQueuedTasksCount(int maxTasksCount) {
>>> - throw new UnsupportedOperationException("Value could not
>>> be changed!");
>>> - }
>>> -
>>> - public String getName() {
>>> - return name;
>>> - }
>>> -
>>> - public void setName(String name) {
>>> - this.name = name;
>>> - }
>>> -
>>> - public int getPriority() {
>>> - return priority;
>>> - }
>>> -
>>> - public void setPriority(int priority) {
>>> - this.priority = priority;
>>> - }
>>> -
>>> - public int getQueueSize() {
>>> - return getQueue().size();
>>> - }
>>> -
>>> - public ByteBufferType getByteBufferType() {
>>> - return byteBufferType;
>>> - }
>>> -
>>> - public void setByteBufferType(ByteBufferType byteBufferType) {
>>> - this.byteBufferType = byteBufferType;
>>> - }
>>> -
>>> - public int getInitialByteBufferSize() {
>>> - return initialByteBufferSize;
>>> - }
>>> -
>>> - public void setInitialByteBufferSize(int
>>> initialByteBufferSize) {
>>> - this.initialByteBufferSize = initialByteBufferSize;
>>> - }
>>> -
>>> - public void start() {
>>> - this.prestartCoreThread();
>>> - }
>>> -
>>> - public void stop() {
>>> - shutdownNow();
>>> - }
>>> -
>>> - public void uncaughtException(Thread thread, Throwable
>>> throwable) {
>>> - Controller.logger().log(Level.WARNING,
>>> - "Uncaught thread exception. Thread: " + thread,
>>> throwable);
>>> - }
>>> -
>>> - @Override
>>> - protected void beforeExecute(Thread t, Runnable r) {
>>> - ((WorkerThreadImpl) t).createByteBuffer(false);
>>> - }
>>> -
>>> - @Override
>>> - protected void afterExecute(Runnable r, Throwable t) {
>>> - ((WorkerThreadImpl) Thread.currentThread()).reset();
>>> - }
>>> -
>>> - private class DefaultWorkerThreadFactory implements
>>> ThreadFactory {
>>> - public Thread newThread(Runnable r) {
>>> - Thread thread = new
>>> WorkerThreadImpl(DefaultThreadPool.this,
>>> - name + "-WorkerThread(" +
>>> - workerThreadCounter.getAndIncrement() + ")", r,
>>> - initialByteBufferSize);
>>> -
>>> thread.setUncaughtExceptionHandler(DefaultThreadPool.this);
>>> - thread.setPriority(priority);
>>> - return thread;
>>> - }
>>> - }
>>> -
>>> - @Override
>>> - public String toString() {
>>> - StringBuilder builder = new StringBuilder(512);
>>> - builder.append("DefaultThreadPool[");
>>> - injectToStringAttributes(builder);
>>> - builder.append(']');
>>> - return builder.toString();
>>> - }
>>> -
>>> - protected void injectToStringAttributes(StringBuilder sb) {
>>> - sb.append("name=").append(name);
>>> - sb.append(", priority=").append(priority);
>>> - sb.append(", min-threads=").append(getCorePoolSize());
>>> - sb.append(", max-threads=").append(getMaximumPoolSize());
>>> - sb.append(", max-queue-
>>> size=").append(getMaxQueuedTasksCount());
>>> - sb.append(", initial-byte-buffer-
>>> size=").append(initialByteBufferSize);
>>> - sb.append(", byte-buffer-type=").append(byteBufferType);
>>> - sb.append(", is-shutdown=").append(isShutdown());
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachmentWrapper.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachmentWrapper.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectionKeyAttachmentWrapper.java (working copy)
>>> @@ -1,77 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.nio.channels.SelectionKey;
>>> -
>>> -/**
>>> - * {_at_link SelectionKey} attachment utility class.
>>> - * This class could be used as wrapper for custom {_at_link
>>> SelectionKey}
>>> - * attachments, which are not subclasses of
>>> <code>SelectionKeyAttachment</code>
>>> - * class.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class SelectionKeyAttachmentWrapper<E> extends
>>> SelectionKeyActionAttachment {
>>> - private E attachment;
>>> -
>>> - public E getAttachment() {
>>> - return attachment;
>>> - }
>>> -
>>> - public void setAttachment(E attachment) {
>>> - this.attachment = attachment;
>>> - }
>>> -
>>> - @Override
>>> - public void process(SelectionKey selectionKey) {
>>> - // Do nothing by default
>>> - }
>>> -
>>> - @Override
>>> - public void postProcess(SelectionKey selectionKey) {
>>> - // Do nothing by default
>>> - }
>>> -
>>> - @Override
>>> - public void release(SelectionKey selectionKey) {
>>> - attachment = null;
>>> - super.release(selectionKey);
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectorFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectorFactory.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> SelectorFactory.java (working copy)
>>> @@ -1,235 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Controller;
>>> -import java.io.IOException;
>>> -import java.nio.channels.Selector;
>>> -import java.util.EmptyStackException;
>>> -import java.util.Stack;
>>> -import java.util.logging.Level;
>>> -import java.util.logging.Logger;
>>> -
>>> -/**
>>> - * Factory used to dispatch/share {_at_link Selector}.
>>> - *
>>> - * @author Scott Oaks
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public class SelectorFactory{
>>> -
>>> - public static final int DEFAULT_MAX_SELECTORS = 20;
>>> -
>>> - /**
>>> - * The timeout before we exit.
>>> - */
>>> - public static long timeout = 5000;
>>> -
>>> -
>>> - /**
>>> - * The number of {_at_link Selector} to create.
>>> - */
>>> - private static int maxSelectors = DEFAULT_MAX_SELECTORS;
>>> -
>>> -
>>> - /**
>>> - * Cache of {_at_link Selector}
>>> - */
>>> - private final static Stack<Selector> selectors = new
>>> Stack<Selector>();
>>> -
>>> -
>>> - /**
>>> - * have we created the Selector instances.
>>> - */
>>> - private static boolean initialized = false;
>>> -
>>> - /**
>>> - * Set max selector pool size.
>>> - * @param size max pool size
>>> - */
>>> - public final static void setMaxSelectors(int size) throws
>>> IOException {
>>> - synchronized(selectors) {
>>> - if (size > maxSelectors || !initialized) {
>>> - // if not initialized yet - grow cache by size
>>> - if (!initialized) maxSelectors = 0;
>>> -
>>> - grow(size);
>>> - } else if (size < maxSelectors) {
>>> - reduce(size);
>>> - }
>>> -
>>> - maxSelectors = size;
>>> - initialized = true;
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Returns max selector pool size
>>> - * @return max pool size
>>> - */
>>> - public final static int getMaxSelectors() {
>>> - return maxSelectors;
>>> - }
>>> -
>>> - /**
>>> - * Get a exclusive {_at_link Selector}
>>> - * @return {_at_link Selector}
>>> - */
>>> - public final static Selector getSelector() {
>>> - synchronized(selectors) {
>>> - if (!initialized) {
>>> - try {
>>> - setMaxSelectors(maxSelectors);
>>> - } catch (IOException e) {
>>> - Logger logger = Controller.logger();
>>> - if (logger.isLoggable(Level.WARNING)) {
>>> - logger.log(Level.WARNING,
>>> "SelectorFactory lazy initialization", e);
>>> - }
>>> - }
>>> - }
>>> -
>>> - Selector s = null;
>>> - try {
>>> - if ( selectors.size() != 0 )
>>> - s = selectors.pop();
>>> - } catch (EmptyStackException ex){}
>>> -
>>> - int attempts = 0;
>>> - try{
>>> - while (s == null && attempts < 2) {
>>> - selectors.wait(timeout);
>>> - try {
>>> - if ( selectors.size() != 0 )
>>> - s = selectors.pop();
>>> - } catch (EmptyStackException ex){
>>> - break;
>>> - }
>>> - attempts++;
>>> - }
>>> - } catch (InterruptedException ex){}
>>> - return s;
>>> - }
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the {_at_link Selector} to the cache
>>> - * @param s {_at_link Selector}
>>> - */
>>> - public final static void returnSelector(Selector s) {
>>> - synchronized(selectors) {
>>> - selectors.push(s);
>>> - if (selectors.size() == 1)
>>> - selectors.notify();
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Executes <code>Selector.selectNow()</code> and returns
>>> - * the {_at_link Selector} to the cache
>>> - */
>>> - public final static void selectNowAndReturnSelector(Selector
>>> s) {
>>> - try {
>>> - s.selectNow();
>>> - returnSelector(s);
>>> - } catch(IOException e) {
>>> - Logger logger = Controller.logger();
>>> - logger.log(Level.WARNING,
>>> - "Unexpected problem when releasing temporary
>>> Selector", e);
>>> - try {
>>> - s.close();
>>> - } catch(IOException ee) {
>>> - // We are not interested
>>> - }
>>> -
>>> - try {
>>> - reimburseSelector();
>>> - } catch(IOException ee) {
>>> - logger.log(Level.WARNING,
>>> - "Problematic Selector could not be
>>> reimbursed!", ee);
>>> - }
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Add Selector to the cache.
>>> - * This method could be called to reimberse a lost or
>>> problematic Selector.
>>> - *
>>> - * @throws java.io.IOException
>>> - */
>>> - public final static void reimburseSelector() throws
>>> IOException {
>>> - returnSelector(createSelector());
>>> - }
>>> -
>>> - /**
>>> - * Creeate Selector
>>> - * @return Selector
>>> - * @throws java.io.IOException
>>> - */
>>> - protected static Selector createSelector() throws IOException {
>>> - return Selector.open();
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Increase {_at_link Selector} pool size
>>> - */
>>> - private static void grow(int size) throws IOException {
>>> - for(int i=0; i<size - maxSelectors; i++) {
>>> - selectors.add(createSelector());
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Decrease {_at_link Selector} pool size
>>> - */
>>> - private static void reduce(int size) {
>>> - for(int i=0; i<maxSelectors - size; i++) {
>>> - try {
>>> - Selector selector = selectors.pop();
>>> - selector.close();
>>> - } catch(IOException e) {
>>> - Logger logger = Controller.logger();
>>> - if (logger.isLoggable(Level.FINE)) {
>>> - logger.log(Level.FINE,
>>> "SelectorFactory.reduce", e);
>>> - }
>>> - }
>>> - }
>>> - }
>>> -
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> LoggingFormatter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> LoggingFormatter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> LoggingFormatter.java (working copy)
>>> @@ -1,166 +0,0 @@
>>> -/*
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.PrintWriter;
>>> -import java.io.StringWriter;
>>> -import java.util.Date;
>>> -import java.util.logging.Formatter;
>>> -import java.util.logging.Level;
>>> -import java.util.logging.LogRecord;
>>> -import java.util.logging.Logger;
>>> -
>>> -/**
>>> - *
>>> - * Format the record to include the Thread that logged the record.
>>> - * To change the default configuration for java.util.logging you
>>> will need to
>>> - * add this in the command line parameters : -
>>> Djava.util.logging.config.file=myfile
>>> - *
>>> - * Here a sample of what you need to include in myfile
>>> - *
>>> - * #the default logger is this add you can replace it with
>>> LoggingFormatter
>>> - * #java.util.logging.ConsoleHandler.formatter =
>>> java.util.logging.SimpleFormatter
>>> - * java.util.logging.ConsoleHandler.formatter =
>>> com.sun.grizzly.util.LoggingFormatter
>>> - *
>>> - * refer to : https://grizzly.dev.java.net/issues/show_bug.cgi?id=291
>>> - *
>>> - * @author Sebastien Dionne
>>> - *
>>> - */
>>> -public class LoggingFormatter extends Formatter {
>>> -
>>> - private static Logger log =
>>> Logger.getLogger(LoggingFormatter.class.getName());
>>> - - // took that from the JDK java.util.logging.SimpleFormatter
>>> - - // Line separator string. This is the value of the
>>> line.separator
>>> - // property at the moment that the SimpleFormatter was created.
>>> - private static String lineSeparator = "\n";
>>> - - static {
>>> - try {
>>> - String separator =
>>> System.getProperty("line.separator");
>>> - - if(separator!=null &&
>>> separator.trim().length()>0){
>>> - lineSeparator = separator;
>>> - }
>>> - } catch(SecurityException se){
>>> - // ignore the exception
>>> - }
>>> - - }
>>> - - public LoggingFormatter() {
>>> - super();
>>> - }
>>> - - /**
>>> - * Format the record to include the Thread that logged this
>>> record.
>>> - * the format should be
>>> - * [WorkerThreadImpl-1, Grizzly] 2008-10-08 18:49:59 [INFO]
>>> com.sun.grizzly.Controller:doSelect message
>>> - *
>>> - * @param record The record to be logged into the logger.
>>> - *
>>> - * @return the record formated to be more human readable
>>> - */
>>> - public String format(LogRecord record) {
>>> - - // Create a StringBuffer to contain the formatted
>>> record
>>> - StringBuffer sb = new StringBuffer();
>>> - -
>>> sb.append("[").append(Thread.currentThread().getName()).append("]
>>> ");
>>> - - // Get the date from the LogRecord and add it to
>>> the buffer
>>> - Date date = new Date(record.getMillis());
>>> - sb.append(date.toString()).append(" ");
>>> - - // Get the level name and add it to the buffer
>>> -
>>> sb
>>> .append
>>> ("[").append(record.getLevel().getLocalizedName()).append("] ");
>>> - - // Get Class name
>>> - if (record.getSourceClassName() != null) { -
>>> sb.append(record.getSourceClassName());
>>> - } else {
>>> - sb.append(record.getLoggerName());
>>> - }
>>> - // Get method name
>>> - if (record.getSourceMethodName() != null)
>>> { - sb.append(" ");
>>> - sb.append(record.getSourceMethodName());
>>> - }
>>> - sb.append(":");
>>> - - // Get the formatted message (includes localization
>>> - // and substitution of parameters) and add it to the buffer
>>> - sb.append(formatMessage(record)).append(lineSeparator);
>>> - - //we log the stackTrace if it's a exception
>>> - if (record.getThrown() != null) {
>>> - try {
>>> - StringWriter sw = new StringWriter();
>>> - PrintWriter pw = new PrintWriter(sw);
>>> - record.getThrown().printStackTrace(pw);
>>> - pw.close();
>>> - sb.append(sw.toString());
>>> - } catch (Exception ex) {
>>> - }
>>> - }
>>> - sb.append(lineSeparator);
>>> -
>>> - return sb.toString();
>>> - }
>>> - - /**
>>> - * Example to test the com.sun.grizzly.util.LoggingFormatter
>>> - * You need to include this parameter in the command line
>>> - * -Djava.util.logging.config.file=myfile
>>> - * @param args main parameters
>>> - */
>>> - public static void main(String[] args) {
>>> - - log.info("Info Event");
>>> - - log.severe("Severe Event");
>>> - - // show the thread info in the logger.
>>> - Thread t = new Thread(new Runnable(){public void run()
>>> {log.info("Info Event in Thread");}}, "Thread into main");
>>> - t.start();
>>> - - log.log(Level.SEVERE, "exception", new
>>> Exception());
>>> - - - }
>>> -}
>>> \ No newline at end of file
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StateHolder.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StateHolder.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> StateHolder.java (working copy)
>>> @@ -1,369 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Controller;
>>> -import java.util.Iterator;
>>> -import java.util.Map;
>>> -import java.util.concurrent.Callable;
>>> -import java.util.concurrent.ConcurrentHashMap;
>>> -import java.util.concurrent.CountDownLatch;
>>> -import java.util.concurrent.atomic.AtomicReference;
>>> -import java.util.concurrent.locks.ReentrantReadWriteLock;
>>> -import java.util.logging.Level;
>>> -
>>> -/**
>>> - * Class, which holds the state.
>>> - * Provides API for state change notification, state read/write
>>> access locking.
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class StateHolder<E> {
>>> - private AtomicReference<E> stateRef;
>>> -
>>> - private ReentrantReadWriteLock readWriteLock;
>>> - private volatile boolean isLockEnabled;
>>> -
>>> - private Map<ConditionListener<E>, Object> conditionListeners;
>>> -
>>> - /**
>>> - * Constructs {_at_link StateHolder}.
>>> - * StateHolder will work in not-locking mode.
>>> - */
>>> - public StateHolder() {
>>> - this(false);
>>> - }
>>> -
>>> - /**
>>> - * Constructs {_at_link StateHolder}.
>>> - * @param isLockEnabled locking mode
>>> - */
>>> - public StateHolder(boolean isLockEnabled) {
>>> - stateRef = new AtomicReference<E>();
>>> - readWriteLock = new ReentrantReadWriteLock();
>>> - conditionListeners = new
>>> ConcurrentHashMap<ConditionListener<E>, Object>();
>>> - this.isLockEnabled = isLockEnabled;
>>> - }
>>> -
>>> - /**
>>> - * Gets current state
>>> - * Current StateHolder locking mode will be used
>>> - * @return state
>>> - */
>>> - public E getState() {
>>> - return getState(isLockEnabled);
>>> - }
>>> -
>>> - /**
>>> - * Gets current state
>>> - * @param locked if true, get will be invoked in locking
>>> mode, false - non-locked
>>> - * @return state
>>> - */
>>> - public E getState(boolean locked) {
>>> - if (locked) {
>>> - readWriteLock.readLock().lock();
>>> - }
>>> -
>>> - E retState = stateRef.get();
>>> -
>>> - if (locked) {
>>> - readWriteLock.readLock().unlock();
>>> - }
>>> - return retState;
>>> - }
>>> -
>>> - /**
>>> - * Sets current state
>>> - * Current StateHolder locking mode will be used
>>> - * @param state
>>> - */
>>> - public void setState(E state) {
>>> - setState(state, isLockEnabled);
>>> - }
>>> -
>>> - /**
>>> - * Sets current state
>>> - * @param state
>>> - * @param locked if true, set will be invoked in locking
>>> mode, false - non-locking
>>> - */
>>> - public void setState(E state, boolean locked) {
>>> - if (locked) {
>>> - readWriteLock.writeLock().lock();
>>> - }
>>> -
>>> - stateRef.set(state);
>>> -
>>> - // downgrading lock to read
>>> - if (locked) {
>>> - readWriteLock.readLock().lock();
>>> - readWriteLock.writeLock().unlock();
>>> - }
>>> -
>>> - checkConditionListeners(state);
>>> -
>>> - if (locked) {
>>> - readWriteLock.readLock().unlock();
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Gets Read/Write locker, which is used by this {_at_link
>>> StateHolder}
>>> - * @return locker
>>> - */
>>> - public ReentrantReadWriteLock getStateLocker() {
>>> - return readWriteLock;
>>> - }
>>> -
>>> - /**
>>> - * Gets current locking mode
>>> - * @return true, if mode is set to locking, false otherwise
>>> - */
>>> - public boolean isLockEnabled() {
>>> - return isLockEnabled;
>>> - }
>>> -
>>> - /**
>>> - * Setss current locking mode
>>> - * @param isLockEnabled true, if mode will be set to locking,
>>> false otherwise
>>> - */
>>> - public void setLockEnabled(boolean isLockEnabled) {
>>> - this.isLockEnabled = isLockEnabled;
>>> - }
>>> -
>>> - /**
>>> - * Register listener, which will be notified, when state will
>>> be equal to passed
>>> - * one. Once listener will be notified - it will be removed
>>> from this
>>> - * {_at_link StateHolder}'s listener set.
>>> - * @param state State, listener is interested in
>>> - * @param listener Object, which will be notified. This
>>> {_at_link StateHolder}
>>> - * implementation works with Runnable, Callable,
>>> CountDownLatch, Object
>>> - * listeners
>>> - * @return <code>ConditionListener</code>, if current state
>>> is not equal to required
>>> - * and listener was registered, null if current
>>> state is equal to required.
>>> - * In both cases listener will be notified
>>> - */
>>> - public ConditionListener<E> notifyWhenStateIsEqual(E state,
>>> Object listener) {
>>> - boolean isLockEnabledLocal = isLockEnabled;
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().lock();
>>> - }
>>> -
>>> - ConditionListener<E> conditionListener = null;
>>> -
>>> - if (stateRef.get().equals(state)) {
>>> - EventListener.notifyListener(listener);
>>> - } else {
>>> - conditionListener = new EqualConditionListener<E>();
>>> - EventListener eventListener = new EventListener();
>>> - eventListener.set(listener);
>>> - conditionListener.set(state, eventListener);
>>> -
>>> - conditionListeners.put(conditionListener, this);
>>> - }
>>> -
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().unlock();
>>> - }
>>> -
>>> - return conditionListener;
>>> - }
>>> -
>>> - /**
>>> - * Register listener, which will be notified, when state will
>>> become not equal
>>> - * to passed one. Once listener will be notified - it will be
>>> removed from
>>> - * this {_at_link StateHolder}'s listener set.
>>> - * @param state State, listener is interested in
>>> - * @param listener Object, which will be notified. This
>>> {_at_link StateHolder}
>>> - * implementation works with Runnable, Callable,
>>> CountDownLatch, Object
>>> - * listeners
>>> - * @return <code>ConditionListener</code>, if current state
>>> is equal to required
>>> - * and listener was registered, null if current
>>> state is not equal to required.
>>> - * In both cases listener will be notified
>>> - */
>>> - public ConditionListener<E> notifyWhenStateIsNotEqual(E
>>> state, Object listener) {
>>> - boolean isLockEnabledLocal = isLockEnabled;
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().lock();
>>> - }
>>> -
>>> - ConditionListener<E> conditionListener = null;
>>> -
>>> - if (!stateRef.get().equals(state)) {
>>> - EventListener.notifyListener(listener);
>>> - } else {
>>> - conditionListener = new NotEqualConditionListener<E>();
>>> - EventListener eventListener = new EventListener();
>>> - eventListener.set(listener);
>>> - conditionListener.set(state, eventListener);
>>> -
>>> - conditionListeners.put(conditionListener, this);
>>> - }
>>> -
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().unlock();
>>> - }
>>> -
>>> - return conditionListener;
>>> - }
>>> -
>>> - /**
>>> - * Register custom condition listener, which will be
>>> notified, when listener's
>>> - * condition will become true. Once listener will be notified
>>> - it will be
>>> - * removed from this {_at_link StateHolder}'s listener set.
>>> - * @param conditionListener contains both condition and
>>> listener, which will be
>>> - * called, when condition become true
>>> - */
>>> - public void
>>> notifyWhenConditionMatchState(ConditionListener<E>
>>> conditionListener) {
>>> - boolean isLockEnabledLocal = isLockEnabled;
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().lock();
>>> - }
>>> -
>>> - E currentState = getState();
>>> -
>>> - if (conditionListener.check(currentState)) {
>>> - conditionListener.notifyListener();
>>> - } else {
>>> - conditionListeners.put(conditionListener, this);
>>> - }
>>> -
>>> - if (isLockEnabledLocal) {
>>> - getStateLocker().writeLock().unlock();
>>> - }
>>> - }
>>> -
>>> - public void removeConditionListener(ConditionListener<E>
>>> conditionListener) {
>>> - if (conditionListener == null) return;
>>> -
>>> - conditionListeners.remove(conditionListener);
>>> - }
>>> -
>>> - protected void checkConditionListeners(E state) {
>>> - Iterator<ConditionListener<E>> it =
>>> conditionListeners.keySet().iterator();
>>> - while(it.hasNext()) {
>>> - ConditionListener<E> listener = it.next();
>>> - try {
>>> - if (listener.check(state)) {
>>> - it.remove();
>>> - listener.notifyListener();
>>> - }
>>> - } catch(Exception e) {
>>> - Controller.logger().log(Level.WARNING, "Error
>>> calling ConditionListener", e);
>>> - }
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Common ConditionListener class, which could be used with
>>> StateHolder, to
>>> - * register custom conditions.
>>> - *
>>> - * On each state change - condition will be checked, if it's
>>> true - Condition's
>>> - * listener will be notified.
>>> - */
>>> - public static abstract class ConditionListener<E> {
>>> - public E state;
>>> - public EventListener listener;
>>> -
>>> - protected void set(E state, EventListener listener) {
>>> - this.state = state;
>>> - this.listener = listener;
>>> - }
>>> -
>>> - public void notifyListener() {
>>> - listener.notifyEvent();
>>> - }
>>> -
>>> - public abstract boolean check(E state);
>>> - }
>>> -
>>> - /**
>>> - * Equal ConditionListener implementation
>>> - * @param E state class
>>> - */
>>> - public static class EqualConditionListener<E> extends
>>> ConditionListener<E> {
>>> - public boolean check(E state) {
>>> - return state.equals(this.state);
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * Not equal ConditionListener implementation
>>> - * @param E state class
>>> - */
>>> - public static class NotEqualConditionListener<E> extends
>>> ConditionListener<E> {
>>> - public boolean check(E state) {
>>> - return !state.equals(this.state);
>>> - }
>>> - }
>>> -
>>> - /**
>>> - * EventListener class, which is a part of
>>> - * <codE>EventConditionListener</code>, and implements
>>> notificatation logic,
>>> - * when condition becomes true.
>>> - */
>>> - public static class EventListener {
>>> - public Object notificationObject;
>>> -
>>> - public void set(Object notificationObject) {
>>> - this.notificationObject = notificationObject;
>>> - }
>>> -
>>> - public void notifyEvent() {
>>> - notifyListener(notificationObject);
>>> - }
>>> -
>>> - protected static void notifyListener(Object listener) {
>>> - if (listener instanceof CountDownLatch) {
>>> - ((CountDownLatch) listener).countDown();
>>> - } else if (listener instanceof Callable) {
>>> - try {
>>> - ((Callable) listener).call();
>>> - } catch(Exception e) {
>>> - throw new RuntimeException(e);
>>> - }
>>> - } else if (listener instanceof Runnable) {
>>> - ((Runnable) listener).run();
>>> - } else {
>>> - synchronized(listener) {
>>> - listener.notify();
>>> - }
>>> - }
>>> - }
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/State.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> State.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> State.java (working copy)
>>> @@ -1,51 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -/**
>>> - * State enum
>>> - * STOPPED - Process is stopped, not running state
>>> - * STARTED - Process is started, running state
>>> - * PAUSED - Process is paused, not processing tasks
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public enum State {
>>> - STOPPED, STARTED, PAUSED
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> InputReader.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> InputReader.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> InputReader.java (working copy)
>>> @@ -1,384 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.InputStream;
>>> -import java.io.IOException;
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.SelectionKey;
>>> -import java.nio.channels.SocketChannel;
>>> -
>>> -/**
>>> - * This class implement IO stream operations on top of a {_at_link
>>> ByteBuffer}.
>>> - * Under the hood, this class use a temporary Selector pool for
>>> reading
>>> - * bytes when the client ask for more and the current Selector is
>>> not yet ready.
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public class InputReader extends InputStream {
>>> -
>>> - /**
>>> - * The {_at_link Channel} type is used to avoid invoking the
>>> instanceof
>>> - * operation when registering the Socket|Datagram Channel to
>>> the Selector.
>>> - */
>>> - public enum ChannelType { SocketChannel, DatagramChannel }
>>> -
>>> -
>>> - /**
>>> - * By default this class will cast the Channel to a
>>> SocketChannel.
>>> - */
>>> - private ChannelType defaultChannelType =
>>> ChannelType.SocketChannel;
>>> -
>>> -
>>> - private static int defaultReadTimeout = 30000;
>>> -
>>> - /**
>>> - * The wrapped <code>ByteBuffer</code<
>>> - */
>>> - protected ByteBuffer byteBuffer;
>>> -
>>> -
>>> - /**
>>> - * The {_at_link SelectionKey} used by this stream.
>>> - */
>>> - protected SelectionKey key = null;
>>> -
>>> -
>>> - /**
>>> - * The time to wait before timing out when reading bytes
>>> - */
>>> - protected int readTimeout = defaultReadTimeout;
>>> -
>>> -
>>> - /**
>>> - * Is the stream secure.
>>> - */
>>> - private boolean secure = false;
>>> -
>>> -
>>> - // -------------------------------------------------
>>> Constructor -------//
>>> -
>>> -
>>> - public InputReader () {
>>> - }
>>> -
>>> -
>>> - public InputReader (final ByteBuffer byteBuffer) {
>>> - this.byteBuffer = byteBuffer;
>>> - }
>>> -
>>> - //
>>> ---------------------------------------------------------------------//
>>> -
>>> -
>>> - /**
>>> - * Set the wrapped {_at_link ByteBuffer}
>>> - * @param byteBuffer The wrapped byteBuffer
>>> - */
>>> - public void setByteBuffer(final ByteBuffer byteBuffer) {
>>> - this.byteBuffer = byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Get the wrapped {_at_link ByteBuffer}
>>> - * @return {_at_link ByteBuffer}
>>> - */
>>> - public ByteBuffer getByteBuffer() {
>>> - return byteBuffer;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the available bytes
>>> - * @return the wrapped byteBuffer.remaining()
>>> - */
>>> - @Override
>>> - public int available () {
>>> - return (byteBuffer.remaining());
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Close this stream.
>>> - */
>>> - @Override
>>> - public void close () {
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return true if mark is supported.
>>> - */
>>> - @Override
>>> - public boolean markSupported() {
>>> - return false;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read the first byte from the wrapped {_at_link ByteBuffer}.
>>> - */
>>> - @Override
>>> - public int read() throws IOException {
>>> - if (!byteBuffer.hasRemaining()){
>>> - byteBuffer.clear();
>>> - int eof = doRead();
>>> -
>>> - if (eof <= 0){
>>> - return -1;
>>> - }
>>> - }
>>> - return (byteBuffer.hasRemaining() ? (byteBuffer.get () &
>>> 0xff): -1);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read the bytes from the wrapped {_at_link ByteBuffer}.
>>> - */
>>> - @Override
>>> - public int read(byte[] b) throws IOException {
>>> - return (read (b, 0, b.length));
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read the first byte of the wrapped {_at_link ByteBuffer}.
>>> - * @param offset
>>> - * @param length
>>> - */
>>> - @Override
>>> - public int read(byte[] b, int offset, int length) throws
>>> IOException {
>>> - if (!byteBuffer.hasRemaining()) {
>>> - byteBuffer.clear();
>>> - int eof = doRead();
>>> -
>>> - if (eof <= 0){
>>> - return -1;
>>> - }
>>> - }
>>> -
>>> - if (length > byteBuffer.remaining()) {
>>> - length = byteBuffer.remaining();
>>> - }
>>> - byteBuffer.get(b, offset, length);
>>> -
>>> - return (length);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read the bytes of the wrapped {_at_link ByteBuffer}.
>>> - * @param bb {_at_link ByteBuffer}
>>> - * @return - number of bytes read
>>> - * @throws java.io.IOException
>>> - */
>>> - public int read(ByteBuffer bb) throws IOException {
>>> - //Switch Buffer
>>> - ByteBuffer oldBB = byteBuffer;
>>> - byteBuffer = bb;
>>> - int initialPosition = bb.position();
>>> - int eof = doRead();
>>> -
>>> - if (eof <= 0){
>>> - return -1;
>>> - }
>>> - // Back to the default one.
>>> - byteBuffer = oldBB;
>>> -
>>> - // Calculate the number of bytes were read
>>> - int bytesRead = bb.limit() - initialPosition;
>>> - return bytesRead;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Recycle this object.
>>> - */
>>> - public void recycle(){
>>> - byteBuffer = null;
>>> - key = null;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the {_at_link SelectionKey} used to reads bytes.
>>> - * @param key {_at_link SelectionKey}
>>> - */
>>> - public void setSelectionKey(SelectionKey key){
>>> - this.key = key;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read bytes using the read <code>ReadSelector</code>
>>> - * @return - number of bytes read
>>> - * @throws java.io.IOException
>>> - */
>>> - protected int doRead() throws IOException{
>>> - if ( key == null ) return -1;
>>> -
>>> - int nRead = -1;
>>> - try{
>>> - if (secure){
>>> - nRead = doSecureRead();
>>> - } else {
>>> - nRead = doClearRead();
>>> - }
>>> - } catch (IOException ex){
>>> - nRead = -1;
>>> - throw ex;
>>> - } finally {
>>> - if (nRead == -1){
>>> - if (Thread.currentThread() instanceof
>>> WorkerThread){
>>> - ConnectionCloseHandler cch =
>>> (ConnectionCloseHandler)
>>> - ((WorkerThread)Thread.currentThread())
>>> - .getAttachment
>>> ().getAttribute("ConnectionCloseHandler");
>>> - if (cch != null){
>>> - cch.remotlyClosed(key);
>>> - }
>>> - }
>>> - }
>>> - return nRead;
>>> - }
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Read and decrypt bytes from the underlying SSL
>>> connections. All
>>> - * the SSLEngine operations are delegated to class {_at_link
>>> SSLUtils}.
>>> - * @return number of bytes read
>>> - * @throws java.io.IOException
>>> - */
>>> - protected int doSecureRead() throws IOException{
>>> - final WorkerThread workerThread =
>>> - (WorkerThread)Thread.currentThread();
>>> -
>>> - int bytesRead = SSLUtils.doSecureRead((SocketChannel)
>>> key.channel(),
>>> - workerThread.getSSLEngine(), byteBuffer,
>>> - workerThread.getInputBB());
>>> - byteBuffer.flip();
>>> -
>>> - return bytesRead;
>>> - }
>>> -
>>> -
>>> - protected int doClearRead() throws IOException{
>>> - int bytesRead =
>>> Utils.readWithTemporarySelector(key.channel(),
>>> - byteBuffer, readTimeout);
>>> - byteBuffer.flip();
>>> -
>>> - return bytesRead;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the timeout between two consecutives
>>> Selector.select() when a
>>> - * temporary Selector is used.
>>> - * @return read timeout being used
>>> - */
>>> - public int getReadTimeout() {
>>> - return readTimeout;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the timeout between two consecutives Selector.select()
>>> when a
>>> - * temporary Selector is used.
>>> - * @param rt - read timeout
>>> - */
>>> - public void setReadTimeout(int rt) {
>>> - readTimeout = rt;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the Selector.select() default time out.
>>> - * @return default time out
>>> - */
>>> - public static int getDefaultReadTimeout() {
>>> - return defaultReadTimeout;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the default Selector.select() time out.
>>> - * @param aDefaultReadTimeout time out value
>>> - */
>>> - public static void setDefaultReadTimeout(int
>>> aDefaultReadTimeout) {
>>> - defaultReadTimeout = aDefaultReadTimeout;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Return the {_at_link Channel} type. The return value is
>>> SocketChannel
>>> - * or DatagramChannel.
>>> - * @return {_at_link Channel} being used
>>> - */
>>> - public ChannelType getChannelType() {
>>> - return defaultChannelType;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the {_at_link Channel} type, which is ocketChannel
>>> - * or DatagramChannel.
>>> - * @param channelType {_at_link Channel} to use
>>> - */
>>> - public void setChannelType(ChannelType channelType) {
>>> - this.defaultChannelType = channelType;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Is this Stream secure.
>>> - * @return true is stream is secure, otherwise false
>>> - */
>>> - public boolean isSecure() {
>>> - return secure;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set this stream secure.
>>> - * @param secure true to set stream secure, otherwise false
>>> - */
>>> - public void setSecure(boolean secure) {
>>> - this.secure = secure;
>>> - }
>>> -}
>>> -
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Cloner.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Cloner.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> Cloner.java (working copy)
>>> @@ -1,101 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import com.sun.grizzly.Controller;
>>> -import java.lang.reflect.Constructor;
>>> -import java.util.logging.Level;
>>> -
>>> -/**
>>> - * Class Cloner creates a clone of given object,
>>> - * which should implement interface <code>Copyable</code>
>>> - *
>>> - * @author Alexey Stashok
>>> - */
>>> -public class Cloner {
>>> - /**
>>> - * Method creates a clone of given object pattern
>>> - * Pattern parameter should implement <class>Copyable</class>
>>> interface
>>> - *
>>> - * @param pattern represents object, which will be cloned.
>>> Should implement <code>Copyable</code>
>>> - * @return clone
>>> - */
>>> - public static <T extends Copyable> T clone(T pattern) {
>>> - try {
>>> - T copy = null;
>>> -
>>> - try {
>>> - // Try default Constructor
>>> - copy = (T) pattern.getClass().newInstance();
>>> - } catch(InstantiationException e) {
>>> - // If didn't succeed with default - try other
>>> public constructors
>>> - Constructor[] constructors =
>>> pattern.getClass().getConstructors();
>>> - if (constructors.length == 0) {
>>> - // if there are no public constructors - try
>>> others
>>> - constructors =
>>> pattern.getClass().getDeclaredConstructors();
>>> - }
>>> -
>>> - for(Constructor constructor : constructors) {
>>> - constructor.setAccessible(true);
>>> - Object[] params =
>>> - new
>>> Object[constructor.getParameterTypes().length];
>>> -
>>> - try {
>>> - copy = (T) constructor.newInstance(params);
>>> - break;
>>> - } catch(InstantiationException ee) {
>>> - }
>>> - }
>>> - }
>>> -
>>> - if (copy == null) {
>>> - throw new InstantiationException("Could not
>>> create " +
>>> - "an instance of class: " +
>>> pattern.getClass().getName());
>>> - }
>>> -
>>> - pattern.copyTo(copy);
>>> - return copy;
>>> - } catch (Exception e) {
>>> - if (Controller.logger().isLoggable(Level.WARNING)) {
>>> - Controller.logger().log(Level.WARNING, "Error
>>> copying objects!", e);
>>> - }
>>> - throw new RuntimeException("Error copying objects! "
>>> + e.getClass().getName() + ": " + e.getMessage());
>>> - }
>>> - }
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadImpl.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadImpl.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadImpl.java (working copy)
>>> @@ -1,296 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.util.concurrent.Callable;
>>> -import com.sun.grizzly.util.ByteBufferFactory.ByteBufferType;
>>> -import com.sun.grizzly.util.ThreadAttachment.Mode;
>>> -
>>> -/**
>>> - * Simple worker thread used for processing HTTP requests. All
>>> threads are
>>> - * synchronized using a {_at_link DefaultThreadPool} object
>>> - *
>>> - * @author Jean-Francois Arcand
>>> - */
>>> -public class WorkerThreadImpl extends WorkerThread {
>>> -
>>> - private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
>>> -
>>> - /**
>>> - * The {_at_link DefaultThreadPool} on which this thread
>>> synchronize.
>>> - */
>>> - protected DefaultThreadPool threadPool;
>>> -
>>> -
>>> - /**
>>> - * The <code>ThreadGroup</code> used.
>>> - */
>>> - protected final static ThreadGroup threadGroup = new
>>> ThreadGroup("Grizzly");
>>> -
>>> -
>>> - /**
>>> - * The state/attributes on this WorkerThread.
>>> - */
>>> - private ThreadAttachment threadAttachment;
>>> -
>>> -
>>> - /**
>>> - * The ByteBufferType used when creating the ByteBuffer
>>> attached to this object.
>>> - */
>>> - private ByteBufferType byteBufferType =
>>> ByteBufferType.HEAP_VIEW;
>>> -
>>> -
>>> - /**
>>> - * The size of the ByteBuffer attached to this object.
>>> - */
>>> - private int initialByteBufferSize;
>>> -
>>> -
>>> - /**
>>> - * Create a Thread that will synchronizes/block on
>>> - * {_at_link DefaultThreadPool} instance.
>>> - * @param threadGroup <code>ThreadGroup</code>
>>> - * @param runnable <code>Runnable</code>
>>> - */
>>> - public WorkerThreadImpl(ThreadGroup threadGroup, Runnable
>>> runnable){
>>> - this(threadGroup, runnable, DEFAULT_BYTE_BUFFER_SIZE);
>>> - }
>>> -
>>> - /**
>>> - * Create a Thread that will synchronizes/block on
>>> - * {_at_link DefaultThreadPool} instance.
>>> - * @param threadGroup <code>ThreadGroup</code>
>>> - * @param runnable <code>Runnable</code>
>>> - * @param initialByteBufferSize initial {_at_link ByteBuffer} size
>>> - */
>>> - public WorkerThreadImpl(ThreadGroup threadGroup, Runnable
>>> runnable,
>>> - int initialByteBufferSize){
>>> - super(threadGroup, runnable);
>>> - setDaemon(true);
>>> - this.initialByteBufferSize = initialByteBufferSize;
>>> - }
>>> -
>>> - /**
>>> - * Create a Thread that will synchronizes/block on
>>> - * {_at_link DefaultThreadPool} instance.
>>> - * @param threadPool {_at_link DefaultThreadPool}
>>> - * @param name <code>String</code>
>>> - */
>>> - public WorkerThreadImpl(DefaultThreadPool threadPool, String
>>> name){
>>> - this(threadPool, name, DEFAULT_BYTE_BUFFER_SIZE);
>>> - }
>>> -
>>> - /**
>>> - * Create a Thread that will synchronizes/block on
>>> - * {_at_link DefaultThreadPool} instance.
>>> - * @param threadPool {_at_link DefaultThreadPool}
>>> - * @param name <code>String</code>
>>> - * @param initialByteBufferSize initial {_at_link ByteBuffer} size
>>> - */
>>> - public WorkerThreadImpl(DefaultThreadPool threadPool, String
>>> name,
>>> - int initialByteBufferSize){
>>> - super(threadGroup, name);
>>> - this.threadPool = threadPool;
>>> - setDaemon(true);
>>> - this.initialByteBufferSize = initialByteBufferSize;
>>> - }
>>> -
>>> - /**
>>> - * Create a Thread that will synchronizes/block on
>>> - * {_at_link DefaultThreadPool} instance.
>>> - * @param threadPool {_at_link DefaultThreadPool}
>>> - * @param name <code>String</code>
>>> - * @param initialByteBufferSize initial {_at_link ByteBuffer} size
>>> - */
>>> - public WorkerThreadImpl(DefaultThreadPool threadPool, String
>>> name,
>>> - Runnable runnable, int initialByteBufferSize){
>>> - super(threadGroup, runnable, name);
>>> - this.threadPool = threadPool;
>>> - setDaemon(true);
>>> - this.initialByteBufferSize = initialByteBufferSize;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Allocate a {_at_link ByteBuffer} if the current instance is
>>> null;
>>> - */
>>> - protected void createByteBuffer(boolean force){
>>> - if (force || byteBuffer == null){
>>> - byteBuffer = ByteBufferFactory.allocate(byteBufferType,
>>> - initialByteBufferSize);
>>> - }
>>> - }
>>> -
>>> -
>>> - public ThreadAttachment updateAttachment(int mode) {
>>> - ThreadAttachment currentAttachment = getAttachment();
>>> - currentAttachment.reset();
>>> -
>>> - if ((mode & Mode.BYTE_BUFFER) != 0) {
>>> - currentAttachment.setByteBuffer(byteBuffer);
>>> - }
>>> -
>>> - if ((mode & Mode.SSL_ENGINE) != 0) {
>>> - currentAttachment.setSSLEngine(sslEngine);
>>> - }
>>> -
>>> - if ((mode & Mode.INPUT_BB) != 0) {
>>> - currentAttachment.setInputBB(inputBB);
>>> - }
>>> -
>>> - if ((mode & Mode.OUTPUT_BB) != 0) {
>>> - currentAttachment.setOutputBB(outputBB);
>>> - }
>>> -
>>> - currentAttachment.setMode(mode);
>>> -
>>> - return currentAttachment;
>>> - }
>>> -
>>> - public ThreadAttachment getAttachment() {
>>> - if (threadAttachment == null) {
>>> - threadAttachment = new ThreadAttachment();
>>> - threadAttachment.associate();
>>> - }
>>> -
>>> - return threadAttachment;
>>> - }
>>> -
>>> - public ThreadAttachment detach() {
>>> - ThreadAttachment currentAttachment = getAttachment();
>>> - int mode = currentAttachment.getMode();
>>> - updateAttachment(mode);
>>> -
>>> - // Re-create a new ByteBuffer
>>> - if ((mode & Mode.BYTE_BUFFER) != 0) {
>>> - createByteBuffer(true);
>>> - }
>>> -
>>> - if ((mode & Mode.SSL_ENGINE) != 0) {
>>> - sslEngine = null;
>>> - }
>>> -
>>> - if ((mode & Mode.INPUT_BB) != 0) {
>>> - inputBB = null;
>>> - }
>>> -
>>> - if ((mode & Mode.OUTPUT_BB) != 0) {
>>> - outputBB = null;
>>> - }
>>> -
>>> - // Switch to the new ThreadAttachment.
>>> - this.threadAttachment = null;
>>> -
>>> - currentAttachment.deassociate();
>>> - return currentAttachment;
>>> - }
>>> -
>>> -
>>> - public void attach(ThreadAttachment threadAttachment) {
>>> - threadAttachment.associate();
>>> - int mode = threadAttachment.getMode();
>>> -
>>> - if ((mode & Mode.BYTE_BUFFER) != 0) {
>>> - byteBuffer = threadAttachment.getByteBuffer();
>>> - }
>>> -
>>> - if ((mode & Mode.SSL_ENGINE) != 0) {
>>> - sslEngine = threadAttachment.getSSLEngine();
>>> - }
>>> -
>>> - if ((mode & Mode.INPUT_BB) != 0) {
>>> - inputBB = threadAttachment.getInputBB();
>>> - }
>>> -
>>> - if ((mode & Mode.OUTPUT_BB) != 0) {
>>> - outputBB = threadAttachment.getOutputBB();
>>> - }
>>> -
>>> - this.threadAttachment = threadAttachment;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * The <code>ByteBufferType</code> used to create the {_at_link
>>> ByteBuffer}
>>> - * associated with this object.
>>> - * @return The <code>ByteBufferType</code> used to create the
>>> {_at_link ByteBuffer}
>>> - * associated with this object.
>>> - */
>>> - public ByteBufferType getByteBufferType() {
>>> - return byteBufferType;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Set the <code>ByteBufferType</code> to use when creating the
>>> - * {_at_link ByteBuffer} associated with this object.
>>> - * @param byteBufferType The ByteBuffer type.
>>> - */
>>> - public void setByteBufferType(ByteBufferType byteBufferType) {
>>> - this.byteBufferType = byteBufferType;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Processes the given task.
>>> - *
>>> - * @param t the task to process
>>> - */
>>> - protected void processTask(Callable t) throws Exception {
>>> - if (t != null){
>>> - t.call();
>>> - }
>>> - }
>>> -
>>> -
>>> - @Override
>>> - protected void reset() {
>>> - if (threadAttachment != null) {
>>> - /**
>>> - * ThreadAttachment was created during prev.
>>> processing and wasn't
>>> - * detached. It could happen due to some error - we
>>> need to release
>>> - * the ThreadAttachment association with the current
>>> thread
>>> - */
>>> - threadAttachment.deassociate();
>>> - }
>>> -
>>> - threadAttachment = null;
>>> - super.reset();
>>> - }
>>> -}
>>> -
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadFactory.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadFactory.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> WorkerThreadFactory.java (working copy)
>>> @@ -1,51 +0,0 @@
>>> -/*
>>> - * The contents of this file are subject to the terms
>>> - * of the Common Development and Distribution License
>>> - * (the License). You may not use this file except in
>>> - * compliance with the License.
>>> - *
>>> - * You can obtain a copy of the license at
>>> - * https://glassfish.dev.java.net/public/CDDLv1.0.html or
>>> - * glassfish/bootstrap/legal/CDDLv1.0.txt.
>>> - * See the License for the specific language governing
>>> - * permissions and limitations under the License.
>>> - *
>>> - * When distributing Covered Code, include this CDDL
>>> - * Header Notice in each file and include the License file
>>> - * at glassfish/bootstrap/legal/CDDLv1.0.txt.
>>> - * If applicable, add the following below the CDDL Header,
>>> - * with the fields enclosed by brackets [] replaced by
>>> - * you own identifying information:
>>> - * "Portions Copyrighted [year] [name of copyright owner]"
>>> - *
>>> - * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.util.concurrent.ThreadFactory;
>>> -
>>> -/**
>>> - * Simple utility class to create {_at_link WorkerThread}
>>> - * @author Jeanfrancois Arcand
>>> - */
>>> -public class WorkerThreadFactory implements ThreadFactory{
>>> -
>>> - /**
>>> - * The {_at_link ThreadGroup}
>>> - */
>>> - private final static ThreadGroup threadGroup = new
>>> ThreadGroup("Grizzly");
>>> -
>>> -
>>> - /**
>>> - * Create a new {_at_link WorkerThread}.
>>> - * @param r a Runabble
>>> - * @return
>>> - */
>>> - public Thread newThread(Runnable r){
>>> - WorkerThreadImpl t = new WorkerThreadImpl(threadGroup,r);
>>> - t.setDaemon(true);
>>> - return t;
>>> - }
>>> -
>>> -}
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferInputStream.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferInputStream.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> ByteBufferInputStream.java (working copy)
>>> @@ -1,51 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -package com.sun.grizzly.util;
>>> -
>>> -/**
>>> - * This class implement IO stream operations on top of a {_at_link
>>> ByteBuffer}.
>>> - * Under the hood, this class use a temporary Selector pool for
>>> reading
>>> - * bytes when the client ask for more and the current Selector is
>>> not yet ready.
>>> - *
>>> - * @author Jeanfrancois Arcand
>>> - * @deprecated - Use {_at_link InputReader} instead
>>> - */
>>> -public class ByteBufferInputStream extends InputReader {
>>> -
>>> -}
>>> -
>>> Index: modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> OutputWriter.java
>>> ===================================================================
>>> --- modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> OutputWriter.java (revision 2047)
>>> +++ modules/grizzly/src/main/java/com/sun/grizzly/util/
>>> OutputWriter.java (working copy)
>>> @@ -1,350 +0,0 @@
>>> -/*
>>> - *
>>> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
>>> - *
>>> - * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
>>> - *
>>> - * The contents of this file are subject to the terms of either
>>> the GNU
>>> - * General Public License Version 2 only ("GPL") or the Common
>>> Development
>>> - * and Distribution License("CDDL") (collectively, the
>>> "License"). You
>>> - * may not use this file except in compliance with the License.
>>> You can obtain
>>> - * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
>>> - * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
>>> the specific
>>> - * language governing permissions and limitations under the
>>> License.
>>> - *
>>> - * When distributing the software, include this License Header
>>> Notice in each
>>> - * file and include the License file at glassfish/bootstrap/legal/
>>> LICENSE.txt.
>>> - * Sun designates this particular file as subject to the
>>> "Classpath" exception
>>> - * as provided by Sun in the GPL Version 2 section of the License
>>> file that
>>> - * accompanied this code. If applicable, add the following below
>>> the License
>>> - * Header, with the fields enclosed by brackets [] replaced by
>>> your own
>>> - * identifying information: "Portions Copyrighted [year]
>>> - * [name of copyright owner]"
>>> - *
>>> - * Contributor(s):
>>> - *
>>> - * If you wish your version of this file to be governed by only
>>> the CDDL or
>>> - * only the GPL Version 2, indicate your decision by adding
>>> "[Contributor]
>>> - * elects to include this software in this distribution under the
>>> [CDDL or GPL
>>> - * Version 2] license." If you don't indicate a single choice of
>>> license, a
>>> - * recipient has the option to distribute your version of this
>>> file under
>>> - * either the CDDL, the GPL Version 2 or to extend the choice of
>>> license to
>>> - * its licensees as provided above. However, if you add GPL
>>> Version 2 code
>>> - * and therefore, elected the GPL Version 2 license, then the
>>> option applies
>>> - * only if the new code is made subject to such option by the
>>> copyright
>>> - * holder.
>>> - *
>>> - */
>>> -
>>> -package com.sun.grizzly.util;
>>> -
>>> -import java.io.IOException;
>>> -import java.net.SocketAddress;
>>> -import java.nio.ByteBuffer;
>>> -import java.nio.channels.DatagramChannel;
>>> -import java.nio.channels.SelectableChannel;
>>> -import java.nio.channels.SelectionKey;
>>> -import java.nio.channels.Selector;
>>> -import java.nio.channels.SocketChannel;
>>> -import java.nio.channels.WritableByteChannel;
>>> -
>>> -/**
>>> - * NIO utility to flush {_at_link ByteBuffer}
>>> - *
>>> - * @author Scott Oaks
>>> - */
>>> -public class OutputWriter {
>>> -
>>> - /**
>>> - * The default rime out before closing the connection
>>> - */
>>> - private static int defaultWriteTimeout = 30000;
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param channel {_at_link SelectableChannel}
>>> - * @param bb the ByteBuffer to write.
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SelectableChannel channel,
>>> ByteBuffer bb)
>>> - throws IOException{
>>> - return flushChannel(channel,bb,defaultWriteTimeout);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param channel {_at_link SelectableChannel}
>>> - * @param bb the ByteBuffer to write.
>>> - * @param writeTimeout
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SelectableChannel channel,
>>> - ByteBuffer bb, long writeTimeout) throws IOException{
>>> -
>>> - if (bb == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. ByteBuffer"
>>> - + " cannot be null.");
>>> - }
>>> -
>>> - if (channel == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. " +
>>> - "SocketChannel cannot be null.");
>>> - }
>>> -
>>> - SelectionKey key = null;
>>> - Selector writeSelector = null;
>>> - int attempts = 0;
>>> - int nWrite = 0;
>>> - int len = -1;
>>> - try {
>>> - WritableByteChannel writableChannel =
>>> (WritableByteChannel) channel;
>>> - while ( bb.hasRemaining() ) {
>>> - len = writableChannel.write(bb);
>>> - if (len > 0){
>>> - attempts = 0;
>>> - nWrite += len;
>>> - } else {
>>> - attempts++;
>>> - if ( writeSelector == null ){
>>> - writeSelector =
>>> SelectorFactory.getSelector();
>>> - if ( writeSelector == null){
>>> - // Continue using the main one.
>>> - continue;
>>> - }
>>> - key = channel.register(writeSelector,
>>> - SelectionKey.OP_WRITE);
>>> - }
>>> -
>>> - if (writeSelector.select(writeTimeout) == 0) {
>>> - if (attempts > 2)
>>> - throw new IOException("Client
>>> disconnected");
>>> - }
>>> - }
>>> - }
>>> - } catch (IOException ex){
>>> - len = -1;
>>> - throw ex;
>>> - } finally {
>>> - if (key != null) {
>>> - key.cancel();
>>> - key = null;
>>> - }
>>> -
>>> - if ( writeSelector != null ) {
>>> - // Cancel the key.
>>> -
>>> SelectorFactory.selectNowAndReturnSelector(writeSelector);
>>> - }
>>> -
>>> - if (len == -1){
>>> - if (Thread.currentThread() instanceof
>>> WorkerThread){
>>> - ConnectionCloseHandler cch =
>>> (ConnectionCloseHandler)
>>> - ((WorkerThread)Thread.currentThread())
>>> - .getAttachment
>>> ().getAttribute("ConnectionCloseHandler");
>>> - if (cch != null){
>>> - cch.remotlyClosed(key);
>>> - }
>>> - }
>>> - }
>>> - }
>>> - return nWrite;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param socketChannel {_at_link SocketChannel}
>>> - * @param bb the ByteBuffer to write.
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SocketChannel socketChannel,
>>> ByteBuffer[] bb)
>>> - throws IOException{
>>> - return flushChannel(socketChannel,bb,defaultWriteTimeout);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param socketChannel {_at_link SocketChannel}
>>> - * @param bb the ByteBuffer to write.
>>> - * @param writeTimeout
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(SocketChannel socketChannel,
>>> - ByteBuffer[] bb, long writeTimeout) throws IOException{
>>> -
>>> - if (bb == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. ByteBuffer"
>>> - + " cannot be null.");
>>> - }
>>> -
>>> - if (socketChannel == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. " +
>>> - "SocketChannel cannot be null.");
>>> - }
>>> -
>>> - SelectionKey key = null;
>>> - Selector writeSelector = null;
>>> - int attempts = 0;
>>> - long totalBytes = 0;
>>> - for (ByteBuffer aBb : bb) {
>>> - totalBytes += aBb.remaining();
>>> - }
>>> -
>>> - long nWrite = 0;
>>> - long len = -1;
>>> - try {
>>> - while (nWrite < totalBytes ) {
>>> - len = socketChannel.write(bb);
>>> - if (len > 0){
>>> - attempts = 0;
>>> - nWrite += len;
>>> - } else {
>>> - if ( writeSelector == null ){
>>> - writeSelector =
>>> SelectorFactory.getSelector();
>>> - if ( writeSelector == null){
>>> - // Continue using the main one.
>>> - continue;
>>> - }
>>> - }
>>> -
>>> - key = socketChannel.register(writeSelector,
>>> -
>>> SelectionKey.OP_WRITE);
>>> -
>>> - if (writeSelector.select(writeTimeout) == 0) {
>>> - if (attempts > 2)
>>> - throw new IOException("Client
>>> disconnected");
>>> - }
>>> - }
>>> - }
>>> - } catch (IOException ex){
>>> - len = -1;
>>> - throw ex;
>>> - } finally {
>>> - if (key != null) {
>>> - key.cancel();
>>> - key = null;
>>> - }
>>> -
>>> - if ( writeSelector != null ) {
>>> - // Cancel the key.
>>> -
>>> SelectorFactory.selectNowAndReturnSelector(writeSelector);
>>> - }
>>> -
>>> - if (len == -1){
>>> - if (Thread.currentThread() instanceof
>>> WorkerThread){
>>> - ConnectionCloseHandler cch =
>>> (ConnectionCloseHandler)
>>> - ((WorkerThread)Thread.currentThread())
>>> - .getAttachment
>>> ().getAttribute("ConnectionCloseHandler");
>>> - if (cch != null){
>>> - cch.remotlyClosed(key);
>>> - }
>>> - }
>>> - }
>>> - }
>>> - return nWrite;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param datagramChannel
>>> - * @param socketAddress
>>> - * @param bb the ByteBuffer to write.
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(DatagramChannel
>>> datagramChannel,
>>> - SocketAddress socketAddress, ByteBuffer bb)
>>> - throws IOException{
>>> - return
>>> flushChannel(datagramChannel,socketAddress,bb,defaultWriteTimeout);
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Flush the buffer by looping until the {_at_link ByteBuffer}
>>> is empty
>>> - * @param datagramChannel
>>> - * @param socketAddress
>>> - * @param bb the ByteBuffer to write.
>>> - * @param writeTimeout
>>> - * @return
>>> - * @throws java.io.IOException
>>> - */
>>> - public static long flushChannel(DatagramChannel
>>> datagramChannel,
>>> - SocketAddress socketAddress, ByteBuffer bb, long
>>> writeTimeout)
>>> - throws IOException{
>>> -
>>> - if (bb == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. ByteBuffer"
>>> - + " cannot be null.");
>>> - }
>>> -
>>> - if (datagramChannel == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. " +
>>> - "DatagramChannel cannot be null.");
>>> - }
>>> -
>>> - if (socketAddress == null){
>>> - throw new IllegalStateException("Invalid Response
>>> State. " +
>>> - "SocketAddress cannot be null.");
>>> - }
>>> -
>>> - SelectionKey key = null;
>>> - Selector writeSelector = null;
>>> - int attempts = 0;
>>> - int nWrite = 0;
>>> - try {
>>> - while ( bb.hasRemaining() ) {
>>> - int len = datagramChannel.send(bb,socketAddress);
>>> - if (len > 0){
>>> - attempts = 0;
>>> - nWrite += len;
>>> - } else {
>>> - if ( writeSelector == null ){
>>> - writeSelector =
>>> SelectorFactory.getSelector();
>>> - if ( writeSelector == null){
>>> - // Continue using the main one.
>>> - continue;
>>> - }
>>> - }
>>> -
>>> - key = datagramChannel.register(writeSelector,
>>> -
>>> SelectionKey.OP_WRITE);
>>> -
>>> - if (writeSelector.select(writeTimeout) == 0) {
>>> - if (attempts > 2)
>>> - throw new IOException("Client
>>> disconnected");
>>> - } else {
>>> - attempts--;
>>> - }
>>> - }
>>> - }
>>> - } finally {
>>> - if (key != null) {
>>> - key.cancel();
>>> - key = null;
>>> - }
>>> -
>>> - if ( writeSelector != null ) {
>>> - // Cancel the key.
>>> -
>>> SelectorFactory.selectNowAndReturnSelector(writeSelector);
>>> - }
>>> - }
>>> - return nWrite;
>>> - }
>>> -
>>> -
>>> - public static int getDefaultWriteTimeout() {
>>> - return defaultWriteTimeout;
>>> - }
>>> -
>>> -
>>> - public static void setDefaultWriteTimeout(int
>>> aDefaultWriteTimeout) {
>>> - defaultWriteTimeout = aDefaultWriteTimeout;
>>> - }
>>> -}
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>