FileDocCategorySizeDatePackage
SerialInitContextFactory.javaAPI DocGlassfish v2 API7234Sun Jul 15 19:10:30 BST 2007com.sun.enterprise.naming

SerialInitContextFactory

public class SerialInitContextFactory extends Object implements InitialContextFactory
Implements the JNDI SPI InitialContextFactory interface used to create the InitialContext objects. It creates an instance of the serial context.

Fields Summary
private Hashtable
defaultEnv
private com.sun.appserv.naming.S1ASCtxFactory
s1asCtxFactory
private static boolean
_initializeOrbManager
Constructors Summary
public SerialInitContextFactory()
Default constructor. Creates an ORB if one is not already created.

        String LBPOLICY = 
	  System.getProperty(S1ASCtxFactory.LOAD_BALANCING_PROPERTY);
      
	String ENDPOINTS = 
	  System.getProperty(S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY);
	if ((LBPOLICY != null &&
	     !LBPOLICY.equals("")) ||
	    (ENDPOINTS != null &&
	     !ENDPOINTS.equals(""))) {
	    s1asCtxFactory = new S1ASCtxFactory();
	} else {
	    // create a default env
	    defaultEnv = new Hashtable();

	    // Client side : removing the initialization of the ORB 
	    // from the constructor since
	    // we need to propagate the host:port values that are 
	    // set in the App client to ORB.init()	    
	    /*    if (_initializeOrbManager) {
	        ORBManager.init(null, null);
		defaultEnv.put("java.naming.corba.orb", ORBManager.getORB());
		}*/
	}
    
Methods Summary
public javax.naming.ContextgetInitialContext(java.util.Hashtable env)
Create the InitialContext object.

        if (env != null) {
	    if (env.get(S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY) != null) {
	        System.setProperty(S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY, 
				   (String)env.get(S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY));
	    } 
	    if (env.get(S1ASCtxFactory.LOAD_BALANCING_PROPERTY) != null) {
	        System.setProperty(S1ASCtxFactory.LOAD_BALANCING_PROPERTY,
				   (String)env.get(S1ASCtxFactory.LOAD_BALANCING_PROPERTY));
	    }

	    String LBPOLICY = 
	      System.getProperty(S1ASCtxFactory.LOAD_BALANCING_PROPERTY);
	    
	    String ENDPOINTS = 
	      System.getProperty(S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY);
    
	    if ((LBPOLICY != null &&
		 !LBPOLICY.equals("")) ||
		(ENDPOINTS != null &&
		 !ENDPOINTS.equals(""))) {
	      s1asCtxFactory = new S1ASCtxFactory();
	        return (s1asCtxFactory.getInitialContext(env));
	    }
	}
	if (_initializeOrbManager && 
	    (env == null || 
	     (env != null && env.get("java.naming.corba.orb") == null))) {

	    //javax.naming.InitialContext passes its own local Hashtable 
	    //variable, so can't cast it to Properties.
	  
	    Properties props = new Properties();
	    if (env != null) {
		String host = (String)env.get("org.omg.CORBA.ORBInitialHost");
		String port = (String)env.get("org.omg.CORBA.ORBInitialPort");
		
		if (host != null) {
		    props.put("org.omg.CORBA.ORBInitialHost", host);
		}

		if (port != null) {
		    props.put("org.omg.CORBA.ORBInitialPort", port);
		}
	    }
	    org.omg.CORBA.ORB orb = ORBManager.getORB(props) ;
	    if (defaultEnv != null)
		defaultEnv.put("java.naming.corba.orb", orb ) ; 
	    if (env != null)
		env.put("java.naming.corba.orb", orb );
	}
	
	if (SerialContext.getSticky() != null) {
	    Context ctx = SerialContext.getStickyContext();	
	    return ctx;
	}

	if (s1asCtxFactory != null) {
	    return (s1asCtxFactory.getInitialContext(env));
	}
        
	if (env != null) {	    	    
            return new SerialContext(env);
        } else {
            return new SerialContext(defaultEnv);
        }
    
public static voidsetInitializeOrbManager(boolean init)
Set to false if you do not want the OrbManager to be initialized. This is necessary in the NodeAgent since OrbManager initialization causes the NSS certificate database to be opended (and loaded) in which case it cannot be synchronized on Windows platforms (file in use).


     
        // setting ORB class and ORB singleton to SE values
        //setting RMI-IIOP delegates to EE values
        com.sun.enterprise.util.ORBManager.setORBSystemProperties();
    
        _initializeOrbManager = init;