Author: mmerz
Date: Fri Jan 28 13:48:22 2005
New Revision: 148921

URL: http://svn.apache.org/viewcvs?view=rev&rev=148921
Log:
Added new registeration/lookup classes
fixed bugs in the WSDLProcessing

Contributor: Daryoush Mehrtash

Added:
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/AxisTypeLookUp.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/SystemLookUpService.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/DebugPrintMessageHandler.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/BindingLookupService.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/GenericHolder.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/xmlbeans/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/xmlbeans/XMLBeanTypeLookUp.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/TypeRegistrar.java
Modified:
   incubator/beehive/trunk/wsm/build.xml
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java

Modified: incubator/beehive/trunk/wsm/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/build.xml?view=diff&rev=148921&p1=incubator/beehive/trunk/wsm/build.xml&r1=148920&p2=incubator/beehive/trunk/wsm/build.xml&r2=148921
==============================================================================
--- incubator/beehive/trunk/wsm/build.xml       (original)
+++ incubator/beehive/trunk/wsm/build.xml       Fri Jan 28 13:48:22 2005
@@ -48,7 +48,9 @@
         <pathelement location="${api.classes}"/>
         <pathelement location="${lib.dir}/wsdltypes.jar"/>
         <pathelement location="${lib.dir}/schematypes.jar"/>
-    </path>
+        <pathelement location="${ext.lib.dir}/jaxrpc.jar"/>
+       <path refid="xbean.dependency.path"/>
+       </path>
     <path id="axis.classpath">
         <path refid="controls.dependency.path"/>
         <path refid="tools.dependency.path"/>

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/AxisTypeLookUp.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/AxisTypeLookUp.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/AxisTypeLookUp.java
 Fri Jan 28 13:48:22 2005
