Author: heiko.braun(a)jboss.com
Date: 2007-01-30 11:51:30 -0500 (Tue, 30 Jan 2007)
New Revision: 2194
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/acessor/JAXBAccessor.java
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/common/jaxb/JAXBContextTestCase.java
Log:
JAXB private API assumes that namespaces and localParts are use internalized
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/acessor/JAXBAccessor.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/acessor/JAXBAccessor.java 2007-01-30
16:33:53 UTC (rev 2193)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/acessor/JAXBAccessor.java 2007-01-30
16:51:30 UTC (rev 2194)
@@ -21,21 +21,15 @@
*/
package org.jboss.ws.metadata.acessor;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-
-import org.jboss.ws.WSException;
-import org.jboss.ws.metadata.umdm.Accessor;
-import org.jboss.ws.metadata.umdm.AccessorFactory;
-import org.jboss.ws.metadata.umdm.AccessorFactoryCreator;
-import org.jboss.ws.metadata.umdm.FaultMetaData;
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
-import org.jboss.ws.metadata.umdm.WrappedParameter;
-
import com.sun.xml.bind.api.AccessorException;
import com.sun.xml.bind.api.JAXBRIContext;
import com.sun.xml.bind.api.RawAccessor;
+import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.umdm.*;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
/**
* A JAXB object accessor.
*
@@ -51,20 +45,20 @@
public AccessorFactory create(ParameterMetaData parameter)
{
- return create(parameter.getJavaType());
+ return create(parameter.getJavaType(),
parameter.getOperationMetaData().getEndpointMetaData().getClassLoader());
}
public AccessorFactory create(FaultMetaData fault)
{
- return create(fault.getFaultBean());
+ return create(fault.getFaultBean(),
fault.getOperationMetaData().getEndpointMetaData().getClassLoader());
}
- private AccessorFactory create(final Class clazz)
+ private AccessorFactory create(final Class clazz, ClassLoader loader)
{
final JAXBRIContext ctx;
try
{
- ctx = (JAXBRIContext)JAXBRIContext.newInstance(new Class[] { clazz });
+ ctx = (JAXBRIContext)JAXBRIContext.newInstance(clazz.getPackage().getName(),
loader);
}
catch (JAXBException e)
{
@@ -73,7 +67,7 @@
throw ex;
}
- return new AccessorFactory()
+ return new AccessorFactory()
{
public Accessor create(WrappedParameter parameter)
{
@@ -81,7 +75,11 @@
try
{
QName name = parameter.getName();
- accessor = ctx.getElementPropertyAccessor(clazz,
name.getNamespaceURI(), name.getLocalPart());
+ accessor = ctx.getElementPropertyAccessor(
+ clazz,
+ name.getNamespaceURI().intern(), // JAXB internally optimizes String
usage towards intern()
+ name.getLocalPart().intern() // see
com.sun.xml.bind.v2.util.QNameMap;
+ );
}
catch (Throwable t)
{
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-01-30
16:33:53 UTC (rev 2193)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-01-30
16:51:30 UTC (rev 2194)
@@ -238,7 +238,7 @@
Class wrapperBean = null;
try
{
- ClassLoader loader =
getOperationMetaData().getEndpointMetaData().getClassLoader();
+ ClassLoader loader = getClassLoader();
wrapperBean = JavaUtils.loadJavaType(javaTypeName, loader);
}
catch (ClassNotFoundException ex)
@@ -258,7 +258,7 @@
{
try
{
- ClassLoader loader = opMetaData.getEndpointMetaData().getClassLoader();
+ ClassLoader loader = getClassLoader();
tmpJavaType = JavaUtils.loadJavaType(javaTypeName, loader);
UnifiedMetaData wsMetaData =
opMetaData.getEndpointMetaData().getServiceMetaData().getUnifiedMetaData();
@@ -436,7 +436,7 @@
// reset java type
javaType = null;
- // FIXME - Remove messageType hack
+ // TODO - Remove messageType hack
Type epType = getOperationMetaData().getEndpointMetaData().getType();
if (getOperationMetaData().isDocumentWrapped() && !isInHeader() &&
!isSwA() && !isMessageType())
{
@@ -445,7 +445,7 @@
if (epType == EndpointMetaData.Type.JAXRPC)
throw new WSException("Autogeneration of wrapper beans not
supported with JAXRPC");
- new DynamicWrapperGenerator(getClassLoader()).generate(this);
+ new DynamicWrapperGenerator( getClassLoader() ).generate(this);
}
// Initialize accessors
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/common/jaxb/JAXBContextTestCase.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/common/jaxb/JAXBContextTestCase.java 2007-01-30
16:33:53 UTC (rev 2193)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/common/jaxb/JAXBContextTestCase.java 2007-01-30
16:51:30 UTC (rev 2194)
@@ -21,6 +21,10 @@
*/
package org.jboss.test.ws.common.jaxb;
+import com.sun.xml.bind.api.JAXBRIContext;
+import com.sun.xml.bind.api.RawAccessor;
+import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
+import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.interop.soapwsdl.basedoclitw.RetByteArray;
@@ -28,9 +32,6 @@
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
-import com.sun.xml.bind.api.JAXBRIContext;
-import com.sun.xml.bind.api.RawAccessor;
-
/**
* Test JAXB usage with artifacts that have been created through a tools layer.
*
@@ -69,11 +70,16 @@
public void testAccessor() throws Exception
{
try {
+
QName name = new
QName("http://tempuri.org/",
"inByteArray");
- Class<RetByteArray> aClass = RetByteArray.class;
- JAXBContext ctx = JAXBContext.newInstance(new Class[] { aClass });
- RawAccessor accessor = ((JAXBRIContext)ctx).getElementPropertyAccessor(aClass,
name.getNamespaceURI(), name.getLocalPart());
+ final Class aClass = RetByteArray.class;
+ JAXBRIContext ctx = (JAXBRIContext)JAXBRIContext.newInstance(new Class[] {
aClass });
+
+ JaxBeanInfo bi = ((JAXBContextImpl)ctx).getBeanInfo(aClass);
+
+ RawAccessor accessor = ctx.getElementPropertyAccessor(aClass,
name.getNamespaceURI(), name.getLocalPart());
assertNotNull(accessor);
+
RetByteArray byteArray = new RetByteArray();
accessor.set(byteArray, "Hello World".getBytes());
assertEquals(accessor.get(byteArray), "Hello World".getBytes());