FileDocCategorySizeDatePackage
POAImpl.javaAPI DocJava SE 5 API44683Fri Aug 26 14:54:26 BST 2005com.sun.corba.se.impl.oa.poa

POAImpl

public class POAImpl extends com.sun.corba.se.spi.oa.ObjectAdapterBase implements org.omg.PortableServer.POA
POAImpl is the implementation of the Portable Object Adapter. It contains an implementation of the POA interfaces specified in COBRA 2.3.1 chapter 11 (formal/99-10-07). This implementation is moving to comply with CORBA 3.0 due to the many clarifications that have been made to the POA semantics since CORBA 2.3.1. Specific comments have been added where 3.0 applies, but note that we do not have the new 3.0 APIs yet.

Fields Summary
private boolean
debug
private static final int
STATE_START
private static final int
STATE_INIT
private static final int
STATE_INIT_DONE
private static final int
STATE_RUN
private static final int
STATE_DESTROYING
private static final int
STATE_DESTROYED
private int
state
private POAPolicyMediator
mediator
private int
numLevels
private com.sun.corba.se.spi.ior.ObjectAdapterId
poaId
private String
name
private POAManagerImpl
manager
private int
uniquePOAId
private POAImpl
parent
private Map
children
private org.omg.PortableServer.AdapterActivator
activator
private int
invocationCount
com.sun.corba.se.impl.orbutil.concurrent.Sync
poaMutex
private com.sun.corba.se.impl.orbutil.concurrent.CondVar
adapterActivatorCV
private com.sun.corba.se.impl.orbutil.concurrent.CondVar
invokeCV
private com.sun.corba.se.impl.orbutil.concurrent.CondVar
beingDestroyedCV
protected ThreadLocal
isDestroying
Constructors Summary
private POAImpl(String name, POAImpl parent, com.sun.corba.se.spi.orb.ORB orb, int initialState)

	super( orb ) ;

	debug = orb.poaDebugFlag ;

	if (debug) {
	    ORBUtility.dprint( this, "Creating POA with name=" + name + 
		" parent=" + parent ) ;
	}

	this.state     = initialState ;
	this.name      = name ;
	this.parent    = parent;
	children = new HashMap();
	activator = null ;

	// This was done in initialize, but I moved it here
	// to get better searchability when tracing.
	uniquePOAId = getPOAFactory( orb ).newPOAId() ;

	if (parent == null) {
	    // This is the root POA, which counts as 1 level
	    numLevels = 1 ;
	} else {
	    // My level is one more than that of my parent
	    numLevels = parent.numLevels + 1 ;

	    parent.children.put(name, this);
	}

	// Get an array of all of the POA names in order to
	// create the poaid.
	String[] names = new String[ numLevels ] ;
	POAImpl poaImpl = this ;
	int ctr = numLevels - 1 ;
	while (poaImpl != null) {
	    names[ctr--] = poaImpl.name ;
	    poaImpl = poaImpl.parent ;
	}

	poaId = new ObjectAdapterIdArray( names ) ;

	invocationCount = 0; 

	poaMutex = new ReentrantMutex( orb.poaConcurrencyDebugFlag ) ;

	adapterActivatorCV = new CondVar( poaMutex, 
	    orb.poaConcurrencyDebugFlag ) ;
	invokeCV           = new CondVar( poaMutex, 
	    orb.poaConcurrencyDebugFlag ) ; 
	beingDestroyedCV   = new CondVar( poaMutex, 
	    orb.poaConcurrencyDebugFlag ) ;

	isDestroying = new ThreadLocal () {
	    protected java.lang.Object initialValue() {
		return Boolean.FALSE;
	    }
	};
    
Methods Summary
public byte[]activate_object(org.omg.PortableServer.Servant servant)
activate_object Section 3.3.8.14

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling activate_object on poa " + this + 
		    " (servant=" + servant + ")" ) ;
	    }

	    // Allocate a new system-generated object-id.
	    // This will throw WrongPolicy if not SYSTEM_ID
	    // policy.
	    byte[] id = mediator.newSystemId();

	    try {
		mediator.activateObject( id, servant ) ;
	    } catch (ObjectAlreadyActive oaa) {
		// This exception can not occur in this case,
		// since id is always brand new.
		// 
	    }

	    return id ;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting activate_object on poa " + this ) ;
	    }

	    unlock() ;
	}
    
