Author: richard.opalka(a)jboss.com
Date: 2010-10-19 03:27:57 -0400 (Tue, 19 Oct 2010)
New Revision: 13152
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-19
05:05:14 UTC (rev 13151)
+++
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-19
07:27:57 UTC (rev 13152)
@@ -53,26 +53,58 @@
{
public final Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRef, final ClassLoader loader)
{
- final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
- WebServiceRef serviceRefAnnotation = null;
- if (annotatedElement != null)
- {
- this.processAddressingAnnotation(serviceRef, annotatedElement);
- this.processMTOMAnnotation(serviceRef, annotatedElement);
- this.processRespectBindingAnnotation(serviceRef, annotatedElement);
- serviceRefAnnotation = this.getWebServiceRefAnnotation(serviceRef,
annotatedElement);
- }
+ this.processAddressingAnnotation(serviceRef);
+ this.processMTOMAnnotation(serviceRef);
+ this.processRespectBindingAnnotation(serviceRef);
+ this.processHandlerChainAnnotation(serviceRef);
- final Class<?> targetClass = getTargetClass(annotatedElement,
serviceRefAnnotation);
+ final WebServiceRef serviceRefAnnotation =
this.getWebServiceRefAnnotation(serviceRef);
+ final Class<?> targetClass = getTargetClass(serviceRef,
serviceRefAnnotation);
final String targetClassName = (targetClass != null ? targetClass.getName() :
null);
final String serviceImplClassName = getServiceImplClassName(serviceRef,
serviceRefAnnotation, targetClass);
+ this.processWsdlOverride(serviceRef, serviceRefAnnotation, loader,
serviceImplClassName);
+
+ return this.createJAXWSReferenceable(serviceImplClassName, targetClassName,
serviceRef);
+ }
+
+ private void processWsdlOverride(final UnifiedServiceRefMetaData serviceRef,
+ final WebServiceRef serviceRefAnnotation, final ClassLoader loader, final String
serviceImplClassName)
+ {
// Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null
&& serviceRefAnnotation.wsdlLocation().length() > 0)
+ if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null
+ && serviceRefAnnotation.wsdlLocation().length() > 0)
serviceRef.setWsdlOverride(serviceRefAnnotation.wsdlLocation());
+ // Extract service QName for target service
+ if (null == serviceRef.getServiceQName())
+ {
+ try
+ {
+ Class<?> serviceClass = loader.loadClass(serviceImplClassName);
+ if (serviceClass.getAnnotation(WebServiceClient.class) != null)
+ {
+ WebServiceClient clientDecl = (WebServiceClient)
serviceClass.getAnnotation(WebServiceClient.class);
+ serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(),
clientDecl.name()));
+ //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl
location returned at this time would be null
+ if (clientDecl.wsdlLocation().length() > 0 &&
serviceRef.getWsdlLocation() == null)
+ {
+ serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ WSFException.rethrow("Cannot extract service QName for target
service", e);
+ }
+ }
+ }
+
+ private void processHandlerChainAnnotation(final UnifiedServiceRefMetaData
serviceRef)
+ {
// Set the handlerChain from @HandlerChain on the annotated element
String handlerChain = serviceRef.getHandlerChain();
+ AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
if (annotatedElement != null)
{
HandlerChain anHandlerChain =
annotatedElement.getAnnotation(HandlerChain.class);
@@ -87,50 +119,34 @@
{
new URL(handlerChain);
}
- catch (MalformedURLException ex)
+ catch (MalformedURLException ignored)
{
- Class<?> declaringClass = null;
- if (annotatedElement instanceof Field)
- declaringClass = ((Field) annotatedElement).getDeclaringClass();
- else if (annotatedElement instanceof Method)
- declaringClass = ((Method) annotatedElement).getDeclaringClass();
- else if (annotatedElement instanceof Class)
- declaringClass = (Class<?>) annotatedElement;
+ final Class<?> declaringClass = getDeclaringClass(annotatedElement);
handlerChain = declaringClass.getPackage().getName().replace('.',
'/') + "/" + handlerChain;
}
serviceRef.setHandlerChain(handlerChain);
}
+ }
- // Extract service QName for target service
- if (null == serviceRef.getServiceQName())
- {
- try
- {
- Class<?> serviceClass = loader.loadClass(serviceImplClassName);
- if (serviceClass.getAnnotation(WebServiceClient.class) != null)
- {
- WebServiceClient clientDecl = (WebServiceClient)
serviceClass.getAnnotation(WebServiceClient.class);
- serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(),
clientDecl.name()));
- //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl
location returned at this time would be null
- if (clientDecl.wsdlLocation().length() > 0 &&
serviceRef.getWsdlLocation() == null)
- {
- serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- WSFException.rethrow("Cannot extract service QName for target
service", e);
- }
- }
+ private Class<?> getDeclaringClass(final AnnotatedElement annotatedElement)
+ {
+ Class<?> declaringClass = null;
+ if (annotatedElement instanceof Field)
+ declaringClass = ((Field) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Method)
+ declaringClass = ((Method) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Class)
+ declaringClass = (Class<?>) annotatedElement;
- return this.createJAXWSReferenceable(serviceImplClassName, targetClassName,
serviceRef);
+ return declaringClass;
}
- private Class<?> getTargetClass(final AnnotatedElement annotatedElement,
WebServiceRef serviceRefAnnotation)
+ private Class<?> getTargetClass(final UnifiedServiceRefMetaData serviceRef,
WebServiceRef serviceRefAnnotation)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
+
Class<?> targetClass = null;
if (annotatedElement instanceof Field)
@@ -161,8 +177,15 @@
protected abstract Referenceable createJAXWSReferenceable(final String
serviceImplClass,
final String targetClassName, final UnifiedServiceRefMetaData serviceRef);
- private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef,
final AnnotatedElement annotatedElement)
+ private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof Addressing)
@@ -178,8 +201,15 @@
}
}
- private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef, final
AnnotatedElement annotatedElement)
+ private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof MTOM)
@@ -194,8 +224,15 @@
}
}
- private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData
serviceRef, final AnnotatedElement annotatedElement)
+ private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData
serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof RespectBinding)
@@ -209,8 +246,15 @@
}
}
- private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData
serviceRef, final AnnotatedElement annotatedElement)
+ private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData
serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement)
serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return null;
+ }
+
// Build the list of @WebServiceRef relevant annotations
final List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
@@ -251,7 +295,8 @@
return wsref;
}
- private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef,
final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
+ private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef,
+ final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
{
String serviceImplClass = null;