## org.openorb.adapter.fwd
Class ForwardAdapter

    java.lang.Object
      |
      +--org.openorb.adapter.fwd.ForwardAdapter

All Implemented Interfaces:
  CorbalocServiceOperations, ObjectAdapter

public class ForwardAdapter
extends java.lang.Object
implements ObjectAdapter, CorbalocServiceOperations

This class provides the implementation for registering objects that can easily accessed by plain-text corbaloc references.

Version:
  $Revision: 1.15 $ $Date: 2002/07/14 18:55:10 $
Author:
  Chris Wood

Field Summary
`static byte[]` `CORBALOC_SVC_ID` The byte representation of the service's name.
`static java.lang.String` `CORBALOC_SVC_NAME` The name of the service.
`static byte[]` `JDK_ID` This is the string sent by the JDK ORB when trying to resolve corbaloc references.

Constructor Summary
`ForwardAdapter(ServerManager server_manager)` Constructor.

Method Summary
`byte[]` `adapter_id(byte[] object_key)` Return the adapter id.
`int` `cache_priority()` Expected lifetime of the adapter.
`void` `cancel_dispatch(ServerRequest req, TargetInfo target)` Cancel a dispatch.
`void` `dispatch(ServerRequest req, TargetInfo ti)` Dispatch a request from a client.
`void` `etherealize(boolean cleanup_in_progress)` Etherialize the adapter.
`ObjectAdapter` `find_adapter(byte[] object_key)` If this adapter serves this object directly it should return itself, otherwise it should return an adapter that does.
`boolean` `forced_marshal(byte[] object_key)` If this returns true then requests for the specified object id must be sent through the network.
`Object` `get_component(byte[] object_key)` get_componenent operation.
`DomainManager[]` `get_domain_managers(byte[] object_key)` get_domain_manager operation.
`Object` `get_interface_def(byte[] object_key)` get_interface_def operation.
`Policy[]` `get_server_policies(int[] ts)` Returns a PolicyList containing the Polices set for the requested PolicyTypes.
`Object` `get(java.lang.String initRef)` Resolve using the given string.
`ServerManager.AdapterManager` `getAdapterManager()` Queue manager for the adapter.
`boolean` `is_a(byte[] object_key, java.lang.String repository_id)` is_a operation.
`boolean` `locate(byte[] object_key)` Respond to a local locate request.
`byte[]` `object_id(byte[] object_key)` Return the object id.
`TargetInfo` `predispatch(ServerRequest req)` Locate the servant object for a request.
`java.lang.String` `put_object(Object object, java.lang.String path)` Add a new initial reference.
`void` `put(java.lang.String initRef, Object obj)` Add a new initial reference.
`void` `register(byte[] oid, Object obj)` Add a new initial reference.
`Object` `resolve(byte[] key)` Resolve using given byte array.
`void` `servant_postinvoke(byte[] object_key, ServantObject srvObject)` Close off a local operation.
`ServantObject` `servant_preinvoke(byte[] object_key, java.lang.String operation, java.lang.Class expectedType)` Preinvoke a local operation.
`boolean` `single_threaded()` Adapter is single threaded.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### JDK_ID

    public static final byte[] JDK_ID

  This is the string sent by the JDK ORB when trying to resolve corbaloc references.

### CORBALOC_SVC_NAME

    public static final java.lang.String CORBALOC_SVC_NAME

  The name of the service.

### CORBALOC_SVC_ID

    public static final byte[] CORBALOC_SVC_ID

  The byte representation of the service's name.

Constructor Detail

### ForwardAdapter

    public ForwardAdapter(ServerManager server_manager)

  Constructor.

Method Detail

### get

    public Object get(java.lang.String initRef)

  Resolve using the given string. Used by JDK clients.
  Specified by:
    `get` in interface `CorbalocServiceOperations`
  Parameters:
    `initRef` - String name of initial reference. Should be RFC2396 encoded.
  Returns:
    the target object.
  Throws:
    `BAD_PARAM` - if the initial reference does not exist.

### put

    public void put(java.lang.String initRef,
                    Object obj)

  Add a new initial reference.
  Specified by:
    `put` in interface `CorbalocServiceOperations`
  Parameters:
    `initRef` - String name of initial reference. Should be RFC2396 encoded.
    `obj` - the target object.
  Throws:
    `BAD_PARAM` - if the initial reference already exists.

