User: jung
Date: 01/01/03 05:54:30
Modified: src/org/zoap/soap/meta/builtin/string DefaultBinding.java
Log:
exception redesign. Improved null-pointer treatment. coherent environment and
logging facilities.
LGPL references.
Revision Changes Path
1.3 +152 -185 zoap/src/org/zoap/soap/meta/builtin/string/DefaultBinding.java
Index: DefaultBinding.java
===================================================================
RCS file:
/products/cvs/ejboss/zoap/src/org/zoap/soap/meta/builtin/string/DefaultBinding.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultBinding.java 2000/12/04 12:36:13 1.2
+++ DefaultBinding.java 2001/01/03 13:54:29 1.3
@@ -1,47 +1,25 @@
-/*
- * $Id: DefaultBinding.java,v 1.2 2000/12/04 12:36:13 jung Exp $
- * Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
- * D-66299 Friedrichsthal, Germany. All Rights Reserved.
+/*
+ * $Source:
/products/cvs/ejboss/zoap/src/org/zoap/soap/meta/builtin/string/DefaultBinding.java,v $
+ * The Zero-effort Object Access Package is a library to support XML/SOAP
serialisation and invocation.
+ * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
+ * D-66299 Friedrichsthal, Germany. All Rights Reserved.
*
- * License Statement
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * Redistribution and use of this software and associated documentation
("Software"), with or without
- * modification, are permitted provided that the following conditions are met:
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * 1. Redistributions of source code must retain copyright statements and
notices.
- * Redistributions must also contain a copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the attached copyright
notice, this list of
- * conditions and the following disclaimer in the documentation and/or
other materials provided
- * with the distribution.
- *
- * 3. The end-user documentation included with the redistribution, if any,
must include the following
- * acknowledgment: "This product includes software developed by infor:
business solutions AG
- * (http://www.infor.de/)." Alternately, this acknowledgment may appear
in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The name "infor" must not be used to endorse or promote products
derived from this
- * Software without prior written permission of infor: business solutions
AG.
- * For written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this Software may not be called "infor" nor may
"infor" appear
- * in their names without prior written permission of infor: business
solutions AG. infor
- * is a registered trademark of infor:business solutions AG.
- *
- * Disclaimer
- *
- * THIS SOFTWARE IS PROVIDED BY INFOR: BUSINESS SOLUTIONS AG AND CONTRIBUTORS "AS
IS" AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- *
- * IN NO EVENT SHALL INFOR: BUSINESS SOLUTIONS AG OR ITS CONTRIBUTORS BE LIABLE
FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
package org.zoap.soap.meta.builtin.string;
import org.zoap.soap.Environment;
@@ -75,230 +53,210 @@
/**
* SoapBinding overrides the default databinding of infor:XML to introduce
SOAP-related
- * schemas, elements, attributes and types.
- * <br>
+ * schemas, elements, attributes and types. <br>
* @see <related>
* @author $Author: jung $
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class DefaultBinding extends SoapBinding {
- private org.zoap.xml.meta.builtin.DefaultBinding objectBinding;
+ private org.zoap.xml.meta.builtin.DefaultBinding objectBinding;
- /** register the additional soap schema which overrides some defaults */
- public DefaultBinding() {
+ /** register the additional soap schema which overrides some defaults */
+ public DefaultBinding() {
- if(Environment.DEBUG_SOAP && Environment.DEBUG_SOAP_META)
- Environment.out.print(toString()+"()\n");
- }
-
- /**
- * looks up a @return Schema by its @arg urn. Here, the SOAP schema and
- * the default schemas.
- * @clientRole *
- * @supplierRole 1
- * @directed
- * @link association
- * @label registeredSchema
- */
+
+ }
+
+ /**
+ * looks up a @return Schema by its @arg urn. Here, the SOAP schema and the
default schemas.
+ * @clientRole *
+ * @supplierRole 1
+ * @directed
+ * @link association
+ * @label registeredSchema
+ */
+
/*#SoapSchema soapSchema;*/
+
+ public Schema getSchema(URN urn) {
- public Schema getSchema(URN urn) {
- if(Environment.DEBUG_SOAP && Environment.DEBUG_SOAP_META)
- Environment.out.print(toString()+".getSchema("+urn+")\n");
- Schema result=super.getSchema(urn);
+ Schema result = super.getSchema(urn);
- if(result==null) {
+ if (result == null) {
- try{
- Class forClass=
- Environment.getClassForUrn(urn);
+ try {
+ Class forClass =
+ Environment.getClassForUrn(urn);
- return getInterfaceSchema(forClass);
- } catch(ClassNotFoundException e) {
+ return getInterfaceSchema(forClass);
+ } catch (ClassNotFoundException e) {
- if(objectBinding==null)
- objectBinding=new org.zoap.xml.meta.builtin.DefaultBinding();
+ if (objectBinding == null)
+ objectBinding = new
org.zoap.xml.meta.builtin.DefaultBinding();
- return objectBinding.getSchema(urn);
- }
- } else
- return result;
- }
+ return objectBinding.getSchema(urn);
+ }
+ } else
+ return result;
+ }
- /**
- * method to lookup a @return Element in the registered schemas
- * whose type complies to the given Java @arg object. Since SOAP must
- * always use a non-empty envelope, this is quite straightforward.
- */
+ /**
+ * method to lookup a @return Element in the registered schemas
+ * whose type complies to the given Java @arg object. Since SOAP must
+ * always use a non-empty envelope, this is quite straightforward.
+ */
- public Element findElementCompatibleTo(Object object, Class clazz) {
+ public Element findElementCompatibleTo(Object object, Class clazz) {
- if(Environment.DEBUG_SOAP && Environment.DEBUG_SOAP_META)
-
Environment.out.println(toString()+".findElementCompatibleTo("+object+","+clazz+")");
- Element result=super.findElementCompatibleTo(object,clazz);
- if(result==null) {
+ Element result = super.findElementCompatibleTo(object, clazz);
- if(object instanceof MethodRequest) {
+ if (result == null) {
- return getInterfaceSchema(((MethodRequest)
object).getMethod().getDeclaringClass()).
- findElementCompatibleTo(object,MethodRequest.class);
+ if (object instanceof MethodRequest) {
- } else if(object instanceof MethodResponse) {
+ return
getInterfaceSchema(((MethodRequest)object).getMethod().getDeclaringClass()).
+ findElementCompatibleTo(object, MethodRequest.class);
- return getInterfaceSchema(((MethodResponse)
object).getMethod().getDeclaringClass()).
- findElementCompatibleTo(object,MethodResponse.class);
+ } else if (object instanceof MethodResponse) {
- } else {
+ return
getInterfaceSchema(((MethodResponse)object).getMethod().getDeclaringClass()).
+ findElementCompatibleTo(object, MethodResponse.class);
- if(objectBinding==null)
- objectBinding=new org.zoap.xml.meta.builtin.DefaultBinding();
+ } else {
- return objectBinding.findElementCompatibleTo(object,clazz);
+ if (objectBinding == null)
+ objectBinding = new
org.zoap.xml.meta.builtin.DefaultBinding();
- }
- } else
- return result;
+ return objectBinding.findElementCompatibleTo(object,
clazz);
- }
+ }
+ } else
+ return result;
- public Type findTypeCompatibleTo(Object object, Class clazz) {
+ }
- if(Environment.DEBUG_SOAP && Environment.DEBUG_SOAP_META)
-
Environment.out.print(toString()+".findTypeCompatibleTo("+object+","+clazz+")\n");
+ public Type findTypeCompatibleTo(Object object, Class clazz) {
- Element element=findElementCompatibleTo(object,clazz);
- if(element!=null)
- return element.getType();
- else
- return null;
- }
+ Element element = findElementCompatibleTo(object, clazz);
- public Schema getInterfaceSchema(Class forClass) {
+ if (element != null)
+ return element.getType();
+ else
+ return null;
+ }
- Schema result=(Schema) classInterfaceSchemaMap.get(forClass);
+ public Schema getInterfaceSchema(Class forClass) {
- if(result==null)
+ Schema result = (Schema)classInterfaceSchemaMap.get(forClass);
- synchronized(classInterfaceSchemaMap) {
+ if (result == null)
- result=(Schema) classInterfaceSchemaMap.get(forClass);
+ synchronized(classInterfaceSchemaMap) {
- if(result==null) {
+ result = (Schema)classInterfaceSchemaMap.get(forClass);
- result=new Schema();
+ if (result == null) {
- result.setUrn(new URN(Environment.INTERNAL_URN.toString()+
- org.zoap.xml.Environment.getNameSpaceForClass(forClass)));
+ result = new Schema();
- addSchema(result);
+ result.setUrn(
+ new
URN(Environment.INTERNAL_URN.toString() +
+
org.zoap.xml.Environment.getNameSpaceForClass(forClass)));
- Method[] methods=forClass.getMethods();
+ addSchema(result);
- for(int count=0;count<methods.length;count++) {
+ Method[] methods = forClass.getMethods();
- RequestElement requestElement=new RequestElement();
- ResponseElement responseElement=new ResponseElement();
+ for (int count = 0; count < methods.length;
count++) {
- // extract our name suffix
-
requestElement.setAppearanceName(methods[count].getName()+"-"+count+"-Request");
-
responseElement.setAppearanceName(methods[count].getName()+"-"+count+"-Response");
+ RequestElement requestElement = new
RequestElement();
+ ResponseElement responseElement = new
ResponseElement();
- // we build up a nice schema for the package of the class
- requestElement.setAppearanceSchema(result);
- responseElement.setAppearanceSchema(result);
+ // extract our name suffix
+
requestElement.setAppearanceName(methods[count].getName() + "-" + count + "-Request");
+
responseElement.setAppearanceName(methods[count].getName() + "-" + count +
"-Response");
- // create a new responsetype
- RequestType requestType=new RequestType();
- ResponseType responseType=new ResponseType();
+ // we build up a nice schema for the
package of the class
+
requestElement.setAppearanceSchema(result);
+
responseElement.setAppearanceSchema(result);
- // extract our name suffix
-
requestType.setTypeName(methods[count].getName()+"-"+count+"-Request");
-
responseType.setTypeName(methods[count].getName()+"-"+count+"-Response");
+ // create a new responsetype
+ RequestType requestType = new
RequestType();
+ ResponseType responseType = new
ResponseType();
- // we build up a nice schema for the package of the class
- requestType.setTypeSchema(result);
- responseType.setTypeSchema(result);
+ // extract our name suffix
+
requestType.setTypeName(methods[count].getName() + "-" + count + "-Request");
+
responseType.setTypeName(methods[count].getName() + "-" + count + "-Response");
- // we set the method name
- requestType.setAssociatedMethod(methods[count]);
- responseType.setAssociatedMethod(methods[count]);
+ // we build up a nice schema for the
package of the class
+ requestType.setTypeSchema(result);
+ responseType.setTypeSchema(result);
- // and we determine the allowed "elements"
- Class[] argClasses=methods[count].getParameterTypes();
- Schema[] argumentSchemas=new Schema[argClasses.length];
- String[] argumentNames=new String[argClasses.length];
+ // we set the method name
+
requestType.setAssociatedMethod(methods[count]);
+
responseType.setAssociatedMethod(methods[count]);
- for(int count2=0;count2<argClasses.length;count2++) {
- argumentSchemas[count2]=result;
-
argumentNames[count2]=methods[count].getName()+"-"+count+"-Argument-"+count2;
- } // for
+ // and we determine the allowed
"elements"
+ Class[] argClasses =
methods[count].getParameterTypes();
+ Schema[] argumentSchemas = new
Schema[argClasses.length];
+ String[] argumentNames = new
String[argClasses.length];
- requestType.setArgumentSchemas(argumentSchemas);
- requestType.setArgumentNames(argumentNames);
+ for (int count2 = 0; count2 <
argClasses.length; count2++) {
+ argumentSchemas[count2] =
result;
+ argumentNames[count2] =
methods[count].getName() + "-" + count + "-Argument-" + count2;
+ } // for
- // and we determine the allowed "elements"
- Class returnClass=methods[count].getReturnType();
+
requestType.setArgumentSchemas(argumentSchemas);
+
requestType.setArgumentNames(argumentNames);
- if(returnClass!=void.class) {
- responseType.setReturnSchema(result);
-
responseType.setReturnName(methods[count].getName()+"-"+count+"-Return");
- } //if
+ // and we determine the allowed
"elements"
+ Class returnClass =
methods[count].getReturnType();
- requestElement.setType(requestType);
- responseElement.setType(responseType);
+ if (returnClass != void.class) {
+
responseType.setReturnSchema(result);
+
responseType.setReturnName(methods[count].getName() + "-" + count + "-Return");
+ } //if
- result.addElement(requestElement);
- result.addElement(responseElement);
+ requestElement.setType(requestType);
+ responseElement.setType(responseType);
- } // for
+ result.addElement(requestElement);
+ result.addElement(responseElement);
- addSchema(result);
+ } // for
- } // if
- } // sync
+ addSchema(result);
- return result;
- }
+ } // if
+ } // sync
- /** we keep a static reference to a singleton */
- private static DefaultBinding defaultBinding;
+ return result;
+ }
- /** retrieve the singleton */
- public static DefaultBinding getDefaultBinding() {
- if(defaultBinding==null)
- synchronized(DefaultBinding.class) {
- if(defaultBinding==null)
- defaultBinding=new DefaultBinding();
- }
+ /** we keep a static reference to a singleton */
+ private static DefaultBinding defaultBinding;
- return defaultBinding;
- }
+ /** retrieve the singleton */
+ public static DefaultBinding getDefaultBinding() {
+ if (defaultBinding == null)
+ synchronized(DefaultBinding.class) {
+ if (defaultBinding == null)
+ defaultBinding = new DefaultBinding();
+ }
- private static Map classInterfaceSchemaMap=new HashMap();
+ return defaultBinding;
+ }
+ private static Map classInterfaceSchemaMap = new HashMap();
+
}
-/*
- * $Log: DefaultBinding.java,v $
- * Revision 1.2 2000/12/04 12:36:13 jung
- * adopted to latest jboss container,
- *
- * added decimal and date
- *
- * removed some problems due to forward-referencing in meta-data
- *
- * added serialisation policy
- *
- * Revision 1.1.1.1 2000/08/10 21:07:16 jung
- * Initial import.
- *
- *
- */
+