org.jboss.remoting.callback
Class ServerInvokerCallbackHandler

java.lang.Object
  extended by org.jboss.remoting.callback.ServerInvokerCallbackHandler
All Implemented Interfaces:
AsynchInvokerCallbackHandler, InvokerCallbackHandler, ConnectionListener

public class ServerInvokerCallbackHandler
extends java.lang.Object
implements AsynchInvokerCallbackHandler, ConnectionListener

Responsible for all callbacks in remoting at invoker level (on the server side). This is created within the ServerInvoker and passed to the server handler as a proxy for the client's callback handler.

Will determin internally if is using pull or push mechanism for delivering callbacks. If is push, will create a Client to call back on the callback server.

Author:
Tom Elrod

Field Summary
static java.lang.String CALLBACK_ERROR_HANDLER_KEY
          The map key to use when looking up any callback error handler that should be used.
static java.lang.String CALLBACK_ID
          This key used to identify a Callback to be acknowledged.
static java.lang.String CALLBACK_LISTENER
          The key used for storing a CallbackListener in the return metadata map of a Callback.
static java.lang.String CALLBACK_MEM_CEILING
          The map key to use when looking up the percentage of free memory available before tiggering persistence.
static java.lang.String CALLBACK_STORE_KEY
          The map key to use when looking up any callback store that should be used.
static java.lang.String CALLBACK_TIMEOUT
          This key is used to identify the timeout used by a callback client
static java.lang.String REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS
           
static java.lang.String SERVER_INVOKER
          The key used to pass to the callback client a reference to ServerInvoker
static java.lang.String SERVER_INVOKER_CALLBACK_HANDLER
          The key used to pass to the callback client a reference this ServerInvokerCallbackHandler
 
Constructor Summary
ServerInvokerCallbackHandler(InvocationRequest invocation, InvokerLocator serverLocator, ServerInvoker owner)
           
 
Method Summary
 void acknowledgeCallbacks(InternalInvocation invocation)
          Calls listeners to acknowledge callbacks
 void connect()
           
 void destroy()
          This method is required to be called upon removing a callback listener so can clean up resources used by the handler.
 Client getCallbackClient()
           
 java.util.List getCallbacks(java.util.Map metadata)
           
 java.lang.String getCallbackSessionId()
           
 java.lang.String getClientSessionId()
           
 java.lang.String getId()
          Returns an id that can be used to identify this particular callback handler, which should be representative of the client invoker it will make callbacks to.
static java.lang.String getId(InvocationRequest invocation)
          Returns an id that can be used to identify this particular callback handler, which should be representative of the client invoker it will make callbacks to.
 java.lang.Double getMemPercentCeiling()
           
 java.lang.String getSubsystem()
           
 void handleCallback(Callback callback)
          Will take the callback message and send back to client.
 void handleCallback(Callback callback, boolean asynch, boolean serverSide)
          For push callbacks:
 void handleCallbackOneway(Callback callback)
          For push callbacks, will send the callback to the server invoker on the client side, hand off processing to a separate thread, and return.
 void handleCallbackOneway(Callback callback, boolean serverSide)
          For push callbacks:
 void handleConnectionException(java.lang.Throwable throwable, Client client)
          Called when a target server or client found to be dead.
 boolean isPullCallbackHandler()
           
 boolean isShouldPersist()
           
 void setMemPercentCeiling(java.lang.Double ceiling)
           
 void setShouldPersist(boolean shouldPersist)
           
 void shutdown()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CALLBACK_STORE_KEY

public static final java.lang.String CALLBACK_STORE_KEY
The map key to use when looking up any callback store that should be used. This key should be used when setting up config in the invoker.

See Also:
Constant Field Values

CALLBACK_ERROR_HANDLER_KEY

public static final java.lang.String CALLBACK_ERROR_HANDLER_KEY
The map key to use when looking up any callback error handler that should be used. This key should be used when setting up config in the invoker.

See Also:
Constant Field Values

CALLBACK_MEM_CEILING

public static final java.lang.String CALLBACK_MEM_CEILING
The map key to use when looking up the percentage of free memory available before tiggering persistence.

See Also:
Constant Field Values

CALLBACK_LISTENER

public static final java.lang.String CALLBACK_LISTENER
The key used for storing a CallbackListener in the return metadata map of a Callback.

See Also:
Constant Field Values

REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS

public static final java.lang.String REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS
See Also:
Constant Field Values

CALLBACK_ID

public static final java.lang.String CALLBACK_ID
This key used to identify a Callback to be acknowledged.

See Also:
Constant Field Values

CALLBACK_TIMEOUT

