You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/11/11 17:06:57 UTC
svn commit: r473743 - in
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws:
marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
wrapper/JAXBWrapperTool.java wrapper/impl/JAXBWrapperToolImpl.java
Author: scheu
Date: Sat Nov 11 08:06:57 2006
New Revision: 473743
URL: http://svn.apache.org/viewvc?view=rev&rev=473743
Log:
AXIS2-1679
Contributor: Rich Scheuerle
JAXB Wrapper Tool cleanup
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java?view=diff&rev=473743&r1=473742&r2=473743
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java Sat Nov 11 08:06:57 2006
@@ -19,6 +19,8 @@
package org.apache.axis2.jaxws.marshaller.impl;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -32,6 +34,7 @@
import org.apache.axis2.jaxws.description.OperationDescriptionJava;
import org.apache.axis2.jaxws.description.ParameterDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.DocLitWrappedMethodMarshaller;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
import org.apache.axis2.jaxws.message.Block;
@@ -43,6 +46,7 @@
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
+import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -202,8 +206,7 @@
mps = createResponseWrapperParameter(returnObject, objectList.toArray());
}
- JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
- Object wrapper = wrapperTool.wrap(wrapperClazz, mps);
+ Object wrapper = wrap(wrapperClazz, mps);
// If the wrapper class does not represent an root element, then make
// the appropriate JAXBElement
@@ -240,15 +243,9 @@
Object jaxbObject = null;
ArrayList<MethodParameter> methodParameters = createRequestWrapperParameters(objects);
- JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
- if (log.isDebugEnabled()) {
- log.debug("JAXBWrapperTool attempting to wrap propertes in WrapperClass :" + wrapperClazz);
- }
- jaxbObject = wrapTool.wrap(wrapperClazz, methodParameters);
- if (log.isDebugEnabled()) {
- log.debug("JAXBWrapperTool wrapped following propertes :");
- }
+ jaxbObject = wrap(wrapperClazz, methodParameters);
+
// If the wrapper class does not represent an root element, then make
// the appropriate JAXBElement
@@ -304,4 +301,35 @@
m.setBodyBlock(0,bodyBlock);
return m;
}
+
+ private Object wrap(Class jaxbClass, ArrayList<MethodParameter> mps) throws JAXBWrapperException{
+ if (log.isDebugEnabled()) {
+ log.debug("start: Create Doc Lit Wrapper");
+ }
+ if(mps == null){
+ throw new JAXBWrapperException(Messages.getMessage("JAXBWrapperErr7"));
+ }
+ ArrayList<String> nameList = new ArrayList<String>();
+ Map<String, Object> objectList = new WeakHashMap<String, Object>();
+ for(MethodParameter mp:mps){
+ ParameterDescription pd = mp.getParameterDescription();
+ String name = null;
+ if(!mp.isWebResult()){
+ name = pd.getParameterName();
+ }else{
+ name = mp.getWebResultName();
+ }
+ Object object = mp.getValue();
+
+ nameList.add(name);
+ objectList.put(name, object);
+ }
+ JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+
+ Object wrapper = wrapperTool.wrap(jaxbClass, nameList, objectList);
+ if (log.isDebugEnabled()) {
+ log.debug("end: Create Doc Lit Wrapper");
+ }
+ return wrapper;
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java?view=diff&rev=473743&r1=473742&r2=473743
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/JAXBWrapperTool.java Sat Nov 11 08:06:57 2006
@@ -20,16 +20,17 @@
import java.util.ArrayList;
import java.util.Map;
-import javax.xml.bind.JAXBElement;
-
-import org.apache.axis2.jaxws.marshaller.MethodParameter;
import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
+/**
+ * The JAXBWrapper tool is used to create a JAXB Object from a series of child objects (wrap) or
+ * get the child objects from a JAXB Object (unwrap)
+ */
public interface JAXBWrapperTool {
/**
* unwrap
- * Returns the list of child elements of the jaxb object
+ * Returns the list of child objects of the jaxb object
* @param jaxbObject that is the wrapper element (JAXBElement or object with @XMLRootElement)
* @param jaxbContext JAXBContext
* @param childNames list of xml child names as String
@@ -50,18 +51,7 @@
* @return list of Objects in the same order as the element names.
*/
public Object wrap(Class jaxbClass, ArrayList<String> childNames, Map<String, Object> childObjects) throws JAXBWrapperException;
- /**
- * wrap
- * Creates a jaxb object that is initialized with the child objects
- *
- * * Note that the jaxbClass must be the class the represents the complexType. (It should never be JAXBElement)
- *
- * @param jaxbClass
- * @param methodParameters
- * @return
- * @throws JAXBWrapperException
- */
- public Object wrap(Class jaxbClass, ArrayList<MethodParameter> methodParameters) throws JAXBWrapperException;
+
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java?view=diff&rev=473743&r1=473742&r2=473743
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java Sat Nov 11 08:06:57 2006
@@ -28,11 +28,8 @@
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.namespace.QName;
-import org.apache.axis2.jaxws.description.ParameterDescription;
import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.marshaller.MethodParameter;
import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
@@ -115,28 +112,6 @@
}catch(NoSuchFieldException e){
throw new JAXBWrapperException(e);
}
- }
-
- public Object wrap(Class jaxbClass, ArrayList<MethodParameter> mps) throws JAXBWrapperException{
- if(mps == null){
- throw new JAXBWrapperException(Messages.getMessage("JAXBWrapperErr7"));
- }
- ArrayList<String> nameList = new ArrayList<String>();
- Map<String, Object> objectList = new WeakHashMap<String, Object>();
- for(MethodParameter mp:mps){
- ParameterDescription pd = mp.getParameterDescription();
- String name = null;
- if(!mp.isWebResult()){
- name = pd.getParameterName();
- }else{
- name = mp.getWebResultName();
- }
- Object object = mp.getValue();
-
- nameList.add(name);
- objectList.put(name, object);
- }
- return wrap(jaxbClass, nameList, objectList);
}
/** creates propertyDescriptor for the childNames using the jaxbClass.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org