public voidactivate_object_with_id(byte[] id, org.omg.PortableServer.Servant servant)
activate_object_with_id Section 3.3.8.15

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling activate_object_with_id on poa " + this + 
		    " (servant=" + servant + " id=" + id + ")" ) ;
	    }

	    // Clone the id to avoid possible errors due to aliasing
	    // (e.g. the client passes the id in and then changes it later).
	    byte[] idClone = (byte[])(id.clone()) ;

	    mediator.activateObject( idClone, servant ) ;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting activate_object_with_id on poa " + this ) ;
	    }

	    unlock() ;
	}
    
public org.omg.PortableServer.POAcreate_POA(java.lang.String name, org.omg.PortableServer.POAManager theManager, org.omg.CORBA.Policy[] policies)
create_POA Section 3.3.8.2

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling create_POA(name=" + name + 
		    " theManager=" + theManager + " policies=" + policies + 
		    ") on poa " + this ) ;
	    }
	    
	    // We cannot create children of a POA that is (being) destroyed.
	    // This has been added to the CORBA 3.0 spec.
	    if (state > STATE_RUN)
		throw omgLifecycleWrapper().createPoaDestroy() ;
		
	    POAImpl poa = (POAImpl)(children.get(name)) ;

	    if (poa == null) {
		poa = new POAImpl( name, this, getORB(), STATE_START ) ;
	    }

	    try {
		poa.lock() ;

		if (debug) {
		    ORBUtility.dprint( this, 
			"Calling create_POA: new poa is " + poa ) ;
		}

		if ((poa.state != STATE_START) && (poa.state != STATE_INIT))
		    throw new AdapterAlreadyExists();

		POAManagerImpl newManager = (POAManagerImpl)theManager ;
		if (newManager == null)
		    newManager = new POAManagerImpl( manager.getFactory(),
			manager.getPIHandler() );

		int defaultCopierId = 
		    getORB().getCopierManager().getDefaultId() ;
		Policies POAPolicies = 
		    new Policies( policies, defaultCopierId ) ;

		poa.initialize( newManager, POAPolicies ) ;

		return poa;
	    } finally {
		poa.unlock() ;
	    }
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.IdAssignmentPolicycreate_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue value)
create_id_assignment_policy Section 3.3.8.5

	return new IdAssignmentPolicyImpl(value);
    
public org.omg.PortableServer.IdUniquenessPolicycreate_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue value)
create_id_uniqueness_policy Section 3.3.8.5

	return new IdUniquenessPolicyImpl(value);
    
public org.omg.PortableServer.ImplicitActivationPolicycreate_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue value)
create_implicit_activation_policy Section 3.3.8.5

	return new ImplicitActivationPolicyImpl(value);
    
public org.omg.PortableServer.LifespanPolicycreate_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue value)
create_lifespan_policy Section 3.3.8.5

	return new LifespanPolicyImpl(value);
    
public org.omg.CORBA.Objectcreate_reference(java.lang.String repId)
create_reference 3.3.8.17

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling create_reference(repId=" + 
		    repId + ") on poa " + this ) ;
	    }

	    return makeObject( repId, mediator.newSystemId()) ;
	} finally {
	    unlock() ;
	}
    
public org.omg.CORBA.Objectcreate_reference_with_id(byte[] oid, java.lang.String repId)
create_reference_with_id 3.3.8.18

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling create_reference_with_id(oid=" + 
		    oid + " repId=" + repId + ") on poa " + this ) ;
	    }

	    // Clone the id to avoid possible errors due to aliasing
	    // (e.g. the client passes the id in and then changes it later).
	    byte[] idClone = (byte[])(oid.clone()) ;

	    return makeObject( repId, idClone ) ;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.RequestProcessingPolicycreate_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue value)
