Prev | Current Page 412 | Next

Frank Zammetti

"Practical DWR 2 Projects"

Its work
is done in the contextInitialized() method, beginning with the task of loading the properties
file. Recall that the file is in the WEB-INF/classes directory, which means it??™s available on
the classpath for the application, so it??™s a simple matter to use the getResourceAsStream()
method of the Classloader of the DWikiContextListener instance to get a stream on the properties
file and use the Java standard Properties class to read it in.
Listing 5-18. The Code of the DWikiContextListener Class
package com.apress.dwrprojects.dwiki;
import java.io.InputStream;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Properties;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DWikiContextListener implements ServletContextListener {
private static Log log = LogFactory.getLog(DWikiContextListener.class);
public void contextInitialized (
final ServletContextEvent inServletContextEvent) {
log.trace("DWikiContextListener.contextInitialized() - Entry");
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(
"dwiki.


Pages:
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424