You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2006/10/27 14:49:59 UTC
svn commit: r468361 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/client/proxy/
src/org/apache/axis2/jaxws/core/controller/
src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/j...
Author: scheu
Date: Fri Oct 27 05:49:57 2006
New Revision: 468361
URL: http://svn.apache.org/viewvc?view=rev&rev=468361
Log:
AXIS2-1450
Contributor: Rich Scheuerle
JAXBBlockContext refactoring
Added:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/ClassUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
Removed:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/BlockContext.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
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/marshaller/impl/MethodMarshallerImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/BlockFactory.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/JAXBBlockFactory.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.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
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java Fri Oct 27 05:49:57 2006
@@ -21,9 +21,11 @@
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.handler.PortData;
import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.marshaller.ClassUtils;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -55,7 +57,10 @@
Message message = null;
try {
JAXBBlockFactory factory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
- Block block = factory.createFrom(value, jaxbContext, null);
+
+ Class clazz = value.getClass();
+ JAXBBlockContext context = new JAXBBlockContext(clazz, !ClassUtils.isXmlRootElementDefined(clazz), jaxbContext);
+ Block block = factory.createFrom(value, context, null);
// The protocol of the Message that is created should be based
// on the binding information available.
@@ -75,8 +80,8 @@
Object value = null;
try {
JAXBBlockFactory factory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
-
- Block block = message.getBodyBlock(0, jaxbContext, factory);
+ JAXBBlockContext context = new JAXBBlockContext(null, false, jaxbContext);
+ Block block = message.getBodyBlock(0, context, factory);
value = block.getBusinessObject(true);
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(e);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java Fri Oct 27 05:49:57 2006
@@ -24,6 +24,7 @@
import org.apache.axis2.jaxws.impl.AsyncListener;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -55,8 +56,8 @@
Message message = mc.getMessage();
try {
JAXBBlockFactory factory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
-
- Block block = message.getBodyBlock(0, jaxbContext, factory);
+ JAXBBlockContext context = new JAXBBlockContext(null, false, jaxbContext);
+ Block block = message.getBodyBlock(0, context, factory);
value = block.getBusinessObject(true);
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(e);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Fri Oct 27 05:49:57 2006
@@ -162,6 +162,7 @@
if (log.isDebugEnabled()) {
log.debug("Attempting to Invoke SEI Method "+ method.getName());
}
+
initialize();
InvocationContext requestIC = InvocationContextFactory.createInvocationContext(null);
MessageContext requestContext = createRequest(method, args);
@@ -282,6 +283,7 @@
if (log.isDebugEnabled()) {
log.debug("Message Converted to response Throwable. Throwing back to client.");
}
+
throw (Throwable)object;
}
Object object = methodMarshaller.demarshalResponse(responseMsg, args);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Fri Oct 27 05:49:57 2006
@@ -128,13 +128,15 @@
// do nothing here. The exception we get is from the endpoint,
// and will be sitting on the message context. We need to save it
// to process it through jaxws
+ System.out.println("Swallowed Exception =" + af);
+ af.printStackTrace(System.out);
}
try {
// Collect the response MessageContext and envelope
axisResponseMsgCtx = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
response = new MessageContext(axisResponseMsgCtx);
-
+
// This assumes that we are on the ultimate execution thread
ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, axisResponseMsgCtx);
} catch (AxisFault e) {
@@ -180,6 +182,8 @@
// do nothing here. The exception we get is from the endpoint,
// and will be sitting on the message context. We need to save it
// to process it through jaxws
+ System.out.println("Swallowed Exception =" + af);
+ af.printStackTrace(System.out);
}
return;
@@ -268,6 +272,8 @@
// do nothing here. The exception we get is from the endpoint,
// and will be sitting on the message context. We need to save it
// to process it through jaxws
+ System.out.println("Swallowed Exception =" + af);
+ af.printStackTrace(System.out);
}
// Now that the request has been sent, start the listener thread so that it can
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/OperationDescription.java Fri Oct 27 05:49:57 2006
@@ -551,13 +551,13 @@
public String getWebFaultClassName() {
// TODO will need to pass in the exception class to compare with the names???
- return getWebFaultClassNames()[0];
+ return getWebFaultClassNames().length== 0 ? null:getWebFaultClassNames()[0];
}
public String getWebExceptionClassName() {
// TODO will need to pass in the fault detail child element name (as a string) to
// compare with the WebFault of the declared exceptions
- return getWebExceptionClassNames()[0];
+ return getWebExceptionClassNames().length== 0 ? null:getWebExceptionClassNames()[0];
}
// ===========================================
// ANNOTATION: WebParam
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Fri Oct 27 05:49:57 2006
@@ -114,3 +114,4 @@
validateUserName=Error: A value must be specified when setting the javax.xml.ws.security.auth.username property.
validatePassword=Error: A value must be specified when setting the javax.xml.ws.security.auth.password property.
checkUsernameAndPassword=Error: The javax.xml.ws.security.auth.username user name and the javax.xml.ws.security.auth.password password must be specified.
+JAXBBlockFactoryErr1=An internal assertion error occurred. The context parameter of JAXBBlockFactory should be a JAXBBlockContext object, but a {0} object was found.
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/ClassUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/ClassUtils.java?view=auto&rev=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/ClassUtils.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/ClassUtils.java Fri Oct 27 05:49:57 2006
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.axis2.jaxws.marshaller;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+
+import javax.management.openmbean.SimpleType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Contains static Class utility methods related to method parameter/argument
+ * marshalling.
+ */
+public class ClassUtils {
+
+ private static Log log = LogFactory.getLog(ClassUtils.class);
+
+
+ /**
+ * Gets the RootCause for an throwable.
+ * The root cause is defined as the first non-InvocationTargetException.
+ * @param e Throwable
+ * @return Throwable root cause
+ */
+ public static Throwable getRootCause(Throwable e) {
+ Throwable t = null;
+
+ if (e != null) {
+ if (e instanceof InvocationTargetException) {
+ t = ((InvocationTargetException) e).getTargetException();
+ } else {
+ t = null;
+ }
+
+ if (t != null) {
+ e = getRootCause(t);
+ }
+ }
+ return e;
+ }
+
+ /**
+ * @param clazz
+ * @return true if this class has a corresponding xml root element
+ */
+ public static boolean isXmlRootElementDefined(Class clazz){
+ // If the clazz is a primitive, then it does not have a corresponding root element.
+ if (clazz.isPrimitive() ||
+ getWrapperClass(clazz) != null) {
+ return false;
+ }
+ // TODO We could also prune out other known classes that will not have root elements defined.
+ // java.util.Date, arrays, java.math.BigInteger.
+
+ XmlRootElement root = (XmlRootElement) clazz.getAnnotation(XmlRootElement.class);
+ return root !=null;
+ }
+
+
+
+
+ private static HashMap loadClassMap = new HashMap();
+ static {
+ loadClassMap.put("byte", byte.class);
+ loadClassMap.put("int", int.class);
+ loadClassMap.put("short", short.class);
+ loadClassMap.put("long", long.class);
+ loadClassMap.put("float", float.class);
+ loadClassMap.put("double", double.class);
+ loadClassMap.put("boolean", boolean.class);
+ loadClassMap.put("char", char.class);
+ loadClassMap.put("void", void.class);
+ }
+
+ /**
+ * Converts text of the form
+ * Foo[] to the proper class name for loading [LFoo
+ */
+ private static HashMap loadableMap = new HashMap();
+ static {
+ loadableMap.put("byte", "B");
+ loadableMap.put("char", "C");
+ loadableMap.put("double", "D");
+ loadableMap.put("float", "F");
+ loadableMap.put("int", "I");
+ loadableMap.put("long", "J");
+ loadableMap.put("short", "S");
+ loadableMap.put("boolean", "Z");
+ }
+
+ /**
+ * @param text String
+ * @return String that can be used for Class.forName
+ */
+ public static String getLoadableClassName(String text) {
+ int bracket = text.indexOf("[");
+ if (text == null ||
+ bracket < 0 || // no array
+ bracket == 0) { // or already loadable
+ return text;
+ }
+ String className = text;
+
+ // Get the className without any array brackets
+ if (bracket > 0) {
+ className = className.substring(0, bracket);
+ }
+
+ // Now get the loadable name from the map or
+ // its L<className>;
+ String loadClass = (String) loadableMap.get(className);
+ if (loadClass == null) {
+ loadClass = "L" + className + ";";
+ }
+
+ // Now prepend [ for each array dimension
+ if (bracket > 0) {
+ int i = text.indexOf("]");
+ while (i > 0) {
+ loadClass = "[" + loadClass;
+ i = text.indexOf("]", i+1);
+ }
+ }
+ return loadClass;
+ }
+
+ /**
+ * Converts text of the form
+ * [LFoo to the Foo[]
+ */
+ public static String getTextClassName(String text) {
+ if (text == null ||
+ text.indexOf("[") != 0)
+ return text;
+ String className = "";
+ int index = 0;
+ while(index < text.length() &&
+ text.charAt(index) == '[') {
+ index ++;
+ className += "[]";
+ }
+ if (index < text.length()) {
+ if (text.charAt(index)== 'B')
+ className = "byte" + className;
+ else if (text.charAt(index) == 'C')
+ className = "char" + className;
+ else if (text.charAt(index) == 'D')
+ className = "double" + className;
+ else if (text.charAt(index) == 'F')
+ className = "float" + className;
+ else if (text.charAt(index) == 'I')
+ className = "int" + className;
+ else if (text.charAt(index) == 'J')
+ className = "long" + className;
+ else if (text.charAt(index) == 'S')
+ className = "short" + className;
+ else if (text.charAt(index) == 'Z')
+ className = "boolean" + className;
+ else if (text.equals("void"))
+ className = "void";
+ else {
+ className = text.substring(index+1, text.indexOf(";")) + className;
+ }
+ }
+ return className;
+ }
+
+ /**
+ * @param primitive
+ * @return java wrapper class or null
+ */
+ public static Class getWrapperClass(Class primitive)
+ {
+ if (primitive == int.class)
+ return java.lang.Integer.class;
+ else if (primitive == short.class)
+ return java.lang.Short.class;
+ else if (primitive == boolean.class)
+ return java.lang.Boolean.class;
+ else if (primitive == byte.class)
+ return java.lang.Byte.class;
+ else if (primitive == long.class)
+ return java.lang.Long.class;
+ else if (primitive == double.class)
+ return java.lang.Double.class;
+ else if (primitive == float.class)
+ return java.lang.Float.class;
+ else if (primitive == char.class)
+ return java.lang.Character.class;
+
+ return null;
+ }
+
+
+ /**
+ * @param wrapper
+ * @return primitive clas or null
+ */
+ public static Class getPrimitiveClass(Class wrapper)
+ {
+ if (wrapper == java.lang.Integer.class)
+ return int.class;
+ else if (wrapper == java.lang.Short.class)
+ return short.class;
+ else if (wrapper == java.lang.Boolean.class)
+ return boolean.class;
+ else if (wrapper == java.lang.Byte.class)
+ return byte.class;
+ else if (wrapper == java.lang.Long.class)
+ return long.class;
+ else if (wrapper == java.lang.Double.class)
+ return double.class;
+ else if (wrapper == java.lang.Float.class)
+ return float.class;
+ else if (wrapper == java.lang.Character.class)
+ return char.class;
+
+ return null;
+ }
+
+}
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=468361&r1=468360&r2=468361
==============================================================================
--- 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 Fri Oct 27 05:49:57 2006
@@ -192,6 +192,9 @@
return message;
}
-
-
+ private Class loadClass(String className)throws ClassNotFoundException{
+ // TODO J2W AccessController Needed
+ // Don't make this public, its a security exposure
+ return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java Fri Oct 27 05:49:57 2006
@@ -30,7 +30,6 @@
import javax.jws.WebParam.Mode;
import javax.management.openmbean.SimpleType;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
@@ -52,6 +51,7 @@
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.ClassUtils;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
import org.apache.axis2.jaxws.message.Block;
@@ -60,7 +60,7 @@
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.XMLFault;
import org.apache.axis2.jaxws.message.XMLFaultReason;
-import org.apache.axis2.jaxws.message.databinding.impl.BlockContext;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
@@ -114,29 +114,31 @@
Exception exception = null;
String className = operationDesc.getWebExceptionClassName();
String jaxbClassName = operationDesc.getWebFaultClassName();
- if(className == null || (className != null && className.length()==0)){
- // TODO do something here, like throw an exception?
- }
- else{
+
try {
- XMLFault xmlfault = message.getXMLFault();
- Class beanclass = loadClass(jaxbClassName);
- Block[] blocks = xmlfault.getDetailBlocks();
-
- if ((beanclass == null) || (blocks == null)) {
- exception = createGenericException(xmlfault.getReason().getText());
- } else {
- // TODO for now, just use the first block, until we do the resolution mentioned above
- Object obj = createFaultBusinessObject(beanclass, blocks[0]);
- // create the exception we actually want to throw
- Class exceptionclass = loadClass(className);
- exception = createCustomException(xmlfault.getReason().getText(), exceptionclass, obj);
- }
- } catch (Exception e) {
- // TODO if we have problems creating the exception object, we'll end up here,
- // where we should return at least a meaningfull exception to the user
- exception = ExceptionFactory.makeWebServiceException(e.toString());
- }
+ XMLFault xmlfault = message.getXMLFault();
+ Class beanclass = (jaxbClassName == null || jaxbClassName.length() ==0 || className == null || className.length() == 0)
+ ? null : loadClass(jaxbClassName);
+ Block[] blocks = xmlfault.getDetailBlocks();
+
+ if ((beanclass == null) || (blocks == null)) {
+ exception = createGenericException(xmlfault.getReason()
+ .getText());
+ } else {
+ // TODO for now, just use the first block, until we do the
+ // resolution mentioned above
+ Object obj = createFaultBusinessObject(beanclass, blocks[0]);
+ // create the exception we actually want to throw
+ Class exceptionclass = loadClass(className);
+ exception = createCustomException(xmlfault.getReason()
+ .getText(), exceptionclass, obj);
+ }
+ } catch (Exception e) {
+ // TODO if we have problems creating the exception object, we'll end
+ // up here,
+ // where we should return at least a meaningfull exception to the
+ // user
+ exception = ExceptionFactory.makeWebServiceException(e.toString());
}
return exception;
@@ -146,7 +148,7 @@
* @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#marshalFaultResponse(java.lang.Throwable)
*/
public Message marshalFaultResponse(Throwable throwable) throws IllegalAccessException, InvocationTargetException, JAXBException, ClassNotFoundException, NoSuchMethodException, MessageException, XMLStreamException {
- Throwable t = getRootCause(throwable);
+ Throwable t = ClassUtils.getRootCause(throwable);
String faultClazzName = operationDesc.getWebFaultClassName();
@@ -156,7 +158,9 @@
if (faultClazzName != null) {
Method getFaultInfo = t.getClass().getMethod("getFaultInfo", null);
faultBean = getFaultInfo.invoke(t, null);
- Block detailBlock = createJAXBBlock(faultBean, this.createJAXBContext(faultClazzName));
+ Class faultClazz = loadClass(faultClazzName);
+ JAXBBlockContext context = createJAXBBlockContext(faultClazz);
+ Block detailBlock = createJAXBBlock(faultBean, context);
String text = t.getMessage();
xmlfault = new XMLFault(null, // Use the default XMLFaultCode
new XMLFaultReason(text), // Assumes text is the language supported by the current Locale
@@ -377,24 +381,24 @@
return methodName.endsWith("Async") && (returnType.isAssignableFrom(Response.class) || returnType.isAssignableFrom(Future.class));
}
- protected boolean isXmlRootElementDefined(Class jaxbClass){
- XmlRootElement root = (XmlRootElement) jaxbClass.getAnnotation(XmlRootElement.class);
- return root !=null;
- }
+
protected <T> ArrayList<T> toArrayList(T[] objects){
return (objects!=null)? new ArrayList<T>(Arrays.asList(objects)):new ArrayList<T>();
}
- protected Block createJAXBBlock(Object jaxbObject, JAXBContext context) throws MessageException{
+ protected Block createJAXBBlock(Object jaxbObject, JAXBBlockContext context) throws MessageException{
JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
return factory.createFrom(jaxbObject,context,null);
}
- protected Block createJAXBBlock(String name, Object jaxbObject, JAXBContext context, String targetNamespace) throws MessageException{
+ protected Block createJAXBBlock(String name,
+ Object jaxbObject,
+ JAXBBlockContext context,
+ String targetNamespace) throws MessageException, JAXBException {
- JAXBIntrospector introspector = context.createJAXBIntrospector();
+ JAXBIntrospector introspector = context.getIntrospector();
if(introspector.isElement(jaxbObject)){
return createJAXBBlock(jaxbObject, context);
}
@@ -417,7 +421,7 @@
}
- protected Block createJAXBBlock(OMElement om, JAXBContext context)throws javax.xml.stream.XMLStreamException{
+ protected Block createJAXBBlock(OMElement om, JAXBBlockContext context)throws XMLStreamException, MessageException {
JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
return factory.createFrom(om,context,null);
@@ -437,19 +441,13 @@
return null;
}
- protected JAXBContext createJAXBContext(String wrapperClazzName) throws ClassNotFoundException, JAXBException {
- Class wrapperClazz = loadClass(wrapperClazzName);
- return createJAXBContext(wrapperClazz);
-
- }
- protected JAXBContext createJAXBContext(Class wrapperClazz) throws JAXBException{
- return JAXBContext.newInstance(new Class[]{wrapperClazz});
- }
-
- protected Class loadClass(String className)throws ClassNotFoundException{
+ private Class loadClass(String className)throws ClassNotFoundException{
+ // TODO J2W AccessController Needed
+ // Don't make this public, its a security exposure
return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
+
/**
* In this method I am trying get the return type of the method.
* if SEI method is Async pooling implmentation then return type is actual type in Generic Response, example Response<ClassName>.
@@ -574,11 +572,11 @@
}
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr2"));
}
- JAXBContext ctx = createJAXBContext(objectType);
+ JAXBBlockContext ctx = createJAXBBlockContext(objectType);
if (log.isDebugEnabled()) {
log.debug("Attempting to create Block");
}
- if(isXmlRootElementDefined(objectType)){
+ if(ClassUtils.isXmlRootElementDefined(objectType)){
block = createJAXBBlock(object, ctx);
}
else{
@@ -606,11 +604,11 @@
protected Message createMessage(Object jaxbObject, Class jaxbClazz, String jaxbClassName, String targetNamespace)throws JAXBException, MessageException, XMLStreamException{
Block bodyBlock = null;
- JAXBContext ctx = createJAXBContext(jaxbClazz);
+ JAXBBlockContext ctx = createJAXBBlockContext(jaxbClazz);
if (log.isDebugEnabled()) {
log.debug("Attempting to create Block");
}
- if(isXmlRootElementDefined(jaxbClazz)){
+ if(ClassUtils.isXmlRootElementDefined(jaxbClazz)){
bodyBlock = createJAXBBlock(jaxbObject, ctx);
}
else{
@@ -641,49 +639,50 @@
}
protected Object createBOFromHeaderBlock(Class jaxbClazz, Message message, String targetNamespace, String localPart) throws JAXBException, MessageException, XMLStreamException{
- JAXBContext ctx = createJAXBContext(jaxbClazz);
+
+ JAXBBlockContext blockContext = createJAXBBlockContext(jaxbClazz);
// Get a JAXBBlockFactory instance. We'll need this to get the JAXBBlock
// out of the Message
JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
- Block block = message.getHeaderBlock(targetNamespace, localPart, ctx, factory);
- return createBusinessObject(jaxbClazz, block);
+ Block block = message.getHeaderBlock(targetNamespace, localPart, blockContext, factory);
+ return block.getBusinessObject(true);
}
protected Object createBOFromBodyBlock(Class jaxbClazz, Message message) throws JAXBException, MessageException, XMLStreamException{
return createBusinessObject(jaxbClazz, message);
}
+
protected Object createBusinessObject(Class jaxbClazz, Message message) throws JAXBException, MessageException, XMLStreamException{
- JAXBContext ctx = createJAXBContext(jaxbClazz);
+ JAXBBlockContext blockContext = createJAXBBlockContext(jaxbClazz);
// Get a JAXBBlockFactory instance. We'll need this to get the JAXBBlock
// out of the Message
JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
- Block block = message.getBodyBlock(0, ctx, factory);
- return createBusinessObject(jaxbClazz, block);
+ Block block = message.getBodyBlock(0, blockContext, factory);
+ return block.getBusinessObject(true);
}
- protected Object createBusinessObject(Class jaxbClazz, Block block)
- throws JAXBException, MessageException, XMLStreamException {
- if (jaxbClazz.isPrimitive() || isSimpleType(jaxbClazz)
- || !isXmlRootElementDefined(jaxbClazz)) {
- BlockContext bc = new BlockContext();
- bc.setDeclareType(jaxbClazz);
- block.setBlockContext(bc);
- }
- return block.getBusinessObject(true);
+ private JAXBBlockContext createJAXBBlockContext(Class jaxbClazz) throws JAXBException, MessageException {
+ // Primitives, simpleTypes and classes without a root element must be represented as a JAXBElement
+ boolean useJAXBElement = !ClassUtils.isXmlRootElementDefined(jaxbClazz);
+
+ JAXBBlockContext blockContext = new JAXBBlockContext(jaxbClazz, useJAXBElement);
+
+ return blockContext;
}
protected Object createFaultBusinessObject(Class jaxbClazz, Block block)
throws JAXBException, MessageException, XMLStreamException {
- JAXBContext ctx = createJAXBContext(jaxbClazz);
+ JAXBBlockContext blockContext = createJAXBBlockContext(jaxbClazz);
+
OMElement om = block.getOMElement();
XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
- Unmarshaller u = ctx.createUnmarshaller();
+ Unmarshaller u = blockContext.getUnmarshaller();
Reader inputReader = new InputStreamReader(new ByteArrayInputStream(om
.toString().getBytes()));
XMLStreamReader sr = xmlFactory.createXMLStreamReader(inputReader);
@@ -765,15 +764,7 @@
}
- protected boolean isSimpleType(Class clazz) {
- String[] allOpenTypes = SimpleType.ALLOWED_CLASSNAMES;
- for (String openType : allOpenTypes) {
- if (clazz.getName().equals(openType)) {
- return true;
- }
- }
- return false;
- }
+
protected Object findProperty(String propertyName, Object jaxbObject)throws JAXBWrapperException{
JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
@@ -809,20 +800,4 @@
return ExceptionFactory.makeWebServiceException(message);
}
- private static Throwable getRootCause(Throwable e) {
- Throwable t = null;
-
- if (e != null) {
- if (e instanceof InvocationTargetException) {
- t = ((InvocationTargetException) e).getTargetException();
- } else {
- t = null;
- }
-
- if (t != null) {
- e = getRootCause(t);
- }
- }
- return e;
- }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java Fri Oct 27 05:49:57 2006
@@ -23,7 +23,6 @@
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMElement;
-import org.apache.axis2.jaxws.message.databinding.impl.BlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
/**
@@ -140,19 +139,4 @@
* Set the XMLPart that will contain this Block.
*/
public void setParent(XMLPart p);
- /**
- * @returns the Block Context, BlockContext stores the context information of the Block. Example, this holds something that the Block would need in order to
- * serialize or deserialize correctly.
- *
- */
- public BlockContext getBlockContext();
-
- /**
- * sets the block context, BlockContext stores the context information of the Block. Example, this holds something that the Block would need in order to
- * serialize or deserialize correctly further example is JAXBBlock store the declared Type that it can later use to unmarshal a Message if it holds
- * a primitive type.
- * @param blockContext
- */
- public void setBlockContext(BlockContext blockContext);
-
}
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java?view=auto&rev=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java Fri Oct 27 05:49:57 2006
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.axis2.jaxws.message.databinding;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.JAXBIntrospector;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+/*
+ * A JAXBBlockContext controls access to the JAXB Context/Marshal/Unmarshal code.
+ * In addition the JAXBBlockContext contains additional contextural information needed
+ * by the JAX-WS component (i.e. the type of the object)
+ *
+ * This class is immutable after construction.
+ */
+public class JAXBBlockContext {
+
+ private Class type = null;
+ private JAXBContext jaxbContext = null;
+ private boolean useJAXBElement = false;
+ private JAXBIntrospector introspector = null;
+
+ /**
+ * Normal Constructor JAXBBlockContext
+ * @param type Class object that represents the actual type of the object.
+ * @param useJAXBElement boolean indicating whether the object should be rendered
+ * as a JAXBElement.
+ *
+ * Example: if the object is a primitive (type=int.class) then
+ * useJAXBElement must be set to true because int is not a JAXB object.
+ *
+ * Example: if the object is a JAXB object you would normally set useJAXBElement
+ * to false. However if the JAXB object does not have a corresponding root element,
+ * then useJAXBElement hould be set to false.
+ */
+ public JAXBBlockContext(Class type, boolean useJAXBElement) {
+ this(type, useJAXBElement, null);
+ }
+
+ /**
+ * "Dispatch" Constructor
+ * Use this full constructor when the JAXBContent is provided by
+ * the customer.
+ * @param type
+ * @param useJAXBElement
+ * @param jaxbContext
+ */
+ public JAXBBlockContext(Class type, boolean useJAXBElement, JAXBContext jaxbContext) {
+ this.type = type;
+ this.useJAXBElement = useJAXBElement;
+ this.jaxbContext = jaxbContext;
+ }
+
+ /**
+ * @return Class representing type of the element
+ */
+ public Class getType() {
+ return type;
+ }
+
+ /**
+ * @return indicate if object should be rendered as JAXBElement
+ */
+ public boolean isUseJAXBElement() {
+ return useJAXBElement;
+ }
+
+ /**
+ * @return get the JAXBContext
+ * @throws JAXBException
+ */
+ public JAXBContext getJAXBContext() throws JAXBException {
+ if (jaxbContext == null) {
+ if (!useJAXBElement) {
+ // TODO Need J2W AccessController
+ // TODO Need to cache this
+ jaxbContext = JAXBContext.newInstance(new Class[]{type});
+ } else {
+ // TODO This may be overkill.
+ jaxbContext = JAXBContext.newInstance(new Class[]{type});
+ }
+ }
+ return jaxbContext;
+ }
+
+
+
+ /**
+ * @return Unmarshaller
+ * @throws JAXBException
+ */
+ public Unmarshaller getUnmarshaller() throws JAXBException {
+ // TODO A New unmarahller is always created. We should consider how to recognize if when a marshaller can be reused.
+
+ Unmarshaller unmarshaller = null;
+ JAXBContext jc = getJAXBContext();
+ if (!useJAXBElement) {
+ // TODO Caching
+ unmarshaller = jc.createUnmarshaller();
+ } else {
+ // TODO There may be a way to share JAXBElement unmarshallers ?
+ unmarshaller = jc.createUnmarshaller();
+ }
+ // TODO Additional options for unmarshaller ?
+
+ // TODO Should we set up MTOM Attachment handler here ?
+
+ return unmarshaller;
+ }
+
+ /**
+ * @return Marshaller
+ * @throws JAXBException
+ */
+ public Marshaller getMarshaller() throws JAXBException {
+ // TODO A New marahller is always created. We should consider how to recognize if when a marshaller can be reused.
+ Marshaller marshaller = null;
+ JAXBContext jc = getJAXBContext();
+ if (!useJAXBElement) {
+ // TODO Caching
+ marshaller = jc.createMarshaller();
+ } else {
+ // TODO There may be a way to share these ?
+ marshaller = jc.createMarshaller();
+ }
+ // TODO Additional options for marshaller ?
+ marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); // No PIs
+
+ // TODO Should we set up MTOM Attachment handler here ?
+ return marshaller;
+ }
+
+ /**
+ * @return Intospector
+ * @throws JAXBException
+ */
+ public JAXBIntrospector getIntrospector() throws JAXBException {
+ if (introspector == null) {
+ JAXBContext jc = getJAXBContext();
+ if (!useJAXBElement) {
+ // TODO Caching
+ introspector = jc.createJAXBIntrospector();
+ } else {
+ // TODO There may be a way to share these ?
+ introspector = jc.createJAXBIntrospector();
+ }
+ // TODO Additional options for unmarshaller ?
+
+ // TODO Should we set up MTOM Attachment handler here ?
+ }
+ return introspector;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockFactoryImpl.java Fri Oct 27 05:49:57 2006
@@ -16,11 +16,17 @@
*/
package org.apache.axis2.jaxws.message.databinding.impl;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.impl.BlockFactoryImpl;
@@ -41,15 +47,37 @@
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.message.BlockFactory#createFrom(org.apache.axiom.om.OMElement, java.lang.Object, javax.xml.namespace.QName)
*/
- public Block createFrom(OMElement omElement, Object context, QName qName) throws XMLStreamException {
- return new JAXBBlockImpl(omElement, context, qName, this);
+ public Block createFrom(OMElement omElement, Object context, QName qName) throws XMLStreamException, MessageException {
+ // The context for a JAXBFactory must be non-null and should be a JAXBBlockContext.
+ if (context == null) {
+ throw ExceptionFactory.makeMessageException(Messages.getMessage("JAXBBlockFactoryErr1", "null"), null);
+ } else if (context instanceof JAXBBlockContext) {
+ ;
+ } else {
+ throw ExceptionFactory.makeMessageException(Messages.getMessage("JAXBBlockFactoryErr1", context.getClass().getName()), null);
+ }
+ return new JAXBBlockImpl(omElement, (JAXBBlockContext) context, qName, this);
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.message.BlockFactory#createFrom(java.lang.Object, java.lang.Object, javax.xml.namespace.QName)
*/
- public Block createFrom(Object businessObject, Object context, QName qName) {
- return new JAXBBlockImpl(businessObject, context, qName, this);
+ public Block createFrom(Object businessObject, Object context, QName qName) throws MessageException {
+
+ // The context for a JAXBFactory must be non-null and should be a JAXBBlockContext.
+ // For legacy reasons, a JAXBContext is also supported (and wrapped into a JAXBBlockContext)
+ if (context == null) {
+ throw ExceptionFactory.makeMessageException(Messages.getMessage("JAXBBlockFactoryErr1", "null"), null);
+ } else if (context instanceof JAXBBlockContext) {
+ ;
+ } else {
+ throw ExceptionFactory.makeMessageException(Messages.getMessage("JAXBBlockFactoryErr1", context.getClass().getName()), null);
+ }
+ try {
+ return new JAXBBlockImpl(businessObject, (JAXBBlockContext) context, qName, this);
+ } catch (JAXBException e) {
+ throw ExceptionFactory.makeMessageException(e);
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Fri Oct 27 05:49:57 2006
@@ -19,7 +19,6 @@
import java.io.StringReader;
import java.io.StringWriter;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
@@ -40,8 +39,8 @@
import org.apache.axis2.jaxws.message.attachments.JAXBAttachmentMarshaller;
import org.apache.axis2.jaxws.message.attachments.JAXBAttachmentUnmarshaller;
import org.apache.axis2.jaxws.message.databinding.JAXBBlock;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
-import org.apache.axis2.jaxws.message.impl.BlockFactoryImpl;
import org.apache.axis2.jaxws.message.impl.BlockImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,10 +63,10 @@
* @param qName
* @param factory
*/
- JAXBBlockImpl(Object busObject, Object busContext, QName qName, BlockFactory factory) {
+ JAXBBlockImpl(Object busObject, JAXBBlockContext busContext, QName qName, BlockFactory factory) throws JAXBException {
super(busObject,
busContext,
- (qName==null) ? getQName(busObject, (JAXBContext) busContext): qName ,
+ (qName==null) ? getQName(busObject, busContext): qName ,
factory);
}
@@ -78,19 +77,18 @@
* @param qName
* @param factory
*/
- JAXBBlockImpl(OMElement omElement, Object busContext, QName qName, BlockFactory factory) {
+ JAXBBlockImpl(OMElement omElement, JAXBBlockContext busContext, QName qName, BlockFactory factory) {
super(omElement, busContext, qName, factory);
}
@Override
protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) throws XMLStreamException, MessageException {
try {
- // Very easy, use the Context to get the Unmarshaller.
- // Use the Unmarshaller to get the jaxb object.
- JAXBContext jc = (JAXBContext) busContext;
- Unmarshaller u = jc.createUnmarshaller();
-
- BlockContext blockContext = getBlockContext();
+ // Get the JAXBBlockContext. All of the necessry information is recorded on it
+ JAXBBlockContext ctx = (JAXBBlockContext) busContext;
+
+ // TODO Re-evaluate Unmarshall construction w/ MTOM
+ Unmarshaller u = ctx.getUnmarshaller();
// If MTOM is enabled, add in the AttachmentUnmarshaller
if (isMTOMEnabled()) {
@@ -104,17 +102,14 @@
aum.setMessage(msg);
u.setAttachmentUnmarshaller(aum);
}
- //Read block context and determine if a declaredType is defined. If yes, then create JAXBElement and use that to create JAXB Object.
- Class declaredType = null;
- if(blockContext !=null){
- declaredType = blockContext.getDeclareType();
- }
- if(declaredType == null){
- Object jaxb = u.unmarshal(reader);
- setQName(getQName(jaxb, jc));
+ if (!ctx.isUseJAXBElement()){
+ // Normal Unmarshalling
+ Object jaxb = u.unmarshal(reader);
+ setQName(getQName(jaxb, ctx));
return jaxb;
}else{
- JAXBElement jaxbElement = u.unmarshal(reader, declaredType);
+ // Unmarshal as a JAXBElement and then get the value
+ JAXBElement jaxbElement = u.unmarshal(reader, ctx.getType());
Object jaxb = jaxbElement.getValue();
return jaxb;
}
@@ -151,10 +146,10 @@
try {
// Very easy, use the Context to get the Marshaller.
// Use the marshaller to write the object.
- JAXBContext jc = (JAXBContext) busContext;
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
-
+ JAXBBlockContext ctx = (JAXBBlockContext) busContext;
+ Marshaller m = ctx.getMarshaller();
+
+ // TODO Should MTOM be inside getMarshaller ?
// If MTOM is enabled, add in the AttachmentMarshaller.
if (isMTOMEnabled()) {
if (log.isDebugEnabled())
@@ -179,8 +174,8 @@
* @param jbc
* @throws MessageException
*/
- private static QName getQName(Object jaxb, JAXBContext jbc){
- JAXBIntrospector jbi = jbc.createJAXBIntrospector();
+ private static QName getQName(Object jaxb, JAXBBlockContext ctx) throws JAXBException {
+ JAXBIntrospector jbi = ctx.getIntrospector();
return jbi.getElementName(jaxb);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java Fri Oct 27 05:49:57 2006
@@ -178,7 +178,7 @@
try{
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result result = new StreamResult(out);
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(src, result);
ByteArrayInputStream bytes = new ByteArrayInputStream(out.toByteArray());
return inputFactory.createXMLStreamReader(bytes);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/BlockFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/BlockFactory.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/BlockFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/BlockFactory.java Fri Oct 27 05:49:57 2006
@@ -46,8 +46,9 @@
* @param context Associated Context or null
* @param QName if known...if null the Block will determine the QName
* @throws XMLStreamException
+ * @throws MessageException
*/
- public Block createFrom(XMLStreamReader reader, Object context, QName qName) throws XMLStreamException;
+ public Block createFrom(XMLStreamReader reader, Object context, QName qName) throws XMLStreamException, MessageException;
/**
* createBlock from XMLStreamReader
@@ -55,8 +56,9 @@
* @param context Associated Context or null
* @param QName if known...if null the Block will determine the QName
* @throws XMLStreamException
+ * @throws MessageException
*/
- public Block createFrom(OMElement omElement, Object context, QName qName) throws XMLStreamException;
+ public Block createFrom(OMElement omElement, Object context, QName qName) throws XMLStreamException, MessageException;
/**
* createBlock from another Block
@@ -67,6 +69,7 @@
* @param other Block
* @param context Associated Context or null
* @throws XMLStreamException
+ * @throws MessageException
*/
public Block createFrom(Block other, Object context) throws XMLStreamException, MessageException;
@@ -75,6 +78,8 @@
* @param businessObject
* @param context Associated Context or null
* @param QName if known...if null the Block will determine the QName
+ * @throws XMLStreamException
+ * @throws MessageException
*/
public Block createFrom(Object businessObject, Object context, QName qName) throws MessageException;
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/JAXBBlockFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/JAXBBlockFactory.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/JAXBBlockFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/factory/JAXBBlockFactory.java Fri Oct 27 05:49:57 2006
@@ -27,5 +27,4 @@
*
*/
public interface JAXBBlockFactory extends BlockFactory {
- // TODO The factory should expose methods to get the default JAXBContext, JAXBInspector, Marshaller, Unmarshaller, etc.
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java Fri Oct 27 05:49:57 2006
@@ -61,7 +61,7 @@
return newBlock;
}
- public Block createFrom(XMLStreamReader reader, Object context, QName qName) throws XMLStreamException {
+ public Block createFrom(XMLStreamReader reader, Object context, QName qName) throws XMLStreamException, MessageException {
StAXOMBuilder builder = new StAXOMBuilder(reader);
OMElement omElement = builder.getDocumentElement();
return createFrom(omElement, context, qName);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java Fri Oct 27 05:49:57 2006
@@ -34,7 +34,6 @@
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.XMLPart;
-import org.apache.axis2.jaxws.message.databinding.impl.BlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.util.Reader2Writer;
@@ -66,7 +65,6 @@
private BlockFactory factory;
private boolean consumed = false;
private XMLPart parent;
- private BlockContext blockContext;
/**
* A Block has the following components
@@ -102,14 +100,6 @@
public BlockFactory getBlockFactory() {
return factory;
}
-
- public BlockContext getBlockContext() {
- return blockContext;
- }
-
- public void setBlockContext(BlockContext blockContext) {
- this.blockContext = blockContext;
- }
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.message.Block#getBusinessContext()
@@ -285,6 +275,11 @@
busObject = null;
busContext = null;
omElement = null;
+ // Create an exception so that we can print a stack trace.
+ //Exception e = new RuntimeException();
+ //System.out.println("consumed block " + this.getClass() + " at ");
+ //e.printStackTrace(System.out);
+
} else {
consumed = false;
}
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=468361&r1=468360&r2=468361
==============================================================================
--- 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 Fri Oct 27 05:49:57 2006
@@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.Map;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
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=468361&r1=468360&r2=468361
==============================================================================
--- 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 Fri Oct 27 05:49:57 2006
@@ -20,19 +20,13 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
-import java.beans.PropertyEditor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Map;
import java.util.WeakHashMap;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.namespace.QName;
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java Fri Oct 27 05:49:57 2006
@@ -26,6 +26,7 @@
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
@@ -115,7 +116,8 @@
ImageDepot imageDepot = new ObjectFactory().createImageDepot();
imageDepot.setImageData(dataHandler);
- JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+ //JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+ JAXBBlockContext context = new JAXBBlockContext(SendImage.class, false);
//Create a request bean with imagedepot bean as value
ObjectFactory factory = new ObjectFactory();
@@ -123,7 +125,7 @@
request.setInput(imageDepot);
BlockFactory blkFactory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
- Block block = blkFactory.createFrom(request, jbc, null);
+ Block block = blkFactory.createFrom(request, context, null);
MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
Message msg = msgFactory.create(Protocol.soap11);
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java Fri Oct 27 05:49:57 2006
@@ -20,7 +20,6 @@
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
import java.io.StringWriter;
-import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBIntrospector;
@@ -45,6 +44,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
@@ -325,13 +325,14 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
- JAXBIntrospector jbi = jbc.createJAXBIntrospector();
+ JAXBBlockContext context = new JAXBBlockContext(EchoString.class, false);
+
+ JAXBIntrospector jbi = context.getIntrospector();
QName expectedQName = jbi.getElementName(jaxb);
// Create a Block using the sample string as the content. This simulates
// what occurs on the outbound JAX-WS dispatch<JAXB> client
- Block block = f.createFrom(jaxb, jbc, null);
+ Block block = f.createFrom(jaxb, context, null);
// JAXB objects set the qname from their internal data
assertTrue(block.isQNameAvailable());
@@ -373,13 +374,14 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
- JAXBIntrospector jbi = jbc.createJAXBIntrospector();
+ JAXBBlockContext context = new JAXBBlockContext(EchoString.class, false);
+
+ JAXBIntrospector jbi = context.getIntrospector();
QName expectedQName = jbi.getElementName(jaxb);
// Create a Block using the sample string as the content. This simulates
// what occurs with an outbound JAX-WS JAXB parameter
- Block block = f.createFrom(jaxb, jbc, expectedQName);
+ Block block = f.createFrom(jaxb, context, expectedQName);
// We did pass in a qname, so the following should return false
assertTrue(block.isQNameAvailable());
@@ -421,20 +423,20 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
+ JAXBBlockContext context = new JAXBBlockContext(EchoString.class, false);
// On inbound, there will already be a XMLStreamReader (probably from OM)
// which represents the message. We will simulate this with inflow.
StringWriter sw = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- jbc.createMarshaller().marshal(jaxb, writer);
+ context.getMarshaller().marshal(jaxb, writer);
writer.flush();
sw.flush();
StringReader sr = new StringReader(sw.toString());
XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
// Create a Block from the inflow.
- Block block = f.createFrom(inflow, jbc, null);
+ Block block = f.createFrom(inflow, context, null);
// We didn't pass in a qname, so the following should return false
assertTrue(!block.isQNameAvailable());
@@ -466,22 +468,23 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
- JAXBIntrospector jbi = jbc.createJAXBIntrospector();
+ JAXBBlockContext context = new JAXBBlockContext(EchoString.class, false);
+
+ JAXBIntrospector jbi = context.getIntrospector();
QName expectedQName = jbi.getElementName(jaxb);
// On inbound, there will already be a XMLStreamReader (probably from OM)
// which represents the message. We will simulate this with inflow.
StringWriter sw = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- jbc.createMarshaller().marshal(jaxb, writer);
+ context.getMarshaller().marshal(jaxb, writer);
writer.flush();
sw.flush();
StringReader sr = new StringReader(sw.toString());
XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
// Create a Block from the inflow.
- Block block = f.createFrom(inflow, jbc, null);
+ Block block = f.createFrom(inflow, context, null);
// We didn't pass in a qname, so the following should return false
assertTrue(!block.isQNameAvailable());
@@ -519,22 +522,23 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
- JAXBIntrospector jbi = jbc.createJAXBIntrospector();
+ JAXBBlockContext context = new JAXBBlockContext(EchoString.class, false);
+
+ JAXBIntrospector jbi = context.getIntrospector();
QName expectedQName = jbi.getElementName(jaxb);
// On inbound, there will already be a XMLStreamReader (probably from OM)
// which represents the message. We will simulate this with inflow.
StringWriter sw = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- jbc.createMarshaller().marshal(jaxb, writer);
+ context.getMarshaller().marshal(jaxb, writer);
writer.flush();
sw.flush();
StringReader sr = new StringReader(sw.toString());
XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
// Create a Block from the inflow.
- Block block = f.createFrom(inflow, jbc, expectedQName);
+ Block block = f.createFrom(inflow, context, expectedQName);
// We passed in a qname, so the following should return false
assertTrue(block.isQNameAvailable());
@@ -916,8 +920,9 @@
ObjectFactory factory = new ObjectFactory();
EchoString jaxb = factory.createEchoString();
jaxb.setInput("Hello World");
- JAXBContext jbc = JAXBContext.newInstance("test");
- JAXBSource src = new JAXBSource(jbc.createMarshaller(), jaxb);
+ JAXBContext context = JAXBContext.newInstance("test");
+
+ JAXBSource src = new JAXBSource(context.createMarshaller(), jaxb);
BlockFactory f = (SourceBlockFactory)
FactoryRegistry.getFactory(SourceBlockFactory.class);
@@ -952,11 +957,12 @@
FactoryRegistry.getFactory(SourceBlockFactory.class);
//Create a JAXBSource
- JAXBContext jbc = JAXBContext.newInstance("test");
- Unmarshaller u = jbc.createUnmarshaller();
+ JAXBContext context = JAXBContext.newInstance("test");
+
+ Unmarshaller u = context.createUnmarshaller();
ByteArrayInputStream inputStream = new ByteArrayInputStream(echoSample.getBytes());
EchoString jaxb = (EchoString)u.unmarshal(inputStream);
- JAXBSource src = new JAXBSource(jbc.createMarshaller(), jaxb);
+ JAXBSource src = new JAXBSource(context.createMarshaller(), jaxb);
// Create a Block using the sample string as the content. This simulates
// what occurs on the outbound JAX-WS dispatch<Source> client
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java Fri Oct 27 05:49:57 2006
@@ -19,7 +19,6 @@
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
-import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
@@ -32,6 +31,7 @@
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
@@ -39,6 +39,7 @@
import org.apache.axis2.jaxws.message.util.SAAJConverter;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import test.EchoString;
import test.EchoStringResponse;
import test.ObjectFactory;
@@ -506,11 +507,11 @@
obj.setEchoStringReturn("sample return value");
// Create the JAXBContext
- JAXBContext jbc = JAXBContext.newInstance("test");
+ JAXBBlockContext context = new JAXBBlockContext(EchoStringResponse.class, false);
// Create a JAXBBlock using the Echo object as the content. This simulates
// what occurs on the outbound JAX-WS Dispatch<Object> client
- Block block = bf.createFrom(obj, jbc, null);
+ Block block = bf.createFrom(obj, context, null);
// Add the block to the message as normal body content.
m.setBodyBlock(0, block);
@@ -572,12 +573,11 @@
obj.setEchoStringReturn("sample return value");
// Create the JAXBContext
- JAXBContext jbc = JAXBContext.newInstance("test");
-
-
+ JAXBBlockContext context = new JAXBBlockContext(EchoStringResponse.class, false);
+
// Create a JAXBBlock using the Echo object as the content. This simulates
// what occurs on the outbound JAX-WS Dispatch<Object> client
- Block block = bf.createFrom(obj, jbc, null);
+ Block block = bf.createFrom(obj, context, null);
// Add the block to the message as normal body content.
m.setBodyBlock(0, block);
@@ -655,10 +655,10 @@
// Create the JAXBContext instance that will be used
// to deserialize the JAX-B object content in the message.
- JAXBContext jbc = JAXBContext.newInstance("test");
+ JAXBBlockContext context = new JAXBBlockContext(EchoStringResponse.class, false);
// Get the JAXBBlock that wraps the content
- Block b = m.getBodyBlock(0, jbc, bf);
+ Block b = m.getBodyBlock(0, context, bf);
// Check to see if the message is a fault. The client/server will always call this method.
// The Message must respond appropriately without doing a conversion.
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java?view=diff&rev=468361&r1=468360&r2=468361
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java Fri Oct 27 05:49:57 2006
@@ -25,7 +25,7 @@
*/
public String echoMessage(String request) {
String response = null;
-
+ System.out.println("echoMessage received: " + request);
response = request.replaceAll("Server", "Client");
return response;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org