1 7 8 package com.sun.corba.se.impl.oa.toa ; 9 10 import org.omg.CORBA.Policy ; 11 import org.omg.PortableInterceptor.ObjectReferenceTemplate ; 12 import org.omg.PortableInterceptor.ObjectReferenceFactory ; 13 import org.omg.PortableInterceptor.ACTIVE ; 14 import org.omg.PortableServer.ServantLocatorPackage.CookieHolder ; 15 16 import com.sun.corba.se.pept.protocol.ClientDelegate ; 17 18 import com.sun.corba.se.spi.copyobject.CopierManager ; 19 import com.sun.corba.se.spi.copyobject.ObjectCopier ; 20 import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ; 21 import com.sun.corba.se.spi.ior.ObjectKeyTemplate ; 22 import com.sun.corba.se.spi.ior.iiop.IIOPAddress ; 23 import com.sun.corba.se.spi.ior.iiop.IIOPFactories ; 24 import com.sun.corba.se.spi.oa.OAInvocationInfo ; 25 import com.sun.corba.se.spi.oa.OADestroyed ; 26 import com.sun.corba.se.spi.oa.ObjectAdapterBase ; 27 import com.sun.corba.se.spi.orb.ORB ; 28 import com.sun.corba.se.spi.presentation.rmi.StubAdapter ; 29 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ; 30 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher ; 31 import com.sun.corba.se.spi.transport.CorbaContactInfoList ; 32 33 import com.sun.corba.se.impl.ior.JIDLObjectKeyTemplate ; 34 import com.sun.corba.se.impl.oa.NullServantImpl; 35 import com.sun.corba.se.impl.oa.poa.Policies; 36 import com.sun.corba.se.impl.oa.toa.TransientObjectManager ; 37 import com.sun.corba.se.impl.orbutil.ORBConstants ; 38 import com.sun.corba.se.impl.protocol.JIDLLocalCRDImpl ; 39 40 59 public class TOAImpl extends ObjectAdapterBase implements TOA 60 { 61 private TransientObjectManager servants ; 62 63 public TOAImpl( ORB orb, TransientObjectManager tom, String codebase ) 64 { 65 super( orb ) ; 66 servants = tom ; 67 68 int serverid = ((ORB)getORB()).getTransientServerId(); 70 int scid = ORBConstants.TOA_SCID ; 71 72 ObjectKeyTemplate oktemp = new JIDLObjectKeyTemplate( orb, scid, serverid ) ; 73 74 Policies policies = Policies.defaultPolicies; 76 77 initializeTemplate( oktemp, true, 79 policies, 80 codebase, 81 null, oktemp.getObjectAdapterId() 83 ) ; 84 } 85 86 88 public ObjectCopierFactory getObjectCopierFactory() 89 { 90 CopierManager cm = getORB().getCopierManager() ; 91 return cm.getDefaultObjectCopierFactory() ; 92 } 93 94 public org.omg.CORBA.Object getLocalServant( byte[] objectId ) 95 { 96 return (org.omg.CORBA.Object )(servants.lookupServant( objectId ) ) ; 97 } 98 99 105 public void getInvocationServant( OAInvocationInfo info ) 106 { 107 java.lang.Object servant = servants.lookupServant( info.id() ) ; 108 if (servant == null) 109 servant = new NullServantImpl( lifecycleWrapper().nullServant() ) ; 112 info.setServant( servant ) ; 113 } 114 115 public void returnServant() 116 { 117 } 119 120 122 public String [] getInterfaces( Object servant, byte[] objectId ) 123 { 124 return StubAdapter.getTypeIds( servant ) ; 125 } 126 127 public Policy getEffectivePolicy( int type ) 132 { 133 return null ; 134 } 135 136 public int getManagerId() 137 { 138 return -1 ; 139 } 140 141 public short getState() 142 { 143 return ACTIVE.value ; 144 } 145 146 public void enter() throws OADestroyed 147 { 148 } 149 150 public void exit() 151 { 152 } 153 154 156 public void connect( org.omg.CORBA.Object objref) 157 { 158 byte[] key = servants.storeServant(objref, null); 161 162 String id = StubAdapter.getTypeIds( objref )[0] ; 164 165 ObjectReferenceFactory orf = getCurrentFactory() ; 167 org.omg.CORBA.Object obj = orf.make_object( id, key ) ; 168 169 172 org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate( 173 obj ) ; 174 CorbaContactInfoList ccil = (CorbaContactInfoList) 175 ((ClientDelegate)delegate).getContactInfoList() ; 176 LocalClientRequestDispatcher lcs = 177 ccil.getLocalClientRequestDispatcher() ; 178 179 if (lcs instanceof JIDLLocalCRDImpl) { 180 JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ; 181 jlcs.setServant( objref ) ; 182 } else { 183 throw new RuntimeException ( 184 "TOAImpl.connect can not be called on " + lcs ) ; 185 } 186 187 StubAdapter.setDelegate( objref, delegate ) ; 188 } 189 190 public void disconnect( org.omg.CORBA.Object objref ) 191 { 192 org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate( 194 objref ) ; 195 CorbaContactInfoList ccil = (CorbaContactInfoList) 196 ((ClientDelegate)del).getContactInfoList() ; 197 LocalClientRequestDispatcher lcs = 198 ccil.getLocalClientRequestDispatcher() ; 199 200 if (lcs instanceof JIDLLocalCRDImpl) { 201 JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ; 202 byte[] oid = jlcs.getObjectId() ; 203 servants.deleteServant(oid); 204 jlcs.unexport() ; 205 } else { 206 throw new RuntimeException ( 207 "TOAImpl.disconnect can not be called on " + lcs ) ; 208 } 209 } 210 } 211 | Popular Tags |