FileDocCategorySizeDatePackage
Servant.javaAPI DocJava SE 5 API9706Fri Aug 26 14:58:36 BST 2005org.omg.PortableServer

Servant

public abstract class Servant extends Object
Defines the native Servant type. In Java, the Servant type is mapped to the Java org.omg.PortableServer.Servant class. It serves as the base class for all POA servant implementations and provides a number of methods that may be invoked by the application programmer, as well as methods which are invoked by the POA itself and may be overridden by the user to control aspects of servant behavior. Based on IDL to Java spec. (CORBA V2.3.1) ptc/00-01-08.pdf.

Fields Summary
private transient org.omg.PortableServer.portable.Delegate
_delegate
Constructors Summary
Methods Summary
public abstract java.lang.String[]_all_interfaces(POA poa, byte[] objectId)
Used by the ORB to obtain complete type information from the servant.

param
poa POA with which the servant is associated.
param
objectId is the id corresponding to the object associated with this servant.
return
list of type information for the object.

public POA_default_POA()
Returns the root POA from the ORB instance associated with the servant. Subclasses may override this method to return a different POA.

return
default_POA the POA associated with the Servant.

        return _get_delegate().default_POA(this);
    
public final org.omg.PortableServer.portable.Delegate_get_delegate()
Gets the ORB vendor-specific implementation of PortableServer::Servant.

return
_delegate the ORB vendor-specific implementation of PortableServer::Servant.

                        
        
        if (_delegate == null) {
            throw 
                new 
                org.omg.CORBA.BAD_INV_ORDER
                ("The Servant has not been associated with an ORB instance");
        }
        return _delegate;
    
public org.omg.CORBA.Object_get_interface_def()
Returns an InterfaceDef object as a CORBA::Object that defines the runtime type of the CORBA::Object implemented by the Servant. The invoker of _get_interface_def must narrow the result to an InterfaceDef in order to use it.

This default implementation of _get_interface_def() can be overridden by derived servants if the default behavior is not adequate. As defined in the CORBA 2.3.1 specification, section 11.3.1, the default behavior of _get_interface_def() is to use the most derived interface of a static servant or the most derived interface retrieved from a dynamic servant to obtain the InterfaceDef. This behavior must be supported by the Delegate that implements the Servant.

return
get_interface_def an InterfaceDef object as a CORBA::Object that defines the runtime type of the CORBA::Object implemented by the Servant.

        // First try to call the delegate implementation class's
        // "Object get_interface_def(..)" method (will work for ORBs
        // whose delegates implement this method).
        // Else call the delegate implementation class's
        // "InterfaceDef get_interface(..)" method using reflection
        // (will work for ORBs that were built using an older version
        // of the Delegate interface with a get_interface method
        // but not a get_interface_def method).

        org.omg.PortableServer.portable.Delegate delegate = _get_delegate();
        try {
            // If the ORB's delegate class does not implement
            // "Object get_interface_def(..)", this will throw
            // an AbstractMethodError.
            return delegate.get_interface_def(this);
        } catch( AbstractMethodError aex ) {
            // Call "InterfaceDef get_interface(..)" method using reflection.
            try {
                Class[] argc = { org.omg.PortableServer.Servant.class };
                java.lang.reflect.Method meth =
                     delegate.getClass().getMethod("get_interface", argc);
                Object[] argx = { this };
                return (org.omg.CORBA.Object)meth.invoke(delegate, argx);
            } catch( java.lang.reflect.InvocationTargetException exs ) {
                Throwable t = exs.getTargetException();
                if (t instanceof Error) {
                    throw (Error) t;
                } else if (t instanceof RuntimeException) {
                    throw (RuntimeException) t;
                } else {
                    throw new org.omg.CORBA.NO_IMPLEMENT();
                }
            } catch( RuntimeException rex ) {
                throw rex;
            } catch( Exception exr ) {
                throw new org.omg.CORBA.NO_IMPLEMENT();
            }
        }
    
public boolean_is_a(java.lang.String repository_id)
Checks to see if the specified repository_id is present on the list returned by _all_interfaces() or is the repository_id for the generic CORBA Object.

param
repository_id the repository_id to be checked in the repository list or against the id of generic CORBA objects.
return
is_a boolean indicating whether the specified repository_id is in the repository list or is same as a generic CORBA object.

        return _get_delegate().is_a(this, repository_id);
    
public boolean_non_existent()
Checks for the existence of an Object. The Servant provides a default implementation of _non_existent() that can be overridden by derived servants.

return
non_existent true if that object does not exist, false otherwise.

        return _get_delegate().non_existent(this);
    
public final byte[]_object_id()
Allows easy execution of common methods, equivalent to calling PortableServer::Current::get_object_id.

return
object_id the Object ID associated with this servant.

        return _get_delegate().object_id(this);
    
public final org.omg.CORBA.ORB_orb()
Returns the instance of the ORB currently associated with the Servant (convenience method).

return
orb the instance of the ORB currently associated with the Servant.

        return _get_delegate().orb(this);
    
public final POA_poa()
Allows easy execution of common methods, equivalent to PortableServer::Current:get_POA.

return
poa POA associated with the servant.

        return _get_delegate().poa(this);
    
public final void_set_delegate(org.omg.PortableServer.portable.Delegate delegate)
Supports the Java ORB portability interfaces by providing a method for classes that support ORB portability through delegation to set their delegate.

param
delegate ORB vendor-specific implementation of the PortableServer::Servant.

        _delegate = delegate;
    
public final org.omg.CORBA.Object_this_object()
Allows the servant to obtain the object reference for the target CORBA object it is incarnating for that request.

return
this_object Object reference associated with the request.

        return _get_delegate().this_object(this);
    
public final org.omg.CORBA.Object_this_object(org.omg.CORBA.ORB orb)
Allows the servant to obtain the object reference for the target CORBA Object it is incarnating for that request.

param
orb ORB with which the servant is associated.
return
_this_object reference associated with the request.

        try {
            ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this);
        }
        catch(ClassCastException e) {
            throw 
                new 
                org.omg.CORBA.BAD_PARAM
                ("POA Servant requires an instance of org.omg.CORBA_2_3.ORB");
        }
        return _this_object();