Methods Summary |
---|
public java.lang.Object | createContext(ApplicationRequest request, ApplicationResponse response)
return new ToolContext(request, response, this);
|
public void | destroy()
|
public java.lang.Class | getContextType()
return ToolContext.class;
|
public Tool[] | getTools()
// Normally the "application" would maintain or have access to a
// pre-existing database connection. Here, for simplicity, we use XML.
return tools;
|
public Tool[] | getTools(java.lang.String state)
// Return only tools of a given state
// (submitted, live, rejected, or dead)
List list = new LinkedList();
for (int i = 0; i < tools.length; i++) {
if (tools[i].getStateFlag().equalsIgnoreCase(state)) {
list.add(tools[i]);
}
}
return (Tool[]) list.toArray(new Tool[0]);
|
public void | init(ApplicationConfig config)
// Keep a log of events specific to this application
log = config.getLog();
// Load the tool data in our init for simplicity
String toolsFile = config.getInitParameter("toolsFile");
if (toolsFile == null) {
throw new ServletException(
"A tools data file must be specified as the toolsFile init parameter");
}
log.debug("Loading tools from " + toolsFile);
try {
tools = Tool.loadTools(toolsFile);
if (tools.length == 0) {
log.warn("No tools found in " + toolsFile);
}
}
catch (Exception e) {
log.error(e);
throw new ServletException(e);
}
|