create_request_processing_policy Section 3.3.8.5

	return new RequestProcessingPolicyImpl(value);
    
public org.omg.PortableServer.ServantRetentionPolicycreate_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue value)
create_servant_retention_policy Section 3.3.8.5

	return new ServantRetentionPolicyImpl(value);
    
public org.omg.PortableServer.ThreadPolicycreate_thread_policy(org.omg.PortableServer.ThreadPolicyValue value)
create_thread_policy Section 3.3.8.5

	return new ThreadPolicyImpl(value);
    
public voiddeactivate_object(byte[] id)
deactivate_object 3.3.8.16

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling deactivate_object on poa " + this + 
		    " (id=" + id + ")" ) ;
	    }

	    mediator.deactivateObject( id ) ;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting deactivate_object on poa " + this ) ; 
	    }

	    unlock() ;
	}
    
public voiddestroy(boolean etherealize, boolean wait_for_completion)
destroy Section 3.3.8.4

        // This is to avoid deadlock
        if (wait_for_completion && getORB().isDuringDispatch()) {
	    throw lifecycleWrapper().destroyDeadlock() ;
        }

        DestroyThread destroyer = new DestroyThread( etherealize, debug );
	destroyer.doIt( this, wait_for_completion ) ;
    
private booleandestroyIfNotInitDone()

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling destroyIfNotInitDone on poa " + this ) ;
	    }

	    boolean success = (state == STATE_INIT_DONE) ;

	    if (success) 
		state = STATE_RUN ;
	    else {
		// Don't just use destroy, because the check for 
		// deadlock is too general, and can prevent this from
		// functioning properly.
		DestroyThread destroyer = new DestroyThread( false, debug );
		destroyer.doIt( this, true ) ;
	    }

	    return success ;
	} finally {
	    adapterActivatorCV.broadcast() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting destroyIfNotInitDone on poa " + this ) ;
	    }

	    unlock() ;
	}
    
public voidenter()

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling enter on poa " + this ) ; 
	    }
		 
	    // Avoid deadlock if this is the thread that is processing the 
	    // POA.destroy because this is the only thread that can notify 
	    // waiters on beingDestroyedCV.  This can happen if an
	    // etherealize upcall invokes a method on a colocated object
	    // served by this POA.
	    while ((state == STATE_DESTROYING) && 
		(isDestroying.get() == Boolean.FALSE)) {
		try {
		    beingDestroyedCV.await();
		} catch (InterruptedException ex) { 
		    // NO-OP
		}
	    }

	    if (!waitUntilRunning())
		throw new OADestroyed() ;
		
	    invocationCount++;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, "Exiting enter on poa " + this ) ; 
	    }
		 
	    unlock() ;
	}

	manager.enter();
    
voidetherealizeAll()

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling etheralizeAll on poa " + this ) ;
	    }
	    
	    mediator.etherealizeAll() ;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting etheralizeAll on poa " + this ) ;
	    }

	    unlock() ;
	}
    
public voidexit()

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling exit on poa " + this ) ;
	    }

	    invocationCount--;

	    if ((invocationCount == 0) && (state == STATE_DESTROYING)) {
		invokeCV.broadcast();
	    }
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, "Exiting exit on poa " + this ) ;
	    }

	    unlock() ;
	}

	manager.exit();
    
