org.webmacro.servlet
Class Servlet20Broker

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

public class Servlet20Broker
extends ServletBroker

An implementation of Broker tailored for Servlet 2.0/2.1 environments.

Loads templates and other resources from:

  1. the class path,

    writes log messages to the servlet log.

    Since:
    0.96
    Author:
    Brian Goetz, Marc Palmer (wj5@wangjammers.org)

    Nested Class Summary
     
    Nested classes inherited from class org.webmacro.servlet.ServletBroker
    ServletBroker.PropertiesPair
     
    Field Summary
    protected  java.lang.ClassLoader _servletClassLoader
               
     
    Fields inherited from class org.webmacro.servlet.ServletBroker
    _servletContext
     
    Fields inherited from class org.webmacro.Broker
    _config, _log, _ls, _myClassLoader, _name, _propertyOperators, _providers, _systemClassLoader, BROKERS, SETTINGS_PREFIX, WEBMACRO_DEFAULTS, WEBMACRO_PROPERTIES
     
    Constructor Summary
    protected Servlet20Broker(javax.servlet.ServletContext sc, java.lang.ClassLoader cl, java.util.Properties additionalProperties)
               
     
    Method Summary
    protected static Broker _getBroker(javax.servlet.ServletContext sc, java.lang.ClassLoader cl, java.util.Properties additionalProperties, boolean fromServlet, java.lang.String servletOrContextName)
              Get an existing instance of the Servlet 2.0/2.1 broker or create a new one.
     java.lang.Class classForName(java.lang.String name)
              Loads a class by name.
    static Broker getBroker(javax.servlet.ServletContext sc, java.lang.ClassLoader cl, java.util.Properties additionalProperties)
              Get a Servlet API 2.0 compatible broker for the ServletContext specified
    static Broker getBroker(javax.servlet.Servlet s, java.util.Properties additionalProperties)
              Get a Servlet API 2.0 compatible broker for the Servlet specified
     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
     
    Methods inherited from class org.webmacro.servlet.ServletBroker
    getBroker, getServletContext, initLog
     
    Methods inherited from class org.webmacro.Broker
    addProvider, destroy, findBroker, get, getAutoContextVariable, getBooleanSetting, getBroker, getBroker, getBroker, getBrokerLocal, getBrokerLog, getClassLoader, getEvaluationExceptionHandler, getFastWriter, getFunction, getIntegerSetting, getIntegerSetting, getLog, getLog, getMacros, getName, getProvider, getProviderTypes, getSetting, getSettings, getTemplate, getValue, init, initLog, loadDefaultSettings, loadSettings, loadSettings, loadSystemSettings, main, putFunction, putFunction, register, registerAutoContextVariable, setBrokerLocal, setEvaluationExceptionHandler, toString
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    _servletClassLoader

    protected java.lang.ClassLoader _servletClassLoader
    Constructor Detail

    Servlet20Broker

    protected Servlet20Broker(javax.servlet.ServletContext sc,
                              java.lang.ClassLoader cl,
                              java.util.Properties additionalProperties)
                       throws InitException
    Method Detail

    getBroker

    public static Broker getBroker(javax.servlet.Servlet s,
                                   java.util.Properties additionalProperties)
                            throws InitException
    Get a Servlet API 2.0 compatible broker for the Servlet specified

    Parameters:
    s - The servlet
    additionalProperties -
    Returns:
    The broker for the servlet context.
    Throws:
    InitException

    getBroker

    public static Broker getBroker(javax.servlet.ServletContext sc,
                                   java.lang.ClassLoader cl,
                                   java.util.Properties additionalProperties)
                            throws InitException
    Get a Servlet API 2.0 compatible broker for the ServletContext specified

    Parameters:
    sc - The Servlet context
    cl - A ClassLoader to use, presumably the webapp classloader
    additionalProperties -
    Returns:
    The broker for the servlet context
    Throws:
    InitException
    Since:
    2.1 JSDK

    _getBroker

    protected static Broker _getBroker(javax.servlet.ServletContext sc,
                                       java.lang.ClassLoader cl,
                                       java.util.Properties additionalProperties,
                                       boolean fromServlet,
                                       java.lang.String servletOrContextName)
                                throws InitException
    Get an existing instance of the Servlet 2.0/2.1 broker or create a new one. Templates will be retrieved relative to the ServletContext root and classes loaded from the ClassLoader passed in. NOTE: Templates will not be loaded from the classpath.

    Parameters:
    sc - The ServletContext to template access
    cl - The ClassLoader for class loading, typically servlet or JSP page's class loader
    additionalProperties -
    fromServlet - true if it is actually an initialization derived from a Servlet instance passed in - just for nicer logging output
    servletOrContextName - Name of the servlet or context originating this broker, for nicer logging
    Returns:
    The broker for the servlet context
    Throws:
    InitException
    Since:
    2.1 JSDK

    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

    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


    Copyright © 1999-2006 WebMacro. All Rights Reserved.