org.openorb.orb.net
Class AbstractServerRequest

java.lang.Object
  |
  +--org.omg.CORBA.LocalObject
        |
        +--org.openorb.orb.net.AbstractServerRequest
All Implemented Interfaces:
org.omg.CORBA.portable.IDLEntity, org.omg.CORBA.Object, org.omg.PortableInterceptor.RequestInfo, org.omg.PortableInterceptor.RequestInfoOperations, org.omg.CORBA.portable.ResponseHandler, java.io.Serializable, ServerRequest, org.omg.PortableInterceptor.ServerRequestInfo, org.omg.PortableInterceptor.ServerRequestInfoOperations
Direct Known Subclasses:
IIOPServerRequest, LocalServerRequest

public abstract class AbstractServerRequest
extends org.omg.CORBA.LocalObject
implements ServerRequest

Base class which implements most of the server request functionality. Only protocol specific things are not implemented.

Version:
$Revision: 1.16 $ $Date: 2004/06/04 08:20:29 $
Author:
Chris Wood
See Also:
Serialized Form

Fields inherited from interface org.openorb.orb.net.ServerRequest
OBJECT_HERE, STATE_COMPLETE, STATE_CREATED, STATE_FIND_ADAPTER, STATE_PROCESSING, STATE_QUEUED, STATE_REPLY, UNKNOWN_OBJECT
 
Constructor Summary
AbstractServerRequest(ServerManager serverManager, ServerChannel channel, int request_id)
          Two pass constructor for locate request.
AbstractServerRequest(ServerManager serverManager, ServerChannel channel, int request_id, byte[] object_key)
          One pass constructor for locate request
AbstractServerRequest(ServerManager serverManager, ServerChannel channel, int request_id, org.omg.CORBA.portable.InputStream argument_stream)
          Two pass constructor for locate request.
AbstractServerRequest(ServerManager serverManager, ServerChannel channel, int request_id, org.omg.CORBA.portable.InputStream argument_stream, byte[] object_key, java.lang.String operation, byte sync_scope, org.omg.IOP.ServiceContext[] request_service_contexts)
          One pass constructor for request
 
Method Summary
 byte[] adapter_id()
          Find the adapter ID.
 ObjectAdapter adapter()
          Server adapter.
 int adapter(ObjectAdapter adapter)
          Set the object adapter and transfer to the QUEUED state.
 void add_reply_service_context(org.omg.IOP.ServiceContext service_context, boolean replace)
          Add a service context to the reply.
 org.omg.CORBA.portable.InputStream argument_stream()
          Get the request input stream.
 org.omg.Dynamic.Parameter[] arguments()
          Request Arguments.
protected abstract  org.omg.CORBA.portable.OutputStream begin_marshal_reply()
          Create a stream for marshaling a successful response.
protected abstract  org.omg.CORBA.portable.OutputStream begin_marshal_user_exception()
          Create a stream for marshaling a user exception response.
 int begin_request()
          Called by the worker thread before every attempt to run the request.
 ServerChannel channel()
          Server channel
 void client_cancel()
          Client intiated request cancelation.
protected abstract  void complete_reply(org.omg.CORBA.portable.OutputStream os)
          Complete the marshaling process.
 java.lang.String[] contexts()
          Request contexts.
 org.omg.CORBA.portable.OutputStream createExceptionReply()
          Create a stream for marshaling a user exception.
 org.omg.CORBA.portable.OutputStream createReply()
          Create a stream for marshaling the reply.
static void disableServiceContextExceptions()
          Disable exceptions in service context methods.
 void dispatch()
          Call predispatch to locate the target, enter the PROCESSING state, call the receive_request interception points and dispatch the request through the adapter.
