1 7 8 package com.sun.corba.se.impl.protocol; 9 10 import org.omg.CORBA.portable.ServantObject ; 11 12 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher; 13 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; 14 15 import com.sun.corba.se.spi.orb.ORB; 16 import com.sun.corba.se.spi.ior.IOR ; 17 import com.sun.corba.se.spi.oa.ObjectAdapterFactory; 18 19 import com.sun.corba.se.spi.ior.ObjectAdapterId; 20 import com.sun.corba.se.spi.ior.TaggedProfile; 21 import com.sun.corba.se.spi.ior.ObjectKeyTemplate; 22 import com.sun.corba.se.spi.ior.ObjectId; 23 24 public abstract class LocalClientRequestDispatcherBase implements LocalClientRequestDispatcher 25 { 26 protected ORB orb; 27 int scid; 28 29 protected boolean servantIsLocal ; 31 protected ObjectAdapterFactory oaf ; 32 protected ObjectAdapterId oaid ; 33 protected byte[] objectId ; 34 35 protected static ThreadLocal isNextCallValid = new ThreadLocal () { 38 protected synchronized Object initialValue() { 39 return Boolean.TRUE; 40 } 41 }; 42 43 protected LocalClientRequestDispatcherBase(ORB orb, int scid, IOR ior) 44 { 45 this.orb = orb ; 46 47 TaggedProfile prof = ior.getProfile() ; 48 servantIsLocal = orb.getORBData().isLocalOptimizationAllowed() && 49 prof.isLocal(); 50 51 ObjectKeyTemplate oktemp = prof.getObjectKeyTemplate() ; 52 this.scid = oktemp.getSubcontractId() ; 53 RequestDispatcherRegistry sreg = orb.getRequestDispatcherRegistry() ; 54 oaf = sreg.getObjectAdapterFactory( scid ) ; 55 oaid = oktemp.getObjectAdapterId() ; 56 ObjectId oid = prof.getObjectId() ; 57 objectId = oid.getId() ; 58 } 59 60 public byte[] getObjectId() 61 { 62 return objectId ; 63 } 64 65 public boolean is_local(org.omg.CORBA.Object self) 66 { 67 return false; 68 } 69 70 85 public boolean useLocalInvocation( org.omg.CORBA.Object self ) 86 { 87 if (isNextCallValid.get() == Boolean.TRUE) 88 return servantIsLocal ; 89 else 90 isNextCallValid.set( Boolean.TRUE ) ; 91 92 return false ; 93 } 94 95 99 protected boolean checkForCompatibleServant( ServantObject so, 100 Class expectedType ) 101 { 102 if (so == null) 103 return false ; 104 105 if (!expectedType.isInstance( so.servant )) { 109 isNextCallValid.set( Boolean.FALSE ) ; 110 111 return false ; 115 } 116 117 return true ; 118 } 119 120 } 121 122 | Popular Tags |