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

POAPolicyMediatorBase_R

public abstract class POAPolicyMediatorBase_R extends POAPolicyMediatorBase

Fields Summary
protected ActiveObjectMap
activeObjectMap
Constructors Summary
POAPolicyMediatorBase_R(Policies policies, POAImpl poa)

	super( policies, poa ) ;

	// assert policies.retainServants() && policies.useActiveObjectMapOnly()
	if (!policies.retainServants())
	    throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;

        activeObjectMap = ActiveObjectMap.create(poa, !isUnique);
    
Methods Summary
public final voidactivateObject(byte[] id, org.omg.PortableServer.Servant servant)

	if (isUnique && activeObjectMap.contains(servant))
	    throw new ServantAlreadyActive();
	ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;

	// Note that this can't happen for system assigned IDs since the
	// POA never hands out the same ID.  However, we make this redundant
	// check here to share the code.
	if (activeObjectMap.containsKey(key))
	    throw new ObjectAlreadyActive() ;

	AOMEntry entry = activeObjectMap.get( key ) ;
	entry.activateObject() ;
	activateServant( key, entry, servant ) ;
    
protected voidactivateServant(ActiveObjectMap.Key key, AOMEntry entry, org.omg.PortableServer.Servant servant)

	setDelegate(servant, key.id );

        if (orb.shutdownDebugFlag) {
            System.out.println("Activating object " + servant + 
	        " with POA " + poa);
        }

	activeObjectMap.putServant( servant, entry ) ;

        if (Util.instance != null) {
	    POAManagerImpl pm = (POAManagerImpl)poa.the_POAManager() ;
	    POAFactory factory = pm.getFactory() ;
            factory.registerPOAForServant(poa, servant);
        }
    
public voidclearAOM()

	activeObjectMap.clear() ;
	activeObjectMap = null ;
    
protected voiddeactivateHelper(ActiveObjectMap.Key key, AOMEntry entry, org.omg.PortableServer.Servant s)

	// Default does nothing, but the USE_SERVANT_MANAGER case
	// must handle etherealization

	activeObjectMap.remove(key);

        if (Util.instance != null) {
	    POAManagerImpl pm = (POAManagerImpl)poa.the_POAManager() ;
	    POAFactory factory = pm.getFactory() ;
            factory.unregisterPOAForServant(poa, s);
        }
    
public org.omg.PortableServer.ServantdeactivateObject(ActiveObjectMap.Key key)

	if (orb.poaDebugFlag) {
	    ORBUtility.dprint( this, 
		"Calling deactivateObject for key " + key ) ;
	}

	try {
	    AOMEntry entry = activeObjectMap.get(key);
	    if (entry == null)
		throw new ObjectNotActive();

	    Servant s = activeObjectMap.getServant( entry ) ;
	    if (s == null)
		throw new ObjectNotActive();

	    if (orb.poaDebugFlag) {
		System.out.println("Deactivating object " + s + " with POA " + poa);
	    }

	    deactivateHelper( key, entry, s ) ;

	    return s ;
	} finally {
	    if (orb.poaDebugFlag) {
		ORBUtility.dprint( this, 
		    "Exiting deactivateObject" ) ;
	    }
	}
    
public org.omg.PortableServer.ServantdeactivateObject(byte[] id)

	ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;
	return deactivateObject( key ) ;
    
protected org.omg.PortableServer.ServantinternalIdToServant(byte[] id)

	ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;
	return internalKeyToServant( key ) ;
    
protected org.omg.PortableServer.ServantinternalKeyToServant(ActiveObjectMap.Key key)

	AOMEntry entry = activeObjectMap.get(key);
	if (entry == null)
	    return null ;

	return activeObjectMap.getServant( entry ) ;
    
public voidreturnServant()

	// NO-OP
    
public byte[]servantToId(org.omg.PortableServer.Servant servant)

	
	// XXX needs to handle call from an invocation on this POA

	if (!isUnique && !isImplicit)
	    throw new WrongPolicy();

	if (isUnique) {
	    ActiveObjectMap.Key key = activeObjectMap.getKey(servant);
	    if (key != null)
		return key.id ;
	} 

	// assert !isUnique || (servant not in activateObjectMap)
	
	if (isImplicit)
	    try {
		byte[] id = newSystemId() ;
		activateObject( id, servant ) ;
		return id ; 
	    } catch (ObjectAlreadyActive oaa) {
		// This can't occur here, since id is always brand new.
		throw poa.invocationWrapper().servantToIdOaa( oaa ) ;
	    } catch (ServantAlreadyActive s) {
		throw poa.invocationWrapper().servantToIdSaa( s ) ;
	    } catch (WrongPolicy w) {
		throw poa.invocationWrapper().servantToIdWp( w ) ;
	    }

	throw new ServantNotActive();