KickJava   Java API By Example, From Geeks To Geeks.

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


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  * WS70ExternalResourceBean.java
22  */

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

36 public class WS70ExternalResourceBean extends WS70BaseResourceBean implements java.io.Serializable JavaDoc{
37     
38     private String JavaDoc externalJndiName;
39     private String JavaDoc resType;
40     private String JavaDoc factoryClass;
41     
42     /**
43      * Creates a new instance of WS70ExternalResourceBean
44      */

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