1   /* ====================================================================
2    * Bigyo Software License, version 1.1
3    * 
4    * Copyright (c) 2004, Zsombor Gegesy. All rights reserved.
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions 
7    * are met:
8    *
9    * 1. Redistributions of source code must retain the above copyright 
10   *    notice, this list of conditions and the following disclaimer.
11   *
12   * 2. Redistributions in binary form must reproduce the above copyright 
13   *    notice, this list of conditions and the following disclaimer in 
14   *    the documentation and/or other materials provided with the 
15   *    distribution.
16   *
17   * 3. Neither the name of the Bigyo Group nor the name "Bigyo" nor
18   *    the names of its contributors may be used to endorse or promote
19   *    products derived from this software without specific prior
20   *    written permission.
21   *
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
23   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
27   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
28   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
31   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32   * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33   * POSSIBILITY OF SUCH DAMAGE.
34   *
35   * ====================================================================
36   */
37  
38  package net.sf.bigyo.container;
39  
40  import java.util.ArrayList;
41  import java.util.HashMap;
42  import java.util.Iterator;
43  import java.util.List;
44  import java.util.Map;
45  
46  /***
47   * @author zsombor
48   *  
49   * Created on 2004.03.31.
50   */
51  public class ComponentDescription {
52  
53      String classAlias; // ezzel kell bealiasolni ...
54      String className; // a komponenst osztaly
55      String configClassName; // a perzisztens adatokat tarolo bean
56  
57      String type; // singleton / many
58  
59      List depends;
60  
61      List provides;
62  
63      String startMethod;
64      String stopMethod;
65      
66      Map classShortcuts;
67  
68      /***
69       *  
70       */
71      public ComponentDescription() {
72          super();
73      }
74  
75      /***
76       * @return Returns the className.
77       */
78      public String getClassName() {
79          return className;
80      }
81  
82      /***
83       * @param className
84       *            The className to set.
85       */
86      public void setClassName(String className) {
87          this.className = className;
88      }
89  
90      /***
91       * @return Returns the depends.
92       */
93      public List getDepends() {
94          return depends;
95      }
96  
97      /***
98       * @param depends
99       *            The depends to set.
100      */
101     public void setDepends(List depends) {
102         this.depends = depends;
103     }
104 
105     /***
106      * @return Returns the name.
107      */
108     public String getClassAlias() {
109         return classAlias;
110     }
111 
112     /***
113      * @param name
114      *            The name to set.
115      */
116     public void setClassAlias(String name) {
117         this.classAlias = name;
118     }
119 
120     /***
121      * @return Returns the type.
122      */
123     public String getType() {
124         return type;
125     }
126 
127     /***
128      * @param type
129      *            The type to set.
130      */
131     public void setType(String type) {
132         this.type = type;
133     }
134 
135     /***
136      * @return Returns the configClassName.
137      */
138     public String getConfigClass() {
139         return configClassName;
140     }
141 
142     /***
143      * @param configClassName
144      *            The configClassName to set.
145      */
146     public void setConfigClass(String configClassName) {
147         this.configClassName = configClassName;
148     }
149 
150     /***
151      * @param classAlias
152      * @param className
153      * @param configClassName
154      * @param type
155      */
156     public ComponentDescription(String classAlias, String className, String configClassName, String type) {
157         super();
158         this.classAlias = classAlias;
159         this.className = className;
160         this.configClassName = configClassName;
161         this.type = type;
162     }
163 
164     /***
165      * @param classAlias
166      * @param className
167      * @param configClassName
168      * @param type
169      */
170     public ComponentDescription(String classAlias, Class componentClass, Class configClass, String type) {
171         super();
172         this.classAlias = classAlias;
173         this.className = componentClass.getName();
174         this.configClassName = (configClass != null ? configClass.getName() : null);
175         this.type = type;
176     }
177 
178     public ComponentDescription addDepend(String name) {
179         if (depends == null)
180             depends = new ArrayList();
181         depends.add(new ClassDependency(name, null));
182         return this;
183     }
184 
185     public ComponentDescription addDepend(String name, String depType) {
186         if (depends == null)
187             depends = new ArrayList();
188         depends.add(new ClassDependency(name, depType));
189         return this;
190     }
191 
192     public ComponentDescription addDependSetter(String name, String methodName) {
193         if (depends == null)
194             depends = new ArrayList();
195         depends.add(new ClassDependency(name, ClassDependency.REQUIRED, methodName));
196         return this;
197     }
198     
199     public ComponentDescription addOptionalDependSetter(String name, String methodName) {
200         if (depends == null)
201             depends = new ArrayList();
202         depends.add(new ClassDependency(name, ClassDependency.OPTIONAL, methodName));
203         return this;
204     }
205     
206     
207 
208     public ClassDependency getDependency(String classAlias) {
209         if (depends == null)
210             return null;
211         if (classAlias == null)
212             throw new NullPointerException("classAlias not specified!");
213         for (Iterator iter = depends.iterator(); iter.hasNext();) {
214             ClassDependency d = (ClassDependency) iter.next();
215             if (classAlias.equals(d.getClassAlias()))
216                 return d;
217         }
218         return null;
219     }
220 
221     /***
222      * @return Returns the startMethod.
223      */
224     public String getStart() {
225         return startMethod;
226     }
227 
228     /***
229      * @param startMethod
230      *            The startMethod to set.
231      */
232     public void setStart(String startMethod) {
233         this.startMethod = startMethod;
234     }
235 
236     /***
237      * @return Returns the stopMethod.
238      */
239     public String getStop() {
240         return stopMethod;
241     }
242 
243     /***
244      * @param stopMethod
245      *            The stopMethod to set.
246      */
247     public void setStop(String stopMethod) {
248         this.stopMethod = stopMethod;
249     }
250 
251     public List getProvides() {
252         return this.provides;
253     }
254 
255     public void setProvides(List provides) {
256         this.provides = provides;
257     }
258 
259     public void addProvideAlias(String alias) {
260         if (provides == null)
261             provides = new ArrayList();
262         provides.add(alias);
263     }
264 
265     Class componentClass;
266 
267     public Class lookupClass() throws ClassNotFoundException {
268         if (componentClass == null) {
269             componentClass = Class.forName(className);
270         }
271         return componentClass;
272     }
273     
274     /***
275      * @return Returns the classShortcuts.
276      */
277     public Map getClassShortcuts() {
278         return classShortcuts;
279     }
280     
281     /***
282      * @param classShortcuts The classShortcuts to set.
283      */
284     public void setClassShortcuts(Map classShortcuts) {
285         this.classShortcuts = classShortcuts;
286     }
287     
288     public void setClassShortcut(String name, String className) {
289         Map m = getClassShortcuts(); 
290         if (m==null) {
291             m = new HashMap();
292             setClassShortcuts(m);
293         }
294         m.put(name,className);
295     }
296     
297 }
This page was automatically generated by Maven