com.sap.conn.jco.server
Class DefaultServerHandlerFactory<T>

java.lang.Object
  extended by com.sap.conn.jco.server.DefaultServerHandlerFactory<T>
Direct Known Subclasses:
DefaultServerHandlerFactory.FunctionHandlerFactory, DefaultServerHandlerFactory.RequestHandlerFactory

public class DefaultServerHandlerFactory<T>
extends java.lang.Object

This class is the base for a trivial default implementation of JCoServerFunctionHandlerFactory and JCoServerRequestHandlerFactory. A simple server application or a server application that dispatches only few functions and is not interested in a flexible handling provided by handler factories, may use DefaultServerHandlerFactory.FunctionHandlerFactory or DefaultServerHandlerFactory.RequestHandlerFactory instead of writing own implementations. The implementation of DefaultServerHandlerFactory allows to define handlers for particular functions and/or a generic handler. The generic handler will be invoked only, if no concrete handler for the function module is registered.


Nested Class Summary
static class DefaultServerHandlerFactory.FunctionHandlerFactory
          Trivial implementation for JCoServerFunctionHandlerFactory.
static class DefaultServerHandlerFactory.RequestHandlerFactory
          Trivial implementation for JCoServerRequestHandlerFactory.
 
Field Summary
static java.lang.String GENERIC_HANDLER
          Name for a generic handler implementation.
 
Constructor Summary
DefaultServerHandlerFactory()
          Creates a new instance for the DefaultServerHandlerFactory.
 
Method Summary
 T getCallHandler(JCoServerContext serverCtx, java.lang.String name)
          Depending on the incarnation of the handler factory this methods either implements the required method for JCoServerFunctionHandlerFactory or JCoServerRequestHandlerFactory.
 void registerGenericHandler(T handler)
          Registers a generic handler with the call handler factory.
 void registerHandler(java.lang.String functionName, T handler)
          Registers a call handler with the call handler factory.
 void removeGenericHandler()
          Unregisters the generic call handler.
 void removeHandler(java.lang.String functionName)
          Unregisters the call handler for the given function module name.
 void sessionClosed(JCoServerContext serverCtx, java.lang.String message, boolean error)
          This method will be invoked by the JCo runtime, in case a stateful session is going to be closed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERIC_HANDLER

public static final java.lang.String GENERIC_HANDLER
Name for a generic handler implementation.

See Also:
Constant Field Values
Constructor Detail

DefaultServerHandlerFactory

public DefaultServerHandlerFactory()
Creates a new instance for the DefaultServerHandlerFactory.

Method Detail

sessionClosed

public void sessionClosed(JCoServerContext serverCtx,
                          java.lang.String message,
                          boolean error)
This method will be invoked by the JCo runtime, in case a stateful session is going to be closed. Fulfills the JCoServerCallHandlerFactory interface method

Parameters:
serverCtx - server context of the closing session
message - a message describing the reason, if there is one available
error - is true if the session was closed because of any errors

getCallHandler

public T getCallHandler(JCoServerContext serverCtx,
                        java.lang.String name)
Depending on the incarnation of the handler factory this methods either implements the required method for JCoServerFunctionHandlerFactory or JCoServerRequestHandlerFactory.

Parameters:
serverCtx - additional description for the call context
name - function name for which a call handler is required
Returns:
the appropriate CallHandler

registerGenericHandler

public void registerGenericHandler(T handler)
                            throws java.lang.RuntimeException
Registers a generic handler with the call handler factory.

Parameters:
handler - the handler to register
Throws:
java.lang.RuntimeException - in case the registration fails (e.g. a registration for a generic handler already exists)

registerHandler

public void registerHandler(java.lang.String functionName,
                            T handler)
                     throws java.lang.RuntimeException
Registers a call handler with the call handler factory.

Parameters:
functionName - the function module name for which the handler shall be registered
handler - the handler to register
Throws:
java.lang.RuntimeException - in case the registration fails (e.g. a registration for a handler for that function module already exists)

removeHandler

public void removeHandler(java.lang.String functionName)
                   throws java.lang.RuntimeException
Unregisters the call handler for the given function module name.

Parameters:
functionName - the function module name that shall be unregistered
Throws:
java.lang.RuntimeException - in case there was no handler registered

removeGenericHandler

public void removeGenericHandler()
                          throws java.lang.RuntimeException
Unregisters the generic call handler.

Throws:
java.lang.RuntimeException - in case there was no generic handler registered


Copyright © 2008-2014 SAP AG. All Rights Reserved.