static void enableServiceContextExceptions()
          Enable exceptions in service context methods.
 boolean equals(java.lang.Object obj)
          Equality depends on request IDs and channels.
 org.omg.CORBA.TypeCode[] exceptions()
          Request exceptions.
 org.omg.IOP.IOR forward_reference_ior()
          The IOR of the forward reference which will be sent in response to the request.
 org.omg.CORBA.Object forward_reference()
          The forward reference which will be sent in response to the request.
 org.omg.IOP.ServiceContext get_reply_service_context(int id)
          Find a reply service context with a given ID.
 org.omg.IOP.ServiceContext[] get_reply_service_contexts()
          Get a list of all the reply service contexts which been set.
 org.omg.IOP.ServiceContext get_request_service_context(int id)
          Get reqest service context.
 org.omg.CORBA.Policy get_server_policy(int type)
          Find the server policy of the specified type.
 org.omg.CORBA.Any get_slot(int id)
          Access the PI current from interceptors.
protected  org.apache.avalon.framework.logger.Logger getLogger()
          Return current logger
 int hashCode()
          Ensure that equal requests have the same hashCode.
 void init(byte[] object_key)
          Second locate request construction pass.
 void init(byte[] object_key, java.lang.String operation, byte sync_scope, org.omg.IOP.ServiceContext[] request_service_contexts)
          second constructor pass.
 boolean is_locate()
          This returns true if this request is a locate request.
protected abstract  void marshal_forward_request(org.omg.CORBA.Object target, boolean permanent)
          Send a forward request result.
protected abstract  void marshal_locate_reply(boolean object_is_here)
          Reply to a locate request.
protected abstract  void marshal_system_exception(java.lang.String repo_id, org.omg.CORBA.SystemException ex)
          Send a system exception result.
 byte[] object_id()
          Find the object ID.
 byte[] object_key()
          Object Key.
 java.lang.String[] operation_context()
          Request contexts.
 java.lang.String operation()
          Operation name.
 org.omg.CORBA.ORB orb()
          Orb
protected abstract  void release_request()
          Release any resources associated with the request.
 short reply_status()
          Get the reply status.
 int request_id()
          Request ID.
 boolean response_expected()
          Response is expected to the request.
 org.omg.CORBA.Any result()
          Request result.
 org.omg.CORBA.Any sending_exception()
          Exception being sent in reply.
 java.lang.String sending_system_exception_id()
          Repository ID of the system exception being sent as a reply.
 org.omg.CORBA.SystemException sending_system_exception()
          System exception being sent as a reply.
 void server_cancel(java.lang.Throwable ex)
          Server intiated request cancelation.
 void set_slot(int id, org.omg.CORBA.Any data)
          Access the PI current from interceptors.
protected  org.omg.CORBA.CompletionStatus state_completion_status()
          Returns completion status appropriate for the request state.
 int state()
          Current request state.
 short sync_scope()
          Message sync scope.
 boolean target_is_a(java.lang.String id)
          Determine if the target implements the given interface.
 java.lang.String target_most_derived_interface()
          Most derrived repository ID of the target.
 java.lang.String toString()
           
 
Methods inherited from class org.omg.CORBA.LocalObject
_create_request, _create_request, _duplicate, _get_domain_managers, _get_interface_def, _get_interface, _get_policy, _hash, _invoke, _is_a, _is_equivalent, _is_local, _non_existent, _orb, _release, _releaseReply, _request, _request, _servant_postinvoke, _servant_preinvoke, _set_policy_override, validate_connection
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.omg.CORBA.Object
_create_request, _create_request, _duplicate, _get_domain_managers, _get_interface_def, _get_interface, _get_policy, _hash, _is_a, _is_equivalent, _non_existent, _release, _request, _set_policy_override
 

Constructor Detail

AbstractServerRequest

public AbstractServerRequest(ServerManager serverManager,
                             ServerChannel channel,
                             int request_id,
                             org.omg.CORBA.portable.InputStream argument_stream,
                             byte[] object_key,
                             java.lang.String operation,
                             byte sync_scope,
                             org.omg.IOP.ServiceContext[] request_service_contexts)
One pass constructor for request

AbstractServerRequest

public AbstractServerRequest(ServerManager serverManager,
                             ServerChannel channel,
                             int request_id,
                             org.omg.CORBA.portable.InputStream argument_stream)
