KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > JaxrpcMappingDescriptorNode


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 package com.sun.enterprise.deployment.node;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.logging.Level JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33
34 import org.xml.sax.Attributes JavaDoc;
35 import org.w3c.dom.Node JavaDoc;
36 import org.w3c.dom.Document JavaDoc;
37
38 import java.io.IOException JavaDoc;
39 import java.io.InputStream JavaDoc;
40
41 import com.sun.enterprise.deployment.Descriptor;
42 import com.sun.enterprise.deployment.JaxrpcMappingDescriptor;
43 import com.sun.enterprise.deployment.node.XMLElement;
44 import com.sun.enterprise.deployment.node.BundleNode;
45 import com.sun.enterprise.deployment.node.RootXMLNode;
46 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
47 import com.sun.enterprise.deployment.util.DOLUtils;
48
49 /**
50  * Root node for jaxrpc mapping deployment descriptor
51  *
52  * @author Kenneth Saks
53  * @version
54  */

55 public class JaxrpcMappingDescriptorNode extends BundleNode
56     implements RootXMLNode
57                                     
58 {
59
60     public final static XMLElement ROOT_ELEMENT =
61         new XMLElement(WebServicesTagNames.JAXRPC_MAPPING_FILE_ROOT);
62
63     public final static String JavaDoc SCHEMA_ID = "j2ee_jaxrpc_mapping_1_1.xsd";
64     private static List JavaDoc<String JavaDoc> systemIDs = null;
65
66     private static final Set JavaDoc complexElements;
67     private JaxrpcMappingDescriptor descriptor=null;
68     private String JavaDoc javaPackage=null;
69     
70     // true if mapping file contains more than just package->namespace mappings.
71
private boolean complexMapping=false;
72
73     static {
74         complexElements = new HashSet JavaDoc();
75         complexElements.add(WebServicesTagNames.JAVA_XML_TYPE_MAPPING);
76         complexElements.add(WebServicesTagNames.EXCEPTION_MAPPING);
77         complexElements.add(WebServicesTagNames.SERVICE_INTERFACE_MAPPING);
78         complexElements.add
79             (WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE_MAPPING);
80     }
81
82     public JaxrpcMappingDescriptorNode() {
83         descriptor = new JaxrpcMappingDescriptor();
84     }
85
86     /**
87      * @return the XML tag associated with this XMLNode
88      */

89     protected XMLElement getXMLRootTag() {
90         return ROOT_ELEMENT;
91     }
92
93     /**
94      * @return the DOCTYPE of the XML file
95      */

96     public String JavaDoc getDocType() {
97         return null;
98     }
99     
100     /**
101      * @return the SystemID of the XML file
102      */

103     public String JavaDoc getSystemID() {
104         return SCHEMA_ID;
105     }
106
107     /**
108      * @return the list of SystemID of the XML schema supported
109      */

110     public List JavaDoc<String JavaDoc> getSystemIDs() {
111         if (systemIDs != null) {
112             return systemIDs;
113         }
114
115         systemIDs = new ArrayList JavaDoc<String JavaDoc>();
116         systemIDs.add(SCHEMA_ID);
117         return systemIDs;
118     }
119
120         /**
121      * @return the complete URL for J2EE schemas
122      */

123     protected String JavaDoc getSchemaURL() {
124        return WebServicesTagNames.IBM_NAMESPACE + "/" + getSystemID();
125     }
126     
127    /**
128     * @return the descriptor instance to associate with this XMLNode
129     */

130     public Object JavaDoc getDescriptor() {
131         return descriptor;
132     }
133
134     public void startElement(XMLElement element, Attributes JavaDoc attributes) {
135         if( complexMapping ) {
136             // NOTE : we don't call super.startElement in this case because
137
// we don't need to process any of the attributes
138
return;
139         } else if( complexElements.contains(element.getQName()) ) {
140             complexMapping = true;
141             descriptor.setIsSimpleMapping(false);
142             // NOTE : we don't call super.startElement in this case because
143
// we don't need to process any of the attributes
144
} else {
145             super.startElement(element, attributes);
146         }
147     }
148          
149     /**
150      * receives notiification of the value for a particular tag
151      *
152      * @param element the xml element
153      * @param value it's associated value
154      */

155     public void setElementValue(XMLElement element, String JavaDoc value) {
156         if (complexMapping) {
157             // We only gather namespace->package mapping. In exhaustive(complex)
158
// mapping case, it's enough to just capture the fact that we
159
// have complex mapping info. The actual processing of the elements
160
// will be done by mapping file modeler during deployment
161
return;
162         } else if(WebServicesTagNames.PACKAGE_TYPE.equals(element.getQName())) {
163             javaPackage = value;
164         } else if(WebServicesTagNames.NAMESPACE_URI.equals(element.getQName())){
165             descriptor.addMapping(javaPackage, value);
166             javaPackage = null;
167         } else {
168             super.setElementValue(element, value);
169         }
170     }
171
172     /**
173      * @return the default spec version level this node complies to
174      */

175     public String JavaDoc getSpecVersion() {
176         return "1.1";
177     }
178
179     
180 }
181
Popular Tags