Author: alessio.soldano(a)jboss.com
Date: 2009-01-22 11:36:24 -0500 (Thu, 22 Jan 2009)
New Revision: 9098
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/FastInfoset.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/JsonEncoding.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
Log:
[JBWS-2446] Adding @WebServiceFeature meta-annotation to JsonEncoding and FastInfoset
feature annotation + rejecting unsupported features
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/FastInfoset.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/FastInfoset.java 2009-01-22
15:14:24 UTC (rev 9097)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/FastInfoset.java 2009-01-22
16:36:24 UTC (rev 9098)
@@ -26,6 +26,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
+
import org.jboss.ws.feature.FastInfosetFeature;
/**
@@ -37,6 +39,7 @@
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE })
@EndpointFeature( id = FastInfosetFeature.ID)
+@WebServiceFeatureAnnotation(id = FastInfosetFeature.ID, bean =
FastInfosetFeature.class)
public @interface FastInfoset {
/**
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/JsonEncoding.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/JsonEncoding.java 2009-01-22
15:14:24 UTC (rev 9097)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/annotation/JsonEncoding.java 2009-01-22
16:36:24 UTC (rev 9098)
@@ -26,6 +26,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
+
import org.jboss.ws.feature.JsonEncodingFeature;
/**
@@ -37,6 +39,7 @@
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE })
@EndpointFeature(id = JsonEncodingFeature.ID)
+@WebServiceFeatureAnnotation(id = JsonEncodingFeature.ID, bean =
JsonEncodingFeature.class)
public @interface JsonEncoding {
/**
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-01-22
15:14:24 UTC (rev 9097)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-01-22
16:36:24 UTC (rev 9098)
@@ -35,6 +35,8 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.jaxws.binding.BindingExt;
import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
+import org.jboss.ws.feature.FastInfosetFeature;
+import org.jboss.ws.feature.JsonEncodingFeature;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.ServiceMetaData;
import org.jboss.ws.metadata.wsdl.Extendable;
@@ -59,14 +61,31 @@
public static <T> void processFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
{
+ boolean supportedFeature = false;
+ if (feature instanceof FastInfosetFeature || feature instanceof
JsonEncodingFeature)
+ supportedFeature = true;
+ supportedFeature = supportedFeature || processAddressingFeature(feature,
epMetaData, stub);
+ supportedFeature = supportedFeature || processMTOMFeature(feature, epMetaData,
stub);
+ supportedFeature = supportedFeature || processRespectBindingFeature(feature,
epMetaData, stub);
+ if (!supportedFeature)
+ {
+ throw new IllegalArgumentException("Unsupported feature: " +
feature);
+ }
epMetaData.addFeature(feature);
- processAddressingFeature(feature, epMetaData, stub);
- processMTOMFeature(feature, epMetaData, stub);
- processRespectBindingFeature(feature, epMetaData, stub);
}
+ /**
+ * Returns true or false depending on the provided WebServiceFeature being an
AddressingFeature or not.
+ * In the former case, addressing is setup.
+ *
+ * @param <T>
+ * @param feature
+ * @param epMetaData
+ * @param stub
+ * @return
+ */
@SuppressWarnings("unchecked")
- private static <T> void processAddressingFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ private static <T> boolean processAddressingFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
{
if (feature instanceof AddressingFeature && feature.isEnabled())
{
@@ -74,19 +93,43 @@
List<Handler> handlers = bindingExt.getHandlerChain(HandlerType.POST);
handlers.add(new WSAddressingClientHandler());
bindingExt.setHandlerChain(handlers, HandlerType.POST);
+ return true;
}
+ return false;
}
- private static <T> void processMTOMFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ /**
+ * Returns true or false depending on the provided WebServiceFeature being an
MTOMFeature or not.
+ * In the former case, mtom is setup.
+ *
+ * @param <T>
+ * @param feature
+ * @param epMetaData
+ * @param stub
+ * @return
+ */
+ private static <T> boolean processMTOMFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
{
if (feature instanceof MTOMFeature)
{
SOAPBinding binding = (SOAPBinding)((BindingProvider)stub).getBinding();
binding.setMTOMEnabled(feature.isEnabled());
+ return true;
}
+ return false;
}
- private static <T> void processRespectBindingFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ /**
+ * Returns true or false depending on the provided WebServiceFeature being an
RespectBindingFeature or not.
+ * In the former case, the respect binding checks are performed.
+ *
+ * @param <T>
+ * @param feature
+ * @param epMetaData
+ * @param stub
+ * @return
+ */
+ private static <T> boolean processRespectBindingFeature(WebServiceFeature
feature, EndpointMetaData epMetaData, T stub)
{
if (feature instanceof RespectBindingFeature && feature.isEnabled())
{
@@ -113,7 +156,9 @@
log.warn("Cannot find port " + epMetaData.getPortName());
}
}
+ return true;
}
+ return false;
}
private static void checkNotUnderstoodExtElements(Extendable extendable,
EndpointMetaData epMetaData)
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-22
15:14:24 UTC (rev 9097)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-22
16:36:24 UTC (rev 9098)
@@ -34,6 +34,7 @@
import javax.xml.ws.soap.MTOM;
import javax.xml.ws.soap.MTOMFeature;
import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.spi.WebServiceFeatureAnnotation;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
@@ -74,40 +75,48 @@
{
for (Annotation an : sepClass.getAnnotations())
{
- if (an.annotationType() == Addressing.class)
+ WebServiceFeatureAnnotation wsfa =
an.annotationType().getAnnotation(WebServiceFeatureAnnotation.class);
+ if (wsfa != null)
{
- Addressing anFeature = sepClass.getAnnotation(Addressing.class);
- AddressingFeature feature = new AddressingFeature(anFeature.enabled(),
anFeature.required());
- sepMetaData.addFeature(feature);
+ if (an.annotationType() == Addressing.class)
+ {
+ Addressing anFeature = sepClass.getAnnotation(Addressing.class);
+ AddressingFeature feature = new AddressingFeature(anFeature.enabled(),
anFeature.required());
+ sepMetaData.addFeature(feature);
+ }
+ else if (an.annotationType() == MTOM.class)
+ {
+ MTOM anFeature = sepClass.getAnnotation(MTOM.class);
+ MTOMFeature feature = new MTOMFeature(anFeature.enabled(),
anFeature.threshold());
+ sepMetaData.addFeature(feature);
+ }
+ else if (an.annotationType() == SchemaValidation.class)
+ {
+ processSchemaValidation(dep, sepMetaData, sepClass);
+ }
+ else if (an.annotationType() == FastInfoset.class)
+ {
+ FastInfoset anFeature = sepClass.getAnnotation(FastInfoset.class);
+ FastInfosetFeature feature = new FastInfosetFeature(anFeature.enabled());
+ sepMetaData.addFeature(feature);
+ }
+ else if (an.annotationType() == JsonEncoding.class)
+ {
+ JsonEncoding anFeature = sepClass.getAnnotation(JsonEncoding.class);
+ JsonEncodingFeature feature = new
JsonEncodingFeature(anFeature.enabled());
+ sepMetaData.addFeature(feature);
+ }
+ else if (an.annotationType() == RespectBinding.class)
+ {
+ RespectBinding anFeature = sepClass.getAnnotation(RespectBinding.class);
+ RespectBindingFeature feature = new
RespectBindingFeature(anFeature.enabled());
+ sepMetaData.addFeature(feature);
+ }
+ else
+ {
+ throw new WebServiceException("Unsupported feature: " +
wsfa.bean());
+ }
}
- else if (an.annotationType() == MTOM.class)
- {
- MTOM anFeature = sepClass.getAnnotation(MTOM.class);
- MTOMFeature feature = new MTOMFeature(anFeature.enabled(),
anFeature.threshold());
- sepMetaData.addFeature(feature);
- }
- else if (an.annotationType() == SchemaValidation.class)
- {
- processSchemaValidation(dep, sepMetaData, sepClass);
- }
- else if (an.annotationType() == FastInfoset.class)
- {
- FastInfoset anFeature = sepClass.getAnnotation(FastInfoset.class);
- FastInfosetFeature feature = new FastInfosetFeature(anFeature.enabled());
- sepMetaData.addFeature(feature);
- }
- else if (an.annotationType() == JsonEncoding.class)
- {
- JsonEncoding anFeature = sepClass.getAnnotation(JsonEncoding.class);
- JsonEncodingFeature feature = new JsonEncodingFeature(anFeature.enabled());
- sepMetaData.addFeature(feature);
- }
- else if (an.annotationType() == RespectBinding.class)
- {
- RespectBinding anFeature = sepClass.getAnnotation(RespectBinding.class);
- RespectBindingFeature feature = new
RespectBindingFeature(anFeature.enabled());
- sepMetaData.addFeature(feature);
- }
}
}