1 23 24 29 30 package com.sun.enterprise.config.pluggable; 31 32 import com.sun.enterprise.config.ConfigRuntimeException; 33 import com.sun.enterprise.config.impl.ConfigEnvironmentImpl; 34 import com.sun.enterprise.config.impl.DefaultConfigBeanInterceptor; 35 import com.sun.enterprise.config.util.LocalStringsHelper; 36 import com.sun.enterprise.config.util.LoggerHelper; 37 46 public class EnvironmentFactory { 47 48 static final String ENVIRONMENT_FACTORY_CLASS = 49 "com.sun.enterprise.config.config_environment_factory_class"; 50 51 private static EnvironmentFactory _ENV = null; 52 53 54 public EnvironmentFactory() { 55 } 56 57 public static synchronized EnvironmentFactory getEnvironmentFactory() { 58 if(_ENV == null) { 59 _ENV = createEnvironmentFactory(); 60 } 61 return _ENV; 62 } 63 64 private static EnvironmentFactory createEnvironmentFactory() { 65 66 String factoryClassName = System.getProperty(ENVIRONMENT_FACTORY_CLASS); 67 68 Class factoryClass; 69 try { 70 if(factoryClassName!= null && !"".equals(factoryClassName)) { 71 factoryClass = Class.forName(factoryClassName); 72 } else { 73 factoryClass = EnvironmentFactory.class; 74 } 75 }catch(Exception e) { 76 throw new ConfigRuntimeException( 77 "error_loading_environment_factory_class", 78 LocalStringsHelper. 79 getString("error_loading_environment_factory_class"), 80 e); 81 } 82 LoggerHelper.fine( 83 "com.sun.enterprise.config.pluggable.EnvironmentFactory.getEnvironmentFactory():" + 84 "Factory Class is " + factoryClass); 85 86 EnvironmentFactory result = null; 87 try { 88 result = (EnvironmentFactory) factoryClass.newInstance(); 89 } catch(Exception e) { 90 throw new ConfigRuntimeException( 91 "error_creating_environment_factory", 92 LocalStringsHelper. 93 getString("error_creating_environment_factory"), 94 e); 95 } 96 97 return result; 98 } 99 100 104 public ConfigEnvironment getConfigEnvironment() { 105 ConfigEnvironment ce = new ConfigEnvironmentImpl(); 106 ce.setConfigBeanInterceptor(new DefaultConfigBeanInterceptor()); 107 return ce; 108 } 109 } 110 | Popular Tags |