public org.omg.PortableServer.POAfind_POA(java.lang.String name, boolean activate)
find_POA Section 3.3.8.3

	POAImpl found = null ;
	AdapterActivator act = null ;

	lock() ;

	if (debug) {
	    ORBUtility.dprint( this, "Calling find_POA(name=" + name + 
		" activate=" + activate + ") on poa " + this ) ;
	}

	found = (POAImpl) children.get(name);

	if (found != null) {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling find_POA: found poa " + found ) ;
	    }
	    
	    try {
		found.lock() ;

		// Do not hold the parent POA lock while 
		// waiting for child to complete initialization.
		unlock() ;

		// Make sure that the child has completed its initialization,
		// if it was created by an AdapterActivator, otherwise throw
		// a standard TRANSIENT exception with minor code 4 (see
		// CORBA 3.0 11.3.9.3, in reference to unknown_adapter)
		if (!found.waitUntilRunning())
		    throw omgLifecycleWrapper().poaDestroyed() ;

		// Note that found may be in state DESTROYING or DESTROYED at
		// this point.  That's OK, since destruction could start at
		// any time.
	    } finally {
		found.unlock() ;
	    }
	} else {
	    try {
		if (debug) {
		    ORBUtility.dprint( this, 
			"Calling find_POA: no poa found" ) ;
		}

		if (activate && (activator != null)) {
		    // Create a child, but don't initialize it.  The newly
		    // created POA will be in state STATE_START, which will 
		    // cause other calls to find_POA that are creating the same
		    // POA to block on the waitUntilRunning call above.
		    // Initialization must be completed by a call to create_POA 
		    // inside the unknown_adapter upcall.  Note that 
		    // this.poaMutex must be held here so that this.children 
		    // can be safely updated.  The state is set to STATE_INIT 
		    // so that initialize can make the correct state transition 
		    // when create_POA is called inside the AdapterActivator.  
		    // This avoids activating the new POA too soon 
		    // by transitioning to STATE_RUN after unknown_adapter 
		    // returns.
		    found = new POAImpl( name, this, getORB(), STATE_INIT ) ;

		    if (debug) {
			ORBUtility.dprint( this, 
			    "Calling find_POA: created poa " + found ) ;
		    }

		    act = activator ;
		} else {
		    throw new AdapterNonExistent();
		}
	    } finally {
		unlock() ;
	    }
	}

	// assert (found != null) 
	// assert not holding this.poaMutex OR found.poaMutex

	// We must not hold either this.poaMutex or found.poaMutex here while 
	// waiting for intialization of found to complete to prevent possible 
	// deadlocks.
	
	if (act != null) {
	    boolean status = false ;
	    boolean adapterResult = false ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling find_POA: calling AdapterActivator"  ) ;
	    }

	    try {
		// Prevent more than one thread at a time from executing in act 
		// in case act is shared between multiple POAs.
		synchronized (act) {
		    status = act.unknown_adapter(this, name);
		}
	    } catch (SystemException exc) {
		throw omgLifecycleWrapper().adapterActivatorException( exc, 
		    name, poaId.toString() ) ;
	    } catch (Throwable thr) {
		// ignore most non-system exceptions, but log them for 
		// diagnostic purposes.
		lifecycleWrapper().unexpectedException( thr, this.toString() ) ;

		if (thr instanceof ThreadDeath)
		    throw (ThreadDeath)thr ;
	    } finally {
		// At this point, we have completed adapter activation.
		// Whether this was successful or not, we must call 
		// destroyIfNotInitDone so that calls to enter() and create_POA()
		// that are waiting can execute again.  Failing to do this
		// will cause the system to hang in complex tests.
		adapterResult = found.destroyIfNotInitDone() ;
	    }

	    if (status) {
		if (!adapterResult)
		    throw omgLifecycleWrapper().adapterActivatorException( name,
			poaId.toString() ) ;
	    } else {
		if (debug) {
		    ORBUtility.dprint( this, 
			"Calling find_POA: AdapterActivator returned false"  ) ;
		}

		// OMG Issue 3740 is resolved to throw AdapterNonExistent if
		// unknown_adapter() returns false.
		throw new AdapterNonExistent();
	    }
	}

	return found;
    
booleangetDebug()

	return debug ;
    
public org.omg.CORBA.PolicygetEffectivePolicy(int type)

	return mediator.getPolicies().get_effective_policy( type ) ;
    
public java.lang.String[]getInterfaces(java.lang.Object servant, byte[] objectId)

	Servant serv = (Servant)servant ;
	return serv._all_interfaces( this, objectId ) ;
    
