KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > IiopService


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class IiopService matches the DTD element iiop-service
26  *
27  */

28
29 package com.sun.enterprise.config.serverbeans;
30
31 import org.w3c.dom.*;
32 import org.netbeans.modules.schema2beans.*;
33 import java.beans.*;
34 import java.util.*;
35 import java.io.Serializable JavaDoc;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.config.StaleWriteConfigException;
39 import com.sun.enterprise.util.i18n.StringManager;
40
41 // BEGIN_NOI18N
42

43 public class IiopService extends ConfigBean implements Serializable JavaDoc
44 {
45
46     static Vector comparators = new Vector();
47     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
48
49     static public final String JavaDoc ORB = "Orb";
50     static public final String JavaDoc SSL_CLIENT_CONFIG = "SslClientConfig";
51     static public final String JavaDoc IIOP_LISTENER = "IiopListener";
52
53     public IiopService() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public IiopService(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("orb", ORB,
63             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
64             Orb.class);
65         this.createAttribute(ORB, "use-thread-pool-ids", "UseThreadPoolIds",
66                         AttrProp.CDATA | AttrProp.REQUIRED,
67                         null, null);
68         this.createAttribute(ORB, "message-fragment-size", "MessageFragmentSize",
69                         AttrProp.CDATA,
70                         null, "1024");
71         this.createAttribute(ORB, "max-connections", "MaxConnections",
72                         AttrProp.CDATA,
73                         null, "1024");
74         this.createProperty("ssl-client-config", SSL_CLIENT_CONFIG,
75             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
76             SslClientConfig.class);
77         this.createProperty("iiop-listener", IIOP_LISTENER,
78             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
79             IiopListener.class);
80         this.createAttribute(IIOP_LISTENER, "id", "Id",
81                         AttrProp.CDATA | AttrProp.REQUIRED,
82                         null, null);
83         this.createAttribute(IIOP_LISTENER, "address", "Address",
84                         AttrProp.CDATA | AttrProp.REQUIRED,
85                         null, null);
86         this.createAttribute(IIOP_LISTENER, "port", "Port",
87                         AttrProp.CDATA,
88                         null, "1072");
89         this.createAttribute(IIOP_LISTENER, "security-enabled", "SecurityEnabled",
90                         AttrProp.CDATA,
91                         null, "false");
92         this.createAttribute(IIOP_LISTENER, "enabled", "Enabled",
93                         AttrProp.CDATA,
94                         null, "true");
95         this.initialize(options);
96     }
97
98     // Setting the default values of the properties
99
void initialize(int options) {
100
101     }
102
103     // This attribute is mandatory
104
public void setOrb(Orb value) {
105         this.setValue(ORB, value);
106     }
107
108     // Get Method
109
public Orb getOrb() {
110         return (Orb)this.getValue(ORB);
111     }
112
113     // This attribute is optional
114
public void setSslClientConfig(SslClientConfig value) {
115         this.setValue(SSL_CLIENT_CONFIG, value);
116     }
117
118     // Get Method
119
public SslClientConfig getSslClientConfig() {
120         return (SslClientConfig)this.getValue(SSL_CLIENT_CONFIG);
121     }
122
123     // This attribute is an array, possibly empty
124
public void setIiopListener(int index, IiopListener value) {
125         this.setValue(IIOP_LISTENER, index, value);
126     }
127
128     // Get Method
129
public IiopListener getIiopListener(int index) {
130         return (IiopListener)this.getValue(IIOP_LISTENER, index);
131     }
132
133     // This attribute is an array, possibly empty
134
public void setIiopListener(IiopListener[] value) {
135         this.setValue(IIOP_LISTENER, value);
136     }
137
138     // Getter Method
139
public IiopListener[] getIiopListener() {
140         return (IiopListener[])this.getValues(IIOP_LISTENER);
141     }
142
143     // Return the number of properties
144
public int sizeIiopListener() {
145         return this.size(IIOP_LISTENER);
146     }
147
148     // Add a new element returning its index in the list
149
public int addIiopListener(IiopListener value)
150             throws ConfigException{
151         return addIiopListener(value, true);
152     }
153
154     // Add a new element returning its index in the list with a boolean flag
155
public int addIiopListener(IiopListener value, boolean overwrite)
156             throws ConfigException{
157         IiopListener old = getIiopListenerById(value.getId());
158         if(old != null) {
159             throw new ConfigException(StringManager.getManager(IiopService.class).getString("cannotAddDuplicate", "IiopListener"));
160         }
161         return this.addValue(IIOP_LISTENER, value, overwrite);
162     }
163
164     //
165
// Remove an element using its reference
166
// Returns the index the element had in the list
167
//
168
public int removeIiopListener(IiopListener value){
169         return this.removeValue(IIOP_LISTENER, value);
170     }
171
172     //
173
// Remove an element using its reference
174
// Returns the index the element had in the list
175
// with boolean overwrite
176
//
177
public int removeIiopListener(IiopListener value, boolean overwrite)
178             throws StaleWriteConfigException{
179         return this.removeValue(IIOP_LISTENER, value, overwrite);
180     }
181
182     public IiopListener getIiopListenerById(String JavaDoc id) {
183      if (null != id) { id = id.trim(); }
184     IiopListener[] o = getIiopListener();
185      if (o == null) return null;
186
187      for (int i=0; i < o.length; i++) {
188          if(o[i].getAttributeValue(Common.convertName(ServerTags.ID)).equals(id)) {
189              return o[i];
190          }
191      }
192
193         return null;
194         
195     }
196     /**
197     * Getter for ClientAuthenticationRequired of the Element iiop-service
198     * @return the ClientAuthenticationRequired of the Element iiop-service
199     */

200     public boolean isClientAuthenticationRequired() {
201         return toBoolean(getAttributeValue(ServerTags.CLIENT_AUTHENTICATION_REQUIRED));
202     }
203     /**
204     * Modify the ClientAuthenticationRequired of the Element iiop-service
205     * @param v the new value
206     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
207     */

208     public void setClientAuthenticationRequired(boolean v, boolean overwrite) throws StaleWriteConfigException {
209         setAttributeValue(ServerTags.CLIENT_AUTHENTICATION_REQUIRED, ""+(v==true), overwrite);
210     }
211     /**
212     * Modify the ClientAuthenticationRequired of the Element iiop-service
213     * @param v the new value
214     */

215     public void setClientAuthenticationRequired(boolean v) {
216         setAttributeValue(ServerTags.CLIENT_AUTHENTICATION_REQUIRED, ""+(v==true));
217     }
218     /**
219     * Get the default value of ClientAuthenticationRequired from dtd
220     */

221     public static String JavaDoc getDefaultClientAuthenticationRequired() {
222         return "false".trim();
223     }
224     /**
225      * Create a new bean using it's default constructor.
226      * This does not add it to any bean graph.
227      */

228     public Orb newOrb() {
229         return new Orb();
230     }
231
232     /**
233      * Create a new bean using it's default constructor.
234      * This does not add it to any bean graph.
235      */

236     public SslClientConfig newSslClientConfig() {
237         return new SslClientConfig();
238     }
239
240     /**
241      * Create a new bean using it's default constructor.
242      * This does not add it to any bean graph.
243      */

244     public IiopListener newIiopListener() {
245         return new IiopListener();
246     }
247
248     /**
249     * get the xpath representation for this element
250     * returns something like abc[@name='value'] or abc
251     * depending on the type of the bean
252     */

253     protected String JavaDoc getRelativeXPath() {
254         String JavaDoc ret = null;
255         ret = "iiop-service";
256         return (null != ret ? ret.trim() : null);
257     }
258
259     /*
260     * generic method to get default value from dtd
261     */

262     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
263         if(attr == null) return null;
264         attr = attr.trim();
265         if(attr.equals(ServerTags.CLIENT_AUTHENTICATION_REQUIRED)) return "false".trim();
266     return null;
267     }
268     //
269
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
270         comparators.add(c);
271     }
272
273     //
274
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
275         comparators.remove(c);
276     }
277     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
278     }
279
280     // Dump the content of this bean returning it as a String
281
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
282         String JavaDoc s;
283         Object JavaDoc o;
284         org.netbeans.modules.schema2beans.BaseBean n;
285         str.append(indent);
286         str.append("Orb"); // NOI18N
287
n = (org.netbeans.modules.schema2beans.BaseBean) this.getOrb();
288         if (n != null)
289             n.dump(str, indent + "\t"); // NOI18N
290
else
291             str.append(indent+"\tnull"); // NOI18N
292
this.dumpAttributes(ORB, 0, str, indent);
293
294         str.append(indent);
295         str.append("SslClientConfig"); // NOI18N
296
n = (org.netbeans.modules.schema2beans.BaseBean) this.getSslClientConfig();
297         if (n != null)
298             n.dump(str, indent + "\t"); // NOI18N
299
else
300             str.append(indent+"\tnull"); // NOI18N
301
this.dumpAttributes(SSL_CLIENT_CONFIG, 0, str, indent);
302
303         str.append(indent);
304         str.append("IiopListener["+this.sizeIiopListener()+"]"); // NOI18N
305
for(int i=0; i<this.sizeIiopListener(); i++)
306         {
307             str.append(indent+"\t");
308             str.append("#"+i+":");
309             n = (org.netbeans.modules.schema2beans.BaseBean) this.getIiopListener(i);
310             if (n != null)
311                 n.dump(str, indent + "\t"); // NOI18N
312
else
313                 str.append(indent+"\tnull"); // NOI18N
314
this.dumpAttributes(IIOP_LISTENER, i, str, indent);
315         }
316
317     }
318     public String JavaDoc dumpBeanNode(){
319         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
320         str.append("IiopService\n"); // NOI18N
321
this.dump(str, "\n "); // NOI18N
322
return str.toString();
323     }}
324
325 // END_NOI18N
326

327
Popular Tags