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 *****/ 005 006 package org.omg.PortableServer; 007 008 abstract public class Servant { 009 010 final public org.omg.CORBA.Object _this_object() { 011 return _get_delegate().this_object(this); 012 } 013 014 final public org.omg.CORBA.Object _this_object(org.omg.CORBA.ORB orb) { 015 try { 016 ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this); 017 } 018 catch (ClassCastException e) { 019 throw new org.omg.CORBA.BAD_PARAM( 020 "POA Servant requires an instanceof org.omg.CORBA_2_3.ORB"); 021 } 022 return _this_object(); 023 } 024 025 final public org.omg.CORBA.ORB _orb() { 026 return _get_delegate().orb(this); 027 } 028 029 final public POA _poa() { 030 return _get_delegate().poa(this); 031 } 032 033 final public byte[] _object_id() { 034 return _get_delegate().object_id(this); 035 } 036 037 public POA _default_POA() { 038 return _get_delegate().default_POA(this); 039 } 040 041 public boolean _is_a(String repository_id) { 042 return _get_delegate().is_a(this, repository_id); 043 } 044 045 public boolean _non_existent() { 046 return _get_delegate().non_existent(this); 047 } 048 049 /** @deprecated Deprecated by CORBA 2.4 050 */ 051 public org.omg.CORBA.InterfaceDef _get_interface() { 052 return _get_delegate().get_interface(this); 053 } 054 055 public org.omg.CORBA.Object _get_interface_def() 056 { 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 = 077 delegate.getClass().getMethod("get_interface", argc); 078 Object[] argx = { this }; 079 return (org.omg.CORBA.Object)meth.invoke(delegate, argx); 080 } catch( java.lang.reflect.InvocationTargetException exs ) { 081 Throwable t = exs.getTargetException(); 082 if (t instanceof Error) { 083 throw (Error) t; 084 } else if (t instanceof RuntimeException) { 085 throw (RuntimeException) t; 086 } else { 087 throw new org.omg.CORBA.NO_IMPLEMENT(); 088 } 089 } catch( RuntimeException rex ) { 090 throw rex; 091 } catch( Exception exr ) { 092 throw new org.omg.CORBA.NO_IMPLEMENT(); 093 } 094 } 095 } 096 097 abstract public String[] _all_interfaces(POA poa, byte[] objectID); 098 099 private transient org.omg.PortableServer.portable.Delegate _delegate =null; 100 101 final public org.omg.PortableServer.portable.Delegate _get_delegate() { 102 if (_delegate == null) { 103 throw new org.omg.CORBA.BAD_INV_ORDER( 104 "The Servant has not been associated with an ORBinstance"); 105 } 106 return _delegate; 107 } 108 109 final public void _set_delegate( 110 org.omg.PortableServer.portable.Delegate delegate) { 111 _delegate = delegate; 112 } 113 }