Methods Summary |
---|
void | close()
try {
if(in != null)
in.close();
if(systemIn != null)
systemIn.close();
} catch (Exception e) {
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, e.getMessage(), e);
throw new AddonFatalException (e);
}
|
private java.util.ArrayList | getNames(java.lang.String suffix)
ArrayList<String> list = new ArrayList();
String str;
for (Enumeration e = registry.propertyNames(); e.hasMoreElements() ;) {
str = (String) e.nextElement();
if (str.endsWith(suffix)) {
list.add(str.substring(0, (str.length() - suffix.length())));
}
}
return list;
|
protected AddonVersionImpl | getOldVersion(AddonVersionImpl newVersion)
String newNamePart = newVersion.getNamePart();
ArrayList<String> al = getNames(CONFIGUREKEY);
if ((al == null) || (al.size() < 1)) return null;
for (String str: al) {
if (str.startsWith(newNamePart)) {
return (new AddonVersionImpl(str));
}
}
return null;
|
com.sun.enterprise.addons.AddonRegistry$status | getStatus(java.lang.String name)Retrieve the current status of the addon.
If the addon does not exist in the registry, then
it should be configured.
If the addon status is changed to enabled/disabled
that is figured out by comparing with the system copy.
of the registry.
If the addon is marked for unconfiguring, the addon
status will be "unconfigure".
If the status is same in user copy and system copy
the status will be "unchanged"
String confFlag =
String.class.cast(registry.get(name+CONFIGUREKEY));
String systemConfFlag =
String.class.cast(systemRegistry.get(name+CONFIGUREKEY));
String enableFlag =
String.class.cast(registry.get(name+ENABLEKEY));
String systemEnableFlag =
String.class.cast(systemRegistry.get(name+ENABLEKEY));
if (isNull(confFlag,systemConfFlag) &&
isNull(enableFlag, systemEnableFlag)) {
return status.CONFIGURE;
}
if (isEqual(confFlag, systemConfFlag) == false) {
if (confFlag != null) {
if (confFlag.equalsIgnoreCase("false")) {
return status.UNCONFIGURE;
} else {
return status.CONFIGURE;
}
}
}
if (isEqual(enableFlag, systemEnableFlag) == false) {
if (enableFlag != null && enableFlag.equalsIgnoreCase("true")) {
return status.ENABLE;
} else {
return status.DISABLE;
}
}
return status.UNCHANGED;
|
public boolean | isConfigurationRequired(java.lang.String name)Utility method that returns, if the addon status
require configuration or not.
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER,
"Status for " + name + " is " + getStatus(name));
if (getStatus(name) == status.UNCHANGED) {
return false;
} else {
return true;
}
|
private boolean | isEqual(java.lang.String flag, java.lang.String systemFlag)
if (flag != null) {
return flag.equals(systemFlag);
} else {
return systemFlag == null;
}
|
public boolean | isInRegistry(java.lang.String name)Utility method that returns, if the addon status
require unconfiguration or not.
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER,
"Status for " + name + " is " + getStatus(name));
String confFlag =
String.class.cast(registry.get(name+CONFIGUREKEY));
String systemConfFlag =
String.class.cast(systemRegistry.get(name+CONFIGUREKEY));
if (isNull(confFlag,systemConfFlag)) {
return false;
}
return true;
|
private boolean | isNull(java.lang.String flag, java.lang.String systemFlag)
if (flag == null && systemFlag == null) {
return true;
} else {
return false;
}
|
public boolean | isUnConfigurationRequired(java.lang.String name)Utility method that returns, if the addon status
require unconfiguration or not.
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER,
"Status for " + name + " is " + getStatus(name));
String confFlag =
String.class.cast(registry.get(name+CONFIGUREKEY));
String systemConfFlag =
String.class.cast(systemRegistry.get(name+CONFIGUREKEY));
if (isNull(confFlag,systemConfFlag)) {
return false;
}
if (isEqual(confFlag, systemConfFlag) == false) {
if (confFlag != null) {
if (confFlag.equalsIgnoreCase("false")) {
return true;
} else {
return false;
}
}
} else {
if (confFlag != null) {
if (confFlag.equalsIgnoreCase("false")) {
return false;
} else {
return true;
}
}
}
return false;
|
private void | load(java.io.File domainRoot)
try {
this.registryFile =
new File(new File(domainRoot, "config"), REGISTRY);
this.systemRegistryFile =
new File(new File(domainRoot,"config"), SYSTEMREGISTRY);
if(!registryFile.exists()) {
registryFile.createNewFile();
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, "Created : " + registryFile);
}
if(!systemRegistryFile.exists()) {
systemRegistryFile.createNewFile();
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, "Created : " + systemRegistryFile);
}
systemIn = new FileInputStream(systemRegistryFile);
systemRegistry = new Properties();
systemRegistry.load(systemIn);
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, "Loaded Registry : " + SYSTEMREGISTRY);
in = new FileInputStream(registryFile);
registry = new Properties();
registry.load(in);
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, "Loaded Registry : " + REGISTRY);
} catch (Exception e) {
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, e.getMessage(), e);
throw new AddonFatalException(e);
}
|
void | setStatus(java.lang.String name, com.sun.enterprise.addons.AddonRegistry$status stat)Change the status. It will make the status the same in
user copy of the registry and system copy.
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER,
"Setting status of " + name + " as" + stat);
}
switch (stat) {
case ENABLE:
registry.setProperty(name+ENABLEKEY, "true");
systemRegistry.setProperty(name+ENABLEKEY, "true");
break;
case DISABLE:
registry.setProperty(name+ENABLEKEY, "false");
systemRegistry.setProperty(name+ENABLEKEY, "false");
break;
case CONFIGURE:
registry.setProperty(name+CONFIGUREKEY, "true");
systemRegistry.setProperty(name+CONFIGUREKEY, "true");
systemRegistry.setProperty
(name+INSTANCEKEY+CONFIGUREKEY, "true");
break;
case UNCONFIGURE:
registry.setProperty(name+CONFIGUREKEY, "false");
systemRegistry.setProperty(name+CONFIGUREKEY, "false");
systemRegistry.setProperty
(name+INSTANCEKEY+CONFIGUREKEY, "false");
break;
case REMOVE:
registry.remove(name+CONFIGUREKEY);
registry.remove(name+ENABLEKEY);
systemRegistry.remove(name+CONFIGUREKEY);
systemRegistry.remove(name+ENABLEKEY);
systemRegistry.remove(name+INSTANCEKEY+CONFIGUREKEY);
break;
default :
}
|
void | store()Write the properties to the file.
try {
out = new FileOutputStream(registryFile);
registry.store(out, null);
out.close();
systemOut = new FileOutputStream(systemRegistryFile);
systemRegistry.store(systemOut, null);
systemOut.close();
} catch (Exception e) {
if (logger.isLoggable(Level.FINER))
logger.log(Level.FINER, e.getMessage(), e);
throw new AddonFatalException(e);
}
|