KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > beans > EjbBindingsType


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.websphere6.dd.beans;
20
21 import org.w3c.dom.*;
22 import org.netbeans.modules.schema2beans.*;
23 import java.beans.*;
24 import java.util.*;
25 /**
26  *
27  * @author dlm198383
28  */

29 public class EjbBindingsType extends org.netbeans.modules.schema2beans.BaseBean implements DDXmiConstants {
30
31     static Vector comparators = new Vector();
32     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
33
34
35     public EjbBindingsType() {
36         this(Common.USE_DEFAULT_VALUES);
37     }
38     public EjbBindingsType(int options) {
39         super(comparators,runtimeVersion);
40         // Properties (see root bean comments for the bean graph)
41
initPropertyTables(4);
42         this.createProperty(ENTERPRISE_BEAN_ID,
43                 ENTERPRISE_BEAN,
44                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
45                 java.lang.String JavaDoc.class);
46         
47         this.createAttribute(ENTERPRISE_BEAN, HREF_ID, ENTERPRISE_BEAN_HREF,
48                 AttrProp.CDATA | AttrProp.IMPLIED,
49                 null, null);
50         this.createAttribute(ENTERPRISE_BEAN, XMI_TYPE_ID, ENTERPRISE_BEAN_TYPE,
51                 AttrProp.CDATA | AttrProp.IMPLIED,
52                 null, null);
53         this.createProperty(RES_REF_BINDINGS_ID,
54                 RES_REF_BINDINGS,
55                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
56                 ResRefBindingsType.class);
57         this.createAttribute(RES_REF_BINDINGS,XMI_ID_ID ,RES_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
58         this.createAttribute(RES_REF_BINDINGS,JNDI_NAME_ID ,RES_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
59         
60         this.createProperty(EJB_REF_BINDINGS_ID,
61                 EJB_REF_BINDINGS,
62                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
63                 EjbRefBindingsType.class);
64         this.createAttribute(EJB_REF_BINDINGS,XMI_ID_ID ,EJB_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
65         this.createAttribute(EJB_REF_BINDINGS,JNDI_NAME_ID ,EJB_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
66         
67         this.createProperty(RES_ENV_REF_BINDINGS_ID, // NOI18N
68
RES_ENV_REF_BINDINGS,
69                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
70                 ResEnvRefBindingsType.class);
71         this.createAttribute(RES_ENV_REF_BINDINGS,XMI_ID_ID ,RES_ENV_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
72         this.createAttribute(RES_ENV_REF_BINDINGS,JNDI_NAME_ID ,RES_ENV_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
73         
74         
75         this.createProperty(CMP_CONNECTION_FACTORY_ID,
76                 CMP_CONNECTION_FACTORY,
77                 Common.TYPE_0_1 | Common.TYPE_STRING| Common.TYPE_KEY,
78                 java.lang.String JavaDoc.class);
79         this.createAttribute(CMP_CONNECTION_FACTORY,XMI_ID_ID,CMP_CONNECTION_FACTORY_XMI_ID,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
80         this.createAttribute(CMP_CONNECTION_FACTORY,JNDI_NAME_ID,CMP_CONNECTION_FACTORY_JNDI_NAME,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
81         this.createAttribute(CMP_CONNECTION_FACTORY,RES_AUTH_ID,CMP_CONNECTION_FACTORY_RES_AUTH,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
82         
83         this.initialize(options);
84     }
85     public void initialize(int options) {
86         setHref("");
87     }
88     
89     public void setEnterpriseBean(String JavaDoc value) {
90         this.setValue(ENTERPRISE_BEAN, value);
91     }
92     
93     public String JavaDoc getEnterpriseBean() {
94         return ( String JavaDoc)this.getValue(ENTERPRISE_BEAN);
95     }
96     
97     public void setXmiId(String JavaDoc value) {
98         this.setAttributeValue(EJB_BINDINGS_XMI_ID,value);
99     }
100     
101     public String JavaDoc getXmiId() {
102         return this.getAttributeValue(EJB_BINDINGS_XMI_ID);
103     }
104     
105     public void setJndiName(String JavaDoc value) {
106         this.setAttributeValue(EJB_BINDINGS_JNDI_NAME,value);
107     }
108     public String JavaDoc getJndiName() {
109         return this.getAttributeValue(EJB_BINDINGS_JNDI_NAME);
110     }
111     public CommonRef [] getReferences() {
112         ResRefBindingsType[] res=getResRefBindings();
113         EjbRefBindingsType[] ejb=getEjbRefBindings();
114         ResEnvRefBindingsType[] resenv=getResEnvRefBindings();
115         CommonRef ref[]=new CommonRef[res.length+ejb.length+resenv.length];
116         int index=0;
117         for (int i=0;i<res.length;i++) {
118             ref[index++]=res[i];
119         }
120         for (int i=0;i<ejb.length;i++) {
121             ref[index++]=ejb[i];
122         }
123         for (int i=0;i<resenv.length;i++) {
124             ref[index++]=resenv[i];
125         }
126         return ref;
127     }
128     
129     
130     
131     // functions for manupulation ResRefBindings
132
public void setResRefBindings(int index,ResRefBindingsType value) {
133         this.setValue(RES_REF_BINDINGS, index,value);
134     }
135     
136     public void setResRefBindings(ResRefBindingsType[]value) {
137         this.setValue(RES_REF_BINDINGS, value);
138     }
139     
140     public ResRefBindingsType[] getResRefBindings() {
141         return (ResRefBindingsType[]) this.getValues(RES_REF_BINDINGS);
142     }
143     public ResRefBindingsType getResRefBindings(int index) {
144         return (ResRefBindingsType)this.getValue(RES_REF_BINDINGS,index);
145     }
146     public int sizeResRefBindings() {
147         return this.size(RES_REF_BINDINGS);
148     }
149     public int addResRefBindings(ResRefBindingsType value) {
150         int positionOfNewItem = this.addValue(RES_REF_BINDINGS, value);
151         return positionOfNewItem;
152     }
153     
154     public int removeResRefBindings(ResRefBindingsType value) {
155         return this.removeValue(RES_REF_BINDINGS, value);
156     }
157     
158 // functions for manupulation ResEnvRefBindings
159
public void setResEnvRefBindings(int index,ResEnvRefBindingsType value) {
160         this.setValue(RES_ENV_REF_BINDINGS, index,value);
161     }
162     
163     public void setResEnvRefBindings(ResEnvRefBindingsType[]value) {
164         this.setValue(RES_ENV_REF_BINDINGS, value);
165     }
166     
167     public ResEnvRefBindingsType[] getResEnvRefBindings() {
168         return (ResEnvRefBindingsType[]) this.getValues(RES_ENV_REF_BINDINGS);
169     }
170     public ResEnvRefBindingsType getResEnvRefBindings(int index) {
171         return (ResEnvRefBindingsType)this.getValue(RES_ENV_REF_BINDINGS,index);
172     }
173     public int sizeResEnvRefBindings() {
174         return this.size(RES_ENV_REF_BINDINGS);
175     }
176     public int addResEnvRefBindings(ResEnvRefBindingsType value) {
177         int positionOfNewItem = this.addValue(RES_ENV_REF_BINDINGS, value);
178         return positionOfNewItem;
179     }
180     
181     public int removeResEnvRefBindings(ResEnvRefBindingsType value) {
182         return this.removeValue(RES_ENV_REF_BINDINGS, value);
183     }
184     
185     // functions for manupulation EjbRefBindings
186
public void setEjbRefBindings(int index,EjbRefBindingsType value) {
187         this.setValue(EJB_REF_BINDINGS, index,value);
188     }
189     
190     public void setEjbRefBindings(EjbRefBindingsType[]value) {
191         this.setValue(EJB_REF_BINDINGS, value);
192     }
193     
194     public EjbRefBindingsType[] getEjbRefBindings() {
195         return (EjbRefBindingsType[]) this.getValues(EJB_REF_BINDINGS);
196     }
197     public EjbRefBindingsType getEjbRefBindings(int index) {
198         return (EjbRefBindingsType)this.getValue(EJB_REF_BINDINGS,index);
199     }
200     public int sizeEjbRefBindings() {
201         return this.size(EJB_REF_BINDINGS);
202     }
203     public int addEjbRefBindings(EjbRefBindingsType value) {
204         int positionOfNewItem = this.addValue(EJB_REF_BINDINGS, value);
205         return positionOfNewItem;
206     }
207     
208     public int removeEjbRefBindings(EjbRefBindingsType value) {
209         return this.removeValue(EJB_REF_BINDINGS, value);
210     }
211     
212     public int addReferenceBinding(CommonRef reference){
213         if(reference instanceof ResRefBindingsType) {
214             return addResRefBindings((ResRefBindingsType)reference);
215         } else if(reference instanceof ResEnvRefBindingsType) {
216             return addResEnvRefBindings((ResEnvRefBindingsType)reference);
217         } else if(reference instanceof EjbRefBindingsType) {
218             return addEjbRefBindings((EjbRefBindingsType)reference);
219         }
220         else return 0;
221     }
222     public int removeReferenceBinding(CommonRef reference){
223         if(reference instanceof ResRefBindingsType) {
224             return removeResRefBindings((ResRefBindingsType)reference);
225         } else if(reference instanceof ResEnvRefBindingsType) {
226             return removeResEnvRefBindings((ResEnvRefBindingsType)reference);
227         } else if(reference instanceof EjbRefBindingsType) {
228             return removeEjbRefBindings((EjbRefBindingsType)reference);
229         }
230         else return 0;
231     }
232     
233     public void setCmpConnectionFactory(String JavaDoc value) {
234         this.setValue(CMP_CONNECTION_FACTORY,value);
235     }
236     public String JavaDoc getCmpConnectionFactory() {
237         return (String JavaDoc)this.getValue(CMP_CONNECTION_FACTORY);
238     }
239     public void setCmpConnectionFactoryXmiId(String JavaDoc value) {
240         if(size(CMP_CONNECTION_FACTORY)==0) {
241             setCmpConnectionFactory("");
242         }
243         this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_XMI_ID,value);
244     }
245     public String JavaDoc getCmpConnectionFactoryXmiId() {
246         if(size(CMP_CONNECTION_FACTORY)==0) {
247             return null;
248         }
249         return (String JavaDoc) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_XMI_ID);
250     }
251     public void setCmpConnectionFactoryJndiName(String JavaDoc value) {
252         if(size(CMP_CONNECTION_FACTORY)==0) {
253             setCmpConnectionFactory("");
254         }
255         this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_JNDI_NAME,value);
256     }
257     public String JavaDoc getCmpConnectionFactoryJndiName() {
258         if(size(CMP_CONNECTION_FACTORY)==0) {
259             return null;
260         }
261         return (String JavaDoc) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_JNDI_NAME);
262     }
263     public void setCmpConnectionFactoryResAuth(String JavaDoc value) {
264         if(size(CMP_CONNECTION_FACTORY)==0) {
265             setCmpConnectionFactory("");
266         }
267         this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_RES_AUTH,value);
268     }
269     public String JavaDoc getCmpConnectionFactoryResAuth() {
270         if(size(CMP_CONNECTION_FACTORY)==0) {
271             return null;
272         }
273         return (String JavaDoc) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_RES_AUTH);
274     }
275     
276     
277     //
278
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
279         comparators.add(c);
280     }
281     
282     //
283
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
284         comparators.remove(c);
285     }
286     
287     public void setHref(java.lang.String JavaDoc value) {
288         setAttributeValue(ENTERPRISE_BEAN, ENTERPRISE_BEAN_HREF,DDXmi.addEjbJarHrefToId(value));
289     }
290     
291     public String JavaDoc getHref() {
292         return DDXmi.getIdFromHref((String JavaDoc)getAttributeValue(ENTERPRISE_BEAN, ENTERPRISE_BEAN_HREF));
293     }
294     
295     public void setXmiType(java.lang.String JavaDoc value) {
296         setAttributeValue(ENTERPRISE_BEAN, ENTERPRISE_BEAN_TYPE,value);
297     }
298     
299     public String JavaDoc getXmiType() {
300         return (String JavaDoc)getAttributeValue(ENTERPRISE_BEAN, ENTERPRISE_BEAN_TYPE);
301     }
302     
303     
304     
305     
306     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
307         
308         if(getEnterpriseBean()==null) {
309             throw new org.netbeans.modules.schema2beans.ValidateException("getEnterpriseBean() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "EnterpriseBean", this); // NOI18N
310
}
311         if(getHref()==null) {
312             throw new org.netbeans.modules.schema2beans.ValidateException("getHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "EnterpriseBean", this); // NOI18N
313
}
314         if(getXmiType()==null) {
315             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiType() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "EnterpriseBean", this); // NOI18N
316
}
317         if(getXmiType()!=EJB_ENTERPRISE_BEAN_TYPE_SESSION) {
318             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiType()!= ejb:Session", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "EnterpriseBean", this); // NOI18N
319
}
320     }
321     // Dump the content of this bean returning it as a String
322
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
323         String JavaDoc s;
324         Object JavaDoc o;
325         org.netbeans.modules.schema2beans.BaseBean n;
326         str.append(indent);
327         str.append("EnterpriseBean"); // NOI18N
328
str.append(indent+"\t"); // NOI18N
329
str.append("<"); // NOI18N
330
o = this.getEnterpriseBean();
331         str.append((o==null?"null":o.toString().trim())); // NOI18N
332
str.append(">\n"); // NOI18N
333
this.dumpAttributes(ENTERPRISE_BEAN, 0, str, indent);
334         
335         
336     }
337     public String JavaDoc dumpBeanNode(){
338         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
339         str.append(getClass().getName()); // NOI18N
340
this.dump(str, "\n "); // NOI18N
341
return str.toString();
342     }
343 }
344
Popular Tags