Two pass constructor for locate request. This constructor must be followed by a call to init.

AbstractServerRequest

public AbstractServerRequest(ServerManager serverManager,
                             ServerChannel channel,
                             int request_id,
                             byte[] object_key)
One pass constructor for locate request

AbstractServerRequest

public AbstractServerRequest(ServerManager serverManager,
                             ServerChannel channel,
                             int request_id)
Two pass constructor for locate request. Must be followed by call to init(byte [] object_key)
Method Detail

init

public void init(byte[] object_key,
                 java.lang.String operation,
                 byte sync_scope,
                 org.omg.IOP.ServiceContext[] request_service_contexts)
second constructor pass.

init

public void init(byte[] object_key)
Second locate request construction pass.

disableServiceContextExceptions

public static void disableServiceContextExceptions()
Disable exceptions in service context methods. This is a performance optimization as assembling the stack trace is a costly operation.

enableServiceContextExceptions

public static void enableServiceContextExceptions()
Enable exceptions in service context methods. Not throwing a performance optimization as assembling the stack trace is a costly operation.

orb

public org.omg.CORBA.ORB orb()
Orb
Specified by:
orb in interface ServerRequest

channel

public ServerChannel channel()
Server channel
Specified by:
channel in interface ServerRequest

state

public int state()
Current request state.
Specified by:
state in interface ServerRequest

state_completion_status

protected org.omg.CORBA.CompletionStatus state_completion_status()
Returns completion status appropriate for the request state.

is_locate

public boolean is_locate()
This returns true if this request is a locate request. Use replyLocate to set the reply. Interceptors are not called for locate requests. ServerRequestInfo operations: arguments, exceptions, contexts, operation_context, result, get_request_service_context, get_reply_service_context, add_reply_service_context are not valid. operation returns the empty string "", response_expected returns true. Note the extra value for reply_status, UNKNOWN_OBJECT.
Specified by:
is_locate in interface ServerRequest

object_key

public byte[] object_key()
Object Key. This is always available.
Specified by:
object_key in interface ServerRequest

request_id

public int request_id()
Request ID. This is always available.
Specified by:
request_id in interface org.omg.PortableInterceptor.RequestInfoOperations

equals

public boolean equals(java.lang.Object obj)
Equality depends on request IDs and channels.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Ensure that equal requests have the same hashCode.
Overrides:
hashCode in class java.lang.Object

operation

public java.lang.String operation()
Operation name. This will return null for locate requests.
Specified by:
operation in interface org.omg.PortableInterceptor.RequestInfoOperations

response_expected

public boolean response_expected()
Response is expected to the request. If this is true then createReply or createExceptionReply is expected to be called by the dispatch operation.
Specified by:
response_expected in interface org.omg.PortableInterceptor.RequestInfoOperations

sync_scope

public short sync_scope()
Message sync scope.
Specified by:
sync_scope in interface org.omg.PortableInterceptor.RequestInfoOperations

arguments

public org.omg.Dynamic.Parameter[] arguments()
Request Arguments. This operation is not available in java.
Specified by:
arguments in interface org.omg.PortableInterceptor.RequestInfoOperations

exceptions

public org.omg.CORBA.TypeCode[] exceptions()
Request exceptions. This operation is not available in java.
Specified by:
exceptions in interface org.omg.PortableInterceptor.RequestInfoOperations

contexts

public java.lang.String[] contexts()
Request contexts. This operation is not available in java.
Specified by:
contexts in interface org.omg.PortableInterceptor.RequestInfoOperations

operation_context

public java.lang.String[] operation_context()
Request contexts. This operation is not available in java.
Specified by:
operation_context in interface org.omg.PortableInterceptor.RequestInfoOperations

result

public org.omg.CORBA.Any result()
Request result. This operation is not available in java.
Specified by:
result in interface org.omg.PortableInterceptor.RequestInfoOperations

get_slot

public org.omg.CORBA.Any get_slot(int id)
                           throws org.omg.PortableInterceptor.InvalidSlot