public static final java.lang.String CALLBACK_TIMEOUT
This key is used to identify the timeout used by a callback client

See Also:
Constant Field Values

SERVER_INVOKER

public static final java.lang.String SERVER_INVOKER
The key used to pass to the callback client a reference to ServerInvoker

See Also:
Constant Field Values

SERVER_INVOKER_CALLBACK_HANDLER

public static final java.lang.String SERVER_INVOKER_CALLBACK_HANDLER
The key used to pass to the callback client a reference this ServerInvokerCallbackHandler

See Also:
Constant Field Values
Constructor Detail

ServerInvokerCallbackHandler

public ServerInvokerCallbackHandler(InvocationRequest invocation,
                                    InvokerLocator serverLocator,
                                    ServerInvoker owner)
                             throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

connect

public void connect()
             throws java.lang.Exception
Throws:
java.lang.Exception

getCallbackSessionId

public java.lang.String getCallbackSessionId()

getClientSessionId

public java.lang.String getClientSessionId()

getSubsystem

public java.lang.String getSubsystem()

setMemPercentCeiling

public void setMemPercentCeiling(java.lang.Double ceiling)

getMemPercentCeiling

public java.lang.Double getMemPercentCeiling()

getCallbackClient

public Client getCallbackClient()

getId

public static java.lang.String getId(InvocationRequest invocation)
Returns an id that can be used to identify this particular callback handler, which should be representative of the client invoker it will make callbacks to. Currently, this is the session id associated with the invocation request.


getId

public java.lang.String getId()
Returns an id that can be used to identify this particular callback handler, which should be representative of the client invoker it will make callbacks to.


getCallbacks

public java.util.List getCallbacks(java.util.Map metadata)

isPullCallbackHandler

public boolean isPullCallbackHandler()

handleCallback

public void handleCallback(Callback callback)
                    throws HandleCallbackException
Will take the callback message and send back to client. If client locator is null, will store them till client polls to get them.

Specified by:
handleCallback in interface InvokerCallbackHandler
Parameters:
callback -
Throws:
HandleCallbackException

handleCallbackOneway

public void handleCallbackOneway(Callback callback)
                          throws HandleCallbackException
For push callbacks, will send the callback to the server invoker on the client side, hand off processing to a separate thread, and return.

For pull callbacks, behaves the same as handleCallback(Callback callback).

Specified by:
handleCallbackOneway in interface AsynchInvokerCallbackHandler
Parameters:
callback -
Throws:
HandleCallbackException

handleCallbackOneway

public void handleCallbackOneway(Callback callback,
                                 boolean serverSide)
                          throws HandleCallbackException
For push callbacks:

if serverSide == false, will send the callback to the server invoker on the client side, hand off processing to a separate thread, and return.

if serverside == true, will hand off to a separate thread the sending of the callback and will then return.

For pull callbacks, behaves the same as handleCallback(Callback callback).

Specified by:
handleCallbackOneway in interface AsynchInvokerCallbackHandler
Parameters:
callback -
serverSide -
Throws:
HandleCallbackException

handleCallback

public void handleCallback(Callback callback,
                           boolean asynch,
                           boolean serverSide)
                    throws HandleCallbackException
For push callbacks:

if asynch == false, behaves the same as handleCallback(Callback callback).

if asynch == true:

if serverSide == false, will send the callback to the server invoker on the client side, hand off processing to a separate thread, and return.

if serverside == true, will hand off to a separate thread the sending of the callback and will then return.

For pull callbacks, behaves the same as handleCallback(Callback callback).

Specified by:
handleCallback in interface AsynchInvokerCallbackHandler
Throws:
HandleCallbackException

acknowledgeCallbacks

public void acknowledgeCallbacks(InternalInvocation invocation)
                          throws java.lang.Exception
Calls listeners to acknowledge callbacks

Parameters:
invocation - carries identities of Callbacks to acknowledge and, optionally, responses
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

destroy

public void destroy()
This method is required to be called upon removing a callback listener so can clean up resources used by the handler. In particular, should call disconnect on internal Client.


shutdown

public void shutdown()

handleConnectionException

public void handleConnectionException(java.lang.Throwable throwable,
                                      Client client)
Description copied from interface: ConnectionListener
Called when a target server or client found to be dead.

Specified by:
handleConnectionException in interface ConnectionListener
Parameters:
throwable - - original exception thrown when trying to connect to target server. If is listener on server for client failure, the exception will be a ClientDisconnectedException if the client disconnected normally, or null if the lease expired.
client - - the client from which this call was made.

isShouldPersist

public boolean isShouldPersist()

setShouldPersist

public void setShouldPersist(boolean shouldPersist)


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.