Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.directwebremoting.impl
Class ContainerUtil

    java.lang.Object
      org.directwebremoting.impl.ContainerUtil

    public class ContainerUtil

extends java.lang.Object

An abstraction of all the common servlet operations that are required to host a DWR service that depends on the servlet spec. It would be good to have a base class for all servlet operations, however lack of MI prevents us from doing this.

Author:
  Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
`static java.lang.String` | `ATTRIBUTE_CONTAINER_LIST` The name under which we publish all `Container`s.
`static java.lang.String` | `INIT_CONFIG` Init parameter: Set a dwr.xml config file.
`static java.lang.String` | `INIT_CUSTOM_CONFIGURATOR` Init parameter: If you wish to use a custom configurator, place its class name here
`static java.lang.String` | `INIT_LOGLEVEL` Init parameter: If we are doing Servlet.log logging, to what level?
`static java.lang.String` | `INIT_PUBLISH_CONTAINER` Init parameter: Should we publish the `Container` to the servlet context, and if so, under what name?
`static java.lang.String` | `INIT_SKIP_DEFAULT` Init parameter: Skip reading the default config file if none are specified.

Constructor Summary
`ContainerUtil()`

Method Summary
`static void` | `configure(Container container, java.util.List configurators)` Allow all the configurators to have a go at the container in turn
`static void` | `configureContainerFully(Container container, javax.servlet.ServletConfig servletConfig)` Run all the default configuration options on a Container
`static boolean` | `configureFromAnnotations(Container container)` Annotations must not break 1.3, so we use reflection to create an `org.directwebremoting.annotations.AnnotationsConfigurator` and the catch all sorts of random exceptions for the benefit of Websphere.
`static void` | `configureFromDefaultDwrXml(Container container)` Configure using the users dwr.xml that sits next in WEB-INF
`static boolean` | `configureFromInitParams(Container container, javax.servlet.ServletConfig servletConfig)` Add configurators from init params to the end of the list of configurators.
`static void` | `configureFromSystemDwrXml(Container container)` Configure using the system dwr.xml from within the JAR file.
`static DefaultContainer` | `createDefaultContainer(javax.servlet.ServletConfig servletConfig)` Create a `DefaultContainer`, allowing users to upgrade to a child of DefaultContainer using an `ServletConfig` init parameter of `org.directwebremoting.Container`.
`static void` | `createUrlMapping(DefaultContainer container, java.lang.String url, java.lang.String propertyName, java.lang.Class handler)` Creates entries in the `Container` so 2 lookups are possible.
`static void` | `debugConfig(Container container)` Create a bunch of debug information about a container
`static java.util.List` | `getAllPublishedContainers(javax.servlet.ServletContext servletContext)` Get a list of all known Containers for the given `ServletContext`
`static void` | `prepareForWebContextFilter(javax.servlet.ServletContext context, javax.servlet.ServletConfig config, Container container, WebContextFactory.WebContextBuilder webContextBuilder, javax.servlet.http.HttpServlet servlet)` Make some changes to the ServletContext so `DwrWebContextFilter` can find the Container etc.
`static void` | `publishContainer(Container container, javax.servlet.ServletConfig servletConfig)` If helps some situations if people can get at the container by looking in the servlet context, under some name.
`static void` | `setupDefaultContainer(DefaultContainer container, javax.servlet.ServletConfig servletConfig)` Setup a `DefaultContainer`.
`static void` | `setupDefaults(DefaultContainer container, javax.servlet.ServletConfig servletConfig)` Take a DefaultContainer and setup the default beans
`static void` | `setupFromServletConfig(DefaultContainer container, javax.servlet.ServletConfig servletConfig)` Take a DefaultContainer and setup the default beans
`static void` | `shutdownServerLoadMonitorsInContainerList(java.util.List containers, java.lang.String title)` Internal use only.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INIT_CONFIG

    public static final java.lang.String INIT_CONFIG

  Init parameter: Set a dwr.xml config file. This is only a prefix since we might have more than 1 config file.

  See Also:
    Constant Field Values

### INIT_SKIP_DEFAULT

    public static final java.lang.String INIT_SKIP_DEFAULT

  Init parameter: Skip reading the default config file if none are specified.

  See Also:
    Constant Field Values

### INIT_LOGLEVEL

    public static final java.lang.String INIT_LOGLEVEL

  Init parameter: If we are doing Servlet.log logging, to what level?

  See Also:
    Constant Field Values

