FileDocCategorySizeDatePackage
POAProtocolMgr.javaAPI DocGlassfish v2 API11046Fri May 04 22:34:54 BST 2007com.sun.enterprise.iiop

POAProtocolMgr

public final class POAProtocolMgr extends LocalObject implements ProtocolManager
This class implements the ProtocolManager interface for the RMI/IIOP ORB with POA (Portable Object Adapter). Note that the POA is now accessed only through the ReferenceFactoryManager for EJB.
author
Vivek Nagar

Fields Summary
private static final Logger
_logger
private static final int
MAPEXCEPTION_CODE
private static final String
InitialObjectsDb
private static final String
ORG_OMG_STUB_PREFIX
private final ORB
orb
private final Switch
theSwitch
private final ContainerFactory
containerFactory
private final com.sun.corba.ee.spi.presentation.rmi.PresentationManager
presentationMgr
Constructors Summary
public POAProtocolMgr(ORB o)


      
    
        this.orb = (ORB)o;

        theSwitch = Switch.getSwitch();
        containerFactory = theSwitch.getContainerFactory();
        this.presentationMgr = 
            ((com.sun.corba.ee.spi.orb.ORB) orb).getPresentationManager();
        if ( containerFactory == null )
        {
            throw new IllegalStateException( "null containerFactory" );
        }
    
Methods Summary
public voidconnectObject(java.rmi.Remote remoteObj)
Connect the RMI object to the protocol.

        StubAdapter.connect
            (remoteObj, (com.sun.corba.ee.spi.orb.ORB)ORBManager.getORB());   
    
private ContainerFactorygetContainerFactory()

        return containerFactory;
    
public EjbDescriptorgetEjbDescriptor(byte[] ejbKey)
Called from SecurityMechanismSelector for each objref creation

	EjbDescriptor result = null;
	try {
	    if(_logger.isLoggable(Level.FINE)) {
		_logger.log(Level.FINE, "POAProtocolMgr.getEjbDescriptor->: "
			    + ejbKey);
	    }

	    if ( ejbKey.length < POARemoteReferenceFactory.EJBID_OFFSET + 8 ) {
		if(_logger.isLoggable(Level.FINE)) {
		    _logger.log(Level.FINE, "POAProtocolMgr.getEjbDescriptor: "
				+ ejbKey
				+ ": " + ejbKey.length + " < "
				+ POARemoteReferenceFactory.EJBID_OFFSET + 8);
		}
		return null;
	    }

	    long ejbId = 
		Utility.bytesToLong(ejbKey, 
				    POARemoteReferenceFactory.EJBID_OFFSET);

	    if(_logger.isLoggable(Level.FINE)) {
		_logger.log(Level.FINE, "POAProtocolMgr.getEjbDescriptor: " 
			    + ejbKey + ": ejbId: " + ejbId);
	    }

	    if ( getContainerFactory() != null ) {
		result = containerFactory.getEjbDescriptor(ejbId);
	    } else {
		if(_logger.isLoggable(Level.FINE)) {
		    _logger.log(Level.FINE, "POAProtocolMgr.getEjbDescriptor: " 
				+ ejbKey + ": no container factory");
		}
	    }

	    return result;
	} finally {
	    if(_logger.isLoggable(Level.FINE)) {
		_logger.log(Level.FINE, "POAProtocolMgr.getEjbDescriptor<-: " 
			    + ejbKey + ": " + result);
	    }
	}
    
public org.omg.CORBA.ORBgetORB()

	return orb;
    
public RemoteReferenceFactorygetRemoteReferenceFactory(Container container, boolean remoteHomeView, java.lang.String id)
Return a factory that can be used to create/destroy remote references for a particular EJB type.

	RemoteReferenceFactory factory = new POARemoteReferenceFactory
            (container, this, orb, remoteHomeView, id);
						    
	// XXX store factory in some kind of table ??
	return factory;
    
public voidinitializeNaming(java.io.File dbDir, int orbInitialPort)

	// NOTE: The TransientNameService reference is NOT HA.
        new TransientNameService((com.sun.corba.ee.spi.orb.ORB)orb);
        _logger.log(Level.FINE, "POAProtocolMgr.initializeNaming: complete");
    
public voidinitializePOAs()

   
	// NOTE:  The RootPOA manager used to activated here.
	ReferenceFactoryManager rfm = 
	    (ReferenceFactoryManager)orb.resolve_initial_references( 
		ORBConstants.REFERENCE_FACTORY_MANAGER ) ;
	rfm.activate() ;
	_logger.log(Level.FINE, "POAProtocolMgr.initializePOAs: RFM resolved and activated");
    
public booleanisIdentical(java.rmi.Remote obj1, java.rmi.Remote obj2)
Return true if the two object references refer to the same remote object.

	org.omg.CORBA.Object corbaObj1 = (org.omg.CORBA.Object)obj1;
	org.omg.CORBA.Object corbaObj2 = (org.omg.CORBA.Object)obj2;

	return corbaObj1._is_equivalent(corbaObj2);
    
public java.lang.ThrowablemapException(java.lang.Throwable exception)
Map the EJB/RMI exception to a protocol-specific (e.g. CORBA) exception


        boolean mapped = true;
        Throwable mappedException = null;

        if ( exception instanceof java.rmi.NoSuchObjectException
            || exception instanceof NoSuchObjectLocalException )
        {
            mappedException = new OBJECT_NOT_EXIST(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if ( exception instanceof java.rmi.AccessException
            || exception instanceof javax.ejb.AccessLocalException )
        {
            mappedException = new NO_PERMISSION(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if ( exception instanceof java.rmi.MarshalException ) {
            mappedException = new MARSHAL(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if ( exception instanceof javax.transaction.TransactionRolledbackException
            || exception instanceof TransactionRolledbackLocalException )
        {
            mappedException = new TRANSACTION_ROLLEDBACK(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if ( exception instanceof javax.transaction.TransactionRequiredException
            || exception instanceof TransactionRequiredLocalException )
        {
            mappedException = new TRANSACTION_REQUIRED(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if ( exception instanceof javax.transaction.InvalidTransactionException ) {
            mappedException = new INVALID_TRANSACTION(MAPEXCEPTION_CODE,
                CompletionStatus.COMPLETED_MAYBE);
        } else if (exception instanceof ConcurrentAccessException) {
            ConcurrentAccessException ex = (ConcurrentAccessException) exception;
            exception = new ParallelAccessException(ex.getMessage(), ex);
            mapped = false;
        } else if ( exception instanceof EJBException ) {
            EJBException ex = (EJBException) exception;
            Throwable cause = ex.getCausedByException();
            if(cause == null) {
                cause = ex.getCause();
            }
            exception = new RemoteException(ex.getMessage(), cause);
            mapped = false;
        } else {
            mapped = false;
        }
        
        return (mapped) 
            ? mappedException.initCause(exception)
            : exception;
    
public voidvalidateTargetObjectInterfaces(java.rmi.Remote targetObj)

        
        if( targetObj != null ) {
            // All Remote interfaces implemented by targetObj will be
            // validated as a side-effect of calling setTarget().
            // A runtime exception will be propagated if validation fails.
            Tie tie = presentationMgr.getTie();
            tie.setTarget(targetObj);
        } else {
            throw new IllegalArgumentException
                ("null passed to validateTargetObjectInterfaces");
        }