Access the PI current from interceptors. From the adapter this operation is also available via the PI Current.
Specified by:
get_slot in interface org.omg.PortableInterceptor.RequestInfoOperations

set_slot

public void set_slot(int id,
                     org.omg.CORBA.Any data)
              throws org.omg.PortableInterceptor.InvalidSlot
Access the PI current from interceptors. From the adapter this operation is also available via the PI Current.
Specified by:
set_slot in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

get_request_service_context

public org.omg.IOP.ServiceContext get_request_service_context(int id)
Get reqest service context. This operation is always available.
Specified by:
get_request_service_context in interface org.omg.PortableInterceptor.RequestInfoOperations

client_cancel

public void client_cancel()
Client intiated request cancelation. This may be called at any time to indicate that a response from the request is no longer expected.
Specified by:
client_cancel in interface ServerRequest

server_cancel

public void server_cancel(java.lang.Throwable ex)
Server intiated request cancelation. This may be called at any time by the server to indicate a server initiated cancel. The request is returned to the server. The completion status of the exception will be set appropriatly.
Specified by:
server_cancel in interface ServerRequest

begin_request

public int begin_request()
Called by the worker thread before every attempt to run the request. This should call the recieve_request_service_context interception point.
Specified by:
begin_request in interface ServerRequest
Returns:
the state of the request.

adapter

public int adapter(ObjectAdapter adapter)
Set the object adapter and transfer to the QUEUED state. This is legal only in the FIND_ADAPTER or COMPLETE states. If COMPLETE this has no effect.
Specified by:
adapter in interface ServerRequest
Returns:
the state of the request. This will be either QUEUED or COMPLETE.

adapter

public ObjectAdapter adapter()
Server adapter. This operation is valid in all states apart from CREATED and FIND_ADAPTER.
Specified by:
adapter in interface ServerRequest

get_server_policy

public org.omg.CORBA.Policy get_server_policy(int type)
Find the server policy of the specified type. This operation is valid in all states apart from CREATED and FIND_ADAPTER.
Specified by:
get_server_policy in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

adapter_id

public byte[] adapter_id()
Find the adapter ID.
Specified by:
adapter_id in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

object_id

public byte[] object_id()
Find the object ID.
Specified by:
object_id in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

target_most_derived_interface

public java.lang.String target_most_derived_interface()
Most derrived repository ID of the target.
Specified by:
target_most_derived_interface in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

target_is_a

public boolean target_is_a(java.lang.String id)
Determine if the target implements the given interface.
Specified by:
target_is_a in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

dispatch

public void dispatch()
              throws AdapterDestroyedException
Call predispatch to locate the target, enter the PROCESSING state, call the receive_request interception points and dispatch the request through the adapter. If sync scope is SYNC_WITH_SERVER an empty response will be sent before the request is dispatched. When this function returns all the terminating interception points will have been called, and state will be COMPLETE. If the target adapter is destroyed between the find_adapter and dispatch requests this function will throw an AdapterDestroyedException and the CREATED state is re-entered, find_adapter function will be called again once the unregister adapter operation is called on the server manager with the target adapter.
Specified by:
dispatch in interface ServerRequest

argument_stream

public org.omg.CORBA.portable.InputStream argument_stream()
Get the request input stream. This function can be called only once while in the PROCESSING state. The returned input stream may throw a system exception if some problem occours while unmarshalling the request arguments. This function, and the reply functions must be called by the same thread, the thread that called the dispatch function.
Specified by:
argument_stream in interface ServerRequest

add_reply_service_context

public void add_reply_service_context(org.omg.IOP.ServiceContext service_context,
                                      boolean replace)
Add a service context to the reply.
Specified by:
add_reply_service_context in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

get_reply_service_context

public org.omg.IOP.ServiceContext get_reply_service_context(int id)
Find a reply service context with a given ID.
Specified by:
get_reply_service_context in interface org.omg.PortableInterceptor.RequestInfoOperations

get_reply_service_contexts