### INIT_PUBLISH_CONTAINER

    public static final java.lang.String INIT_PUBLISH_CONTAINER

  Init parameter: Should we publish the `Container` to the servlet context, and if so, under what name?

  See Also:
    Constant Field Values

### INIT_CUSTOM_CONFIGURATOR

    public static final java.lang.String INIT_CUSTOM_CONFIGURATOR

  Init parameter: If you wish to use a custom configurator, place its class name here

  See Also:
    Constant Field Values

### ATTRIBUTE_CONTAINER_LIST

    public static final java.lang.String ATTRIBUTE_CONTAINER_LIST

  The name under which we publish all `Container`s.

  See Also:
    Constant Field Values

Constructor Detail

### ContainerUtil

    public ContainerUtil()

Method Detail

### createDefaultContainer

    public static DefaultContainer createDefaultContainer(javax.servlet.ServletConfig servletConfig)
                                                   throws javax.servlet.ServletException

  Create a `DefaultContainer`, allowing users to upgrade to a child of DefaultContainer using an `ServletConfig` init parameter of `org.directwebremoting.Container`. Note that while the parameter name is the classname of `Container`, currently the only this can only be used to create children that inherit from `DefaultContainer`. This restriction may be relaxed in the future. Unlike `setupDefaultContainer(DefaultContainer, ServletConfig)`, this method does not call any setup methods.

  Parameters:
    `servletConfig` - The source of init parameters
  Returns:
    An unsetup implementaion of DefaultContainer
  Throws:
    `javax.servlet.ServletException` - If the specified class could not be found
  See Also:
    `ServletConfig.getInitParameter(String)`

### setupDefaultContainer

    public static void setupDefaultContainer(DefaultContainer container,
                                             javax.servlet.ServletConfig servletConfig)
                                      throws java.lang.InstantiationException,
                                             java.lang.IllegalAccessException

  Setup a `DefaultContainer`. Using `createDefaultContainer(ServletConfig)` followed by `setupFromServletConfig(DefaultContainer, ServletConfig)` before calling `DefaultContainer.setupFinished()`.

  Parameters:
    `container` - The container to configure
    `servletConfig` - The source of init parameters
  Throws:
    `java.lang.InstantiationException` - If we can't instantiate a bean
    `java.lang.IllegalAccessException` - If we have access problems creating a bean

### setupDefaults

    public static void setupDefaults(DefaultContainer container,
                                     javax.servlet.ServletConfig servletConfig)
                              throws java.lang.InstantiationException,
                                     java.lang.IllegalAccessException

  Take a DefaultContainer and setup the default beans

  Parameters:
    `container` - The container to configure
    `servletConfig` - The source of init parameters
  Throws:
    `java.lang.InstantiationException` - If we can't instantiate a bean
    `java.lang.IllegalAccessException` - If we have access problems creating a bean

### createUrlMapping

    public static void createUrlMapping(DefaultContainer container,
                                        java.lang.String url,
                                        java.lang.String propertyName,
                                        java.lang.Class handler)
                                 throws java.lang.InstantiationException,
                                        java.lang.IllegalAccessException

  Creates entries in the `Container` so 2 lookups are possible.
  - You can find a `Handler` for a URL. Used by `UrlProcessor`
  - You can inject (or lookup) the URL assigned to a `Handler`

  Parameters:
    `container` - The container to create the entries in
    `url` - The URL of the new `Handler`
    `propertyName` - The property name (for injection and lookup)
    `handler` - The class of Handler
  Throws:
    `java.lang.InstantiationException` - From `DefaultContainer.addParameter(Object, Object)`
    `java.lang.IllegalAccessException` - From `DefaultContainer.addParameter(Object, Object)`

### setupFromServletConfig

    public static void setupFromServletConfig(DefaultContainer container,
                                              javax.servlet.ServletConfig servletConfig)
                                       throws java.lang.InstantiationException,
                                              java.lang.IllegalAccessException

  Take a DefaultContainer and setup the default beans

  Parameters:
    `container` - The container to configure
    `servletConfig` - The servlet configuration (null to ignore)
  Throws:
    `java.lang.InstantiationException` - If we can't instantiate a bean
    `java.lang.IllegalAccessException` - If we have access problems creating a bean

