com.sun.grizzly.util
Class ThreadAttachment

java.lang.Object
  extended by com.sun.grizzly.util.SelectionKeyAttachment
      extended by com.sun.grizzly.util.SelectionKeyActionAttachment
          extended by com.sun.grizzly.util.ThreadAttachment
All Implemented Interfaces:
AttributeHolder
Direct Known Subclasses:
KeepAliveThreadAttachment

public class ThreadAttachment
extends SelectionKeyActionAttachment
implements AttributeHolder

This object represent the state of a WorkerThread. This include the ByteBuffer binded to the WorkerThread, application data etc.

Author:
Jeanfrancois Arcand, Alexey Stashok

Nested Class Summary
static class ThreadAttachment.Mode
           
 
Nested classes/interfaces inherited from class com.sun.grizzly.util.SelectionKeyAttachment
SelectionKeyAttachment.KeySelectionListener, SelectionKeyAttachment.TimeOutListener
 
Field Summary
 
Fields inherited from class com.sun.grizzly.util.SelectionKeyAttachment
DEREGISTERED, idleTimeoutDelay, keySelectionListener, timeout, timeoutListener, UNLIMITED_TIMEOUT, UNSET_TIMEOUT
 
Constructor Summary
ThreadAttachment()
           
 
Method Summary
 Thread activeThread()
          Return the current Thread which is executing this object.
 void associate()
          Associates ThreadAttachment with the current thread
 void deassociate()
          Releases ThreadAttachment association with the current thread
 Object getAttribute(String key)
          Return an object based on a name.
 Map<String,Object> getAttributes()
          Return a Map of attribute name/value pairs.
 ByteBuffer getByteBuffer()
          Return the ByteBuffer shared this thread
 long getIdleTimeoutDelay()
          Returns the idle timeout delay.
 ByteBuffer getInputBB()
          Return the encrypted ByteBuffer used to handle request.
 int getMode()
           
 ByteBuffer getOutputBB()
          Return the encrypted ByteBuffer used to handle response.
 SSLEngine getSSLEngine()
          Set theSSLEngine.
 String getThreadId()
          Return the name of the Thread on which this instance is binded.
 long getTransactionTimeout()
          Return the time, in milliseconds, this object can be attached to a Thread
protected static boolean isNotSetTimeout(long timeout)
           
protected static boolean isUnlimitedTimeout(long timeout)
           
 void postProcess(SelectionKey selectionKey)
          SelectionKey attachment postProcessing
 void process(SelectionKey selectionKey)
          SelectionKey attachment processing
 void release(SelectionKey selectionKey)
           
 Object removeAttribute(String key)
          Remove a name/value object.
 void reset()
           
 void setAttribute(String key, Object value)
          Set a name/value object.
 void setAttributes(Map<String,Object> attributes)
          Set a Map of attribute name/value pairs.
 void setByteBuffer(ByteBuffer byteBuffer)
          Set the ByteBuffer shared this thread
 void setIdleTimeoutDelay(long idleTimeoutDelay)
          Set the idle timeout delay.
 void setInputBB(ByteBuffer inputBB)
          Set the encrypted ByteBuffer used to handle request.
 void setMode(int mode)
           
 void setOutputBB(ByteBuffer outputBB)
          Set the encrypted ByteBuffer used to handle response.
 void setSSLEngine(SSLEngine sslEngine)
          Get theSSLEngine.
 void setThreadId(String threadName)
          Set the Thread's name on which this instance is binded.
 void setTransactionTimeout(long transactionTimeout)
          Set the time, in milliseconds, this object can be attached to a Thread
 String toString()
           
 
Methods inherited from class com.sun.grizzly.util.SelectionKeyAttachment
getAttachment, getKeySelectionListener, getTimeout, getTimeoutListener, handleSelectedKey, setKeySelectionListener, setTimeout, setTimeoutListener, timedOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadAttachment

public ThreadAttachment()
Method Detail

getMode

public int getMode()

setMode

public void setMode(int mode)

setAttribute

public void setAttribute(String key,
                         Object value)
Description copied from interface: AttributeHolder
Set a name/value object.

Specified by:
setAttribute in interface AttributeHolder
Parameters:
key - - name of an attribute
value - - value of named attribute

getAttribute

public Object getAttribute(String key)
Description copied from interface: AttributeHolder
Return an object based on a name.