@@ -0,0 +1,63 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+
+package org.apache.beehive.wsm.axis.dataBinding;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.wsdl.fromJava.Namespaces;
+import org.apache.axis.wsdl.fromJava.Types;
+import org.apache.beehive.wsm.dataBinding.BindingLookupService;
+
+
+
+public class AxisTypeLookUp implements BindingLookupService {
+       TypeMapping tm;
+       
+       
+       /**
+        * @param tm
+        */
+       public AxisTypeLookUp(TypeMapping tm) {
+               super();
+               this.tm = tm;
+       }
+       
+       /* (non-Javadoc)
+        * @see TypeLookUpServices#getClassQName(java.lang.Class)
+        */
+       public QName class2qname(Class cls) {
+        String namespace = Namespaces.makeNamespace(cls.getName());
+        if (namespace == null || namespace
+            .endsWith("DefaultNamespace")) {
+            namespace = "http://no.namespace.specified";;
+        }
+        return new QName(namespace,
+                              Types.getLocalNameFromFullName(cls.getName()));
+
+       }
+       
+          public Class qname2class(QName qType) {
+               return tm.getClassForQName(qType);
+          }
+
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/SystemLookUpService.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/SystemLookUpService.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/dataBinding/SystemLookUpService.java
    Fri Jan 28 13:48:22 2005
@@ -0,0 +1,70 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.axis.dataBinding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.encoding.XMLType;
+
+import org.apache.beehive.wsm.dataBinding.BindingLookupService;
+import org.apache.beehive.wsm.dataBinding.xmlbeans.XMLBeanTypeLookUp;
+
+
+
+public class SystemLookUpService implements BindingLookupService {
+
+    List<BindingLookupService> lookupServiceList = new 
ArrayList<BindingLookupService>();
+       /**
+        * 
+        */
+       public SystemLookUpService(org.apache.axis.encoding.TypeMapping tm) {
+        lookupServiceList.add(new XMLBeanTypeLookUp());
+        lookupServiceList.add(new AxisTypeLookUp(tm));
+
+       }
+       /* (non-Javadoc)
+        * @see TypeLookUpServices#getClassQName(java.lang.Class)
+        */
+       public QName class2qname(Class cls) {
+               QName qname = null;
+               
+               // DOES THE LOOK UP SERVICE CHECK FOR THE PRIMITIVE TPYTES?  IF 
so we don't need this here.
+               if(cls == String.class) { 
+                       return XMLType.XSD_STRING;
+               }
+               
+               for(BindingLookupService lookUpService : lookupServiceList) {
+                       if( null != (qname = lookUpService.class2qname(cls))) 
break;
+               }
+               return qname;
+       }
+       /* (non-Javadoc)
+        * @see TypeLookUpServices#Qname2Class(javax.xml.namespace.QName)
+        */
+       public Class qname2class(QName qname) {
+               Class cls = null;
+               for(BindingLookupService lookUpService : lookupServiceList) {
+                       if( null != (cls = lookUpService.qname2class(qname))) 
break;
+               }
+               return cls;     }
+
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
     Fri Jan 28 13:48:22 2005
@@ -0,0 +1,216 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.axis.registration;
+
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Type;
+import java.rmi.Remote;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.description.ElementDesc;
+import org.apache.axis.description.FieldDesc;
+import org.apache.axis.description.TypeDesc;
+import org.apache.axis.encoding.DeserializerFactory;
+import org.apache.axis.encoding.SerializerFactory;
+import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.encoding.XMLType;
+import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
+import org.apache.axis.encoding.ser.ArraySerializerFactory;
+import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.encoding.ser.BeanSerializerFactory;
+import org.apache.axis.utils.BeanPropertyDescriptor;
+import org.apache.beehive.wsm.axis.util.encoding.XmlBeanDeserializerFactory;
+import org.apache.beehive.wsm.axis.util.encoding.XmlBeanSerializerFactory;
+import org.apache.beehive.wsm.dataBinding.BindingLookupService;
+import org.apache.beehive.wsm.jsr181.util.InvalidTypeMappingException;
+import org.apache.beehive.wsm.registration.TypeRegistrar;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlObject;
+
+
+
+public class AxisTypeRegistrar extends TypeRegistrar {
+       static Logger logger = Logger.getLogger(AxisTypeRegistrar.class);
+
+
+
+       public AxisTypeRegistrar(TypeMapping tm, BindingLookupService 
lookupService) {
+               super(tm, lookupService);
+       }
+
+
+       // Class cls = super.q2Class(qType);
+       // if (Object.class.equals(cls) && mTypeMapping != null) {
+       // cls = mTypeMapping.getClassForQName(qType);
+       // return cls;
+       // }
+       // else {
+       // return null;
+       // }
+       // }
+
+       /**
+        * @param cls
+        * @param q
+        */
+       protected void registerClassAsWithDefaultSearialization(Class cls, 
QName q) {
+               logger.debug("Register class: " + cls.getCanonicalName() + " 
qname:" + q);
+               TypeDesc td = TypeDesc.getTypeDescForClass(cls);  // a class 
can provide its own descriptors
+               TypeDesc superTd = null;
+               BeanPropertyDescriptor[] superPd = null;
+               if (null == td) {
+                       td = new TypeDesc(cls);
+                       Class supa = cls.getSuperclass();
+                       if ((supa != null) && (supa != java.lang.Object.class)
+                                       && (supa != java.lang.Exception.class)
+                                       && (supa != java.lang.Throwable.class)
+                                       && (supa != 
java.rmi.RemoteException.class)
+                                       && (supa != 
org.apache.axis.AxisFault.class)) {
+                               registerType(supa);
+                       }
+                       superTd = TypeDesc.getTypeDescForClass(supa);
+                       if (superTd != null) {
+                               superPd = superTd.getPropertyDescriptors();
+                       }
+                       td.setXmlType(q);
+                       TypeDesc.registerTypeDescForClass(cls, td);
+               } else {
+                       td = null;
+               }
+               mTypeMapping.register(cls, q, new BeanSerializerFactory(cls, q),
+               /*
+                * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- should check that the 
type to
+                * deserialize has a default contructor but with this setup 
there is no
+                * way to know if it is used only in serialization.
+                */
+               new BeanDeserializerFactory(cls, q));
+               Map serProps = BeanDeserializerFactory.getProperties(cls, null);
+               for (BeanPropertyDescriptor beanProps : 
(Collection<BeanPropertyDescriptor>) serProps
+                               .values()) {
+                       Class subType = beanProps.getType();
+                       if (!(subType.isPrimitive()
+                                       || 
subType.getName().startsWith("java.") || subType
+                                       .getName().startsWith("javax."))) {
+                               registerType(subType);
+                       }
+                       if (td != null) {
+                               String ns = q.getNamespaceURI();
+                               if (superTd != null && superPd != null) {
+                                       for (int j = 0; j < superPd.length; 
j++) {
+                                               if 
(beanProps.getName().equals(superPd[j].getName())) {
+                                                       ns = 
superTd.getXmlType().getNamespaceURI();
+                                                       break;
+                                               }
+                                       }
+                               }
+                               FieldDesc fd = new ElementDesc();
+                               fd.setJavaType(subType);
+                               fd.setFieldName(beanProps.getName());
+                               fd.setXmlName(new QName(ns, 
beanProps.getName()));
+                               // NOTE [EMAIL PROTECTED] 2004-Oct-28 -- might
+                               // need
+                               // to do more to ensure a useful type QName.
+                               fd.setXmlType(getRegisteredQName(subType));
+                               td.addFieldDesc(fd);
+                       }
+               }
+       }
+
+       /**
+        * @param cls
+        * @param q
+        */
+       protected void registerClassAsXMLBeans(Class cls, QName q) {
+               mTypeMapping.register(cls, q, new XmlBeanSerializerFactory(cls, 
q),
+                               new XmlBeanDeserializerFactory(cls, q));
+       }
+
+       /**
+        * @param cls
+        * @param q
+        * @throws ClassNotFoundException
+        * @throws NoSuchMethodException
+        * @throws InstantiationException
+        * @throws IllegalAccessException
+        * @throws InvocationTargetException
+        */
+       protected void registerClassAsDataHandler(Class cls, QName q)
+                       throws ClassNotFoundException, NoSuchMethodException,
+                       InstantiationException, IllegalAccessException,
+                       InvocationTargetException {
+               /*
+                * NOTE [EMAIL PROTECTED] 2004-Oct-08 -- doing reflection here 
in case
+                * AXIS was built without attachment support.
+                */
+               ClassLoader cl = getClass().getClassLoader();
+               Class<SerializerFactory> sfClass = (Class<SerializerFactory>) cl
+                               
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
+               Class<DeserializerFactory> dsfClass = 
(Class<DeserializerFactory>) cl
+                               
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
+               Constructor<SerializerFactory> sfCon = sfClass.getConstructor(
+                               Class.class, QName.class);
+               Constructor<DeserializerFactory> dsfCon = 
dsfClass.getConstructor(
+                               Class.class, QName.class);
+               SerializerFactory sf = sfCon.newInstance(cls, q);
+               DeserializerFactory dsf = dsfCon.newInstance(cls, q);
+               mTypeMapping.register(cls, q, sf, dsf);
+       }
+
+       /**
+        * @param cls
+        * @param q
+        */
+       protected void registerClassAsArray(Class cls, QName q) {
+               mTypeMapping.register(cls, q, new ArraySerializerFactory(cls, 
q),
+                               new ArrayDeserializerFactory());
+       }
+
+       /**
+        * @param cls
+        * @param q
+        * @return
+        */
+       protected boolean classIsRegistered(Class cls, QName q) {
+               return mTypeMapping.isRegistered(cls, q);
+       }
+
+
+       /**
+        * @param cls
+        * @return
+        */
+       protected QName getRegisteredQName(Class cls) {
+               QName currentQName = 
((org.apache.axis.encoding.TypeMapping)mTypeMapping).getTypeQName(cls);
+               return currentQName;
+       }
+       /**
+        * @return
+        */
+       public QName getVoidType() {
+               return XMLType.AXIS_VOID;
+               
+       }
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/DebugPrintMessageHandler.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/DebugPrintMessageHandler.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/DebugPrintMessageHandler.java
      Fri Jan 28 13:48:22 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.beehive.wsm.axis.util;
+
+import java.io.IOException;
+
+import javax.xml.soap.SOAPException;
+
+import org.apache.axis.AxisFault;
+import org.apache.axis.MessageContext;
+import org.apache.axis.handlers.BasicHandler;
+
+
+public class DebugPrintMessageHandler extends BasicHandler {
+
+       /* (non-Javadoc)
+        * @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
+        */
+       public void invoke(MessageContext mc) throws AxisFault {
+               try {
+                       System.out.println("RequestMessage.....");
+                       mc.getRequestMessage().writeTo(System.out);
+                       System.out.println("\n");
+               } catch (SOAPException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+
+       }
+
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/BindingLookupService.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/BindingLookupService.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/BindingLookupService.java
        Fri Jan 28 13:48:22 2005
@@ -0,0 +1,40 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.dataBinding;
+
+
+import javax.xml.namespace.QName;
+/*
+ * There are varieties of XML-Java binding (XMLBeans, Axis, Castor, etc) 
+ * implementations, each with its own nuances. 
+ * The TypeLookUpServices interface is intended to abstract the particular 
+ * implementations strategy. 
+ * 
+ * The qname to class mappings must  be predictable.  So that for a given 
+ * class: 
+ *             classA  = qname2Class(class2qname(ClassA)
+ * 
+ * And for a given QName:
+ *             qnameA = class2qname(qname2class(qnameA)
+*/
+public interface BindingLookupService {
+       public abstract QName class2qname(Class cls);
+       public Class qname2class(QName qname);
+}
\ No newline at end of file

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/GenericHolder.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/GenericHolder.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/GenericHolder.java
       Fri Jan 28 13:48:22 2005
@@ -0,0 +1,39 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.dataBinding;
+
+import javax.xml.rpc.holders.Holder;
+
+/*******************************************************************************
+ * 
+ *
+ * @author Jonathan Colwell
+ */
+public class GenericHolder<T> implements Holder {
+    
+    public T value;
+    
+    public GenericHolder(T value) {
+        this.value = value;
+    }
+
+    public GenericHolder() {}
+
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/xmlbeans/XMLBeanTypeLookUp.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/xmlbeans/XMLBeanTypeLookUp.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/dataBinding/xmlbeans/XMLBeanTypeLookUp.java
  Fri Jan 28 13:48:22 2005
@@ -0,0 +1,144 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.dataBinding.xmlbeans;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.beehive.wsm.dataBinding.BindingLookupService;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.SchemaField;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlObject;
+
+
+
+public class XMLBeanTypeLookUp implements BindingLookupService {
+       static Logger logger = Logger.getLogger(XMLBeanTypeLookUp.class);
+
+       public QName class2qname( Class cls) {
+           if (XmlObject.class.isAssignableFrom(cls)) {
+            return XmlBeans.typeForClass(cls).getName();
+        }
+           return null;
+       }
+
+       /* (non-Javadoc)
+        * @see TypeLookUpServices#Qname2Class(javax.xml.namespace.QName)
+        */
+       public Class qname2class(QName qname) {
+               logger.debug("Get XMLBeans class for Qname: " + qname);
+               SchemaTypeLoader stl = XmlBeans.getContextTypeLoader();
+               SchemaType st = stl.findType(qname);
+               if (st == null) {
+                   SchemaField sf = stl.findElement(qname);
+                   if (sf != null) {
+                       st = sf.getType();
+                   }
+               }
+
+               if (st != null) {
+                   Class xmlClass = st.getJavaClass();
+
+                   //String clName = xmlClass.getName();
+                   if (st.isBuiltinType()) {
+                       Method[] declared = xmlClass.getDeclaredMethods();
+                       Class natural =
+                           scanDeclaredMethodsForViableReturnType(declared);
+                       if (natural != null) {
+                           return natural;
+                       }
+                       else {
+                           // NOTE [EMAIL PROTECTED] 2004-Nov-12 --
+                           // XmlString declares no methods
+
+                           if (xmlClass.isInterface()) {
+                               for (Class cl : xmlClass.getInterfaces()) {
+                                   natural = 
scanDeclaredMethodsForViableReturnType
+                                       (cl.getDeclaredMethods());
+                                   if (natural != null) {
+                                       return natural;
+                                   }
+                               }
+                           }
+                           else {
+                               declared = 
xmlClass.getSuperclass().getDeclaredMethods();
+                               natural = scanDeclaredMethodsForViableReturnType
+                                   (declared);
+                               if (natural != null) {
+                                   return natural;
+                               }
+                           }
+                       }
+                   }
+                   /*
+                   else if (st.isSimpleType()){
+                       System.out.println(clName + " is simple but not built 
in");
+                   }
+                   else {
+                       System.out.println(clName + " is NOT built in");
+                   }
+                   System.out.println("resulting class: " + 
xmlClass.getName());
+                   */
+                   return xmlClass;
+               }
+               else {
+                   // NOTE [EMAIL PROTECTED] 2004-Nov-30 -- 
+                   // keep in mind that a real TMU based on a viable SOAP 
stack should
+                   // be used and this pure XmlBean implementation is just a 
fallback.
+                   return null;
+               }
+           }
+       
+          private Class scanDeclaredMethodsForViableReturnType
+       (Method[] declared) {
+       
+               System.out.println("POSSIBLE BUG..... NEED TO USE TABLE LOOK UP 
FOR PRIMITIVE TYPES");
+       for (Method meth : declared) {
+               
+           Class returnType = meth.getReturnType();
+           //System.out.println(returnType.getName());
+           if (!returnType.equals(Void.TYPE)) {
+               /*
+                * NOTE [EMAIL PROTECTED] 2004-Nov-12 -- 
+                * built-in XmlBeans types may be of the following natural
+                * types:
+                * primitives, byte arrays, Strings, Calendars, BigIntegers
+                * and BigDecimals
+                */
+               if (returnType.isArray()
+                   || returnType.isPrimitive()
+                   || returnType.equals(String.class)
+                   || returnType.equals(QName.class)
+                   || returnType.equals(java.util.Calendar.class)
+                   || returnType.equals(java.math.BigDecimal.class)
+                   || returnType.equals(java.math.BigInteger.class)) {
+
+                   return returnType;
+               }
+           }
+       }
+       return null;
+   }
+       
+}

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java?view=diff&rev=148921&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java&r1=148920&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java&r2=148921
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
       (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
       Fri Jan 28 13:48:22 2005
@@ -56,4 +56,8 @@
     
     QName getXmlReturnType();
     void setXmlReturnType(QName xmlType);
+       /**
+        * @param javaType
+        */
+       void setReturnType(Class javaType);
 }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java?view=diff&rev=148921&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r1=148920&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r2=148921
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   Fri Jan 28 13:48:22 2005
@@ -343,4 +343,12 @@
     public void setXmlReturnType(QName xmlReturnType) {
        mXMLReturnType = xmlReturnType;
     }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadata#setReturnType(java.lang.Class)
+        */
+       public void setReturnType(Class javaType) {
+               this.javaReturnType = javaType;
+               
+       }
 }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java?view=diff&rev=148921&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java&r1=148920&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java&r2=148921
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java
        (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java
        Fri Jan 28 13:48:22 2005
@@ -232,8 +232,9 @@
             returnXMLType = null;  
             if (paraMeta.length > 1) {
                 outParamMap = new HashMap<String, 
Jsr181ParameterMetadata>(paraMeta.length);
+                boolean returnIsSet = false;
                 for (Jsr181ParameterMetadata cpm : paraMeta) {
-                    outParamMap.put(cpm.getWpName(), cpm);
+                               outParamMap.put(cpm.getWpName(), cpm);
                 }
             }
         }
@@ -302,10 +303,17 @@
 
         // do the pure out parameters.
         if (outParamMap != null && outParamMap.size() > 0) {
-            for (Jsr181ParameterMetadata wpm : outParamMap.values()) {
-                wpm.setWpMode(WebParam.Mode.OUT);
-                wmm.addParam(wpm);
-            }
+               if( outParamMap.size() == 1)  {
+                       Jsr181ParameterMetadata wpm = 
outParamMap.values().iterator().next();
+                       wmm.setXmlReturnType(wpm.getXmlType());
+                       wmm.setReturnType(wpm.getJavaType());
+                       wmm.setOneWay(false);                    
+               } else {
+                   for (Jsr181ParameterMetadata wpm : outParamMap.values()) {
+                       wpm.setWpMode(WebParam.Mode.OUT);
+                       wmm.addParam(wpm);
+                   }
+               }
         }
             
         List<Jsr181ParameterMetadata> params = wmm.getParams();
@@ -708,7 +716,12 @@
     public static org.xmlsoap.schemas.wsdl.soap.TBinding[]
             getSOAPBinding(TBinding b)
             throws IllegalAccessException, NoSuchFieldException {
-        return selectChildren(b, org.xmlsoap.schemas.wsdl.soap.TBinding.class);
+       XmlObject[] kids =  b.selectChildren(new 
QName("http://schemas.xmlsoap.org/wsdl/soap/";, "binding"));
+
+               org.xmlsoap.schemas.wsdl.soap.TBinding[] res = new 
org.xmlsoap.schemas.wsdl.soap.TBinding[kids.length];
+               for(int i=0; i<kids.length; i++) 
res[i]=(org.xmlsoap.schemas.wsdl.soap.TBinding) kids[i];
+       
+        return res;
     }
 
     public static org.xmlsoap.schemas.wsdl.soap.TBody[]

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/TypeRegistrar.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/TypeRegistrar.java?view=auto&rev=148921
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/TypeRegistrar.java
      Fri Jan 28 13:48:22 2005
@@ -0,0 +1,262 @@
+/*
+ * 
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * 
+ */
+package org.apache.beehive.wsm.registration;
+
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Type;
+import java.rmi.Remote;
+import org.apache.log4j.*;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.encoding.TypeMapping;
+import javax.xml.rpc.holders.Holder;
+
+import org.apache.beehive.wsm.dataBinding.BindingLookupService;
+import org.apache.beehive.wsm.dataBinding.GenericHolder;
+
+
+public abstract class TypeRegistrar {
+       static Logger logger = Logger.getLogger(TypeRegistrar.class);
+       protected TypeMapping mTypeMapping;
+       protected BindingLookupService lookupService;
+       
+/**
+ * @param typeMapping
+ * @param lookupService
+ */
+       public TypeRegistrar(TypeMapping typeMapping,
+               BindingLookupService lookupService) {
+               super();
+               mTypeMapping = typeMapping;
+               this.lookupService = lookupService;
+       }
+
+       /**
+        * @param cls
+        * @return
+        */
+       protected abstract QName getRegisteredQName(Class cls);
+       
+       /**
+        * @param cls
+        * @param q
+        */
+       abstract protected void registerClassAsWithDefaultSearialization(Class 
cls, QName q);
+
+       /**
+        * @param cls
+        * @param q
+        */
+       abstract protected void registerClassAsXMLBeans(Class cls, QName q);
+
+       /**
+        * @param cls
+        * @param q
+        * @throws ClassNotFoundException
+        * @throws NoSuchMethodException
+        * @throws InstantiationException
+        * @throws IllegalAccessException
+        * @throws InvocationTargetException
+        */
+       abstract protected void registerClassAsDataHandler(Class cls, QName q)
+                       throws ClassNotFoundException, NoSuchMethodException,
+                       InstantiationException, IllegalAccessException,
+                       InvocationTargetException;
+
+       /**
+        * @param cls
+        * @param q
+        */
+       abstract protected  void registerClassAsArray(Class cls, QName q);
+
+       /**
+        * @param cls
+        * @param q
+        * @return
+        */
+       abstract protected boolean classIsRegistered(Class cls, QName q);
+
+       
+       /**
+        * @return
+        */
+       abstract public QName getVoidType();
+       
+       public QName registerType(Class cls) {
+               return registerType(cls, lookupService.class2qname(cls));
+       }
+
+       public QName registerType(Class cls, QName q) {
+               logger.debug("Register class: " + cls.getCanonicalName() + " 
qName: "
+                               + q);
+
+               QName currentQName = getRegisteredQName(cls);
+               logger.debug("Got a q from typemapping: " + currentQName);
+
+               if (currentQName != null ) { // && currentQName.equals(q)) {
+                       logger.debug("Type is already registered.");
+                       return q; // Already registered.
+               }
+
+//             // IF generic holders are used, just register the type of the
+//             // underlying object.
+//             if (GenericHolder.class.isAssignableFrom(cls)) {
+//                     Type[] typeArgs = cls.getGenericInterfaces();
+//                     return registerType((Class) typeArgs[0]);
+//             }
+//             // for other holders get the underlying class
+//             if(Holder.class.isAssignableFrom(cls)) {
+//                     registerType(getUnderlyingType(cls));
+//             }
+               // if (q == null || (expectedType != null &&
+               // !expectedType.equals(q))) {
+               //
+               // if (expectedType == null) {
+               // q = generateQName(cls, "http://no.namespace.specified";);
+               // } else {
+               // q = expectedType;
+               // }
+
+               if (cls.isArray()) {
+                       if (!classIsRegistered(cls, q)) {
+                               registerClassAsArray(cls, q);
+                       }
+                       q = registerType(cls.getComponentType());
+                       // TODO: fix the expected type thing for arrays.
+                       // if (expectedType != null) {
+                       // q = expectedType;
+                       // }
+               } else if (q == null || !classIsRegistered(cls, q)) { // WHY
+                       // IS
+                       // THIS
+                       // NEEDED?
+                       if 
(org.apache.xmlbeans.XmlObject.class.isAssignableFrom(cls)) {
+                               registerClassAsXMLBeans(cls, q);
+                       }
+                       /*
+                        * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- these 
datahandler using
+                        * classes are generally already registered but just in 
case...
+                        */
+                       else if (isActivationEnabled()
+                                       && 
(java.awt.Image.class.isAssignableFrom(cls)
+                                                       || 
getMultipartClass().isAssignableFrom(cls) || getDataHandlerClass()
+                                                       
.isAssignableFrom(cls))) {
+                               try {
+                                       registerClassAsDataHandler(cls, q);
+                               } catch (Exception e) {
+                                       /*
+                                        * FIXME [EMAIL PROTECTED] 2004-Oct-08 
-- log this properly
+                                        */
+                                       e.printStackTrace();
+                               }
+                       } else if (!Remote.class.isAssignableFrom(cls)
+                       /*
+                        * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- 
java.rmi.Remote is
+                        * prohibited by the jax-rpc spec.
+                        */
+
+                       /*
+                        * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- restricting 
against File
+                        * since, it doesn't make sense to serialize as a bean. 
That and it
+                        * causes an infinite loop as it keeps returning itself 
from the
+                        * getAbsoluteFile and getCanonicalFile calls
+                        */
+                       && !File.class.isAssignableFrom(cls)) {
+                               registerClassAsWithDefaultSearialization(cls, 
q);
+                       } else {
+                               throw new RuntimeException("failed to register "
+                                               + cls.getName() + " as a valid 
web service datatype,"
+                                               + " consider using a custom 
type mapping");
+                       }
+               }
+               // }
+               // }
+               return q;
+       } // public Class q2Class(QName qType) { //
+
+
+
+       
+       private boolean isActivationEnabled() {
+               return null != getDataHandlerClass() && null != 
getMultipartClass();
+       }
+
+       private Class getDataHandlerClass() {
+               try {
+                       return getClass().getClassLoader().loadClass(
+                                       "javax.activation.DataHandler");
+               } catch (Exception e) {
+               }
+               return null;
+       }
+
+       private Class getMultipartClass() {
+               try {
+                       return getClass().getClassLoader().loadClass(
+                                       "javax.mail.internet.MimeMultipart");
+               } catch (Exception e) {
+               }
+               return null;
+       }
+
+
+       
+       /**
+        * @param t
+        * @throws Exception
+        */
+       static public Class getUnderlyingType(Type t)  {
+               Class nxtType = null;
+               if (t instanceof Class) {
+                       // for holder class we need to get the value field type
+                       if( Holder.class.isAssignableFrom((Class)t)) {          
                        
+                             Field[] publicFields = ((Class) t).getFields();
+                             for (int i = 0; i < publicFields.length; i++) {
+                                if( 0 == 
"value".compareTo(publicFields[i].getName())) {
+                                       nxtType= publicFields[i].getType();
+ System.out.println("******************************class : " + 
t.getClass().getCanonicalName() + " is converted to: " + 
nxtType.getCanonicalName());
+                                       break;
+                                }
+                             }
+                       } else {  // if it is not a holder just use the type as 
is
+                               nxtType = (Class) t;
+                       }
+               } else if (t instanceof java.lang.reflect.ParameterizedType) {
+                       java.lang.reflect.ParameterizedType pt = 
((java.lang.reflect.ParameterizedType) t);
+                       Type[] typeArgs = pt.getActualTypeArguments();
+                       Type raw = pt.getRawType();
+                       if (GenericHolder.class.isAssignableFrom((Class) raw)
+                                       && typeArgs.length == 1) {
+                               nxtType = (Class) typeArgs[0];
+                       } else {
+                               throw new RuntimeException(raw + " ~ " + 
typeArgs[0]);
+                       }
+               } else {
+                       throw new RuntimeException("Only Classes and 
ParameterizedTypes"
+                                       + " are currently handled, support for 
" + t.getClass()
+                                       + " should be added.");
+               }
+               return nxtType;
+       }
+}
+       

Reply via email to