1 7 8 package com.sun.corba.se.impl.oa.poa; 9 10 import java.util.*; 11 import org.omg.CORBA.CompletionStatus ; 12 import org.omg.PortableServer.CurrentPackage.NoContext ; 13 import org.omg.PortableServer.POA ; 14 import org.omg.PortableServer.Servant ; 15 import org.omg.PortableServer.ServantLocatorPackage.CookieHolder ; 16 17 import com.sun.corba.se.spi.oa.OAInvocationInfo ; 18 import com.sun.corba.se.spi.oa.ObjectAdapter ; 19 20 import com.sun.corba.se.spi.orb.ORB ; 21 22 import com.sun.corba.se.spi.logging.CORBALogDomains ; 23 24 import com.sun.corba.se.impl.logging.POASystemException ; 25 26 28 public class POACurrent extends org.omg.CORBA.portable.ObjectImpl 29 implements org.omg.PortableServer.Current 30 { 31 private ORB orb; 32 private POASystemException wrapper ; 33 34 public POACurrent(ORB orb) 35 { 36 this.orb = orb; 37 wrapper = POASystemException.get( orb, 38 CORBALogDomains.OA_INVOCATION ) ; 39 } 40 41 public String [] _ids() 42 { 43 String [] ids = new String [1]; 44 ids[0] = "IDL:omg.org/PortableServer/Current:1.0"; 45 return ids; 46 } 47 48 52 public POA get_POA() 53 throws 54 NoContext 55 { 56 POA poa = (POA )(peekThrowNoContext().oa()); 57 throwNoContextIfNull(poa); 58 return poa; 59 } 60 61 public byte[] get_object_id() 62 throws 63 NoContext 64 { 65 byte[] objectid = peekThrowNoContext().id(); 66 throwNoContextIfNull(objectid); 67 return objectid; 68 } 69 70 74 public ObjectAdapter getOA() 75 { 76 ObjectAdapter oa = peekThrowInternal().oa(); 77 throwInternalIfNull(oa); 78 return oa; 79 } 80 81 public byte[] getObjectId() 82 { 83 byte[] objectid = peekThrowInternal().id(); 84 throwInternalIfNull(objectid); 85 return objectid; 86 } 87 88 Servant getServant() 89 { 90 Servant servant = (Servant )(peekThrowInternal().getServantContainer()); 91 return servant; 95 } 96 97 CookieHolder getCookieHolder() 98 { 99 CookieHolder cookieHolder = peekThrowInternal().getCookieHolder(); 100 throwInternalIfNull(cookieHolder); 101 return cookieHolder; 102 } 103 104 public String getOperation() 108 { 109 String operation = peekThrowInternal().getOperation(); 110 throwInternalIfNull(operation); 111 return operation; 112 } 113 114 void setServant(Servant servant) 115 { 116 peekThrowInternal().setServant( servant ); 117 } 118 119 123 private OAInvocationInfo peekThrowNoContext() 124 throws 125 NoContext 126 { 127 OAInvocationInfo invocationInfo = null; 128 try { 129 invocationInfo = orb.peekInvocationInfo() ; 130 } catch (EmptyStackException e) { 131 throw new NoContext (); 132 } 133 return invocationInfo; 134 } 135 136 private OAInvocationInfo peekThrowInternal() 137 { 138 OAInvocationInfo invocationInfo = null; 139 try { 140 invocationInfo = orb.peekInvocationInfo() ; 141 } catch (EmptyStackException e) { 142 throw wrapper.poacurrentUnbalancedStack( e ) ; 145 } 146 return invocationInfo; 147 } 148 149 private void throwNoContextIfNull(Object o) 150 throws 151 NoContext 152 { 153 if ( o == null ) { 154 throw new NoContext (); 155 } 156 } 157 158 private void throwInternalIfNull(Object o) 159 { 160 if ( o == null ) { 161 throw wrapper.poacurrentNullField( CompletionStatus.COMPLETED_MAYBE ) ; 162 } 163 } 164 } 165 | Popular Tags |