Author: thomas.diesler(a)jboss.com
Date: 2008-02-29 04:16:37 -0500 (Fri, 29 Feb 2008)
New Revision: 5863
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
Log:
[JBWS-1857] JAXBContext created for every wrapper type
Fix NPE with JAXRPC clients
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-02-29
08:56:48 UTC (rev 5862)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-02-29
09:16:37 UTC (rev 5863)
@@ -620,22 +620,37 @@
private void eagerInitializeAccessors()
{
// Collect the list of all used types
+ boolean useJAXBAccessorFactory = false;
List<Class> types = new ArrayList<Class>();
for (OperationMetaData opMetaData : operations)
{
for (ParameterMetaData paramMetaData : opMetaData.getParameters())
{
+ AccessorFactoryCreator factoryCreator =
paramMetaData.getAccessorFactoryCreator();
+ if (factoryCreator instanceof JAXBAccessorFactoryCreator)
+ useJAXBAccessorFactory = true;
+
types.add(paramMetaData.getJavaType());
}
ParameterMetaData retParam = opMetaData.getReturnParameter();
if (retParam != null)
+ {
+ AccessorFactoryCreator factoryCreator =
retParam.getAccessorFactoryCreator();
+ if (factoryCreator instanceof JAXBAccessorFactoryCreator)
+ useJAXBAccessorFactory = true;
+
types.add(retParam.getJavaType());
+ }
}
// Create a JAXBContext for those types
- Class[] typeArr = new Class[types.size()];
- JAXBRIContext jaxbCtx =
(JAXBRIContext)JAXBContextFactory.newInstance().createContext(types.toArray(typeArr));
+ JAXBRIContext jaxbCtx = null;
+ if (useJAXBAccessorFactory)
+ {
+ Class[] typeArr = new Class[types.size()];
+ jaxbCtx =
(JAXBRIContext)JAXBContextFactory.newInstance().createContext(types.toArray(typeArr));
+ }
// Create the accessors using a shared JAXBContext
for (OperationMetaData opMetaData : operations)
@@ -655,14 +670,12 @@
{
AccessorFactoryCreator factoryCreator = paramMetaData.getAccessorFactoryCreator();
if (factoryCreator instanceof JAXBAccessorFactoryCreator)
- {
((JAXBAccessorFactoryCreator)factoryCreator).setJAXBContext(jaxbCtx);
- AccessorFactory factory = factoryCreator.create(paramMetaData);
- for (WrappedParameter wrapped : paramMetaData.getWrappedParameters())
- wrapped.setAccessor(factory.create(wrapped));
- }
+
+ AccessorFactory factory = factoryCreator.create(paramMetaData);
+ for (WrappedParameter wrapped : paramMetaData.getWrappedParameters())
+ wrapped.setAccessor(factory.create(wrapped));
}
-
// ---------------------------------------------------------------
// Configuration provider impl
Show replies by date