org.webmacro.servlet
Class Servlet22Broker

java.lang.Object
  extended byorg.webmacro.Broker
      extended byorg.webmacro.servlet.ServletBroker
          extended byorg.webmacro.servlet.Servlet22Broker

public class Servlet22Broker
extends ServletBroker

An implementation of Broker tailored for Servlet 2.2 environments. Loads templates and other resources from the servlet context (WAR file), writes log messages to the servlet log, and loads properties from the WAR file context parameters.

Since:
0.96
Author:
Brian Goetz

Field Summary
protected  java.lang.ClassLoader _servletClassLoader
           
protected  java.lang.String _templatePrefix
           
 
Fields inherited from class org.webmacro.servlet.ServletBroker
_servletContext
 
Fields inherited from class org.webmacro.Broker
_config, _log, _ls, _myClassLoader, _name, _prof, _propertyOperators, _providers, _systemClassLoader, BROKERS, SETTINGS_PREFIX, WEBMACRO_DEFAULTS, WEBMACRO_PROPERTIES
 
Constructor Summary
protected Servlet22Broker(javax.servlet.ServletContext sc, java.lang.ClassLoader cl)
          Creates the broker looking in WEB-INF first for WebMacro.properties before looking in the application root.
 
Method Summary
 java.lang.Class classForName(java.lang.String name)
          Loads a class by name.
static Broker getBroker(javax.servlet.Servlet s)
           
 java.net.URL getResource(java.lang.String name)
          Get a resource (file) from the the Broker's class loader
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Get a resource (file) from the Broker's class loader
 java.net.URL getTemplate(java.lang.String name)
          Get a template; kind of like getting a resource, but might come from a different place
protected  void init()
          Constructors should call this after they've set up the properties to set up common things like profiling, providers, etc.
protected  void loadServletSettings(java.lang.String prefix)
           
 
Methods inherited from class org.webmacro.servlet.ServletBroker
getServletContext, initLog
 
Methods inherited from class org.webmacro.Broker
addProvider, findBroker, get, getBooleanSetting, getBroker, getBroker, getBrokerLocal, getClassLoader, getEvaluationExceptionHandler, getFastWriter, getFunction, getIntegerSetting, getIntegerSetting, getLog, getLog, getName, getProvider, getSetting, getSettings, getValue, initLog, loadDefaultSettings, loadSettings, loadSystemSettings, main, newProfile, putFunction, register, setBrokerLocal, setEvaluationExceptionHandler, shutdown, startClient, stopClient, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_servletClassLoader

protected final java.lang.ClassLoader _servletClassLoader

_templatePrefix

protected java.lang.String _templatePrefix
Constructor Detail

Servlet22Broker

protected Servlet22Broker(javax.servlet.ServletContext sc,
                          java.lang.ClassLoader cl)
                   throws InitException
Creates the broker looking in WEB-INF first for WebMacro.properties before looking in the application root.

Method Detail

loadServletSettings

protected void loadServletSettings(java.lang.String prefix)
                            throws InitException
Throws:
InitException

init

protected void init()
             throws InitException
Description copied from class: Broker
Constructors should call this after they've set up the properties to set up common things like profiling, providers, etc.

Overrides:
init in class Broker
Throws:
InitException

getBroker

public static Broker getBroker(javax.servlet.Servlet s)
                        throws InitException
Throws:
InitException

getResource

public java.net.URL getResource(java.lang.String name)
Get a resource (file) from the the Broker's class loader

Overrides:
getResource in class Broker

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Get a resource (file) from the Broker's class loader

Overrides:
getResourceAsStream in class Broker

getTemplate

public java.net.URL getTemplate(java.lang.String name)
Get a template; kind of like getting a resource, but might come from a different place

Overrides:
getTemplate in class Broker

classForName

public java.lang.Class classForName(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Loads a class by name. Uses the servlet classloader to load the class. If the class is not found uses the Broker classForName implementation.

Overrides:
classForName in class Broker
Throws:
java.lang.ClassNotFoundException