public voidgetInvocationServant(com.sun.corba.se.spi.oa.OAInvocationInfo info)

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling getInvocationServant on poa " + this ) ;
	    }
	    
	    java.lang.Object servant = null ;

	    try {
		servant = mediator.getInvocationServant( info.id(), 
		    info.getOperation() );
	    } catch (ForwardRequest freq) {
		throw new ForwardException( getORB(), freq.forward_reference ) ;
	    }

	    info.setServant( servant ) ;
	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting getInvocationServant on poa " + this ) ;
	    }

	    unlock() ;
	}
    
public org.omg.CORBA.ObjectgetLocalServant(byte[] objectId)

	return null ;
    
public intgetManagerId()

	return manager.getManagerId() ;
    
protected com.sun.corba.se.spi.copyobject.ObjectCopierFactorygetObjectCopierFactory()

	int copierId = mediator.getPolicies().getCopierId() ;
	CopierManager cm = getORB().getCopierManager() ;
	return cm.getObjectCopierFactory( copierId ) ;
    
static POAFactorygetPOAFactory(com.sun.corba.se.spi.orb.ORB orb)

	return (POAFactory)orb.getRequestDispatcherRegistry().
	    getObjectAdapterFactory( ORBConstants.TRANSIENT_SCID ) ;
    
intgetPOAId()

	return uniquePOAId ;
    
PoliciesgetPolicies()

	return mediator.getPolicies() ;
    
public shortgetState()

	return manager.getORTState() ;
    
public org.omg.PortableServer.Servantget_servant()
get_servant Section 3.3.8.12

	try {
	    lock() ;

	    return mediator.getDefaultServant() ;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.ServantManagerget_servant_manager()
get_servant_manager Section 3.3.8.10

	try {
	    lock() ;

	    return mediator.getServantManager() ;
	} finally {
	    unlock() ;
	}
    
public byte[]id()
id 11.3.8.26 in ptc/00-08-06

	try {
	    lock() ;

	    return getAdapterId() ;
	} finally {
	    unlock() ;
	}
    
public org.omg.CORBA.Objectid_to_reference(byte[] id)
id_to_reference 3.3.8.24

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling id_to_reference(id=" + 
		    id + ") on poa " + this ) ;
	    }
	    
            if( state >= STATE_DESTROYING ) {
		throw lifecycleWrapper().adapterDestroyed() ;
            }
	    
	    Servant s = mediator.idToServant( id ) ;
	    String repId = s._all_interfaces( this, id )[0] ;
	    return makeObject(repId, id );
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.Servantid_to_servant(byte[] id)
id_to_servant 3.3.8.23

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling id_to_servant(id=" + 
		    id + ") on poa " + this ) ;
	    }
	    
            if( state >= STATE_DESTROYING ) {
		throw lifecycleWrapper().adapterDestroyed() ;
            }
	    return mediator.idToServant( id ) ;
	} finally {
	    unlock() ;
	}
    
private voidinitialize(POAManagerImpl manager, Policies policies)

	if (debug) {
	    ORBUtility.dprint( this, "Initializing poa " + this + 
		" with POAManager=" + manager + " policies=" + policies ) ;
	}
	
	this.manager = manager;
	manager.addPOA(this);

	mediator = POAPolicyMediatorFactory.create( policies, this ) ;

	// Construct the object key template
	int serverid = mediator.getServerId() ;
	int scid = mediator.getScid() ;
	String orbId = getORB().getORBData().getORBId();

	ObjectKeyTemplate oktemp = new POAObjectKeyTemplate( getORB(), 
	    scid, serverid, orbId, poaId ) ;

	if (debug) {
	    ORBUtility.dprint( this, "Initializing poa: oktemp=" + oktemp ) ;
	}

	// Note that parent == null iff this is the root POA.
	// This was used to avoid executing interceptors on the RootPOA.
	// That is no longer necessary.
	boolean objectAdapterCreated = true; // parent != null ;
    
	// XXX extract codebase from policies and pass into initializeTemplate
	// after the codebase policy change is finalized.
	initializeTemplate( oktemp, objectAdapterCreated,
			    policies, 
			    null, // codebase
			    null, // manager id
			    oktemp.getObjectAdapterId()
			    ) ;

	if (state == STATE_START)
	    state = STATE_RUN ;
	else if (state == STATE_INIT)
	    state = STATE_INIT_DONE ;
	else
	    throw lifecycleWrapper().illegalPoaStateTrans() ; 
    
