You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@locus.apache.org on 2000/11/25 21:36:00 UTC
cvs commit: xml-soap/java/src/org/apache/soap/server DeploymentDescriptor.java
dug 00/11/25 12:36:00
Modified: java/src/org/apache/soap/server DeploymentDescriptor.java
Log:
Fixed a bug found by Wouter - 'props' might be null.
Revision Changes Path
1.13 +72 -71 xml-soap/java/src/org/apache/soap/server/DeploymentDescriptor.java
Index: DeploymentDescriptor.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/DeploymentDescriptor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DeploymentDescriptor.java 2000/11/08 12:58:22 1.12
+++ DeploymentDescriptor.java 2000/11/25 20:36:00 1.13
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -115,7 +115,7 @@
/**
* ID of this service.
*/
-
+
public void setID (String id) {
this.id = id;
}
@@ -126,7 +126,7 @@
/**
* Type of the service: message or procedural service. Defaults to being
- * a procedural service. The difference is that if its procedural then
+ * a procedural service. The difference is that if its procedural then
* the methods are invoked by decoding the children of the first body
* element as being parameters of the method call. If its message-oriented,
* then no decoding is done and the method is invoked giving the envelope
@@ -141,7 +141,7 @@
}
/**
- * Lifecyle of the object providing the service.
+ * Lifecyle of the object providing the service.
*/
public void setScope (int scope) {
this.scope = scope;
@@ -158,7 +158,7 @@
public String getDefaultSMRClass() {
return defaultSMRClass;
}
-
+
/**
* Methods provided by the service.
*/
@@ -171,7 +171,7 @@
}
/**
- * Type of provider.
+ * Type of provider.
*/
public void setProviderType (byte providerType) {
this.providerType = providerType;
@@ -240,7 +240,7 @@
/**
* Type mappings between XML types of certain encodings and
- * Java types.
+ * Java types.
*
* @param map the structure containing the mapping info
*/
@@ -274,31 +274,31 @@
public SOAPFaultRouter buildFaultRouter() {
- if (fr != null) return fr;
-
- fr = new SOAPFaultRouter();
+ if (fr != null) return fr;
+
+ fr = new SOAPFaultRouter();
- if (faultListener == null) return fr;
+ if (faultListener == null) return fr;
- SOAPFaultListener[] lis = new SOAPFaultListener[faultListener.length];
- try {
- for (int i = 0; i< faultListener.length; lis[i] = (SOAPFaultListener)Class.forName(faultListener[i]).newInstance(), i++);
- }
- catch (Exception e) {}
+ SOAPFaultListener[] lis = new SOAPFaultListener[faultListener.length];
+ try {
+ for (int i = 0; i< faultListener.length; lis[i] = (SOAPFaultListener)Class.forName(faultListener[i]).newInstance(), i++);
+ }
+ catch (Exception e) {}
- fr.setFaultListener(lis);
- return fr;
+ fr.setFaultListener(lis);
+ return fr;
}
/**
- * Write out the deployment descriptor according to the
+ * Write out the deployment descriptor according to the
* the deployment descriptor DTD.
*/
public void toXML (Writer pr) {
PrintWriter pw = new PrintWriter (pr);
-
+
pw.println ("<isd:service xmlns:isd=\"" +
- Constants.NS_URI_XML_SOAP_DEPLOYMENT + "\" id=\"" + id +
+ Constants.NS_URI_XML_SOAP_DEPLOYMENT + "\" id=\"" + id +
(serviceType != SERVICE_TYPE_RPC ? " type=\"message" : "") +
"\">");
@@ -306,14 +306,14 @@
String[] scopes = {"Request", "Session", "Application"};
String providerString = null ;
- if ( pt == DeploymentDescriptor.PROVIDER_JAVA )
+ if ( pt == DeploymentDescriptor.PROVIDER_JAVA )
providerString = "java" ;
else if ( pt == DeploymentDescriptor.PROVIDER_USER_DEFINED )
providerString = serviceClass ;
else
providerString = "script" ;
- pw.print (" <isd:provider type=\"" + providerString +
+ pw.print (" <isd:provider type=\"" + providerString +
"\" scope=\"" + scopes[scope] + "\" methods=\"");
for (int i = 0; i < methods.length; i++) {
pw.print (methods[i]);
@@ -343,22 +343,23 @@
"\" static=\"" + (isStatic ? "true" : "false") + "\"/>");
}
- for ( Enumeration e = props.keys() ; e.hasMoreElements(); ) {
- String key = (String) e.nextElement() ;
- String value = (String) props.get(key);
- pw.println(" <isd:option key=\"" + key + "\" value=\"" +
- value + "\" />" );
- }
+ if ( props != null )
+ for ( Enumeration e = props.keys() ; e.hasMoreElements(); ) {
+ String key = (String) e.nextElement() ;
+ String value = (String) props.get(key);
+ pw.println(" <isd:option key=\"" + key + "\" value=\"" +
+ value + "\" />" );
+ }
pw.println (" </isd:provider>");
- if (faultListener != null) {
- for (int i = 0; i < faultListener.length; i++) {
- pw.println("<isd:faultListener>");
- pw.println(faultListener[i]);
- pw.println("</isd:faultListener>");
- }
- }
+ if (faultListener != null) {
+ for (int i = 0; i < faultListener.length; i++) {
+ pw.println("<isd:faultListener>");
+ pw.println(faultListener[i]);
+ pw.println("</isd:faultListener>");
+ }
+ }
if (mappings != null) {
pw.println (" <isd:mappings");
@@ -367,7 +368,7 @@
} else {
pw.print(">");
}
-
+
for (int i = 0; i < mappings.length; i++) {
TypeMapping tm = mappings[i];
pw.print (" <isd:map encodingStyle=\"" + tm.encodingStyle +
@@ -406,7 +407,7 @@
DeploymentDescriptor dd = new DeploymentDescriptor ();
NodeList nl;
Element e;
-
+
String id = DOMUtils.getAttribute (root, "id");
if (id == null) {
throw new IllegalArgumentException ("required 'id' attribute " +
@@ -446,7 +447,7 @@
"or methods attribute in provider " +
"element of deployment descriptor");
}
-
+
int scope = -1;
String[] methods;
@@ -506,7 +507,7 @@
dd.setServiceClass (typeStr);
Element saved_E = e ;
- nl = e.getElementsByTagNameNS(Constants.NS_URI_XML_SOAP_DEPLOYMENT,
+ nl = e.getElementsByTagNameNS(Constants.NS_URI_XML_SOAP_DEPLOYMENT,
"option" );
for ( int i = 0 ; nl != null && i < nl.getLength() ; i++ ) {
String key, value ;
@@ -516,11 +517,11 @@
value = DOMUtils.getAttribute( e, "value" );
if ( key == null || key.equals("") )
- throw new IllegalArgumentException("Missing 'key' attribute on " +
- "'option' element in deployment " +
- "desriptor" );
- if ( dd.props == null ) dd.props = new Hashtable();
- dd.props.put( key, value );
+ throw new IllegalArgumentException("Missing 'key' attribute on " +
+ "'option' element in deployment " +
+ "desriptor" );
+ if ( dd.props == null ) dd.props = new Hashtable();
+ dd.props.put( key, value );
}
// Support old 'java' tag
@@ -574,24 +575,24 @@
methods[i] = st.nextToken ();
}
dd.setMethods (methods);
-
+
- //read the fault listeners
+ //read the fault listeners
nl = root.getElementsByTagNameNS (Constants.NS_URI_XML_SOAP_DEPLOYMENT,
"faultListener");
- String[] lis = new String[nl.getLength()];
+ String[] lis = new String[nl.getLength()];
- try {
- for (int i = 0; i < nl.getLength(); i++) {
- Class.forName(DOMUtils.getChildCharacterData((Element)nl.item(i))).newInstance();
- lis[i] = DOMUtils.getChildCharacterData((Element)nl.item(i));
- }
- }
- catch (Exception ex) {
- throw new IllegalArgumentException(ex.getMessage());
- }
+ try {
+ for (int i = 0; i < nl.getLength(); i++) {
+ Class.forName(DOMUtils.getChildCharacterData((Element)nl.item(i))).newInstance();
+ lis[i] = DOMUtils.getChildCharacterData((Element)nl.item(i));
+ }
+ }
+ catch (Exception ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
- dd.setFaultListener(lis);
+ dd.setFaultListener(lis);
// read the type mappings
nl = root.getElementsByTagNameNS (Constants.NS_URI_XML_SOAP_DEPLOYMENT,
@@ -602,12 +603,12 @@
}
if (nl.getLength () == 1) {
e = (Element) nl.item (0);
-
+
String className = e.getAttribute("defaultRegistryClass");
if (className != "") {
dd.setDefaultSMRClass(className);
}
-
+
nl = e.getElementsByTagNameNS (Constants.NS_URI_XML_SOAP_DEPLOYMENT,
"map");
int nmaps = nl.getLength ();
@@ -615,13 +616,13 @@
TypeMapping[] tms = new TypeMapping[nmaps];
dd.setMappings (tms);
for (int i = 0; i < nmaps; i++) {
- e = (Element) nl.item (i);
+ e = (Element) nl.item (i);
String qnameQname = DOMUtils.getAttribute (e, "qname");
int pos = qnameQname.indexOf (':');
String prefix = qnameQname.substring (0, pos);
String localPart = qnameQname.substring (pos+1);
String nsURI = DOMUtils.getNamespaceURIFromPrefix (e, prefix);
- tms[i] =
+ tms[i] =
new TypeMapping (DOMUtils.getAttribute (e, "encodingStyle"),
new QName (nsURI, localPart),
DOMUtils.getAttribute (e, "javaType"),
@@ -660,17 +661,17 @@
body += "', static='" + isStatic + "', ";
}
- StringBuffer lis = new StringBuffer("[");
- if (faultListener != null) for (int i = 0; i < faultListener.length; lis.append(faultListener[i]), lis.append(" "), i++);
- lis.append("]");
- return header + body + "methods='" + methodsStrbuf + "', " + "faultListener='" + lis + "', " +
+ StringBuffer lis = new StringBuffer("[");
+ if (faultListener != null) for (int i = 0; i < faultListener.length; lis.append(faultListener[i]), lis.append(" "), i++);
+ lis.append("]");
+ return header + body + "methods='" + methodsStrbuf + "', " + "faultListener='" + lis + "', " +
"mappings='" + mappings + "]";
}
/**
* Utility to generate an XML serialization registry from all the
* type mappings registered into a deployment descriptor.
- *
+ *
* @param dd the deployment descriptor
* @return the xml serialization registry
*/
@@ -718,7 +719,7 @@
}
smr.mapTypes (tm.encodingStyle, tm.elementType, javaType, s, d);
} catch (Exception e2) {
- String m = "deployment error in SOAP service '" + dd.getID () +
+ String m = "deployment error in SOAP service '" + dd.getID () +
"': ";
if (step == 0) {
m += "class name '" + tm.javaType + "' could not be resolved: ";