Methods Summary |
---|
private static void | addConfigContextToCache(java.lang.String url, ConfigContext ctx)
_ctxCache.put(url, ctx);
|
public ConfigContext | createConfigContext(java.lang.String url, java.lang.String rootClass)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.
TBD
ConfigEnvironment ce = getConfigEnvironment();
ce.setUrl(url);
ce.setRootClass(rootClass);
return createConfigContext(ce);
|
public static ConfigContext | createConfigContext(com.sun.enterprise.config.pluggable.ConfigEnvironment ce)
if(!ce.isCachingEnabled()) {
//log that a new one is created //FIXME
return newConfigContext(ce);
}
ConfigContext context = getConfigContextFromCache(ce.getUrl());
if(context == null) {
context = newConfigContext(ce);
addConfigContextToCache(ce.getUrl(), context);
//log that it was created. //FIXME
} else {
//log that it was found in cache //FIXME
}
return context;
|
public static boolean | enableLastModifiedCheck(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.
return ((ConfigContextImpl)ctx).enableLastModifiedCheck(value);
|
public static ConfigContext | getConfigContextFromCache(java.lang.String url)
return (ConfigContext) _ctxCache.get(url);
|
private static com.sun.enterprise.config.pluggable.ConfigEnvironment | getConfigEnvironment()
ConfigEnvironment ce = null;
try {
ce = EnvironmentFactory.
getEnvironmentFactory().
getConfigEnvironment();
} catch(Exception e) {
throw new ConfigRuntimeException
("err_getting_config_env",
"err_getting_config_env",
e); //FIXME
}
return ce;
|
private static void | invalidateConfigContext(java.lang.Object obj)
try {
if(obj != null)
((ConfigContextImpl)obj).cleanup(); //FIXME
} catch(Exception e) {
// ignore since it is just cleanup.
// multiple calls to remove should not fail.
}
|
private static ConfigContext | newConfigContext(com.sun.enterprise.config.pluggable.ConfigEnvironment ce)
return new ConfigContextImpl(ce);
|
public static void | removeConfigContext(ConfigContext ctx)
String url = ctx.getUrl();
removeConfigContext(url);
|
public static synchronized void | removeConfigContext(java.lang.String url)
Object obj = _ctxCache.remove(url);
invalidateConfigContext(obj);
|
public static synchronized void | replaceConfigContext(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.
assert (oldCtx != null);
assert (newCtx != null);
String url = oldCtx.getUrl();
if(_ctxCache.containsKey(url)) {
_ctxCache.put(url, newCtx);
} else {
throw new ConfigException
("Old ConfigContext is not found. Cannot replace with new one");
//FIxME
}
|