KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005-2006 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$
20  * -------------------------------------------------------------------------
21  */

22
23 package org.objectweb.petals.tools.jbicommon.descriptor;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import org.apache.commons.lang.builder.EqualsBuilder;
29 import org.apache.commons.lang.builder.HashCodeBuilder;
30 import org.apache.commons.lang.builder.ToStringBuilder;
31
32 /**
33  * The services element is used to declare the static services provided and
34  * consumed by a service unit. The term "static" in this context means those
35  * services that are provided or consumed due to the deployment of the service
36  * unit, and that are known at design- and/or deployment-time.
37  *
38  * @version $Rev: 438 $ $Date: 2006-05-19 11:12:26Z $
39  * @since Petals 1.0
40  * @author <a HREF="mailto:rmarins@fossilec.com">Rafael Marins</a>
41  */

42 public class Services extends ExtensibleJbiElement {
43
44     /**
45      * Used to distinguish between service engine and binding component.
46      */

47     private boolean bindingComponent;
48
49     /**
50      * Services provided by a service unit.
51      */

52     private List JavaDoc<Provides> provides;
53
54     /**
55      * Services consumed by a service unit.
56      */

57     private List JavaDoc<Consumes> consumes;
58
59     /**
60      * Default constructor.
61      */

62     public Services() {
63         super();
64         consumes = new ArrayList JavaDoc<Consumes>();
65         provides = new ArrayList JavaDoc<Provides>();
66     }
67
68     @Override JavaDoc
69     public boolean equals(final Object JavaDoc other) {
70         if (!(other instanceof Services)) {
71             return false; // NOPMD by gblondelle
72
}
73         Services castOther = (Services) other;
74         return new EqualsBuilder().append(bindingComponent,
75                 castOther.bindingComponent)
76                 .append(provides, castOther.provides).append(consumes,
77                         castOther.consumes).isEquals();
78     }
79
80     //
81
// Getters and Setters
82
//
83

84     @Override JavaDoc
85     public int hashCode() {
86         return new HashCodeBuilder().append(bindingComponent).append(provides)
87                 .append(consumes).toHashCode();
88     }
89
90     /**
91      * Attribute used to distinguish if the services declared is related to a
92      * service engine or a binding component.
93      *
94      * @return <code>boolean</code> indicates if it's a binding component.
95      */

96     public boolean isBindingComponent() {
97         return bindingComponent;
98     }
99
100     @Override JavaDoc
101     public String JavaDoc toString() {
102         return new ToStringBuilder(this).append("bindingComponent",
103                 bindingComponent).append("provides", provides).append(
104                 "consumes", consumes).toString();
105     }
106
107     protected void addConsumes(final Consumes consumesElem) {
108         consumes.add(consumesElem);
109     }
110
111     protected void addProvides(final Provides providesElem) {
112         provides.add(providesElem);
113     }
114
115     /**
116      * Set if it's relative to a binding component.
117      *
118      * @param bindingComponent
119      * <code>true</code> to indicate it's a binding component.
120      */

121     protected void setBindingComponent(final boolean bindingComponent) {
122         this.bindingComponent = bindingComponent;
123     }
124
125     /**
126      * Set the list of services consumed by a service unit deployed.
127      *
128      * @param consumes
129      * the list of consumed services.
130      */

131     protected void setConsumes(final List JavaDoc<Consumes> consumes) {
132         this.consumes = consumes;
133     }
134
135     /**
136      * Returns the list of services consumed by a service unit deployed.
137      * @return consumes the list of consumed services.
138      */

139     public List JavaDoc<Consumes> getConsumes() {
140         return consumes;
141     }
142
143     /**
144      * Set the list of services provided with the deployment of a service unit.
145      *
146      * @param provides
147      * the list of provided services.
148      */

149     void setProvides(final List JavaDoc<Provides> provides) {
150         this.provides = provides;
151     }
152
153     /**
154      * Returns the list of services provided with the deployment of a service unit.
155      * @return provides the list of provided services.
156      */

157     public List JavaDoc<Provides> getProvides() {
158         return provides;
159     }
160
161 }
162
Popular Tags