# OpenORB 1.3.1: Class AbstractServerRequest

## org.openorb.net
Class AbstractServerRequest

    java.lang.Object
      |
      +--org.omg.CORBA.LocalObject
            |
            +--org.openorb.net.AbstractServerRequest

All Implemented Interfaces:
  IDLEntity, Object, RequestInfo, RequestInfoOperations, ResponseHandler, java.io.Serializable, ServerRequest, ServerRequestInfo, ServerRequestInfoOperations

Direct Known Subclasses:
  IIOPServerRequest, LocalServerRequest

public abstract class AbstractServerRequest
extends 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: 2002/07/14 19:12:36 $
Author:
  Chris Wood
See Also:
  Serialized Form

Fields inherited from interface org.openorb.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, java.lang.Object transportAssociation, int request_id)` Two pass constructor for locate request.
`AbstractServerRequest(ServerManager serverManager, ServerChannel channel, java.lang.Object transportAssociation, int request_id, byte[] object_key)` One pass constructor for locate request
`AbstractServerRequest(ServerManager serverManager, ServerChannel channel, java.lang.Object transportAssociation, int request_id, InputStream argument_stream)` Two pass constructor for locate request.
`AbstractServerRequest(ServerManager serverManager, ServerChannel channel, java.lang.Object transportAssociation, int request_id, InputStream argument_stream, byte[] object_key, java.lang.String operation, byte sync_scope, 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(ServiceContext service_context, boolean replace)` Add a service context to the reply.
`InputStream` `argument_stream()` Get the request input stream.
`Parameter[]` `arguments()` Request Arguments.
`int` `begin_request()` Called by the worker thread before every attempt to run the request.
`ServerChannel` `channel()` Server channel
`boolean` `checkRequestTransportAssoc(java.lang.Object tpAssc)` Check the transport association, take appropriate action if association is incorrect.
`void` `client_cancel()` Client intiated request cancelation.
`java.lang.String[]` `contexts()` Request contexts.
`OutputStream` `createExceptionReply()` Create a stream for marshaling a user exception.
`OutputStream` `createReply()` Create a stream for marshaling the reply.
`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.
`boolean` `equals(java.lang.Object obj)` Equality depends on request IDs and channels.
`TypeCode[]` `exceptions()` Request exceptions.
`IOR` `forward_reference_ior()` The IOR of the forward reference which will be sent in response to the request.
`Object` `forward_reference()` The forward reference which will be sent in response to the request.
`ServiceContext` `get_reply_service_context(int id)` Find a reply service context with a given ID.
`ServiceContext[]` `get_reply_service_contexts()` Get a list of all the reply service contexts which been set.
`ServiceContext` `get_request_service_context(int id)` Get reqest service context.
`Policy` `get_server_policy(int type)` Find the server policy of the specified type.
`Any` `get_slot(int id)` Access the PI current from interceptors.
`java.lang.Object` `get_transport_association()` Get the transport association.
`void` `init(byte[] object_key)` Second locate request construction pass.
`void` `init(byte[] object_key, java.lang.String operation, byte sync_scope, ServiceContext[] request_service_contexts)` second constructor pass.
`boolean` `is_locate()` This returns true if this request is a locate request.
`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.
`ORB` `orb()` Orb
`short` `reply_status()` Get the reply status.
`int` `request_id()` Request ID.
`boolean` `response_expected()` Response is expected to the request.
`Any` `result()` Request result.
`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.
`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, Any data)` Access the PI current from interceptors.
`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.

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
`getClass, hashCode, notify, notifyAll, toString, 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,
                                 java.lang.Object transportAssociation,
                                 int request_id,
                                 InputStream argument_stream,
                                 byte[] object_key,
                                 java.lang.String operation,
                                 byte sync_scope,
                                 ServiceContext[] request_service_contexts)

  One pass constructor for request

### AbstractServerRequest

    public AbstractServerRequest(ServerManager serverManager,
                                 ServerChannel channel,
                                 java.lang.Object transportAssociation,
                                 int request_id,
                                 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,
                                 java.lang.Object transportAssociation,
                                 int request_id,
                                 byte[] object_key)

  One pass constructor for locate request