Specified by:
getAttribute in interface AttributeHolder
Parameters:
key - - name of an attribute
Returns:
- attribute value for the name, null if name does not exist in attributes

removeAttribute

public Object removeAttribute(String key)
Description copied from interface: AttributeHolder
Remove a name/value object.

Specified by:
removeAttribute in interface AttributeHolder
Parameters:
key - - name of an attribute
Returns:
attribute which has been removed

setAttributes

public void setAttributes(Map<String,Object> attributes)
Description copied from interface: AttributeHolder
Set a Map of attribute name/value pairs. Old AttributeHolder values will not be available. Later changes of this Map will lead to changes to the current AttributeHolder.

Specified by:
setAttributes in interface AttributeHolder
Parameters:
attributes - - map of name/value pairs

getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: AttributeHolder
Return a Map of attribute name/value pairs. Updates, performed on the returned Map will be reflected in this AttributeHolder

Specified by:
getAttributes in interface AttributeHolder
Returns:
- Map of attribute name/value pairs

setByteBuffer

public void setByteBuffer(ByteBuffer byteBuffer)
Set the ByteBuffer shared this thread


getByteBuffer

public ByteBuffer getByteBuffer()
Return the ByteBuffer shared this thread


getInputBB

public ByteBuffer getInputBB()
Return the encrypted ByteBuffer used to handle request.

Returns:
ByteBuffer

setInputBB

public void setInputBB(ByteBuffer inputBB)
Set the encrypted ByteBuffer used to handle request.

Parameters:
inputBB - ByteBuffer

getOutputBB

public ByteBuffer getOutputBB()
Return the encrypted ByteBuffer used to handle response.

Returns:
ByteBuffer

setOutputBB

public void setOutputBB(ByteBuffer outputBB)
Set the encrypted ByteBuffer used to handle response.

Parameters:
outputBB - ByteBuffer

getSSLEngine

public SSLEngine getSSLEngine()
Set theSSLEngine.


setSSLEngine

public void setSSLEngine(SSLEngine sslEngine)
Get theSSLEngine.

Parameters:
sslEngine{@link - SSLEngine}

getThreadId

public String getThreadId()
Return the name of the Thread on which this instance is binded.


setThreadId

public void setThreadId(String threadName)
Set the Thread's name on which this instance is binded.


associate

public void associate()
Associates ThreadAttachment with the current thread


deassociate

public void deassociate()
Releases ThreadAttachment association with the current thread


process

public void process(SelectionKey selectionKey)
SelectionKey attachment processing

Specified by:
process in class SelectionKeyActionAttachment
Parameters:
selectionKey -

postProcess

public void postProcess(SelectionKey selectionKey)
SelectionKey attachment postProcessing

Specified by:
postProcess in class SelectionKeyActionAttachment
Parameters:
selectionKey -

reset

public void reset()

release

public void release(SelectionKey selectionKey)
Overrides:
release in class SelectionKeyAttachment

toString

public String toString()
Overrides:
toString in class Object

activeThread

public Thread activeThread()
Return the current Thread which is executing this object.

Returns:
the current Thread which is executing this object.

getTransactionTimeout

public long getTransactionTimeout()
Return the time, in milliseconds, this object can be attached to a Thread

Returns:
the time, in milliseconds, this object can be attached to a Thread

setTransactionTimeout

public void setTransactionTimeout(long transactionTimeout)
Set the time, in milliseconds, this object can be attached to a Thread

Parameters:
transactionTimeout - the time, in milliseconds, this object can be attached to a Thread

setIdleTimeoutDelay

public void setIdleTimeoutDelay(long idleTimeoutDelay)
Description copied from class: SelectionKeyAttachment
Set the idle timeout delay. Default it returns UNLIMITED_TIMEOUT, meaning no idle timeout delay.

Overrides:
setIdleTimeoutDelay in class SelectionKeyAttachment

getIdleTimeoutDelay

public long getIdleTimeoutDelay()
Description copied from class: SelectionKeyAttachment
Returns the idle timeout delay. Default it returns UNLIMITED_TIMEOUT, meaning no idle timeout delay.

Overrides:
getIdleTimeoutDelay in class SelectionKeyAttachment
Returns:

isUnlimitedTimeout

protected static boolean isUnlimitedTimeout(long timeout)

isNotSetTimeout

protected static boolean isNotSetTimeout(long timeout)


Copyright © 2013 Oracle Corporation. All Rights Reserved.