FileDocCategorySizeDatePackage
ServerConfiguration.javaAPI DocGlassfish v2 API9975Fri May 04 22:33:16 BST 2007com.sun.enterprise

ServerConfiguration

public class ServerConfiguration extends Object
A Server Configuration is a singleton object that stores all the properties that are needed by various components.
author
Harish Prabandham

Fields Summary
private static Logger
_logger
public static final String
JNDI_NAME
private static final boolean
debug
private static ServerConfiguration
serverconfig
private com.sun.enterprise.repository.Configuration
config
private boolean
remote
Constructors Summary
private ServerConfiguration()

        try{
            config = (Configuration) Utility.lookupObject(
                    JNDI_NAME, Configuration.class);
        } catch (Exception ne) {
            // we could not connect to the naming .. lets use a local copy
// IASRI 4660742
            // ne.printStackTrace(System.err);
// START OF IASRI 4660742
            // _logger.log(Level.WARNING,"enterprise.error_connecting",ne);
// END OF IASRI 4660742
            try{
                config = new ConfigurationImpl();
		/* not needed for local copy
		javax.rmi.PortableRemoteObject.exportObject(config);
		if(ORBManager.getORB() != null) {
		    Tie servantsTie = javax.rmi.CORBA.Util.getTie(config);
		    servantsTie.orb(ORBManager.getORB());
		}
		*/
                remote = false;
            } catch(Exception e) {
		if ( debug )
// IASRI 4660742 		    e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.WARNING,"enterprise.config_create_error",e);
// END OF IASRI 4660742
            }
        }
    
Methods Summary
public static com.sun.enterprise.ServerConfigurationgetConfiguration()


        
        if(serverconfig == null) {
            serverconfig = new ServerConfiguration();
        }
        return serverconfig;
    
public static com.sun.enterprise.repository.J2EEResourceFactorygetJ2EEResourceFactory()

        /*   IASRI #4626188
        return new J2EEResourceFactoryImpl();
         */
        // START OF IASRI #4626188
        return new IASJ2EEResourceFactoryImpl();
        // END OF IASRI #4626188
    
public java.lang.String[]getKeys(java.lang.String index)
This method returns all the keys for a given index.

        String[] keys = null;

        try {
            keys = config.getKeys(index);
        } catch(Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.getkey_exception",e);
// END OF IASRI 4660742
        }
        return keys;
        
    
public java.lang.ObjectgetObject(java.lang.String key)
This method gets an Object associated with the given key.

return
An Object corresponding to the key

        Object obj = null;

        try {
            obj = config.getObject(key);
        } catch (Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.getobject_exception",e);
// END OF IASRI 4660742
        }
        return obj;
       
    
public java.util.PropertiesgetProperties(java.lang.String index)
Return the subset of properties for a given index.

        Properties props = new Properties();
        try {
            String[] keys = config.getKeys(index);
            for (int i=0; i<keys.length; i++) {
                props.put(keys[i], getProperty(keys[i]));
            }
        } catch (Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.get_put_key_exception",e);
// END OF IASRI 4660742
        } 
        return props;
        
    
public java.lang.StringgetProperty(java.lang.String key)
This method gets a property value associated with the given key.

return
A property value corresponding to the key

        String val = null;

        try {
            val = config.getProperty(key);
        } catch (Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.getpropertry_exception",e);
// END OF IASRI 4660742
        } 
        return val;
        
    
public java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultvalue)
This method gets a property value associated with the given key.

param
The key
param
The default Value
return
A property value corresponding to the key

        String val = defaultvalue;

        try {
            val = config.getProperty(key);
        } catch (Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.getpropertry_exception",e);
// END OF IASRI 4660742
        }
	    if(val != null) {
		return val;
	    } else {
		return defaultvalue;
	    }
        
    
public voidremoveObject(java.lang.String key)

        try {
            if (remote) {
                config.removeObject(key);
	    } else {
                throw new IllegalStateException("Cannot remove objects in local mode");
            }
        } catch(Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.remove_object_exception",e);
// END OF IASRI 4660742
        }
    
public voidremoveProperty(java.lang.String key)

        try {
            if (remote) {
                config.removeProperty(key);
            }  else {
                throw new IllegalStateException("Cannot remove properties in local mode");
            }
        } catch(Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.remove_property_exception",e);
// END OF IASRI 4660742
        }
    
public voidsetObject(java.lang.String key, java.lang.Object obj)
This method associates an Object with the given key.

        try {
            if (remote) {
                config.setObject(key, obj);
	    }  else {
                throw new IllegalStateException("Cannot set objects in local mode");
            }
        } catch(Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.setobject_exception",e);
// END OF IASRI 4660742
        }
    
public voidsetProperty(java.lang.String key, java.lang.String value)
This method associates a property value with the given key.

// IASRI 466074
	// System.out.println("Setting Property: " + key + " value =" + value +
	//	   " " + remote);
// START OF IASRI 4660742
        //  _logger.log(Level.FINE,"Setting Property: " + key + " value =" + value +
        //         " " + remote);
// END OF IASRI 4660742
        try {
            if (remote) {
                config.setProperty(key, value);
            } else {
                throw new IllegalStateException("Cannot set properties n local mode");
            }
        } catch (Exception e) {
// IASRI 4660742            e.printStackTrace(System.err);
// START OF IASRI 4660742
            _logger.log(Level.SEVERE,"enterprise.setpropertry_exception",e);
// END OF IASRI 4660742
        }