### resolve

    public Object resolve(byte[] key)

  Resolve using given byte array.
  Specified by:
    `resolve` in interface `CorbalocServiceOperations`
  Parameters:
    `key` - Initial reference key.
  Returns:
    the target object.
  Throws:
    `BAD_PARAM` - if the initial reference does not exist.

### register

    public void register(byte[] oid,
                         Object obj)

  Add a new initial reference.
  Specified by:
    `register` in interface `CorbalocServiceOperations`
  Parameters:
    `initRef` - String name of initial reference. Should be RFC2396 encoded.
    `obj` - the target object.
  Throws:
    `BAD_PARAM` - if obj is null.

### put_object

    public java.lang.String put_object(Object object,
                                       java.lang.String path)

  Add a new initial reference.
  Specified by:
    `put_object` in interface `CorbalocServiceOperations`
  Parameters:
    `object` - the object to register
    `path` - String name of initial reference. Should be RFC2396 encoded.
  Returns:
    String the corbaloc URL
  Throws:
    `BAD_PARAM` - if the supplied object is null.

### cache_priority

    public int cache_priority()

  Expected lifetime of the adapter. Higher numbers are more likley to be dropped from the lookup cache. If this returns 0 then the adapter should never be dropped. This value should be stable throughout the lifetime of the adapter. The highest byte will be used for determining the binding priority. Suggested values: = 0 Root adapters. Always keep. < 0x1000000 Adpaters created directly. < 0x2000000 Adapters created dynamicaly. < 0x3000000 Objects created directly. < 0x4000000 Objects created dynamicaly. < 0 Never cache adapter, single invocation only. These should not be returned from find_adapter.
  Specified by:
    `cache_priority` in interface `ObjectAdapter`

### single_threaded

    public boolean single_threaded()

  Adapter is single threaded. Calls to all single threaded Adapters are serialized.
  Specified by:
    `single_threaded` in interface `ObjectAdapter`

### etherealize

    public void etherealize(boolean cleanup_in_progress)

  Etherialize the adapter. When this function returns the adapter's memory resident state should have been minimized. This function will always be called before purging the adapter from the cache. If cleanup_in_progress is true the adapter is being perminently deactivated and will no longer have to dispatch operations.
  Specified by:
    `etherealize` in interface `ObjectAdapter`
  Following copied from interface: `org.openorb.adapter.ObjectAdapter`
  Parameters:
    `cleanup_in_progress` - if true the adapter is being perminently deactivated and will no longer have to dispatch operations.

### getAdapterManager

    public ServerManager.AdapterManager getAdapterManager()

  Queue manager for the adapter. This may return null for an adapter which is always active. To create an adapter manager for an adapter use the create_manager operation on the ServerManager.
  Specified by:
    `getAdapterManager` in interface `ObjectAdapter`

### find_adapter

    public ObjectAdapter find_adapter(byte[] object_key)
                               throws AdapterDestroyedException

  If this adapter serves this object directly it should return itself, otherwise it should return an adapter that does. If an adapter for an object with the given object id cannot be found this returns null. The returned adapter may be cached for future use.
  Specified by:
    `find_adapter` in interface `ObjectAdapter`

### adapter_id

    public byte[] adapter_id(byte[] object_key)

  Return the adapter id. This should be a prefix of the object_key, it should be stable with respect to a given object_key and will be treated as read-only. If an object with the given object_key is not served by this adapter this may return null.
  Specified by:
    `adapter_id` in interface `ObjectAdapter`

### object_id

    public byte[] object_id(byte[] object_key)

  Return the object id. This should should be a suffix of the object_key if the object id is cacheable, it should be stable with respect to a given object_key and will be treated as read-only. If an object with the given object_key is not served by this adapter this returns null.
  Specified by:
    `object_id` in interface `ObjectAdapter`

### get_server_policies

    public Policy[] get_server_policies(int[] ts)

  Returns a PolicyList containing the Polices set for the requested PolicyTypes. If the specified sequence is empty, all Policy overrides will be returned. If none of the requested PolicyTypes are overridden an empty sequence is returned.
  Specified by:
    `get_server_policies` in interface `ObjectAdapter`

