View Javadoc

1   /*
2    * 
3    * $Revision: 1.4 $
4    * $Date: 2004/07/09 18:03:10 $
5    *
6    * ====================================================================
7    * struts-it
8    * Copyright (C) 2004 - strutsit community
9    * 
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   * 
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   * 
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   *
22   * created: 2004-06-05  Manfred Wolff
23   */
24  package org.strutsit.chain.interfaces;
25  
26  import org.apache.commons.chain.Context;
27  import org.strutsit.chain.ChainException;
28  
29  /***
30   * Interface for a chain-facade.
31   * <p>
32   * This interface provides all methods that are need to configure a chain and
33   * get access to it. It is possible to configure the chain framework with
34   * several methods (configurations).
35   * </p>
36   * <ul>
37   * <li>With a xml file (supported by the commons-chain framework)</li>
38   * <li>With a property file.</li>
39   * <li>With a java class implementation.</li>
40   * </ul>
41   * <p>
42   * The way to configure it is described in the chain.properties file. If no file
43   * is found the standard behavior is choosed.
44   * <p>
45   * 
46   * <pre>
47   * 
48   * chain.properties
49   *   
50   * # Configuration mode: Maybe xml|prop|class
51   * chain.configuration=xml
52   * # Full qualified java class of the XML-Configuration
53   * chain.configuration.xml=org.strutsit.chain.configuration.ChainXMLConfiguration
54   * # Full qualified java class of the Chain-implementation. If no Dependencycheck
55   * # is need also the original class maybe used org.apache.commons.chain.impl.ChainBase
56   * chain.baseclass=org.strutsit.chain.configuration.ChainConfBase;
57   *
58   * # Name of the configuration item default is:
59   * # xml   : /org/struts-it/chain/config/chain-config.xml
60   * # prop  : /org/struts-it/chain/config/chain-config.properties
61   * # class : org.strutsit.chain.config.Configure.class
62   * configuration.name=/chain-config.xml
63   *  
64   * </pre>
65   * 
66   * @author <a href="mailto:wolff@struts-it.de">Manfred Wolff </a>
67   * @since JDK 1.4
68   * @version $Revision: 1.4 $
69   */
70  public interface ChainFacade {
71  
72      /***
73       * Inits the framework. The method has the following responsibilities:
74       * <ul>
75       * <li>Reading the configuration and preparing the ChainConfiguration.
76       * </li>
77       * <li>Checking the dependencies of the chains and commands.</li>
78       * </ul>
79       * 
80       * @throws ChainException if something fails
81       */
82      void initFacade() throws ChainException;
83  
84      /***
85       * Frees all Resources.
86       */
87      void destroy();
88  
89      /***
90       * Executes a chain or a single command by name.
91       * 
92       * @param commandString The name of the command or chain.
93       * @param context The Context for executing
94       * @return True if the command can fulfill the operation, otherwise false
95       * @throws ChainException if something goes wrong
96       */
97      boolean execute(String commandString, Context context)
98              throws ChainException;
99  }
100