1   /*
2    * Copyright 2002,2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.commons.jelly.tags.bean;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  
24  /***
25   * A sample bean that we can construct via Jelly tags
26   *
27   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
28   * @version $Revision: 155420 $
29   */
30  public class Manager {
31  
32      /*** The Log to which logging calls will be made. */
33      private static final Log log = LogFactory.getLog(Manager.class);
34  
35      private List customers = new ArrayList();
36  
37      boolean invoked = false;
38  
39      public Manager() {
40      }
41  
42      public String toString() {
43          return super.toString() + "[customers=" + customers + "]";
44      }
45  
46      /***
47       * The invoke method which is called when the bean is constructed
48       */
49      public void run() {
50          invoked = true;
51  
52          log.info("Invoked the run() method with customers: " + customers);
53      }
54  
55  
56      public List getCustomers() {
57          return customers;
58      }
59  
60      public void addCustomer(Customer customer) {
61          customers.add(customer);
62      }
63  
64      public void removeCustomer(Customer customer) {
65          customers.remove(customer);
66      }
67  
68      /***
69       * @return boolean
70       */
71      public boolean isInvoked() {
72          return invoked;
73      }
74  
75      /***
76       * Sets the invoked.
77       * @param invoked The invoked to set
78       */
79      public void setInvoked(boolean invoked) {
80          this.invoked = invoked;
81      }
82  
83  }