Methods Summary |
---|
public static java.lang.String | getProperty(java.lang.String key)Get a property, but substitute $DIR with JABADOT_DIR
if (ctx==null)
throw new IllegalStateException(
"JDConstants.getProperty: not initialized!");
return lookup(key);
|
public void | init()This init servlet method loads the Properties. We know we'll
get called once at the beginning of time, since we're set up
that way in web.xml (as a pre-loaded servlet).
ctx = getServletConfig().getServletContext();
// Get the JABADOT_DIR before all else!
// Be careful of the difference between
// ServletContext.getInitParameter and Servlet.getInitParameter!
// Be sure the installer puts in in jabadot/WEB-INF/web.xml,
// NOT in tomcat/conf/web.xml - it will be ignored there!!
JABADOT_DIR = ctx.getInitParameter("jabadot.dir");
if (JABADOT_DIR == null) {
System.out.println(
"+------------- ERROR --------------------");
System.out.println(
"jabadot.dir not set as a context parameter.");
System.out.println(
"Please RTFM and try again"); // Time to WTFM!
System.out.println(
"+----------------------------------------");
} else {
System.out.println("JABADOT_DIR " + JABADOT_DIR);
}
|
private static java.lang.String | lookup(java.lang.String key)
String val = ctx.getInitParameter(key);
if (val == null)
return null;
String nval = replace("$DIR", JABADOT_DIR, val);
return nval;
|
public static java.lang.String | replace(java.lang.String oldStr, java.lang.String newStr, java.lang.String inString)Replace one string in another
int start = inString.indexOf(oldStr);
if (start == -1) {
return inString;
}
StringBuffer sb = new StringBuffer();
sb.append(inString.substring(0, start));
sb.append(newStr);
sb.append(inString.substring(start+oldStr.length()));
return sb.toString();
|