### forced_marshal

    public boolean forced_marshal(byte[] object_key)
                           throws AdapterDestroyedException

  If this returns true then requests for the specified object id must be sent through the network. This will be true for example when using the DSI. This should return true if the object_key is unknown to the adapter. The result should be stable with respect to a given object ID.
  Specified by:
    `forced_marshal` in interface `ObjectAdapter`

### servant_preinvoke

    public ServantObject servant_preinvoke(byte[] object_key,
                                           java.lang.String operation,
                                           java.lang.Class expectedType)
                                    throws ForwardRequest,
                                           AdapterDestroyedException

  Preinvoke a local operation. Always paired with a call to servant_postinvoke. If the given object_key was not created by this adapter an OBJ_ADAPTER exception is thrown, if the object does not exist this returns null.
  Specified by:
    `servant_preinvoke` in interface `ObjectAdapter`

### servant_postinvoke

    public void servant_postinvoke(byte[] object_key,
                                   ServantObject srvObject)

  Close off a local operation. Always paired with a call to servant_preinvoke
  Specified by:
    `servant_postinvoke` in interface `ObjectAdapter`

### locate

    public boolean locate(byte[] object_key)
                   throws ForwardRequest,
                          AdapterDestroyedException

  Respond to a local locate request. This returns true if the object is located locally, false if the object is unknown and throws a forward request for a location forward. This should not throw a system exception.
  Specified by:
    `locate` in interface `ObjectAdapter`

### is_a

    public boolean is_a(byte[] object_key,
                        java.lang.String repository_id)
                 throws ForwardRequest,
                        AdapterDestroyedException

  is_a operation. If the given object_key was not created by this adapter an OBJ_ADAPTER exception is thrown, if the object does not exist OBJECT_NOT_EXIST is thrown.
  Specified by:
    `is_a` in interface `ObjectAdapter`

### get_interface_def

    public Object get_interface_def(byte[] object_key)
                             throws ForwardRequest,
                                    AdapterDestroyedException

  get_interface_def operation. If the given object_key was not created by this adapter an OBJ_ADAPTER exception is thrown, if the object does not exist OBJECT_NOT_EXIST is thrown.
  Specified by:
    `get_interface_def` in interface `ObjectAdapter`

### get_domain_managers

    public DomainManager[] get_domain_managers(byte[] object_key)
                                        throws ForwardRequest,
                                               AdapterDestroyedException

  get_domain_manager operation. If the given object_key was not created by this adapter an OBJ_ADAPTER exception is thrown, if the object does not exist OBJECT_NOT_EXIST is thrown.
  Specified by:
    `get_domain_managers` in interface `ObjectAdapter`

### get_component

    public Object get_component(byte[] object_key)
                         throws ForwardRequest,
                                AdapterDestroyedException

  get_componenent operation. If the given object_key was not created by this adapter an OBJ_ADAPTER exception is thrown, if the object does not exist OBJECT_NOT_EXIST is thrown.
  Specified by:
    `get_component` in interface `ObjectAdapter`

### predispatch

    public TargetInfo predispatch(ServerRequest req)
                           throws ForwardRequest,
                                  AdapterDestroyedException

  Locate the servant object for a request. The returned object is handed to the dispatch operation. This may throw a system exception or respond with a forward request if one is indicated, in which case the dispatch operation will not be called.
  Specified by:
    `predispatch` in interface `ObjectAdapter`
  Parameters:
    `ids` - out parameter holding repository ids of all available interfaces with the most derived interface appearing first.
  Returns:
    the 'target' of the operation. This is simply passed to the dispatch operation and is not interpreted in any way.

### dispatch

    public void dispatch(ServerRequest req,
                         TargetInfo ti)

  Dispatch a request from a client. This may throw a system exception at any time or call the ResponseHandler interface on the request to create a standard reply. If this returns without calling a response handler an empty reply is constructed, this is the usual situation for a locate request.
  Specified by:
    `dispatch` in interface `ObjectAdapter`

### cancel_dispatch

    public void cancel_dispatch(ServerRequest req,
                                TargetInfo target)

  Cancel a dispatch. This may follow a predispatch or dispatch call to indicate that the client no longer expects any reply from the request and the server can stop expending effort towards completing it.
  Specified by:
    `cancel_dispatch` in interface `ObjectAdapter`