KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > services > binding > ServiceConfig


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.services.binding;
23
24 /** A ServiceConfig is a mapping from an mbean service name to its
25  * ServiceBindings.
26  *
27  * @author <a HREF="mailto:bitpushr@rochester.rr.com">Mike Finn</a>.
28  * @author Scott.Stark@jboss.org
29  * @version $Revision: 37459 $
30  */

31 public class ServiceConfig implements Cloneable JavaDoc
32 {
33    /** The javax.management.ObjectName string of the service the config
34     applies to.
35     */

36    private String JavaDoc serviceName;
37    /** The ServicesConfigDelegate implementation class
38     */

39    private String JavaDoc serviceConfigDelegateClassName;
40    /** An aribtrary object used to configure the behavior of
41     the ServicesConfigDelegate. An example would be an XML Element.
42     */

43    private Object JavaDoc serviceConfigDelegateConfig;
44    /** The bindings associated with the service
45     */

46    private ServiceBinding[] bindings;
47
48    /** Creates a new instance of ServiceConfig */
49    public ServiceConfig()
50    {
51    }
52
53    /** Make a deep copy of the ServiceConfig bindings
54     */

55    public Object JavaDoc clone()
56    {
57       ServiceConfig copy = new ServiceConfig();
58       // Immutable so no reason to copy
59
copy.serviceName = serviceName;
60       copy.serviceConfigDelegateClassName = serviceConfigDelegateClassName;
61       int length = bindings != null ? bindings.length : 0;
62       copy.bindings = new ServiceBinding[length];
63       for(int b = 0; b < length; b ++)
64       {
65          copy.bindings[b] = (ServiceBinding) bindings[b].clone();
66       }
67       return copy;
68    }
69
70    /** Getter for property serviceName.
71     * @return Value of property serviceName.
72     */

73    public String JavaDoc getServiceName()
74    {
75       return this.serviceName;
76    }
77
78    /** Setter for property serviceName.
79     * @param serviceName New value of property serviceName.
80     */

81    public void setServiceName(String JavaDoc serviceName)
82    {
83       this.serviceName = serviceName;
84    }
85
86    /** Getter for property port.
87     * @return Value of property port.
88     */

89    public ServiceBinding[] getBindings()
90    {
91       return this.bindings;
92    }
93
94    /** Setter for property port.
95     * @param port New value of property port.
96     */

97    public void setBindings(ServiceBinding[] bindings)
98    {
99       this.bindings = bindings;
100    }
101
102    /** Getter for property serviceConfigDelegateClassName.
103     * @return Value of property serviceConfigDelegateClassName.
104     */

105    public String JavaDoc getServiceConfigDelegateClassName()
106    {
107       return serviceConfigDelegateClassName;
108    }
109
110    /** Setter for property serviceConfigDelegateClassName.
111     * @param serviceConfigDelegateClassName New value of property serviceConfigDelegateClassName.
112     */

113    public void setServiceConfigDelegateClassName(String JavaDoc serviceConfigDelegateClassName)
114    {
115       this.serviceConfigDelegateClassName = serviceConfigDelegateClassName;
116    }
117
118    /** Getter for property serviceConfigDelegateConfig.
119     * @return Value of property serviceConfigDelegateConfig.
120     */

121    public Object JavaDoc getServiceConfigDelegateConfig()
122    {
123       return serviceConfigDelegateConfig;
124    }
125
126    /** Setter for property serviceConfigDelegateConfig.
127     * @param serviceConfigDelegateConfig New value of property serviceConfigDelegateConfig.
128     */

129    public void setServiceConfigDelegateConfig(Object JavaDoc serviceConfigDelegateConfig)
130    {
131       this.serviceConfigDelegateConfig = serviceConfigDelegateConfig;
132    }
133
134    /** Equality is based on the serviceName string
135     */

136    public boolean equals(Object JavaDoc obj)
137    {
138       boolean equals = false;
139       if( obj instanceof ServiceConfig )
140       {
141          ServiceConfig sc = (ServiceConfig) obj;
142          equals = this.serviceName.equals(sc.serviceName);
143       }
144       else
145       {
146          equals = super.equals(obj);
147       }
148       return equals;
149    }
150
151    /** The hash code is based on the serviceName string hashCode.
152     */

153    public int hashCode()
154    {
155       int hashCode = serviceName == null ? 0 : serviceName.hashCode();
156       return hashCode;
157    }
158
159    public String JavaDoc toString()
160    {
161       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("ServiceConfig(name=");
162       buffer.append(serviceName);
163       buffer.append("), bindings=<");
164       int length = bindings != null ? bindings.length : 0;
165       for(int b = 0; b < length; b ++)
166       {
167          buffer.append(bindings[b].toString());
168       }
169       buffer.append(">");
170       return buffer.toString();
171    }
172    
173 }
174
Popular Tags