View Javadoc

    1   /*
    2    * $Id: DefinitionsFactory.java 471754 2006-11-06 14:55:09Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21
    22
    23  package org.apache.struts.tiles;
    24
    25  import java.io.Serializable;
    26
    27  import javax.servlet.ServletContext;
    28  import javax.servlet.ServletRequest;
    29
    30  /**
    31   * Tiles Definition factory.
    32   * This interface replace old ComponentDefinitionsFactory.
    33   * Main method getDefinition() is exactly the same. Initialization method change.
    34   * This interface allows to retrieve a definition by its name, independently of
    35   * the factory implementation.
    36   * Object life cycle is as follow:
    37   * <ul>
    38   * <li>Constructor: create object</li>
    39   * <li>setConfig: set config and initialize factory. After first call to this
    40   * method, factory is operational.</li>
    41   * <li>destroy: factory is being shutdown.</li>
    42   * </ul>
    43   * Implementation must be Serializable, in order to be compliant with web Container
    44   * having this constraint (Weblogic 6.x).
    45   */
    46  public interface DefinitionsFactory extends Serializable
    47  {
    48
    49     /**
    50       * Get a definition by its name.
    51       * @param name Name of requested definition.
    52       * @param request Current servelet request
    53       * @param servletContext current servlet context
    54       * @throws DefinitionsFactoryException An error occur while getting definition.
    55       * @throws NoSuchDefinitionException No definition found for specified name
    56       * Implementation can throw more accurate exception as a subclass of this exception
    57     */
    58     public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext)
    59       throws NoSuchDefinitionException,DefinitionsFactoryException;
    60
    61     /**
    62      * Init definition factory.
    63      * This method is called immediately after factory creation, and prior any call
    64      * to setConfig().
    65      *
    66      * @param config Configuration object used to set factory configuration.
    67      * @param servletContext Servlet Context passed to factory.
    68      * @throws DefinitionsFactoryException An error occur during initialization.
    69      */
    70     public void init(DefinitionsFactoryConfig config, ServletContext servletContext)
    71       throws DefinitionsFactoryException;
    72
    73      /**
    74       * <p>Receive notification that the factory is being
    75       * shut down.</p>
    76       */
    77      public void destroy();
    78
    79     /**
    80      * Set factory configuration.
    81      * This method is used to change factory configuration.
    82      * This method is optional, and can send an exception if implementation
    83      * doesn't allow change in configuration.
    84      *
    85      * @param config Configuration object used to set factory configuration.
    86      * @param servletContext Servlet Context passed to factory.
    87      * @throws DefinitionsFactoryException An error occur during initialization.
    88      */
    89     public void setConfig(DefinitionsFactoryConfig config, ServletContext servletContext)
    90       throws DefinitionsFactoryException;
    91
    92     /**
    93      * Get factory configuration.
    94      * @return TilesConfig
    95      */
    96     public DefinitionsFactoryConfig getConfig();
    97
    98
    99  }