FileDocCategorySizeDatePackage
POAFactory.javaAPI DocJava SE 6 API5947Tue Jun 10 00:21:38 BST 2008com.sun.corba.se.impl.oa.poa

POAFactory

public class POAFactory extends Object implements ObjectAdapterFactory

Fields Summary
private Map
exportedServantsToPOA
private Set
poaManagers
private int
poaManagerId
private int
poaId
private POAImpl
rootPOA
private DelegateImpl
delegateImpl
private ORB
orb
private POASystemException
wrapper
private OMGSystemException
omgWrapper
private boolean
isShuttingDown
Constructors Summary
public POAFactory()
All object adapter factories must have a no-arg constructor.

	poaManagers = Collections.synchronizedSet(new HashSet(4));
	poaManagerId = 0 ;
	poaId = 0 ;
	rootPOA = null ;
	delegateImpl = null ;
	orb = null ;
    
Methods Summary
public synchronized voidaddPoaManager(org.omg.PortableServer.POAManager manager)

        poaManagers.add(manager);
    
public com.sun.corba.se.spi.oa.ObjectAdapterfind(com.sun.corba.se.spi.ior.ObjectAdapterId oaid)

	POA poa=null;
	try {
	    boolean first = true ;
	    Iterator iter = oaid.iterator() ;
	    poa = getRootPOA();
	    while (iter.hasNext()) {
		String name = (String)(iter.next()) ;

		if (first) {
		    if (!name.equals( ORBConstants.ROOT_POA_NAME ))
			throw wrapper.makeFactoryNotPoa( name ) ;
		    first = false ;
		} else {
		    poa = poa.find_POA( name, true ) ;
		}
	    }
	} catch ( org.omg.PortableServer.POAPackage.AdapterNonExistent ex ){
	    throw omgWrapper.noObjectAdaptor( ex ) ;
	} catch ( OBJECT_NOT_EXIST ex ) {
	    throw ex;
	} catch ( TRANSIENT ex ) {
	    throw ex;
	} catch ( Exception ex ) {
	    throw wrapper.poaLookupError( ex ) ;
	}

	if ( poa == null )
	    throw wrapper.poaLookupError() ;

	return (ObjectAdapter)poa;
    
public org.omg.PortableServer.portable.DelegategetDelegateImpl()

	return delegateImpl ;
    
public com.sun.corba.se.spi.orb.ORBgetORB()

	return orb ;
    
public synchronized org.omg.PortableServer.POAgetRootPOA()

	if (rootPOA == null) {
	    // See if we are trying to getRootPOA while shutting down the ORB.
	    if (isShuttingDown) {
		throw omgWrapper.noObjectAdaptor( ) ;
	    }

	    try {
		Object obj = orb.resolve_initial_references(
		    ORBConstants.ROOT_POA_NAME ) ;
		rootPOA = (POAImpl)obj ;
	    } catch (InvalidName inv) {
		throw wrapper.cantResolveRootPoa( inv ) ;
	    } 
	}

	return rootPOA;
    
public com.sun.corba.se.impl.logging.POASystemExceptiongetWrapper()


       
    
	return wrapper ;
    
public voidinit(com.sun.corba.se.spi.orb.ORB orb)

	this.orb = orb ;
	wrapper = POASystemException.get( orb,
	    CORBALogDomains.OA_LIFECYCLE ) ;
	omgWrapper = OMGSystemException.get( orb,
	    CORBALogDomains.OA_LIFECYCLE ) ;
	delegateImpl = new DelegateImpl( orb, this ) ;
	registerRootPOA() ;

	POACurrent poaCurrent = new POACurrent(orb);
	orb.getLocalResolver().register( ORBConstants.POA_CURRENT_NAME, 
	    ClosureFactory.makeConstant( poaCurrent ) ) ;
    
public synchronized org.omg.PortableServer.POAlookupPOA(org.omg.PortableServer.Servant servant)

        return (POA)exportedServantsToPOA.get(servant);
    
public synchronized intnewPOAId()

	return poaId++ ;
    
public synchronized intnewPOAManagerId()

	return poaManagerId++ ;
    
public synchronized voidregisterPOAForServant(org.omg.PortableServer.POA poa, org.omg.PortableServer.Servant servant)

        exportedServantsToPOA.put(servant, poa);
    
public voidregisterRootPOA()

	// We delay the evaluation of makeRootPOA until
	// a call to resolve_initial_references( "RootPOA" ).
	// The Future guarantees that makeRootPOA is only called once.
	Closure rpClosure = new Closure() {
	    public Object evaluate() {
		return POAImpl.makeRootPOA( orb ) ;
	    }
	} ;

	orb.getLocalResolver().register( ORBConstants.ROOT_POA_NAME, 
	    ClosureFactory.makeFuture( rpClosure ) ) ;
    
public synchronized voidremovePoaManager(org.omg.PortableServer.POAManager manager)

        poaManagers.remove(manager);
    
public voidshutdown(boolean waitForCompletion)

    	// It is important to copy the list of POAManagers first because 
	// pm.deactivate removes itself from poaManagers!
	Iterator managers = null ;
	synchronized (this) {
	    isShuttingDown = true ;
	    managers = (new HashSet(poaManagers)).iterator();
	}

	while ( managers.hasNext() ) {
	    try {
	        ((POAManager)managers.next()).deactivate(true, waitForCompletion);
	    } catch ( org.omg.PortableServer.POAManagerPackage.AdapterInactive e ) {}
	}
    
public synchronized voidunregisterPOAForServant(org.omg.PortableServer.POA poa, org.omg.PortableServer.Servant servant)

        exportedServantsToPOA.remove(servant);