### AbstractServerRequest

    public AbstractServerRequest(ServerManager serverManager,
                                 ServerChannel channel,
                                 java.lang.Object transportAssociation,
                                 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,
                     ServiceContext[] request_service_contexts)

  second constructor pass.

### init

    public void init(byte[] object_key)

  Second locate request construction pass.

### orb

    public ORB orb()

  Orb
  Specified by:
    `orb` in interface `ServerRequest`

### channel

    public ServerChannel channel()

  Server channel
  Specified by:
    `channel` in interface `ServerRequest`

### get_transport_association

    public java.lang.Object get_transport_association()

  Get the transport association.
  Specified by:
    `get_transport_association` in interface `ServerRequest`

### checkRequestTransportAssoc

    public boolean checkRequestTransportAssoc(java.lang.Object tpAssc)

  Check the transport association, take appropriate action if association is incorrect. This will be called once for each request fragment and cancel request message.

### state

    public int state()

  Current request state.
  Specified by:
    `state` in interface `ServerRequest`

### 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 `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### equals

    public boolean equals(java.lang.Object obj)

  Equality depends on request IDs and channels.
  Overrides:
    `equals` 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 `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### 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 `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### sync_scope

    public short sync_scope()

  Message sync scope.
  Specified by:
    `sync_scope` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### arguments

    public Parameter[] arguments()

  Request Arguments. This operation is not available in java.
  Specified by:
    `arguments` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### exceptions

    public TypeCode[] exceptions()

  Request exceptions. This operation is not available in java.
  Specified by:
    `exceptions` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### contexts

    public java.lang.String[] contexts()

  Request contexts. This operation is not available in java.
  Specified by:
    `contexts` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### operation_context

    public java.lang.String[] operation_context()

  Request contexts. This operation is not available in java.
  Specified by:
    `operation_context` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### result

    public Any result()

  Request result. This operation is not available in java.
  Specified by:
    `result` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### get_slot

    public Any get_slot(int id)
                 throws 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 `RequestInfoOperations`

### set_slot

    public void set_slot(int id,
                         Any data)
                  throws 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 `ServerRequestInfoOperations`

### get_request_service_context

    public ServiceContext get_request_service_context(int id)

  Get reqest service context. This operation is always available.
  Specified by:
    `get_request_service_context` in interface `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 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 `ServerRequestInfoOperations`

### adapter_id

    public byte[] adapter_id()

  Find the adapter ID.
  Specified by:
    `adapter_id` in interface `ServerRequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.ServerRequestInfoOperations`
  Returns:
    the attribute value

### object_id

    public byte[] object_id()

  Find the object ID.
  Specified by:
    `object_id` in interface `ServerRequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.ServerRequestInfoOperations`
  Returns:
    the attribute value

### 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 `ServerRequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.ServerRequestInfoOperations`
  Returns:
    the attribute value

### 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 `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 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(ServiceContext service_context,
                                          boolean replace)

  Add a service context to the reply.
  Specified by:
    `add_reply_service_context` in interface `ServerRequestInfoOperations`

### get_reply_service_context

    public ServiceContext get_reply_service_context(int id)

  Find a reply service context with a given ID.
  Specified by:
    `get_reply_service_context` in interface `RequestInfoOperations`

### get_reply_service_contexts

    public 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 `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### forward_reference

    public Object forward_reference()

  The forward reference which will be sent in response to the request.
  Specified by:
    `forward_reference` in interface `RequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.RequestInfoOperations`
  Returns:
    the attribute value

### forward_reference_ior

    public 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 Any sending_exception()

  Exception being sent in reply. This will only contain system exceptions.
  Specified by:
    `sending_exception` in interface `ServerRequestInfoOperations`
  Following copied from interface: `org.omg.PortableInterceptor.ServerRequestInfoOperations`
  Returns:
    the attribute value

### sending_system_exception

    public 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 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 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`