FileDocCategorySizeDatePackage
ObjectImpl.javaAPI DocJava SE 6 API20614Tue Jun 10 00:27:28 BST 2008org.omg.CORBA.portable

ObjectImpl

public abstract class ObjectImpl extends Object implements Object
The common base class for all stub classes; provides default implementations of the org.omg.CORBA.Object methods. All method implementations are forwarded to a Delegate object stored in the ObjectImpl instance. ObjectImpl allows for portable stubs because the Delegate can be implemented by a different vendor-specific ORB.

Fields Summary
private transient Delegate
__delegate
The field that stores the Delegate instance for this ObjectImpl object. This Delegate instance can be implemented by a vendor-specific ORB. Stub classes, which are derived from this ObjectImpl class, can be portable because they delegate all of the methods called on them to this Delegate object.
Constructors Summary
Methods Summary
public org.omg.CORBA.Request_create_request(org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result)
Creates a Request object that contains the given context, method, argument list, and container for the result.

param
ctx the Context for the request
param
operation the method that the new Request object will invoke
param
arg_list the arguments for the method; an NVList in which each argument is a NamedValue object
param
result a NamedValue object to be used for returning the result of executing the request's method
return
a new Request object initialized with the given context, method, argument list, and container for the return value

        return _get_delegate().create_request(this,
					      ctx,
					      operation,
					      arg_list,
					      result);
    
public org.omg.CORBA.Request_create_request(org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result, org.omg.CORBA.ExceptionList exceptions, org.omg.CORBA.ContextList contexts)
Creates a Request object that contains the given context, method, argument list, container for the result, exceptions, and list of property names to be used in resolving the context strings. This Request object is for use in the Dynamic Invocation Interface.

param
ctx the Context object that contains the context strings that must be resolved before they are sent along with the request
param
operation the method that the new Request object will invoke
param
arg_list the arguments for the method; an NVList in which each argument is a NamedValue object
param
result a NamedValue object to be used for returning the result of executing the request's method
param
exceptions a list of the exceptions that the given method throws
param
contexts a list of the properties that are needed to resolve the contexts in ctx; the strings in contexts are used as arguments to the method Context.get_values, which returns the value associated with the given property
return
a new Request object initialized with the given context strings to resolve, method, argument list, container for the result, exceptions, and list of property names to be used in resolving the context strings

        return _get_delegate().create_request(this,
					      ctx,
					      operation,
					      arg_list,
					      result,
					      exceptions,
					      contexts);
    
public org.omg.CORBA.Object_duplicate()
Returns a duplicate of this ObjectImpl object.

return
an orb.omg.CORBA.Object object that is a duplicate of this object

        return _get_delegate().duplicate(this);
    
public org.omg.CORBA.portable.Delegate_get_delegate()
Retrieves the reference to the vendor-specific Delegate object to which this ObjectImpl object delegates all methods invoked on it.

return
the Delegate contained in this ObjectImpl instance
throws
BAD_OPERATION if the delegate has not been set
see
#_set_delegate

        if (__delegate == null)
	    throw new BAD_OPERATION("The delegate has not been set!");
        return __delegate;
    
public org.omg.CORBA.DomainManager[]_get_domain_managers()
Retrieves a list of the domain managers for this ObjectImpl object.

return
an array containing the DomainManager objects for this instance of ObjectImpl

        return _get_delegate().get_domain_managers(this);
    
public org.omg.CORBA.Object_get_interface_def()
Retrieves the interface definition for this ObjectImpl object.