private byte[]internalReferenceToId(org.omg.CORBA.Object reference)

	IOR ior = ORBUtility.getIOR( reference ) ;
	IORTemplateList thisTemplate = ior.getIORTemplates() ;

	ObjectReferenceFactory orf = getCurrentFactory() ;
	IORTemplateList poaTemplate = 
	    IORFactories.getIORTemplateList( orf ) ;

	if (!poaTemplate.isEquivalent( thisTemplate ))
	    throw new WrongAdapter();
	    
	// Extract the ObjectId from the first TaggedProfile in the IOR.
	// If ior was created in this POA, the same ID was used for 
	// every profile through the profile templates in the currentFactory,
	// so we will get the same result from any profile.
	Iterator iter = ior.iterator() ;
	if (!iter.hasNext())
	    throw iorWrapper().noProfilesInIor() ;
	TaggedProfile prof = (TaggedProfile)(iter.next()) ;
	ObjectId oid = prof.getObjectId() ;

	return oid.getId();
    
voidlock()

	SyncUtil.acquire( poaMutex ) ;

	if (debug) {
	    ORBUtility.dprint( this, "LOCKED poa " + this ) ; 
	}
    
static com.sun.corba.se.impl.oa.poa.POAImplmakeRootPOA(com.sun.corba.se.spi.orb.ORB orb)

	POAManagerImpl poaManager = new POAManagerImpl( getPOAFactory( orb ), 
	    orb.getPIHandler() ) ;

	POAImpl result = new POAImpl( ORBConstants.ROOT_POA_NAME, 
	    null, orb, STATE_START ) ;
	result.initialize( poaManager, Policies.rootPOAPolicies ) ;

	return result ;
    
public byte[]reference_to_id(org.omg.CORBA.Object reference)
reference_to_id 3.3.8.22

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling reference_to_id(reference=" + 
		    reference + ") on poa " + this ) ;
	    }
	    
            if( state >= STATE_DESTROYING ) {
		throw lifecycleWrapper().adapterDestroyed() ;
            }
	    
	    return internalReferenceToId( reference ) ;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.Servantreference_to_servant(org.omg.CORBA.Object reference)
reference_to_servant 3.3.8.21

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling reference_to_servant(reference=" + 
		    reference + ") on poa " + this ) ;
	    }
	    
            if ( state >= STATE_DESTROYING ) {
		throw lifecycleWrapper().adapterDestroyed() ;
            }

	    // reference_to_id should throw WrongAdapter
	    // if the objref was not created by this POA
	    byte [] id = internalReferenceToId(reference);
	    
	    return mediator.idToServant( id ) ;	
	} finally {
	    unlock() ;
	}
    
public voidreturnServant()
Called from the subcontract to let this POA cleanup after an invocation. Note: If getServant was called, then returnServant MUST be called, even in the case of exceptions. This may be called multiple times for a single request.

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling returnServant on poa " + this  ) ;
	    }
	    
	    mediator.returnServant();
	} catch (Throwable thr) {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exception " + thr + " in returnServant on poa " + this  ) ;
	    }

	    if (thr instanceof Error)
		throw (Error)thr ;
	    else if (thr instanceof RuntimeException)
		throw (RuntimeException)thr ;

	} finally {
	    if (debug) {
		ORBUtility.dprint( this, 
		    "Exiting returnServant on poa " + this  ) ;
	    }
	    
	    unlock() ;
	}
    
public byte[]servant_to_id(org.omg.PortableServer.Servant servant)
servant_to_id 3.3.8.19

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling servant_to_id(servant=" + 
		    servant + ") on poa " + this ) ;
	    }

	    return mediator.servantToId( servant ) ;
	} finally {
	    unlock() ;
	}
    
