1 7 package com.sun.corba.se.impl.oa.poa; 8 9 import java.util.EmptyStackException ; 10 11 import org.omg.PortableServer.*; 12 13 import com.sun.corba.se.spi.orb.ORB ; 14 15 import com.sun.corba.se.spi.logging.CORBALogDomains ; 16 17 import com.sun.corba.se.impl.logging.POASystemException ; 18 19 public class DelegateImpl implements org.omg.PortableServer.portable.Delegate 20 { 21 private ORB orb ; 22 private POASystemException wrapper ; 23 private POAFactory factory; 24 25 public DelegateImpl(ORB orb, POAFactory factory){ 26 this.orb = orb ; 27 this.wrapper = POASystemException.get( orb, 28 CORBALogDomains.OA ) ; 29 this.factory = factory; 30 } 31 32 public org.omg.CORBA.ORB orb(Servant self) 33 { 34 return orb; 35 } 36 37 public org.omg.CORBA.Object this_object(Servant self) 38 { 39 byte[] oid; 40 POA poa; 41 try { 42 oid = orb.peekInvocationInfo().id(); 43 poa = (POA)orb.peekInvocationInfo().oa(); 44 String repId = self._all_interfaces(poa,oid)[0] ; 45 return poa.create_reference_with_id(oid, repId); 46 } catch (EmptyStackException notInInvocationE) { 47 POAImpl defaultPOA = null; 49 try { 50 defaultPOA = (POAImpl)self._default_POA(); 51 } catch (ClassCastException exception){ 52 throw wrapper.defaultPoaNotPoaimpl( exception ) ; 53 } 54 55 try { 56 if (defaultPOA.getPolicies().isImplicitlyActivated() || 57 (defaultPOA.getPolicies().isUniqueIds() && 58 defaultPOA.getPolicies().retainServants())) { 59 return defaultPOA.servant_to_reference(self); 60 } else { 61 throw wrapper.wrongPoliciesForThisObject() ; 62 } 63 } catch ( org.omg.PortableServer.POAPackage.ServantNotActive e) { 64 throw wrapper.thisObjectServantNotActive( e ) ; 65 } catch ( org.omg.PortableServer.POAPackage.WrongPolicy e) { 66 throw wrapper.thisObjectWrongPolicy( e ) ; 67 } 68 } catch (ClassCastException e) { 69 throw wrapper.defaultPoaNotPoaimpl( e ) ; 70 } 71 } 72 73 public POA poa(Servant self) 74 { 75 try { 76 return (POA)orb.peekInvocationInfo().oa(); 77 } catch (EmptyStackException exception){ 78 POA returnValue = factory.lookupPOA(self); 79 if (returnValue != null) { 80 return returnValue; 81 } 82 83 throw wrapper.noContext( exception ) ; 84 } 85 } 86 87 public byte[] object_id(Servant self) 88 { 89 try{ 90 return orb.peekInvocationInfo().id(); 91 } catch (EmptyStackException exception){ 92 throw wrapper.noContext(exception) ; 93 } 94 } 95 96 public POA default_POA(Servant self) 97 { 98 return factory.getRootPOA(); 99 } 100 101 public boolean is_a(Servant self, String repId) 102 { 103 String [] repositoryIds = self._all_interfaces(poa(self),object_id(self)); 104 for ( int i=0; i<repositoryIds.length; i++ ) 105 if ( repId.equals(repositoryIds[i]) ) 106 return true; 107 108 return false; 109 } 110 111 public boolean non_existent(Servant self) 112 { 113 try{ 115 byte[] oid = orb.peekInvocationInfo().id(); 116 if( oid == null) return true; 117 else return false; 118 } catch (EmptyStackException exception){ 119 throw wrapper.noContext(exception) ; 120 } 121 } 122 123 125 public org.omg.CORBA.Object get_interface_def(Servant Self) 126 { 127 throw wrapper.methodNotImplemented() ; 128 } 129 } 130 | Popular Tags |