View Javadoc
1   /*
2    * 
3    * $Revision: 1.2 $
4    * $Date: 2004/07/09 18:02:28 $
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-20  Manfred Wolff
23   */
24  package org.strutsit.chain;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  import java.util.StringTokenizer;
29  
30  import org.apache.commons.chain.Command;
31  
32  /***
33   * Base implementation of a {@link Command}that is used in the conf-chain
34   * framework. This command reads some attributes, that can configured in the
35   * chain-conf.xml:
36   * 
37   * <ul>
38   * <li>idref Reference to a chain that is already configured (composite).</li>
39   * <li>depends List of dependencies to this command (may only other commands).
40   * </li>
41   * </ul>
42   * 
43   * @author <a href="mailto:wolff@struts-it.de">Manfred Wolff </a>
44   * @since JDK 1.4
45   * @version $Revision: 1.2 $
46   */
47  public abstract class ConfCommand implements Command {
48  
49      /// The idref property of this command.
50      private String idref;
51  
52      /// The depends property of this command.
53      private String depends;
54  
55      /// List of dependencies
56      protected List dependencies = new ArrayList();
57  
58      /***
59       * @return Returns the depends.
60       */
61      public String getDepends() {
62          return depends;
63      }
64  
65      /***
66       * @param depends
67       *            The depends to set.
68       */
69      public void setDepends(String depends) {
70  
71          this.depends = depends;
72          dependencies.clear();
73          StringTokenizer tokenizer = new StringTokenizer(depends, ",");
74          while (tokenizer.hasMoreTokens()) {
75              String token = tokenizer.nextToken();
76              token = token.trim();
77              dependencies.add(token);
78          }
79      }
80  
81      /***
82       * @return Returns the idref.
83       */
84      public String getIdref() {
85          return idref;
86      }
87  
88      /***
89       * @param idref
90       *            The idref to set.
91       */
92      public void setIdref(String idref) {
93          this.idref = idref;
94      }
95  }