FileDocCategorySizeDatePackage
ConfigFactory.javaAPI DocGlassfish v2 API13578Fri May 04 22:31:18 BST 2007com.sun.enterprise.config

ConfigFactory

public class ConfigFactory extends Object
A factory to create ConfigContext objects and ConfigBeans.
deprecated
use ConfigContextFactory

Fields Summary
Constructors Summary
Methods Summary
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, org.xml.sax.helpers.DefaultHandler dh)

        final ConfigEnvironment ce = getConfigEnvironment(fileUrl, false, false, true, true);
        ce.setHandler(dh.getClass().getName());
        return ConfigContextFactory.createConfigContext(ce);
    
public static ConfigContextcreateConfigContext(java.lang.String fileUrl)
Creates a configuration context for the specified URL.

param
fileUrl The URL to server.xml If a configuration context object for this URL was previously created then that object is returned.

            return  createConfigContext(fileUrl, false, false);
        
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly)
Creates a configuration context for the specified URL and in the specified mode.

param
fileUrl The URL to server.xml
param
readOnly if true, then the ConfigContext returned cannot be used to make changes to the XML file
return
If a configuration context object for this URL was previously created then that object is returned.

            return  createConfigContext(fileUrl, readOnly, false);
        
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly, boolean autoCommit)
Creates a configuration context for the specified URL and in the specified mode.

param
fileUrl The URL to server.xml
param
readOnly if true, then the ConfigContext returned cannot be used to make changes to the XML file
param
autoCommit if true, then changes to the ConfigContext object are automatically committed to the file.
return
If a configuration context object for this URL was previously created then that object is returned.

            return  createConfigContext(fileUrl, readOnly, autoCommit, true);
        
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly, boolean autoCommit, boolean cache)
Returns a ConfigContext object that was either previously created (and stored in the cache) or created anew. If cache is true then the factory looks up its cache of previously created ConfigContext objects and if a matching one is found then that is returned. If the cache lookup failed, then a new ConfigContext is created and inserted into the cache. If cache is false then the cache is not used and a new ConfigContext object is returned. This object is not inserted into the cache. Note that if ConfigContext already exists, readOnly and autoCommit are not used.

param
fileUrl
param
readOnly
param
autoCommit
param
cache
throws
ConfigException
return

           
           return createConfigContext(fileUrl, readOnly, autoCommit, 
                   cache, true);
        
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly, boolean autoCommit, boolean cache, boolean resolvePath)
Returns a ConfigContext object that was either previously created (and stored in the cache) or created anew. If cache is true then the factory looks up its cache of previously created ConfigContext objects and if a matching one is found then that is returned. If the cache lookup failed, then a new ConfigContext is created and inserted into the cache. If cache is false then the cache is not used and a new ConfigContext object is returned. This object is not inserted into the cache. If resolvePath is true then the absolute paths of certain attributes in domain.xml are resolved as in the runtime context. Note that if ConfigContext already exists, readOnly and autoCommit are not used.

param
fileUrl
param
readOnly
param
autoCommit
param
cache
param
resolvePath
throws
ConfigException
return

    

            return ConfigContextFactory.createConfigContext(
                    getConfigEnvironment(fileUrl, readOnly, autoCommit, 
                        cache, resolvePath));
        
public static ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly, boolean autoCommit, boolean cache, java.lang.Class rootClass)
this method adds a validation handler for creating a context default is com.sun.enterprise.config.serverbeans.ServerValidationHandler

 
                    
           ConfigEnvironment ce = getConfigEnvironment(fileUrl, readOnly, 
               autoCommit, cache, true);
           ce.setRootClass(rootClass.getName());
           return ConfigContextFactory.createConfigContext(ce);
        
public static synchronized ConfigContextcreateConfigContext(java.lang.String fileUrl, boolean readOnly, boolean autoCommit, boolean cache, java.lang.Class rootClass, org.xml.sax.helpers.DefaultHandler dh)
Creates a different class of beans based on rootClass By default, in the other createConfigContext APIs, rootClass is com.sun.enterprise.config.Server This API can be used to create serverbeans, clientbeans, or any other class of beans

 
                    
            ConfigEnvironment ce = getConfigEnvironment(fileUrl, readOnly, 
                    autoCommit, cache, true);
            ce.setRootClass(rootClass.getName());
            ce.setHandler(dh.getClass().getName());
            return ConfigContextFactory.createConfigContext(ce);
        
public static booleanenableLastModifiedCheck(ConfigContext ctx, boolean value)
This method is used to activate the lastModified checking for a configContext If activated, configbeans will carry a lastmodified timestamp in every bean. This time is also carried onto the configChangeList and also to clones. When configContext.updateFromConfigChangeList is called, the timestamp is first checked to see if the bean has not changed since the clone and then the update is made. If a modification to the bean is detected, a staleWriteConfigException is thrown.

param
ctx ConfigContext on which to enable/disable checking
param
value boolean to enable/disable
return
boolean previous value that was set (not the changed value)

        return ConfigContextFactory.enableLastModifiedCheck(ctx, value);
    
private static com.sun.enterprise.config.pluggable.ConfigEnvironmentgetConfigEnvironment(java.lang.String fileUrl, boolean readOnly, boolean autoCommit, boolean cache, boolean resolvePath)


        ConfigEnvironment ce = EnvironmentFactory.getEnvironmentFactory().
            getConfigEnvironment();
        ce.setUrl(fileUrl);
        ce.setReadOnly(readOnly);
        ce.setCachingEnabled(cache);
        ce.getConfigBeanInterceptor().setResolvingPaths(resolvePath);
        return ce;
    
public static synchronized voidremoveConfigContext(java.lang.String fileUrl)

            ConfigContextFactory.removeConfigContext(fileUrl);
        
public static voidremoveConfigContext(ConfigContext ctx)

                     
            ConfigContextFactory.removeConfigContext(ctx);
        
public static synchronized voidreplaceConfigContext(ConfigContext oldCtx, ConfigContext newCtx)
Replaces a cached context with a new context So, next time the Url is accessed, it returns the new context Note the subtlity of this method: This method gets the url of the old context and replaces the value for that key with the new object Hence, even though there might be a configContext with the same url but a different object, it is still replaced. This behavior is desirable since we would like to have the newCtx set anyway. However, if the url was not present, then ConfigException is thrown with that message. Note that: this class is not i18n complaint. If the old context cannot be found in cache, then throw ConfigException This method is synchronized so to make it thread safe.

param
oldCtx Old ConfigContext that was cached in this class. This cannot be null.
param
newCtx New ConfigContext that will be replaced in the cache. This cannot be null.
throws
ConfigException if url for old ctx is not found in cache

            ConfigContextFactory.replaceConfigContext(oldCtx, newCtx);