KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 Fossil E-Commerce, http://www.fossilec.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: JBIDescriptor.java 477 2006-05-29 15:18:07Z rmarins $
20  * -------------------------------------------------------------------------
21  */

22
23 package org.objectweb.petals.tools.jbicommon.descriptor;
24
25 import org.apache.commons.lang.builder.EqualsBuilder;
26 import org.apache.commons.lang.builder.HashCodeBuilder;
27 import org.apache.commons.lang.builder.ToStringBuilder;
28
29 /**
30  * JBI Descriptor.
31  *
32  * @version $Rev: 477 $ $Date: 2006-05-29 15:18:07Z $
33  * @since Petals 1.0
34  * @author <a HREF="mailto:rmarins@fossilec.com">Rafael Marins</a>
35  */

36 public class JBIDescriptor {
37
38     // ----------------------------------------------------------------------
39
// constants and inner classes declarations
40
// ----------------------------------------------------------------------
41

42     /**
43      * ClassLoader parent first delegation option (<code>"parent-first"</code>).
44      */

45     private static final String JavaDoc CL_PARENT_FIRST = "parent-first";
46
47     /**
48      * ClassLoader self first delegation option (<code>"self-first"</code>).
49      */

50     private static final String JavaDoc CL_SELF_FIRST = "self-first";
51
52     /**
53      * JBI Component production.
54      */

55     private ComponentDescription component;
56
57     /**
58      * Service Assembly production.
59      */

60     private ServiceAssembly serviceAssembly;
61
62     /**
63      * Services production.
64      */

65     private Services services;
66
67     /**
68      * Shared Library production.
69      */

70     private SharedLibrary sharedLibrary;
71
72     /**
73      * JBI Descriptor version.
74      */

75     private double version;
76
77     /**
78      * Default constructor.
79      */

80     public JBIDescriptor() { // NOPMD by gblondelle
81
super();
82     }
83     
84     /**
85      * Return true if the delegation model is "parent-first" or null (default)
86      * Return false otherwise
87      */

88     public static boolean isParentFirst(final String JavaDoc delegation) {
89         return (delegation == null) || (CL_PARENT_FIRST.equals(delegation));
90     }
91
92     /**
93      * Return true if the delegation model is "self-first" Return false
94      * otherwise
95      */

96     public static boolean isSelfFirst(final String JavaDoc delegation) {
97         return CL_SELF_FIRST.equals(delegation);
98
99     }
100
101     @Override JavaDoc
102     public boolean equals(final Object JavaDoc other) {
103         if (!(other instanceof JBIDescriptor)) {
104             return false; // NOPMD by gblondelle
105
}
106         JBIDescriptor castOther = (JBIDescriptor) other;
107         return new EqualsBuilder().append(component, castOther.component)
108                 .append(serviceAssembly, castOther.serviceAssembly).append(
109                         services, castOther.services).append(sharedLibrary,
110                         castOther.sharedLibrary).append(version,
111                         castOther.version).isEquals();
112     }
113
114     // ----------------------------------------------------------------------
115
// Getters and Setters
116
// ----------------------------------------------------------------------
117

118     /**
119      * Returns the component production loaded from JBI Descriptor.
120      *
121      * @return Returns the component.
122      */

123     public ComponentDescription getComponent() {
124         return component;
125     }
126
127     /**
128      * Returns the service assembly production loaded from JBI Descriptor.
129      *
130      * @return Returns the serviceAssembly.
131      */

132     public ServiceAssembly getServiceAssembly() {
133         return serviceAssembly;
134     }
135
136     /**
137      * Returns the services production loaded from JBI Descriptor.
138      *
139      * @return Returns the services.
140      */

141     public Services getServices() {
142         return services;
143     }
144
145     /**
146      * Returns the shared library production from JBI Descriptor.
147      *
148      * @return Returns the sharedLibrary.
149      */

150     public SharedLibrary getSharedLibrary() {
151         return sharedLibrary;
152     }
153
154     /**
155      * Attribute version is a decimal value indicating the version of descriptor
156      * in use.
157      *
158      * @return <code>double</code> the version.
159      */

160     public double getVersion() {
161         return version;
162     }
163
164     @Override JavaDoc
165     public int hashCode() {
166         return new HashCodeBuilder().append(component).append(serviceAssembly)
167                 .append(services).append(sharedLibrary).append(version)
168                 .toHashCode();
169     }
170
171     @Override JavaDoc
172     public String JavaDoc toString() {
173         return new ToStringBuilder(this).append("component", component).append(
174                 "serviceAssembly", serviceAssembly)
175                 .append("services", services).append("sharedLibrary",
176                         sharedLibrary).append("version", version).toString();
177     }
178
179     /**
180      * Set the component JBI Descriptor production loaded from a XML.
181      *
182      * @param component
183      * the component production.
184      */

185     protected void setComponent(final ComponentDescription component) {
186         this.component = component;
187     }
188
189     /**
190      * Set the service assembly JBI Descriptor production loaded from a XML.
191      *
192      * @param serviceAssembly
193      * the service assembly production.
194      */

195     protected void setServiceAssembly(final ServiceAssembly serviceAssembly) {
196         this.serviceAssembly = serviceAssembly;
197     }
198
199     /**
200      * Set the services JBI Descriptor production loaded from a XML.
201      *
202      * @param services
203      * the services production.
204      */

205     protected void setServices(final Services services) {
206         this.services = services;
207     }
208
209     // ----------------------------------------------------------------------
210
// static Descriptor utility methods
211
// ----------------------------------------------------------------------
212

213     /**
214      * Set the shared library JBI Descriptor production loaded from a XML.
215      *
216      * @param sharedLibrary
217      * the shared library production.
218      */

219     protected void setSharedLibrary(final SharedLibrary sharedLibrary) {
220         this.sharedLibrary = sharedLibrary;
221     }
222
223     /**
224      * Attribute version is a decimal value indicating the version of descriptor
225      * in use.
226      *
227      * @param version
228      * The version <code>double</code> value to set.
229      */

230     protected void setVersion(final double version) {
231         this.version = version;
232     }
233 }
234
Popular Tags