return
the org.omg.CORBA.Object instance that is the interface definition for this ObjectImpl object

	// First try to call the delegate implementation class's
	// "Object get_interface_def(..)" method (will work for JDK1.2 ORBs).
	// Else call the delegate implementation class's
	// "InterfaceDef get_interface(..)" method using reflection
	// (will work for pre-JDK1.2 ORBs).

        org.omg.CORBA.portable.Delegate delegate = _get_delegate();         
        try {
	    // If the ORB's delegate class does not implement 
	    // "Object get_interface_def(..)", this will call 
	    // get_interface_def(..) on portable.Delegate. 
            return delegate.get_interface_def(this);
        } 
	catch( org.omg.CORBA.NO_IMPLEMENT ex ) {
	    // Call "InterfaceDef get_interface(..)" method using reflection.
            try {
		Class[] argc = { org.omg.CORBA.Object.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 org.omg.CORBA.Policy_get_policy(int policy_type)
Retrieves the Policy object for this ObjectImpl object that has the given policy type.

param
policy_type an int indicating the policy type
return
the Policy object that is the specified policy type and that applies to this ObjectImpl object
see
org.omg.CORBA.PolicyOperations#policy_type

        return _get_delegate().get_policy(this, policy_type);
    
public int_hash(int maximum)
Retrieves the hash code that serves as an ORB-internal identifier for this ObjectImpl object.

param
maximum an int indicating the upper bound on the hash value returned by the ORB
return
an int representing the hash code for this ObjectImpl object

        return _get_delegate().hash(this, maximum);
    
public abstract java.lang.String[]_ids()
Retrieves a string array containing the repository identifiers supported by this ObjectImpl object. For example, for a stub, this method returns information about all the interfaces supported by the stub.

return
the array of all repository identifiers supported by this ObjectImpl instance

public org.omg.CORBA.portable.InputStream_invoke(org.omg.CORBA.portable.OutputStream output)
Invokes an operation and returns an InputStream object for reading the response. The stub provides the OutputStream object that was previously returned by a call to the _request method. The method specified as an argument to _request when it was called previously is the method that this method invokes.

If an exception occurs, the _invoke method may throw an ApplicationException object that contains an InputStream from which the user exception state may be unmarshalled.

param
output an OutputStream object for dispatching the request
return
an InputStream object containing the marshalled response to the method invoked
throws
ApplicationException if the invocation meets application-defined exception
throws
RemarshalException if the invocation leads to a remarshalling error
see
#_request

	return _get_delegate().invoke(this, output);
    
public boolean_is_a(java.lang.String repository_id)
Checks whether the object identified by the given repository identifier is an ObjectImpl object.

param
repository_id a String object with the repository identifier to check
return
true if the object identified by the given repository id is an instance of ObjectImpl; false otherwise

        return _get_delegate().is_a(this, repository_id);
    
public boolean_is_equivalent(org.omg.CORBA.Object that)
Checks whether the the given ObjectImpl object is equivalent to this ObjectImpl object.

param
that an instance of ObjectImpl to compare with this ObjectImpl object
return
true if the given object is equivalent to this ObjectImpl object; false otherwise

        return _get_delegate().is_equivalent(this, that);
    
public boolean_is_local()
Checks whether this ObjectImpl object is implemented by a local servant. If so, local invocation API's may be used.

return
true if this object is implemented by a local servant; false otherwise

        return _get_delegate().is_local(this);
    
public boolean_non_existent()
Checks whether the server object for this ObjectImpl object has been destroyed.

return
true if the ORB knows authoritatively that the server object does not exist; false otherwise

        return _get_delegate().non_existent(this);
    
public org.omg.CORBA.ORB_orb()
Returns a reference to the ORB associated with this object and its delegate. This is the ORB object that created the delegate.

return
the ORB instance that created the Delegate object contained in this ObjectImpl object

        return _get_delegate().orb(this);
    
public void_release()
Releases the resources associated with this ObjectImpl object.

        _get_delegate().release(this);
    
public void_releaseReply(org.omg.CORBA.portable.InputStream input)
Releases the given reply stream back to the ORB when unmarshalling has completed after a call to the method _invoke. Calling this method is optional for the stub.

param
input the InputStream object that was returned by the _invoke method or the ApplicationException.getInputStream method; may be null, in which case this method does nothing
see
#_invoke

	_get_delegate().releaseReply(this, input);
    
public org.omg.CORBA.Request_request(java.lang.String operation)
Creates a Request object containing the given method that can be used with the Dynamic Invocation Interface.

param
operation the method to be invoked by the new Request object
return
a new Request object initialized with the given method

        return _get_delegate().request(this, operation);
    
public org.omg.CORBA.portable.OutputStream_request(java.lang.String operation, boolean responseExpected)
Returns an OutputStream object to use for marshalling the arguments of the given method. This method is called by a stub, which must indicate if a response is expected, that is, whether or not the call is oneway.

param
operation a String giving the name of the method.
param
responseExpected a boolean -- true if the request is not one way, that is, a response is expected
return
an OutputStream object for dispatching the request

	return _get_delegate().request(this, operation, responseExpected);
    
public void_servant_postinvoke(org.omg.CORBA.portable.ServantObject servant)
Is called by the local stub after it has invoked an operation on the local servant that was previously retrieved from a call to the method _servant_preinvoke. The _servant_postinvoke method must be called if the _servant_preinvoke method returned a non-null value, even if an exception was thrown by the method invoked by the servant. For this reason, the call to the method _servant_postinvoke should be placed in a Java finally clause.

param
servant the instance of the ServantObject returned by the _servant_preinvoke method

        _get_delegate().servant_postinvoke(this, servant);
    
public org.omg.CORBA.portable.ServantObject_servant_preinvoke(java.lang.String operation, java.lang.Class expectedType)
Returns a Java reference to the local servant that should be used for sending a request for the method specified. If this ObjectImpl object is a local stub, it will invoke the _servant_preinvoke method before sending a request in order to obtain the ServantObject instance to use.

If a ServantObject object is returned, its servant field has been set to an object of the expected type (Note: the object may or may not be the actual servant instance). The local stub may cast the servant field to the expected type, and then invoke the operation directly. The ServantRequest object is valid for only one invocation and cannot be used for more than one invocation.

param
operation a String containing the name of the method to be invoked. This name should correspond to the method name as it would be encoded in a GIOP request.
param
expectedType a Class object representing the expected type of the servant that is returned. This expected type is the Class object associated with the operations class for the stub's interface. For example, a stub for an interface Foo would pass the Class object for the FooOperations interface.
return
(1) a ServantObject object, which may or may not be the actual servant instance, or (2) null if (a) the servant is not local or (b) the servant has ceased to be local due to a ForwardRequest from a POA ServantManager
throws
org.omg.CORBA.BAD_PARAM if the servant is not the expected type

        return _get_delegate().servant_preinvoke(this, operation,
						 expectedType);
    
public void_set_delegate(org.omg.CORBA.portable.Delegate delegate)
Sets the Delegate for this ObjectImpl instance to the given Delegate object. All method invocations on this ObjectImpl object will be forwarded to this delegate.

param
delegate the Delegate instance to which all method calls on this ObjectImpl object will be delegated; may be implemented by a third-party ORB
see
#_get_delegate

        __delegate = delegate;
    
public org.omg.CORBA.Object_set_policy_override(org.omg.CORBA.Policy[] policies, org.omg.CORBA.SetOverrideType set_add)
Sets this ObjectImpl object's override type for the given policies to the given instance of SetOverrideType.

param
policies an array of Policy objects with the policies that will replace the current policies or be added to the current policies
param
set_add either SetOverrideType.SET_OVERRIDE, indicating that the given policies will replace any existing ones, or SetOverrideType.ADD_OVERRIDE, indicating that the given policies should be added to any existing ones
return
an Object with the given policies replacing or added to its previous policies

	return _get_delegate().set_policy_override(this, policies,
						   set_add);
    
public booleanequals(java.lang.Object obj)
Compares this ObjectImpl object with the given one for equality.

param
obj the object with which to compare this object
return
true if the two objects are equal; false otherwise

        if ( __delegate != null )
           return __delegate.equals(this, obj);
        else
           return (this==obj);
    
public inthashCode()
Returns the hash code for this ObjectImpl object.

return
the hash code for this object

        if ( __delegate != null )
           return __delegate.hashCode(this);
        else
            return super.hashCode();
    
public java.lang.StringtoString()
Returns a String object that represents this ObjectImpl object.

return
the String representation of this object

        if ( __delegate != null )
           return __delegate.toString(this);
        else
           return getClass().getName() + ": no delegate set";