public org.omg.CORBA.Objectservant_to_reference(org.omg.PortableServer.Servant servant)
servant_to_reference 3.3.8.20

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, 
		    "Calling servant_to_reference(servant=" + 
		    servant + ") on poa " + this ) ;
	    }

	    byte[] oid = mediator.servantToId(servant);
	    String repId = servant._all_interfaces( this, oid )[0] ;
	    return create_reference_with_id(oid, repId);
	} finally {
	    unlock() ;
	}
    
public voidset_servant(org.omg.PortableServer.Servant defaultServant)
set_servant Section 3.3.8.13

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling set_servant on poa " +
		    this + " defaultServant=" + defaultServant ) ;
	    }

	    mediator.setDefaultServant( defaultServant ) ;
	} finally {
	    unlock() ;
	}
    
public voidset_servant_manager(org.omg.PortableServer.ServantManager servantManager)
set_servant_manager Section 3.3.8.10

	try {
	    lock() ;

	    if (debug) {
		ORBUtility.dprint( this, "Calling set_servant_manager on poa " +
		    this + " servantManager=" + servantManager ) ;
	    }

	    mediator.setServantManager( servantManager ) ;
	} finally {
	    unlock() ;
	}
    
private java.lang.StringstateToString()

 // destruction complete

      
    
	switch (state) {
	    case STATE_START :
		return "START" ;
	    case STATE_INIT :
		return "INIT" ;
	    case STATE_INIT_DONE :
		return "INIT_DONE" ;
	    case STATE_RUN :
		return "RUN" ;
	    case STATE_DESTROYING :
		return "DESTROYING" ;
	    case STATE_DESTROYED :
		return "DESTROYED" ;
	    default :
		return "UNKNOWN(" + state + ")" ;
	} 
    
public org.omg.PortableServer.POAManagerthe_POAManager()
the_POAManager Section 3.3.8.8

	try {
	    lock() ;

	    return manager;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.AdapterActivatorthe_activator()
the_activator Section 3.3.8.9

	try {
	    lock() ;

	    return activator;
	} finally {
	    unlock() ;
	}
    
public voidthe_activator(org.omg.PortableServer.AdapterActivator activator)
the_activator Section 3.3.8.9

	try {
	    lock() ;
	    
	    if (debug) {
		ORBUtility.dprint( this, "Calling the_activator on poa " +
		    this + " activator=" + activator ) ;
	    }

	    this.activator = activator;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.POA[]the_children()
the_children

	try {
	    lock() ;

	    Collection coll = children.values() ;
	    int size = coll.size() ;
	    POA[] result = new POA[ size ] ;
	    int index = 0 ;
	    Iterator iter = coll.iterator() ;
	    while (iter.hasNext()) {
	        POA poa = (POA)(iter.next()) ;
	        result[ index++ ] = poa ;
	    }

	    return result ;
	} finally {
	    unlock() ;
	}
    
public java.lang.Stringthe_name()
the_name Section 3.3.8.6

	try {
	    lock() ;

	    return name;
	} finally {
	    unlock() ;
	}
    
public org.omg.PortableServer.POAthe_parent()
the_parent Section 3.3.8.7

	try {
	    lock() ;

	    return parent;
	} finally {
	    unlock() ;
	}
    
public java.lang.StringtoString()

	return "POA[" + poaId.toString() + 
	    ", uniquePOAId=" + uniquePOAId + 
	    ", state=" + stateToString() + 
	    ", invocationCount=" + invocationCount + "]" ;
    
voidunlock()

	if (debug) {
	    ORBUtility.dprint( this, "UNLOCKED poa " + this ) ; 
	}

	poaMutex.release() ;
    
private booleanwaitUntilRunning()

	if (debug) {
	    ORBUtility.dprint( this, 
		"Calling waitUntilRunning on poa " + this ) ;
	}

	while (state < STATE_RUN) {
	    try {
		adapterActivatorCV.await() ; 
	    } catch (InterruptedException exc) {
		// NO-OP
	    }
	} 

	if (debug) {
	    ORBUtility.dprint( this, 
		"Exiting waitUntilRunning on poa " + this ) ;
	}

	// Note that a POA could be destroyed while in STATE_INIT due to a 
	// failure in the AdapterActivator upcall.
	return (state == STATE_RUN) ;