FileDocCategorySizeDatePackage
EnvironmentFactory.javaAPI DocGlassfish v2 API4935Fri May 04 22:31:20 BST 2007com.sun.enterprise.config.pluggable

EnvironmentFactory

public class EnvironmentFactory extends Object
provides a implementation of factory. Users can extend this class and implement required methods and set their class in environment variable ENVIRONMENT_FACTORY_CLASS. The statis create method in this class reads the variable and instantiates the class. Note that the implemented factory needs a no arg constructor
author
sridatta

Fields Summary
static final String
ENVIRONMENT_FACTORY_CLASS
private static EnvironmentFactory
_ENV
Constructors Summary
public EnvironmentFactory()
Creates a new instance of EnvironmentFactory

    
           
      
    
Methods Summary
private static com.sun.enterprise.config.pluggable.EnvironmentFactorycreateEnvironmentFactory()

                                            
        String factoryClassName = System.getProperty(ENVIRONMENT_FACTORY_CLASS);
        
        Class factoryClass;
        try {
            if(factoryClassName!= null && !"".equals(factoryClassName)) {
                factoryClass = Class.forName(factoryClassName);
            } else {
                factoryClass = EnvironmentFactory.class;
            }
        }catch(Exception e) {
            throw new ConfigRuntimeException(
                    "error_loading_environment_factory_class",
                    LocalStringsHelper.
                        getString("error_loading_environment_factory_class"),
                    e);
        }
        LoggerHelper.fine(
            "com.sun.enterprise.config.pluggable.EnvironmentFactory.getEnvironmentFactory():" +
                    "Factory Class is " + factoryClass);
        
        EnvironmentFactory result = null;
        try {
            result = (EnvironmentFactory) factoryClass.newInstance();
        } catch(Exception e) {
            throw new ConfigRuntimeException(
                "error_creating_environment_factory", 
                LocalStringsHelper.
                        getString("error_creating_environment_factory"),
                e);
        }
        
        return result;
    
public ConfigEnvironmentgetConfigEnvironment()
creates a new configEnvironmentImpl with defaults

        ConfigEnvironment ce = new ConfigEnvironmentImpl();
        ce.setConfigBeanInterceptor(new DefaultConfigBeanInterceptor());
        return ce;
    
public static synchronized com.sun.enterprise.config.pluggable.EnvironmentFactorygetEnvironmentFactory()

        if(_ENV == null) {
           _ENV = createEnvironmentFactory();
        } 
        return _ENV;