KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > ServiceRefPortInfoRuntimeNode


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 package com.sun.enterprise.deployment.node.runtime;
24
25 import java.util.Map JavaDoc;
26 import java.util.Set JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30
31 import javax.xml.namespace.QName JavaDoc;
32 import com.sun.enterprise.deployment.node.XMLElement;
33 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
34 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
35 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
36 import com.sun.enterprise.deployment.ServiceRefPortInfo;
37 import com.sun.enterprise.deployment.NameValuePairDescriptor;
38 import com.sun.enterprise.deployment.node.NameValuePairNode;
39 import com.sun.enterprise.deployment.node.runtime.common.MessageSecurityBindingNode;
40 import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor;
41
42 import com.sun.enterprise.deployment.util.DOLUtils;
43
44 /**
45  * This node is responsible for handling runtime info for
46  * a service reference wsdl port.
47  *
48  * @author Kenneth Saks
49  * @version
50  */

51 public class ServiceRefPortInfoRuntimeNode extends DeploymentDescriptorNode {
52
53     private String JavaDoc namespaceUri;
54
55     public ServiceRefPortInfoRuntimeNode() {
56         super();
57         registerElementHandler
58             (new XMLElement(WebServicesTagNames.STUB_PROPERTY),
59              NameValuePairNode.class, "addStubProperty");
60         registerElementHandler
61             (new XMLElement(WebServicesTagNames.CALL_PROPERTY),
62              NameValuePairNode.class, "addCallProperty");
63         registerElementHandler(new XMLElement(WebServicesTagNames.MESSAGE_SECURITY_BINDING), MessageSecurityBindingNode.class, "setMessageSecurityBinding");
64     }
65
66     /**
67      * all sub-implementation of this class can use a dispatch table to map xml element to
68      * method name on the descriptor class for setting the element value.
69      *
70      * @return the map with the element name as a key, the setter method as a value
71      */

72     protected Map JavaDoc getDispatchTable() {
73         Map JavaDoc table = super.getDispatchTable();
74         table.put(WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE,
75                   "setServiceEndpointInterface");
76         return table;
77     }
78     
79     /**
80      * receives notiification of the value for a particular tag
81      *
82      * @param element the xml element
83      * @param value it's associated value
84      */

85
86     public void setElementValue(XMLElement element, String JavaDoc value) {
87         String JavaDoc name = element.getQName();
88         if (WebServicesTagNames.NAMESPACE_URI.equals(name)) {
89             namespaceUri = value;
90         } else if (WebServicesTagNames.LOCAL_PART.equals(name)) {
91             ServiceRefPortInfo desc = (ServiceRefPortInfo)
92                 getDescriptor();
93             QName JavaDoc wsdlPort = new QName JavaDoc(namespaceUri, value);
94             desc.setWsdlPort(wsdlPort);
95             namespaceUri = null;
96         } else super.setElementValue(element, value);
97         
98     }
99     
100     /**
101      * write the descriptor class to a DOM tree and return it
102      *
103      * @param parent node for the DOM tree
104      * @param node name for the descriptor
105      * @param the descriptor to write
106      * @return the DOM tree top node
107      */

108     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
109                                 ServiceRefPortInfo desc) {
110         Node JavaDoc serviceRefPortInfoRuntimeNode =
111             super.writeDescriptor(parent, nodeName, desc);
112
113         appendTextChild(serviceRefPortInfoRuntimeNode,
114                         WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE,
115                         desc.getServiceEndpointInterface());
116
117         QName JavaDoc port = desc.getWsdlPort();
118
119         if( port != null ) {
120             Node JavaDoc wsdlPortNode = appendChild(serviceRefPortInfoRuntimeNode,
121                                             WebServicesTagNames.WSDL_PORT);
122             appendTextChild(wsdlPortNode,
123                             WebServicesTagNames.NAMESPACE_URI,
124                             port.getNamespaceURI());
125             appendTextChild(wsdlPortNode,
126                             WebServicesTagNames.LOCAL_PART,
127                             port.getLocalPart());
128         }
129
130         // stub-property*
131

132         NameValuePairNode nameValueNode = new NameValuePairNode();
133
134         Set JavaDoc stubProperties = desc.getStubProperties();
135         for(Iterator JavaDoc iter = stubProperties.iterator(); iter.hasNext();) {
136             NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next();
137             nameValueNode.writeDescriptor
138                 (serviceRefPortInfoRuntimeNode,
139                  WebServicesTagNames.STUB_PROPERTY, next);
140         }
141
142         // call-property*
143
for(Iterator JavaDoc iter = desc.getCallProperties().iterator();
144             iter.hasNext();) {
145             NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next();
146             nameValueNode.writeDescriptor
147                 (serviceRefPortInfoRuntimeNode,
148                  WebServicesTagNames.CALL_PROPERTY, next);
149         }
150
151         // message-security-binding
152
MessageSecurityBindingDescriptor messageSecBindingDesc =
153             desc.getMessageSecurityBinding();
154         if (messageSecBindingDesc != null) {
155             MessageSecurityBindingNode messageSecBindingNode =
156                 new MessageSecurityBindingNode();
157             messageSecBindingNode.writeDescriptor(serviceRefPortInfoRuntimeNode, WebServicesTagNames.MESSAGE_SECURITY_BINDING, messageSecBindingDesc);
158         }
159
160         return serviceRefPortInfoRuntimeNode;
161     }
162     
163 }
164
Popular Tags