Author: mmerz
Date: Fri Jan 14 16:40:10 2005
New Revision: 125236

URL: http://svn.apache.org/viewcvs?view=rev&rev=125236
Log:
Added Documentation to the code.

Contributor: Daryoush Mehrtash

Modified:
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java?view=diff&rev=125236&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java&r1=125235&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java&r2=125236
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
   (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
   Fri Jan 14 16:40:10 2005
@@ -279,6 +279,11 @@
                          * attachment support.
                          */
                         ClassLoader cl = AxisHook.class.getClassLoader();
+                        // Loadclass could have been done in import also, but 
if there are no activation.jar then this would 
+                        // cause error when the class is loaded.  To prevent 
that we load the class explicitly at this point.
+                        // if we had done the "new 
org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" then the class
+                        // would have had dependecies to the org.apache... 
class which would not have worked in case activation was
+                        // not on the path.
                         Class<SerializerFactory> sfClass =
                             (Class<SerializerFactory>)
                             
cl.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
@@ -320,9 +325,11 @@
                     TypeDesc td = TypeDesc.getTypeDescForClass(type);
                     TypeDesc superTd = null;
                     BeanPropertyDescriptor[] superPd = null;
+                    // type desc is used for java-xml mapping, make sure the 
class and all its super classes have a type desc defined.
                     if (null == td)
                     {
-                        td = new TypeDesc(type);
+                        td = new TypeDesc(type);  // create type descriptor 
for this class --- NOT its super classes at this point.
+                        // add super class types.
                         Class supa = type.getSuperclass();
                         if ((supa != null)
                             && (supa != java.lang.Object.class)
@@ -333,18 +340,24 @@
                         {
                             configureTypeMapping(desc, supa, defaultNameSpace);
                         }
-                        superTd = TypeDesc.getTypeDescForClass(supa);
-                        if (superTd != null)
+                        // check to see if a type mapping was created for the 
super class.
+                       superTd = TypeDesc.getTypeDescForClass(supa);
+                        if (superTd != null)  // super class is a regular java 
bean with axis typedesc.
                         {
-                            superPd = superTd.getPropertyDescriptors();
+                            superPd = superTd.getPropertyDescriptors();  // 
this is mapping for all my super classes.
                         }
                         td.setXmlType(q);
                         TypeDesc.registerTypeDescForClass(type, td);
+                        // NOTE: this is partially finished td, so more 
processing to follow that is why its td is not set to null as it is 
+                        // for the case when it is already provided (when td 
!=null)
                     }
                     else
                     {
-                        td = null;
+                        td = null;  // we don't need type desc. any more this 
is a complete td
                     }
+                    
+                    // At this all parent bean classes and their properties 
(attributes) have been registered with typedecriptor and type mapping.
+                    // next regidster type for this class.
                     tm.register(type,
                                 q,
                                 new BeanSerializerFactory(type, q),
@@ -356,23 +369,31 @@
                                  * used only in serialization.
                                  */
                                 new BeanDeserializerFactory(type, q));
-                    Map serProps =
-                        BeanDeserializerFactory.getProperties(type, null);
+                    
+                    // now register the types for this bean properties 
(attributes)
+                    // Note: we have to consider the case that one of the 
properties may be XML bean
+                    // or a class that can deal with its own serialization.
+                   Map serProps =
+                        BeanDeserializerFactory.getProperties(type, null);  // 
Note this is all of the bean properties
                     for (BeanPropertyDescriptor beanProps : 
(Collection<BeanPropertyDescriptor>) serProps.values())
                     {
                         Class subType = beanProps.getType();
+                        // make sure the property type is configred with Type 
mapping and its serializer information
                         if (! (subType.isPrimitive()
                                || subType.getName().startsWith("java.")
                                || subType.getName().startsWith("javax.")))
                         {
                             configureTypeMapping(desc,
                                                  subType,
-                                                 defaultNameSpace);
+                                                 defaultNameSpace);  // if 
this was XML bean this recursion would take care of it
                         }
 
-                        if (td != null) {
-                            String ns = q.getNamespaceURI();
-                            if (superTd != null && superPd != null) {
+                        if (td != null) {  // if I didn't have type descriptor 
when I came to this method... I created partially filled one above
+                                                          // now need to 
complete this.
+                            String ns = q.getNamespaceURI();  // name space 
for the class if there is no parent
+                            // find proper namespace for this element... we 
need to find out whihc class in the hierarchy the element came from
+                            // once you know where the element came form 
(which class) then you know the element's name space.
+                            if (superTd != null && superPd != null) {  // if I 
had a parent, 
                                 for (int j = 0; j < superPd.length; j++) {
                                     if (beanProps.getName()
                                         .equals(superPd[j]

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=125236&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java&r1=125235&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessor.java&r2=125236
==============================================================================
--- 
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 14 16:40:10 2005
@@ -73,6 +73,7 @@
 import org.w3.x2001.xmlSchema.Element;
 import org.w3.x2001.xmlSchema.Group;
 import org.w3.x2001.xmlSchema.ComplexType;
+import org.w3.x2001.xmlSchema.SchemaDocument;
 import org.w3.x2001.xmlSchema.SchemaDocument.Schema;
 
 
/*******************************************************************************
@@ -232,7 +233,7 @@
             // either there is no return value or there are multiple so make 
this a 
             // void function and later set OUT parameters if needed.
             returnType=Void.TYPE;
-            returnXMLType = null;  // correct?
+            returnXMLType = null;  
             if (paraMeta.length > 1) {
                 outParamMap = new HashMap<String, 
ClientParameterMetadata>(paraMeta.length);
                 for (ClientParameterMetadata cpm : paraMeta) {
@@ -264,19 +265,23 @@
         
         methodMap.put(opName, wmm);
             
-        List paramOrder = op.getParameterOrder();
+        List paramOrder = op.getParameterOrder();  // this is the one used by 
rpc wsdls.
         TParam inputParam = op.getInput();
         if (inputParam != null) {
             
             ClientParameterMetadata[] params = 
                 processParameters(inputParam, types, messageMap, wsm);
                 
-            if (paramOrder != null) {
-                for (Object ord : paramOrder) {
+            if (paramOrder != null) {  // walk the parameters according to 
order if they exist.  
+                                                          // note that the 
ClientMethodMetadata needs correct order of the parameters (simnilar reflection 
of method).
+               
+               // TODO:  Paramorder is only used for rpc.  This code should be 
modified so that in/out parameters are all handled in one place.
+               // if there is a paramoder then order the parameters, then all 
the parameters and look at in/out flag.
+                for (Object ord : paramOrder) {  
                     for (ClientParameterMetadata wpm : params) {
                         if (ord.equals(wpm.getWpName())) {
                                 
-                            wpm.setWpMode(WebParam.Mode.IN);
+                            wpm.setWpMode(WebParam.Mode.IN);  //THIUS MAY BE 
BUG... WE NEED TO MAKE SURE TO HANDLE THE OUT PARAMTERS ALSO (like the code for 
below) 
                             wmm.addParam(wpm);
                             break;
                         }
@@ -288,7 +293,7 @@
                     // FIXME [EMAIL PROTECTED] 2005-Jan-04 -- 
                     // Double check DOC/Lit rules
                     if (outParamMap != null && 
outParamMap.containsKey(wpm.getWpName())) {
-                        outParamMap.remove(wpm.getWpName());
+                        outParamMap.remove(wpm.getWpName());  // important... 
if this param is in.out it was in the out list also, so remove it.
                         wpm.setWpMode(WebParam.Mode.INOUT);
                     }
                     else {
@@ -299,6 +304,7 @@
             }
         }
 
+        // do the pure out parameters.
         if (outParamMap != null && outParamMap.size() > 0) {
             for (ClientParameterMetadata wpm : outParamMap.values()) {
                 wpm.setWpMode(WebParam.Mode.OUT);
@@ -338,24 +344,33 @@
 
             
                 QName paramXmlType;                
-                if (messagePart.isSetElement()) {
+                if (messagePart.isSetElement()) { // if element attribute is 
set we are looking at document style 
+                                                     // in case of rpc message 
part would look something like: <part name="key" type="xsd:string"/>
+                                                     // otherwise it case of 
document it looks liek <part element="xxxx" name="parameters">
+                       // we know we are document, and thus literal.  and most 
likely using xml beans, but can use axis too.
                     QName element = messagePart.getElement();
-                    Class javaType = getTypeMappingUtil().q2Class(element);
-                    if (Object.class.equals(javaType)) {
-                        if (types != null) {
+                    Class javaType = getTypeMappingUtil().q2Class(element);  
// in case of xml beans (or other registered types) we don't need to dig any 
further
+                    if (Object.class.equals(javaType)) {  // if q2class fails, 
it reutrns an object.  
+                       // we know  document, literal, there are no reguistered 
types for the messasge.
+                       // system needs to wrap/unwrap the messages.  Thus the 
method metadata must reflect this.
+                       
+                       
+                        if (types != null) {  // if there are some type 
sections.   
                             try {
                                 Schema[] schemas = selectChildren(types,
-                                                                  
Schema.class);
+                                                                  
Schema.class);  // We are looking at schemas that are defined in this schema.
+                                                                               
   //---- THIS WOULD NOT RECOGNIZE IMPORTED SCHEMAS.
 
                                 for (Schema s : schemas) {
                                     if (s.getTargetNamespace()
-                                        .equals(element.getNamespaceURI())) {
+                                        .equals(element.getNamespaceURI())) {  
// if namespace matched the element.
                                         Element[] elements = 
s.getElementArray();
                                         for (Element e : elements) {
                                             if (e.getName()
                                                 
.equals(element.getLocalPart())) {
                                          
-                                                if (e.isSetType()) {
+                                                if (e.isSetType()) {  // 
simple type, element has name and type in same node for complex type it is only
+                                                                         // 
name  and type is defined as <complexType> child./
                                                     ClientParameterMetadata 
wpm =
                                                         new 
ClientParameterMetadataImpl();
                                          
@@ -376,11 +391,17 @@
                                                     paramList.add(wpm);
                                                 }
                                                 else {
+                                                       // we have <element 
name=xxx> and its child must be comlexType, or somethig is wrong
+
                                                     ComplexType ct = 
e.getComplexType();
                                                     if (ct != null
                                                         && ct.isSetSequence()) 
{
                                                         // DOC/LIT WSDL
-                                                        Group g = 
ct.getSequence();
+                                                        Group g = 
ct.getSequence();  // NOTE there may other groupings also here (e.g. for arrays)
+                                                                               
      // that we are not handling correctly.
+                                                               // its child is 
either <element name="xxxx" type="xxx" /> or 
+                                                       //<element ref="xxx />
+
                                                         for (Element el : 
g.getElementArray()) {
 
                                                             
ClientParameterMetadata wpm =
@@ -438,7 +459,8 @@
                             }
                         }
                     }
-                    else {
+                    else {  // if we did find object form qname.  also we know 
that there are xml-aware classes that can decode the xml we let them do the 
+                       // processing.
 
                         // NOTE [EMAIL PROTECTED] 2005-Jan-07 -- Doc/Lit Bare
                         
wsm.getSoapBinding().setParameterStyle(SOAPBinding.ParameterStyle.BARE);
@@ -453,7 +475,7 @@
                         paramList.add(wpm);
                     }
                 }
-                else {
+                else {  // this is an rpc and with no element attribute
                     ClientParameterMetadata wpm =
                         new ClientParameterMetadataImpl();
                     // FIXME [EMAIL PROTECTED] 2004-Nov-09 -- figure out where 
RPC parameter namespaces should be specified in the WSDL.
@@ -710,9 +732,36 @@
             throws IllegalAccessException, NoSuchFieldException {
         // retrieve the SchemaType from the static type field
         SchemaType st = (SchemaType) childClass.getField("type").get(null);
-        XmlObject[] kids = parent.selectChildren(st.getDocumentElementName());
+        SchemaType originalType = null;
+        QName element;
+        if (st.isAnonymousType()) {
+            originalType = st;
+            st = st.getOuterType();
+        }
+        if (st.isDocumentType()) {
+            element = st.getDocumentElementName();
+            if (originalType != null) {
+                st = originalType;
+            }
+        }
+        else {
+            element = st.getName();
+        }
+        /*System.out.println("Selecting children " + element +" of class " 
+          + st.getJavaClass()); */
+        XmlObject[] kids = parent.selectChildren(element);
+      
         T[] castKids = (T[]) Array.newInstance(childClass, kids.length);
         for (int j = 0; j < castKids.length; j++) {
+
+            if (!st.getJavaClass().isAssignableFrom(kids[j].getClass())) {
+                //System.out.println("before typechange " + 
kids[j].getClass());
+                kids[j] = kids[j].changeType(st);
+                //System.out.println("after typechange " + kids[j].getClass());
+            }
+            else {
+                // System.out.println("no typechange needed");
+            }
             castKids[j] = childClass.cast(kids[j]);
         }
         return castKids;

Reply via email to