* Use new ResourceProperties.getSubProperties(String prefix) feature to

get application config props.
This commit is contained in:
hns 2006-01-27 15:43:23 +00:00
parent 729a7fa888
commit f2441616e1

View file

@ -298,48 +298,46 @@ public class ApplicationManager implements XmlRpcHandler {
* Creates an AppDescriptor from the properties. * Creates an AppDescriptor from the properties.
*/ */
AppDescriptor(String name) { AppDescriptor(String name) {
ResourceProperties conf = props.getSubProperties(name + '.');
appName = name; appName = name;
mountpoint = getMountpoint(props.getProperty(name + ".mountpoint", mountpoint = getMountpoint(conf.getProperty("mountpoint", appName));
appName));
pathPattern = getPathPattern(mountpoint); pathPattern = getPathPattern(mountpoint);
staticDir = props.getProperty(name + ".static"); staticDir = conf.getProperty("static");
staticMountpoint = getPathPattern(props.getProperty(name + ".staticMountpoint", staticMountpoint = getPathPattern(conf.getProperty("staticMountpoint",
joinMountpoint(mountpoint, "static"))); joinMountpoint(mountpoint, "static")));
staticIndex = "true".equalsIgnoreCase(props.getProperty(name+ staticIndex = "true".equalsIgnoreCase(conf.getProperty("staticIndex"));
".staticIndex")); String home = conf.getProperty("staticHome");
String home = props.getProperty(name + ".staticHome");
if (home == null) { if (home == null) {
staticHome = new String[] {"index.html", "index.htm"}; staticHome = new String[] {"index.html", "index.htm"};
} else { } else {
staticHome = StringUtils.split(home, ","); staticHome = StringUtils.split(home, ",");
} }
protectedStaticDir = props.getProperty(name + ".protectedStatic"); protectedStaticDir = conf.getProperty("protectedStatic");
cookieDomain = props.getProperty(name + ".cookieDomain"); cookieDomain = conf.getProperty("cookieDomain");
sessionCookieName = props.getProperty(name + ".sessionCookieName"); sessionCookieName = conf.getProperty("sessionCookieName");
protectedSessionCookie = props.getProperty(name + ".protectedSessionCookie"); protectedSessionCookie = conf.getProperty("protectedSessionCookie");
uploadLimit = props.getProperty(name + ".uploadLimit"); uploadLimit = conf.getProperty("uploadLimit");
uploadSoftfail = props.getProperty(name + ".uploadSoftfail"); uploadSoftfail = conf.getProperty("uploadSoftfail");
debug = props.getProperty(name + ".debug"); debug = conf.getProperty("debug");
encode = "true".equalsIgnoreCase(props.getProperty(name + encode = "true".equalsIgnoreCase(conf.getProperty("responseEncoding"));
".responseEncoding")); String appDirName = conf.getProperty("appdir");
String appDirName = props.getProperty(name + ".appdir");
appDir = (appDirName == null) ? null : new File(appDirName); appDir = (appDirName == null) ? null : new File(appDirName);
String dbDirName = props.getProperty(name + ".dbdir"); String dbDirName = conf.getProperty("dbdir");
dbDir = (dbDirName == null) ? null : new File(dbDirName); dbDir = (dbDirName == null) ? null : new File(dbDirName);
// got ignore dirs // got ignore dirs
ignoreDirs = props.getProperty(name + ".ignore"); ignoreDirs = conf.getProperty("ignore");
// read and configure app repositories // read and configure app repositories
ArrayList repositoryList = new ArrayList(); ArrayList repositoryList = new ArrayList();
Class[] parameters = { String.class }; Class[] parameters = { String.class };
for (int i = 0; true; i++) { for (int i = 0; true; i++) {
String repositoryArgs = props.getProperty(name + ".repository." + i); String repositoryArgs = conf.getProperty("repository." + i);
if (repositoryArgs != null) { if (repositoryArgs != null) {
// lookup repository implementation // lookup repository implementation
String repositoryImpl = props.getProperty(name + ".repository." + i + String repositoryImpl = conf.getProperty("repository." + i +
".implementation"); ".implementation");
if (repositoryImpl == null) { if (repositoryImpl == null) {
// implementation not set manually, have to guess it // implementation not set manually, have to guess it
@ -350,9 +348,8 @@ public class ApplicationManager implements XmlRpcHandler {
} }
} }
Repository newRepository = null;
try { try {
newRepository = (Repository) Class.forName(repositoryImpl) Repository newRepository = (Repository) Class.forName(repositoryImpl)
.getConstructor(parameters) .getConstructor(parameters)
.newInstance(new Object[] { repositoryArgs }); .newInstance(new Object[] { repositoryArgs });
repositoryList.add(newRepository); repositoryList.add(newRepository);