001: /***** Copyright (c) 1999-2000 Object Management Group. Unlimited rights to
002: duplicate and use this code are hereby granted provided that this
003: copyright notice is included.
004: *****/package org.omg.PortableServer;
005:
006: abstract public class Servant {
007:
008: final public org.omg.CORBA.Object _this _object() {
009: return _get_delegate().this _object(this );
010: }
011:
012: final public org.omg.CORBA.Object _this _object(org.omg.CORBA.ORB orb) {
013: try {
014: ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this );
015: } catch (ClassCastException e) {
016: throw new org.omg.CORBA.BAD_PARAM(
017: "POA Servant requires an instanceof org.omg.CORBA_2_3.ORB");
018: }
019: return _this _object();
020: }
021:
022: final public org.omg.CORBA.ORB _orb() {
023: return _get_delegate().orb(this );
024: }
025:
026: final public POA _poa() {
027: return _get_delegate().poa(this );
028: }
029:
030: final public byte[] _object_id() {
031: return _get_delegate().object_id(this );
032: }
033:
034: public POA _default_POA() {
035: return _get_delegate().default_POA(this );
036: }
037:
038: public boolean _is_a(String repository_id) {
039: return _get_delegate().is_a(this , repository_id);
040: }
041:
042: public boolean _non_existent() {
043: return _get_delegate().non_existent(this );
044: }
045:
046: public org.omg.CORBA.Object _get_component() {
047: return _get_delegate().get_component(this );
048: }
049:
050: /** @deprecated Deprecated by CORBA 2.4
051: */
052: public org.omg.CORBA.InterfaceDef _get_interface() {
053: return _get_delegate().get_interface(this );
054: }
055:
056: public org.omg.CORBA.Object _get_interface_def() {
057: // First try to call the delegate implementation class's
058: // "Object get_interface_def(..)" method (will work for ORBs
059: // whose delegates implement this method).
060: // Else call the delegate implementation class's
061: // "InterfaceDef get_interface(..)" method using reflection
062: // (will work for ORBs that were built using an older version
063: // of the Delegate interface with a get_interface method
064: // but not a get_interface_def method).
065:
066: org.omg.PortableServer.portable.Delegate delegate = _get_delegate();
067: try {
068: // If the ORB's delegate class does not implement
069: // "Object get_interface_def(..)", this will throw
070: // an AbstractMethodError.
071: return delegate.get_interface_def(this );
072: } catch (AbstractMethodError aex) {
073: // Call "InterfaceDef get_interface(..)" method using reflection.
074: try {
075: Class[] argc = { org.omg.PortableServer.Servant.class };
076: java.lang.reflect.Method meth = delegate.getClass()
077: .getMethod("get_interface", argc);
078: Object[] argx = { this };
079: return (org.omg.CORBA.Object) meth.invoke(delegate,
080: argx);
081: } catch (java.lang.reflect.InvocationTargetException exs) {
082: Throwable t = exs.getTargetException();
083: if (t instanceof Error) {
084: throw (Error) t;
085: } else if (t instanceof RuntimeException) {
086: throw (RuntimeException) t;
087: } else {
088: throw new org.omg.CORBA.NO_IMPLEMENT();
089: }
090: } catch (RuntimeException rex) {
091: throw rex;
092: } catch (Exception exr) {
093: throw new org.omg.CORBA.NO_IMPLEMENT();
094: }
095: }
096: }
097:
098: abstract public String[] _all_interfaces(POA poa, byte[] objectID);
099:
100: private transient org.omg.PortableServer.portable.Delegate _delegate = null;
101:
102: final public org.omg.PortableServer.portable.Delegate _get_delegate() {
103: if (_delegate == null) {
104: throw new org.omg.CORBA.BAD_INV_ORDER(
105: "The Servant has not been associated with an ORBinstance");
106: }
107: return _delegate;
108: }
109:
110: final public void _set_delegate(
111: org.omg.PortableServer.portable.Delegate delegate) {
112: _delegate = delegate;
113: }
114: }
|