Author: richard.opalka(a)jboss.com
Date: 2011-08-15 08:37:12 -0400 (Mon, 15 Aug 2011)
New Revision: 14844
Modified:
common/trunk/src/main/java/org/jboss/ws/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
Log:
[JBWS-3338] construct ports using features properly
Modified:
common/trunk/src/main/java/org/jboss/ws/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2011-08-15
12:23:15 UTC (rev 14843)
+++
common/trunk/src/main/java/org/jboss/ws/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2011-08-15
12:37:12 UTC (rev 14844)
@@ -193,7 +193,9 @@
Class<?> retType = method.getReturnType();
if (methodName.startsWith("get") &&
targetClass.isAssignableFrom(retType))
{
- port = method.invoke(target, new Object[0]);
+ final Method targetMethod = getMethodFor(methodName, features,
serviceClass);
+ final Object[] args = getArgumentsFor(features);
+ port = targetMethod.invoke(target, args);
retVal = port;
break;
}
@@ -202,7 +204,7 @@
if (port == null)
{
- Method method = getMethodFor(portQName, features, serviceClass);
+ Method method = getMethodFor("getPort", portQName, features,
serviceClass);
Object[] args = getArgumentsFor(portQName, features, targetClass);
port = method.invoke(target, args);
retVal = port;
@@ -347,25 +349,38 @@
return null;
}
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features,
final Class<?> serviceClass)
+ private Method getMethodFor(final String methodName, final QName portQName, final
WebServiceFeature[] features, final Class<?> serviceClass)
throws NoSuchMethodException
{
if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
+ return serviceClass.getMethod(methodName, new Class[]
{Class.class});
if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
+ return serviceClass.getMethod(methodName, new Class[]
{QName.class, Class.class});
if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
+ return serviceClass.getMethod(methodName, new Class[]
{Class.class, WebServiceFeature[].class});
if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
+ return serviceClass.getMethod(methodName, new Class[]
{QName.class, Class.class, WebServiceFeature[].class});
throw new IllegalStateException();
}
+ private Method getMethodFor(final String methodName, final WebServiceFeature[]
features, final Class<?> serviceClass)
+ throws NoSuchMethodException
+ {
+ if (features == null)
+ {
+ return serviceClass.getMethod(methodName, new Class[] {});
+ }
+ else
+ {
+ return serviceClass.getMethod(methodName, new Class[] {
WebServiceFeature[].class } );
+ }
+ }
+
private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[]
features,
final Class<?> targetClass) throws NoSuchMethodException
{
@@ -385,6 +400,18 @@
throw new IllegalStateException();
}
+ private Object[] getArgumentsFor(final WebServiceFeature[] features) throws
NoSuchMethodException
+ {
+ if (features == null)
+ {
+ return new Object[] {};
+ }
+ else
+ {
+ return new Object[] {features};
+ }
+ }
+
private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
{
List<WebServiceFeature> features = new
LinkedList<WebServiceFeature>();
@@ -427,8 +454,9 @@
{
List<WebServiceFeature> features = new
LinkedList<WebServiceFeature>();
// configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
+ if (portComponentRefMD.isAddressingAnnotationSpecified())
{
+ final boolean enabled = portComponentRefMD.isAddressingEnabled();
final boolean required = portComponentRefMD.isAddressingRequired();
final String refResponses = portComponentRefMD.getAddressingResponses();
AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
@@ -437,7 +465,7 @@
if ("NON_ANONYMOUS".equals(refResponses))
responses = AddressingFeature.Responses.NON_ANONYMOUS;
- features.add(new AddressingFeature(true, required, responses));
+ features.add(new AddressingFeature(enabled, required, responses));
}
// configure @MTOM feature
@@ -447,9 +475,10 @@
}
// configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
+ if (portComponentRefMD.isRespectBindingAnnotationSpecified())
{
- features.add(new RespectBindingFeature(true));
+ final boolean enabled = portComponentRefMD.isRespectBindingEnabled();
+ features.add(new RespectBindingFeature(enabled));
}
return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]