1 7 8 package com.sun.corba.se.impl.oa.poa ; 9 10 import java.util.Collection ; 11 import java.util.Enumeration ; 12 13 import org.omg.PortableServer.Servant ; 14 import org.omg.PortableServer.ForwardRequest ; 15 import org.omg.PortableServer.POAPackage.WrongPolicy ; 16 17 import com.sun.corba.se.spi.extension.ServantCachingPolicy ; 18 import com.sun.corba.se.spi.orb.ORB ; 19 import com.sun.corba.se.spi.transport.SocketOrChannelAcceptor; 20 21 import com.sun.corba.se.impl.orbutil.ORBConstants ; 22 import com.sun.corba.se.impl.orbutil.ORBUtility ; 23 import com.sun.corba.se.impl.orbutil.concurrent.SyncUtil ; 24 25 26 29 public abstract class POAPolicyMediatorBase implements POAPolicyMediator { 30 protected POAImpl poa ; 31 protected ORB orb ; 32 33 private int sysIdCounter ; 34 private Policies policies ; 35 private DelegateImpl delegateImpl ; 36 37 private int serverid ; 38 private int scid ; 39 40 protected boolean isImplicit ; 41 protected boolean isUnique ; 42 protected boolean isSystemId ; 43 44 public final Policies getPolicies() 45 { 46 return policies ; 47 } 48 49 public final int getScid() 50 { 51 return scid ; 52 } 53 54 public final int getServerId() 55 { 56 return serverid ; 57 } 58 59 POAPolicyMediatorBase( Policies policies, POAImpl poa ) 60 { 61 if (policies.isSingleThreaded()) 62 throw poa.invocationWrapper().singleThreadNotSupported() ; 63 64 POAManagerImpl poam = (POAManagerImpl)(poa.the_POAManager()) ; 65 POAFactory poaf = poam.getFactory() ; 66 delegateImpl = (DelegateImpl)(poaf.getDelegateImpl()) ; 67 this.policies = policies ; 68 this.poa = poa ; 69 orb = (ORB)poa.getORB() ; 70 71 switch (policies.servantCachingLevel()) { 72 case ServantCachingPolicy.NO_SERVANT_CACHING : 73 scid = ORBConstants.TRANSIENT_SCID ; 74 break ; 75 case ServantCachingPolicy.FULL_SEMANTICS : 76 scid = ORBConstants.SC_TRANSIENT_SCID ; 77 break ; 78 case ServantCachingPolicy.INFO_ONLY_SEMANTICS : 79 scid = ORBConstants.IISC_TRANSIENT_SCID ; 80 break ; 81 case ServantCachingPolicy.MINIMAL_SEMANTICS : 82 scid = ORBConstants.MINSC_TRANSIENT_SCID ; 83 break ; 84 } 85 86 if ( policies.isTransient() ) { 87 serverid = orb.getTransientServerId(); 88 } else { 89 serverid = orb.getORBData().getPersistentServerId(); 90 scid = ORBConstants.makePersistent( scid ) ; 91 } 92 93 isImplicit = policies.isImplicitlyActivated() ; 94 isUnique = policies.isUniqueIds() ; 95 isSystemId = policies.isSystemAssignedIds() ; 96 97 sysIdCounter = 0 ; 98 } 99 100 public final java.lang.Object getInvocationServant( byte[] id, 101 String operation ) throws ForwardRequest 102 { 103 java.lang.Object result = internalGetServant( id, operation ) ; 104 105 return result ; 106 } 107 108 protected final void setDelegate(Servant servant, byte[] id) 112 { 113 servant._set_delegate(delegateImpl); 116 } 117 118 public synchronized byte[] newSystemId() throws WrongPolicy 119 { 120 if (!isSystemId) 121 throw new WrongPolicy () ; 122 123 byte[] array = new byte[8]; 124 ORBUtility.intToBytes(++sysIdCounter, array, 0); 125 ORBUtility.intToBytes( poa.getPOAId(), array, 4); 126 return array; 127 } 128 129 protected abstract java.lang.Object internalGetServant( byte[] id, 130 String operation ) throws ForwardRequest ; 131 } 132 | Popular Tags |