KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > jbicommon > descriptor > ComponentDescription


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: ComponentDescription.java 12:14:20 rmarins $
20  * -------------------------------------------------------------------------
21  */

22
23 package org.objectweb.petals.tools.jbicommon.descriptor;
24
25 import java.util.List JavaDoc;
26
27 import org.apache.commons.lang.builder.EqualsBuilder;
28 import org.apache.commons.lang.builder.HashCodeBuilder;
29 import org.apache.commons.lang.builder.ToStringBuilder;
30
31 /**
32  * Component production is used to describe a component installation package.
33  *
34  * @version $Rev: 76 $ $Date: 2006-01-17 18:15:44 +0100 (mar., 17 janv. 2006) $
35  * @since Petals 1.0
36  * @author <a HREF="mailto:rmarins@fossilec.com">Rafael Marins</a>
37  */

38 public class ComponentDescription extends ExtensibleJbiElement {
39
40     /**
41      * Component type: <code>"binding-component"</code>
42      */

43     private static final String JavaDoc BC_TYPE = "binding-component";
44
45     /**
46      * Compoment type: <code>"service-engine"</code>
47      */

48     private static final String JavaDoc SE_TYPE = "service-engine";
49
50     /**
51      * Component's bootstrap class loading delegation model:
52      * <code>"self-first"</code> or <code>"parent-first"</code>.
53      */

54     private String JavaDoc bootstrapClassLoaderDelegation;
55
56     /**
57      * Fully qualified name for bootstrap's <code>Bootstrap</code>
58      * implementation.
59      */

60     private String JavaDoc bootstrapClassName;
61
62     /**
63      * Bootstrap Class Path.
64      */

65     private List JavaDoc<String JavaDoc> bootstrapClassPath;
66
67     /**
68      * Component's class loading delegation model: <code>"self-first"</code>
69      * or <code>"parent-first"</code>.
70      */

71     private String JavaDoc componentClassLoaderDelegation;
72
73     /**
74      * Fully qualified name for component's <code>Component</code>
75      * implementation.
76      */

77     private String JavaDoc componentClassName;
78
79     /**
80      * Component Class Path.
81      */

82     private List JavaDoc<String JavaDoc> componentClassPath;
83
84     /**
85      * Component identification data.
86      */

87     private Identification identification;
88
89     /**
90      * List of Shared Libraries used by this component.
91      */

92     private List JavaDoc<SharedLibraryList> sharedLibraryList;
93
94     /**
95      * Compoment type: SERVICE_ENGINE_TYPE or BINDING_COMPOMENT_TYPE.
96      */

97     private String JavaDoc type;
98
99     /**
100      * Default constructor.
101      */

102     public ComponentDescription() { // NOPMD by gblondelle
103
super();
104     }
105
106     @Override JavaDoc
107     public boolean equals(final Object JavaDoc other) {
108         if (!(other instanceof ComponentDescription)) {
109             return false; // NOPMD by gblondelle
110
}
111         ComponentDescription castOther = (ComponentDescription) other;
112         return new EqualsBuilder().append(bootstrapClassLoaderDelegation,
113                 castOther.bootstrapClassLoaderDelegation).append(
114                 bootstrapClassName, castOther.bootstrapClassName).append(
115                 bootstrapClassPath, castOther.bootstrapClassPath).append(
116                 componentClassLoaderDelegation,
117                 castOther.componentClassLoaderDelegation).append(
118                 componentClassName, castOther.componentClassName).append(
119                 componentClassPath, castOther.componentClassPath).append(
120                 identification, castOther.identification).append(
121                 sharedLibraryList, castOther.sharedLibraryList).append(type,
122                 castOther.type).isEquals();
123     }
124
125     /**
126      * Returns the class loading delegation model of component's bootstrap used
127      * during component installation. If <code>null</code> the "parent-first"
128      * default delegation model must be used.
129      *
130      * @return <code>String</code> the delegation model:
131      * <code>"parent-first"</code> or <code>"self-first"</code>.
132      */

133     public String JavaDoc getBootstrapClassLoaderDelegation() {
134         return bootstrapClassLoaderDelegation;
135     }
136
137     /**
138      * Returns the fully-qualified class name for the component's
139      * <code>Bootstrap</code> implementation. This is used during component
140      * installation.
141      *
142      * @return <code>String</code> the fully-qualified class name.
143      */

144     public String JavaDoc getBootstrapClassName() {
145         return bootstrapClassName;
146     }
147
148     //
149
// Getters and Setters
150
//
151

152     /**
153      * Returns the class path used during installation processing
154      * (bootstrapping) of the component.
155      *
156      * @return <code>List<String></code> the bootstrap class path.
157      */

158     public List JavaDoc<String JavaDoc> getBootstrapClassPath() {
159         return bootstrapClassPath;
160     }
161
162     /**
163      * Returns the class loading delegation model of this component used during
164      * its execution phase. If <code>null</code> the "parent-first" default
165      * delegation model must be used.
166      *
167      * @return <code>String</code> the delegation model:
168      * <code>"parent-first"</code> or <code>"self-first"</code>.
169      */

170     public String JavaDoc getComponentClassLoaderDelegation() {
171         return componentClassLoaderDelegation;
172     }
173
174     /**
175      * Returns the fully-qualified class name for the component's
176      * <code>Component</code> implementation. This is used during component's
177      * execution phase of its lifecycle.
178      *
179      * @return <code>String</code> the fully-qualified class name.
180      */

181     public String JavaDoc getComponentClassName() {
182         return componentClassName;
183     }
184
185     /**
186      * Returns the class path used after the component is installed. This class
187      * path, along with shared-libraries, constitutes the full class path
188      * avaiable to the component through its default class loader context as
189      * provided by JBI.
190      *
191      * @return <code>List<String></code> the component class path.
192      */

193     public List JavaDoc<String JavaDoc> getComponentClassPath() {
194         return componentClassPath;
195     }
196
197     /**
198      * Returns component's identification data.
199      *
200      * @return <code>Identification</code> the component's identification.
201      */

202     public Identification getIdentification() {
203         return identification;
204     }
205
206     /**
207      * Returns a list of shared libraries (by name and optional version) used by
208      * the component. The implementation may use the version information to
209      * verify that the shared library version declared by the component matches
210      * the version of the shared library installed in the JBI environment.
211      *
212      * @return <code>List<SharedLibraryList></code> used by this component.
213      */

214     public List JavaDoc<SharedLibraryList> getSharedLibraryList() {
215         return sharedLibraryList;
216     }
217
218     /**
219      * The component type string representation specifying whether this is a
220      * service engine or a binding component.
221      *
222      * @return <code>String</code> the component type.
223      */

224     public String JavaDoc getType() {
225         return type;
226     }
227
228     @Override JavaDoc
229     public int hashCode() {
230         return new HashCodeBuilder().append(bootstrapClassLoaderDelegation)
231                 .append(bootstrapClassName).append(bootstrapClassPath).append(
232                         componentClassLoaderDelegation).append(
233                         componentClassName).append(componentClassPath).append(
234                         identification).append(sharedLibraryList).append(type)
235                 .toHashCode();
236     }
237
238     /**
239      * Returns <code>true</code> if this component type is a Binding
240      * Component. Otherwise returns <code>false</code>.
241      */

242     public boolean isBindingComponent() {
243         return BC_TYPE.equals(type);
244     }
245
246     /**
247      * Returns <code>true</code> if this component type is a Service Engine.
248      * Otherwise returns <code>false</code>.
249      */

250     public boolean isServiceEngine() {
251         return SE_TYPE.equals(type);
252     }
253
254     @Override JavaDoc
255     public String JavaDoc toString() {
256         return new ToStringBuilder(this).append(
257                 "bootstrapClassLoaderDelegation",
258                 bootstrapClassLoaderDelegation).append("bootstrapClassName",
259                 bootstrapClassName).append("bootstrapClassPath",
260                 bootstrapClassPath).append("componentClassLoaderDelegation",
261                 componentClassLoaderDelegation).append("componentClassName",
262                 componentClassName).append("componentClassPath",
263                 componentClassPath).append("identification", identification)
264                 .append("sharedLibraryList", sharedLibraryList).append("type",
265                         type).toString();
266     }
267
268     /**
269      * Set the Bootstrap class loading delegation model.
270      *
271      * @param delegationModel
272      * The delegation model to set: <code>"parent-first"</code> or
273      * <code>"self-first"</code>.
274      */

275     protected void setBootstrapClassLoaderDelegation(
276             final String JavaDoc delegationModel) {
277         this.bootstrapClassLoaderDelegation = delegationModel;
278     }
279
280     /**
281      * Set the class name of component's <code>Bootstrap</code>
282      * implementation.
283      *
284      * @param className
285      * <code>String</code> fully-qualified class name.
286      */

287     protected void setBootstrapClassName(final String JavaDoc className) {
288         this.bootstrapClassName = className;
289     }
290
291     /**
292      * Set the class path used by this component's <code>Bootstrap</code>
293      * during installation process.
294      *
295      * @param classPath
296      * <code>List<String></code> the bootstrap class path.
297      */

298     protected void setBootstrapClassPath(final List JavaDoc<String JavaDoc> classPath) {
299         this.bootstrapClassPath = classPath;
300     }
301
302     /**
303      * Set the Component class loading delegation model.
304      *
305      * @param delegationModel
306      * the delegation model to set: <code>"parent-first"</code> or
307      * <code>"self-first"</code>.
308      */

309     protected void setComponentClassLoaderDelegation(
310             final String JavaDoc delegationModel) {
311         this.componentClassLoaderDelegation = delegationModel;
312     }
313
314     /**
315      * Set the class name of this component implementation.
316      *
317      * @param className
318      * <code>String</code> fully-qualified class name.
319      */

320     protected void setComponentClassName(final String JavaDoc className) {
321         this.componentClassName = className;
322     }
323
324     /**
325      * Set the class path used by this component during its execution
326      * processing.
327      *
328      * @param classPath
329      * <code>List<String></code> the component class path.
330      */

331     protected void setComponentClassPath(final List JavaDoc<String JavaDoc> classPath) {
332         this.componentClassPath = classPath;
333     }
334
335     /**
336      * Set the component identification data.
337      *
338      * @param identification
339      * The identification to set.
340      */

341     protected void setIdentification(final Identification identification) {
342         this.identification = identification;
343     }
344
345     //
346
// Implementation methods
347
//
348

349     /**
350      * Set shared library list used by this component.
351      *
352      * @param sharedLibraryList
353      * <code>List<SharedLibraryList></code> shared library list to
354      * set.
355      */

356     protected void setSharedLibraryList(
357             final List JavaDoc<SharedLibraryList> sharedLibraryList) {
358
359         this.sharedLibraryList = sharedLibraryList;
360     }
361
362     /**
363      * Set the component type: <code>SERVICE_ENGINE_TYPE</code> or
364      * <code>BINDING_COMPONENT_TYPE</code>.
365      *
366      * @param type
367      * <code>String</code> the component type to set.
368      */

369     protected void setType(final String JavaDoc type) {
370         this.type = type;
371     }
372 }
373
Popular Tags