1 23 24 package com.sun.enterprise.config; 25 26 import java.util.Map ; 27 import java.util.ArrayList ; 28 29 import org.xml.sax.helpers.DefaultHandler ; 30 import com.sun.enterprise.config.impl.ConfigContextImpl; 31 import com.sun.enterprise.config.pluggable.EnvironmentFactory; 32 import com.sun.enterprise.config.pluggable.ConfigEnvironment; 33 34 39 public class ConfigFactory { 40 41 42 public static ConfigContext createConfigContext(String fileUrl, DefaultHandler dh) throws ConfigException { 43 final ConfigEnvironment ce = getConfigEnvironment(fileUrl, false, false, true, true); 44 ce.setHandler(dh.getClass().getName()); 45 return ConfigContextFactory.createConfigContext(ce); 46 } 47 48 56 public static ConfigContext createConfigContext(String fileUrl) 57 throws ConfigException { 58 return createConfigContext(fileUrl, false, false); 59 } 60 61 71 public static ConfigContext createConfigContext(String fileUrl, 72 boolean readOnly) throws ConfigException { 73 return createConfigContext(fileUrl, readOnly, false); 74 } 75 76 88 public static ConfigContext createConfigContext(String fileUrl, 89 boolean readOnly, boolean autoCommit) throws ConfigException { 90 return createConfigContext(fileUrl, readOnly, autoCommit, true); 91 } 92 93 115 public static ConfigContext createConfigContext(String fileUrl, 116 boolean readOnly, boolean autoCommit, boolean cache) 117 throws ConfigException { 118 119 return createConfigContext(fileUrl, readOnly, autoCommit, 120 cache, true); 121 } 122 123 152 public static ConfigContext createConfigContext(String fileUrl, 153 boolean readOnly, boolean autoCommit, boolean cache, 154 boolean resolvePath) 155 throws ConfigException { 156 157 return ConfigContextFactory.createConfigContext( 158 getConfigEnvironment(fileUrl, readOnly, autoCommit, 159 cache, resolvePath)); 160 } 161 162 166 public static ConfigContext createConfigContext(String fileUrl, 167 boolean readOnly, boolean autoCommit, boolean cache, Class rootClass) 168 throws ConfigException { 169 170 ConfigEnvironment ce = getConfigEnvironment(fileUrl, readOnly, 171 autoCommit, cache, true); 172 ce.setRootClass(rootClass.getName()); 173 return ConfigContextFactory.createConfigContext(ce); 174 } 175 176 184 public static synchronized ConfigContext createConfigContext(String fileUrl, 185 boolean readOnly, boolean autoCommit, boolean cache, Class rootClass, 186 DefaultHandler dh) 187 throws ConfigException { 188 189 ConfigEnvironment ce = getConfigEnvironment(fileUrl, readOnly, 190 autoCommit, cache, true); 191 ce.setRootClass(rootClass.getName()); 192 ce.setHandler(dh.getClass().getName()); 193 return ConfigContextFactory.createConfigContext(ce); 194 } 195 196 public static void removeConfigContext(ConfigContext ctx) { 197 ConfigContextFactory.removeConfigContext(ctx); 198 } 199 200 public static synchronized void removeConfigContext(String fileUrl) { 201 ConfigContextFactory.removeConfigContext(fileUrl); 202 } 203 204 227 public static synchronized void replaceConfigContext( 228 ConfigContext oldCtx, 229 ConfigContext newCtx) 230 throws ConfigException { 231 ConfigContextFactory.replaceConfigContext(oldCtx, newCtx); 232 } 233 234 244 248 249 261 public static boolean enableLastModifiedCheck(ConfigContext ctx, boolean value) { 262 return ConfigContextFactory.enableLastModifiedCheck(ctx, value); 263 } 264 281 282 private static ConfigEnvironment getConfigEnvironment(String fileUrl, 283 boolean readOnly, boolean autoCommit, boolean cache, 284 boolean resolvePath) { 285 286 ConfigEnvironment ce = EnvironmentFactory.getEnvironmentFactory(). 287 getConfigEnvironment(); 288 ce.setUrl(fileUrl); 289 ce.setReadOnly(readOnly); 290 ce.setCachingEnabled(cache); 291 ce.getConfigBeanInterceptor().setResolvingPaths(resolvePath); 292 return ce; 293 } 294 } 295 | Popular Tags |