### prepareForWebContextFilter

    public static void prepareForWebContextFilter(javax.servlet.ServletContext context,
                                                  javax.servlet.ServletConfig config,
                                                  Container container,
                                                  WebContextFactory.WebContextBuilder webContextBuilder,
                                                  javax.servlet.http.HttpServlet servlet)

  Make some changes to the ServletContext so `DwrWebContextFilter` can find the Container etc.

  Parameters:
    `context` - The servlet context
    `config` - The servlet configuration
    `container` - The container to save in the ServletContext
    `webContextBuilder` - The WebContextBuilder to save
    `servlet` - The Servlet to save

### configureFromSystemDwrXml

    public static void configureFromSystemDwrXml(Container container)
                                          throws java.io.IOException,
                                                 javax.xml.parsers.ParserConfigurationException,
                                                 org.xml.sax.SAXException

  Configure using the system dwr.xml from within the JAR file.

  Parameters:
    `container` - The container to configure
  Throws:
    `javax.xml.parsers.ParserConfigurationException` - If the config file parse fails
    `java.io.IOException` - If the config file read fails
    `org.xml.sax.SAXException` - If the config file parse fails

### configureFromDefaultDwrXml

    public static void configureFromDefaultDwrXml(Container container)
                                           throws java.io.IOException,
                                                  javax.xml.parsers.ParserConfigurationException,
                                                  org.xml.sax.SAXException

  Configure using the users dwr.xml that sits next in WEB-INF

  Parameters:
    `container` - The container to configure
  Throws:
    `javax.xml.parsers.ParserConfigurationException` - If the config file parse fails
    `java.io.IOException` - If the config file read fails
    `org.xml.sax.SAXException` - If the config file parse fails

### configureFromInitParams

    public static boolean configureFromInitParams(Container container,
                                                  javax.servlet.ServletConfig servletConfig)
                                           throws java.io.IOException,
                                                  javax.xml.parsers.ParserConfigurationException,
                                                  org.xml.sax.SAXException

  Add configurators from init params to the end of the list of configurators.

  Parameters:
    `container` - The container to configure
    `servletConfig` - The source of init parameters
  Returns:
    true if any Configurators were read
  Throws:
    `org.xml.sax.SAXException` - If the config file parse fails
    `javax.xml.parsers.ParserConfigurationException` - If the config file parse fails
    `java.io.IOException` - If the config file read fails

### configureFromAnnotations

    public static boolean configureFromAnnotations(Container container)

  Annotations must not break 1.3, so we use reflection to create an `org.directwebremoting.annotations.AnnotationsConfigurator` and the catch all sorts of random exceptions for the benefit of Websphere.

  Parameters:
    `container` - The container to configure
  Returns:
    true if the configuration worked.

### configure

    public static void configure(Container container,
                                 java.util.List configurators)

  Allow all the configurators to have a go at the container in turn

  Parameters:
    `container` - The container to configure
    `configurators` - A list of configurators to run against the container

### configureContainerFully

    public static void configureContainerFully(Container container,
                                               javax.servlet.ServletConfig servletConfig)
                                        throws java.io.IOException,
                                               javax.xml.parsers.ParserConfigurationException,
                                               org.xml.sax.SAXException

  Run all the default configuration options on a Container

  Parameters:
    `container` - The container to configure
    `servletConfig` - The source of init parameters
  Throws:
    `org.xml.sax.SAXException` - If the config file parse fails
    `javax.xml.parsers.ParserConfigurationException` - If the config file parse fails
    `java.io.IOException` - If the config file read fails

### publishContainer

    public static void publishContainer(Container container,
                                        javax.servlet.ServletConfig servletConfig)

  If helps some situations if people can get at the container by looking in the servlet context, under some name. The name is specified in an initParameter.

  Parameters:
    `container` - The container to publish
    `servletConfig` - Source of initParams to dictate publishing and contexts to publish to

### getAllPublishedContainers

    public static java.util.List getAllPublishedContainers(javax.servlet.ServletContext servletContext)

  Get a list of all known Containers for the given `ServletContext`

  Parameters:
    `servletContext` - The context in which `Container`s are stored.
  Returns:
    a list of published `Container`s.

### shutdownServerLoadMonitorsInContainerList

    public static void shutdownServerLoadMonitorsInContainerList(java.util.List containers,
                                                                 java.lang.String title)

  Internal use only.

  If we detect that the server is being shutdown then we want to kill any reverse ajax threads.

  Parameters:
    `containers` - The list of containers to look for ServerLoadMonitors in
    `title` - What causes this (for debug purposes)

### debugConfig

    public static void debugConfig(Container container)

  Create a bunch of debug information about a container

  Parameters:
    `container` - The container to print debug information about

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¬ 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD