FileDocCategorySizeDatePackage
PEORBConfigurator.javaAPI DocGlassfish v2 API10328Mon Jul 30 15:00:22 BST 2007com.sun.enterprise.iiop

PEORBConfigurator

public class PEORBConfigurator extends Object implements com.sun.corba.ee.spi.orb.ORBConfigurator

Fields Summary
private static final Logger
logger
private static final String
OPT_COPIER_CLASS
private static com.sun.jts.pi.InterceptorImpl
jtsInterceptor
private static org.omg.CORBA.TSIdentification
tsIdent
private static com.sun.corba.ee.spi.orb.ORB
theORB
private static com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager
threadpoolMgr
private static boolean
txServiceInitialized
Constructors Summary
Methods Summary
public voidconfigure(com.sun.corba.ee.spi.orb.DataCollector dc, com.sun.corba.ee.spi.orb.ORB orb)


     
	tsIdent = new TSIdentificationImpl();
    
        //begin temp fix for bug 6320008
        // this is needed only because we are using transient Name Service
        //this should be removed once we have the persistent Name Service in place
	orb.setBadServerIdHandler( 
	    new BadServerIdHandler() {
		public void handle( ObjectKey objectkey ) {
		    // NO-OP
		}
	    }
	) ;
	//end temp fix for bug 6320008
	if (threadpoolMgr != null) {
	    // This will be the case for the Server Side ORB created
	    // For client side threadpoolMgr will be null, so we will
	    // never come here
	    orb.setThreadPoolManager(threadpoolMgr);
	}

	configureCopiers(orb);
        configureCallflowInvocationInterceptor(orb);
    
private static voidconfigureCallflowInvocationInterceptor(com.sun.corba.ee.spi.orb.ORB orb)

        orb.setInvocationInterceptor(
	    new InvocationInterceptor() {
		public void preInvoke() {		    
		    Agent agent = Switch.getSwitch().getCallFlowAgent();
		    if (agent != null) {
		        agent.startTime(
					ContainerTypeOrApplicationType.ORB_CONTAINER);
		    }
		}
		public void postInvoke() {
		    Agent agent = Switch.getSwitch().getCallFlowAgent();
		    if (agent != null) {
		        agent.endTime();
		    }
		}
	    }
	);
    
private static voidconfigureCopiers(com.sun.corba.ee.spi.orb.ORB orb)

	ObjectCopierFactory stream;
	CopierManager cpm = orb.getCopierManager();

	// Get the default copier factory
	stream = CopyobjectDefaults.makeORBStreamObjectCopierFactory(orb);
	cpm.registerObjectCopierFactory(stream, 
			    POARemoteReferenceFactory.PASS_BY_VALUE_ID);
	cpm.setDefaultId(POARemoteReferenceFactory.PASS_BY_VALUE_ID);

	// Detect if the optimized copier class exists in the classpath
	// or not. For the RI, one should get a ClassNotFoundException
	try {
	    Class cls =  Class.forName(OPT_COPIER_CLASS);
	    configureOptCopier(orb, cls, stream);
	} catch (ClassNotFoundException cnfe) {
	    // Don't do anything. This is true for RI and the default 
	    // stream copier is fine for that
	}
    
private static voidconfigureOptCopier(com.sun.corba.ee.spi.orb.ORB orb, java.lang.Class cls, com.sun.corba.ee.spi.orbutil.copyobject.ObjectCopierFactory stream)

	CopierManager cpm = orb.getCopierManager();
	
	// Get the reference copier factory
	ObjectCopierFactory reference = CopyobjectDefaults.
				getReferenceObjectCopierFactory();
	
	try {
	    Method m = cls.getMethod("makeReflectObjectCopierFactory",
		    new Class[] {com.sun.corba.ee.spi.orb.ORB.class});
	    ObjectCopierFactory reflect = 
		(ObjectCopierFactory)m.invoke(cls, new Object[] {orb});
	    ObjectCopierFactory fallback = 
		CopyobjectDefaults.makeFallbackObjectCopierFactory(reflect, stream);
	    cpm.registerObjectCopierFactory(fallback, 
		    POARemoteReferenceFactory.PASS_BY_VALUE_ID);
	    cpm.registerObjectCopierFactory(reference, 
		    POARemoteReferenceFactory.PASS_BY_REFERENCE_ID);
	    cpm.setDefaultId(POARemoteReferenceFactory.PASS_BY_VALUE_ID);
	} catch (NoSuchMethodException e) {
	    logger.log(Level.FINE,"Caught NoSuchMethodException - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	} catch (IllegalAccessException e) {
	    logger.log(Level.FINE,"Caught IllegalAccessException - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	} catch (IllegalArgumentException e) {
	    logger.log(Level.FINE,"Caught IllegalArgumentException - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	} catch (InvocationTargetException e) {
	    logger.log(Level.FINE,"Caught InvocationTargetException - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	} catch (NullPointerException e) {
	    logger.log(Level.FINE,"Caught NullPointerException - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	} catch (ExceptionInInitializerError e) {
	    logger.log(Level.FINE,"Caught ExceptionInInitializerError - " + e.getMessage());
	    logger.log(Level.FINE,"Proceeding with pass-by-value copier set to stream copier");
	}
    
public static synchronized voidinitTransactionService(java.lang.String jtsClassName, java.util.Properties jtsProperties)

        if (txServiceInitialized == false ) {
	    String clsName = (jtsClassName == null) ? 
	      "com.sun.jts.CosTransactions.DefaultTransactionService" : jtsClassName;
	    try {
	        Class theJTSClass = Class.forName(clsName);

		if (theJTSClass != null) {
		    try {
		        TransactionService jts = (TransactionService)theJTSClass.newInstance();
			jts.identify_ORB(theORB, tsIdent, jtsProperties ) ; 
			jtsInterceptor.setTSIdentification(tsIdent);
			// XXX should jts.get_current() be called everytime
			// resolve_initial_references is called ??
			org.omg.CosTransactions.Current transactionCurrent =
			  jts.get_current();
			
			theORB.getLocalResolver().register(
							   ORBConstants.TRANSACTION_CURRENT_NAME,
							   new Constant(transactionCurrent));
			
			// the JTS PI use this to call the proprietary hooks
			theORB.getLocalResolver().register(
							   "TSIdentification", new Constant(tsIdent));
			txServiceInitialized = true;	
		    } catch (Exception ex) {
		        throw new org.omg.CORBA.INITIALIZE(
							   "JTS Exception: "+ex, POASystemException.JTS_INIT_ERROR ,
							   CompletionStatus.COMPLETED_MAYBE);
		    }
		}
	    } catch (ClassNotFoundException cnfe) {
	        logger.log(Level.SEVERE,"iiop.inittransactionservice_exception",cnfe);
	    }	    
	}

    
static voidsetJTSInterceptor(com.sun.jts.pi.InterceptorImpl intr, com.sun.corba.ee.spi.orb.ORB orb)

	theORB = orb;
        jtsInterceptor = intr;

        // Set ORB and TSIdentification: needed for app clients, 
        // standalone clients.
        jtsInterceptor.setOrb(theORB);
    
public static voidsetThreadPoolManager()

	threadpoolMgr = S1ASThreadPoolManager.getThreadPoolManager();