KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > beans > WS70CustomResourceBean


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
20 /*
21  * WS70CustomResourceBean.java
22  *
23  */

24
25 package org.netbeans.modules.j2ee.sun.ws7.serverresources.beans;
26 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70CustomResource;
27 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70Resources;
28 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.PropertyElement;
29
30 import java.util.Vector JavaDoc;
31 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair;
32
33
34 /**
35  *
36  * @author Administrator
37  */

38 public class WS70CustomResourceBean extends WS70BaseResourceBean implements java.io.Serializable JavaDoc{
39     
40     private String JavaDoc resType;
41     private String JavaDoc factoryClass;
42     
43     
44     /** Creates a new instance of WS70CustomResourceBean */
45     public WS70CustomResourceBean() {
46     }
47     public String JavaDoc getResType() {
48         return resType;
49     }
50     public void setResType(String JavaDoc value) {
51         String JavaDoc oldValue = resType;
52         this.resType = value;
53         initPropertyChangeSupport();
54         propertySupport.firePropertyChange ("resType", oldValue, resType);//NOI18N
55
}
56     public String JavaDoc getFactoryClass() {
57         return factoryClass;
58     }
59     public void setFactoryClass(String JavaDoc value) {
60         String JavaDoc oldValue = factoryClass;
61         this.factoryClass = value;
62         initPropertyChangeSupport();
63         propertySupport.firePropertyChange ("factoryClass", oldValue, factoryClass);//NOI18N
64
}
65
66
67     public static WS70CustomResourceBean createBean(WS70CustomResource customresource) {
68         WS70CustomResourceBean bean = new WS70CustomResourceBean();
69         //name attribute in bean is for studio display purpose.
70
//It is not part of the custom-resource dtd.
71
bean.setName(customresource.getJndiName());
72         bean.setDescription(customresource.getDescription());
73         bean.setJndiName(customresource.getJndiName());
74         bean.setFactoryClass(customresource.getFactoryClass());
75         bean.setResType(customresource.getResType());
76         bean.setIsEnabled(customresource.getEnabled());
77            
78         PropertyElement[] extraProperties = customresource.getPropertyElement();
79         Vector JavaDoc vec = new Vector JavaDoc();
80         for (int i = 0; i < extraProperties.length; i++) {
81             NameValuePair pair = new NameValuePair();
82             pair.setParamName(extraProperties[i].getName());
83             pair.setParamValue(extraProperties[i].getValue());
84             vec.add(pair);
85         }
86         
87         if (vec != null && vec.size() > 0) {
88             NameValuePair[] props = new NameValuePair[vec.size()];
89             bean.setExtraParams((NameValuePair[])vec.toArray(props));
90         }
91         
92         return bean;
93     }
94     
95     public WS70Resources getGraph(){
96         WS70Resources res = getResourceGraph();
97         WS70CustomResource customresource = res.newWS70CustomResource();
98         customresource.setDescription(getDescription());
99         customresource.setJndiName(getJndiName());
100         
101         customresource.setResType(getResType());
102         customresource.setFactoryClass(getFactoryClass());
103         customresource.setEnabled(getIsEnabled());
104         
105         // set properties
106
NameValuePair[] params = getExtraParams();
107         if (params != null && params.length > 0) {
108             for (int i = 0; i < params.length; i++) {
109                 NameValuePair pair = params[i];
110                 PropertyElement prop = customresource.newPropertyElement();
111                 prop = populatePropertyElement(prop, pair);
112                 customresource.addPropertyElement(prop);
113             }
114         }
115         
116         res.addWS70CustomResource(customresource);
117         return res;
118     }
119     
120 }
121
Popular Tags