public org.omg.IOP.ServiceContext[] get_reply_service_contexts()
Get a list of all the reply service contexts which been set.
Specified by:
get_reply_service_contexts in interface ServerRequest

reply_status

public short reply_status()
Get the reply status. This operation is available in the REPLY and COMPLETE states.
Specified by:
reply_status in interface org.omg.PortableInterceptor.RequestInfoOperations

forward_reference

public org.omg.CORBA.Object forward_reference()
The forward reference which will be sent in response to the request.
Specified by:
forward_reference in interface org.omg.PortableInterceptor.RequestInfoOperations

forward_reference_ior

public org.omg.IOP.IOR forward_reference_ior()
The IOR of the forward reference which will be sent in response to the request.
Specified by:
forward_reference_ior in interface ServerRequest

sending_exception

public org.omg.CORBA.Any sending_exception()
Exception being sent in reply. This will only contain system exceptions.
Specified by:
sending_exception in interface org.omg.PortableInterceptor.ServerRequestInfoOperations

sending_system_exception

public org.omg.CORBA.SystemException sending_system_exception()
System exception being sent as a reply.
Specified by:
sending_system_exception in interface ServerRequest

sending_system_exception_id

public java.lang.String sending_system_exception_id()
Repository ID of the system exception being sent as a reply.
Specified by:
sending_system_exception_id in interface ServerRequest

createReply

public org.omg.CORBA.portable.OutputStream createReply()
Description copied from interface: ServerRequest
Create a stream for marshaling the reply. The send_reply interception points are called, if this results in a system exception the exception is thrown, otherwise a stream is retured. The returned stream may raise a system exception when attempting to write to it indicating a transmission problem. Such an exception is not reported to interceptors. This function is inherited from the ResponseHandler interface.
Specified by:
createReply in interface ServerRequest

createExceptionReply

public org.omg.CORBA.portable.OutputStream createExceptionReply()
Description copied from interface: ServerRequest
Create a stream for marshaling a user exception. The send_exception interception points are called, if this results in a system exception the exception is thrown, otherwise a stream is retured. The returned stream may raise a system exception when attempting to write to it indicating a transmission problem. Such an exception is not reported to interceptors. This function is inherited from the ResponseHandler interface.
Specified by:
createExceptionReply in interface ServerRequest

marshal_system_exception

protected abstract void marshal_system_exception(java.lang.String repo_id,
                                                 org.omg.CORBA.SystemException ex)
Send a system exception result. Note that a failed locate request will always result in an OBJECT_NOT_FOUND system exception, which this function is free to convert into a failed locate reply. This may throw a system exception indicating a transport problem.

marshal_forward_request

protected abstract void marshal_forward_request(org.omg.CORBA.Object target,
                                                boolean permanent)
Send a forward request result. This may throw a system exception indicating a transport problem.

marshal_locate_reply

protected abstract void marshal_locate_reply(boolean object_is_here)
Reply to a locate request. This argument to this function will be true when called from this class, however marshal_system_exception may convert a system exception response into a locate failure. This may throw a system exception indicating a transport problem.

begin_marshal_reply

protected abstract org.omg.CORBA.portable.OutputStream begin_marshal_reply()
Create a stream for marshaling a successful response. This is paired with a call to complete_marshal. The returned stream may throw a system exception at any time to indicate transport problems.

begin_marshal_user_exception

protected abstract org.omg.CORBA.portable.OutputStream begin_marshal_user_exception()
Create a stream for marshaling a user exception response. This is paired with a call to complete_marshal. The returned stream may throw a system exception at any time to indicate transport problems.

complete_reply

protected abstract void complete_reply(org.omg.CORBA.portable.OutputStream os)
Complete the marshaling process. Paired with a call to begin_marshal_* . This may throw a system exception to indicate transport problems.

release_request

protected abstract void release_request()
Release any resources associated with the request. This is called when the complete state is entered.

getLogger

protected org.apache.avalon.framework.logger.Logger getLogger()
Return current logger

toString

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