You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2014/06/10 18:55:16 UTC
svn commit: r1601682 - in
/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws:
AxiomOptimizationEnabler.java SourceExtractionStrategy.java
Author: veithen
Date: Tue Jun 10 16:55:16 2014
New Revision: 1601682
URL: http://svn.apache.org/r1601682
Log:
AXIOM-447: Add a "NONE" source extraction strategy that is used when we know that a bean will never access the payload.
Modified:
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java?rev=1601682&r1=1601681&r2=1601682&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java Tue Jun 10 16:55:16 2014
@@ -110,7 +110,7 @@ public class AxiomOptimizationEnabler im
static {
strategyMap = new HashMap<Class<?>,SourceExtractionStrategy>();
- strategyMap.put(AxiomPayloadRootAnnotationMethodEndpointMapping.class, null);
+ strategyMap.put(AxiomPayloadRootAnnotationMethodEndpointMapping.class, SourceExtractionStrategy.NONE);
strategyMap.put(JDomPayloadMethodProcessor.class, SourceExtractionStrategy.SAX_CONSUME);
strategyMap.put(DomPayloadMethodProcessor.class, SourceExtractionStrategy.DOM_OR_SAX_CONSUME);
strategyMap.put(AnnotationActionEndpointMapping.class, SourceExtractionStrategy.DOM_OR_SAX_PRESERVE);
@@ -156,38 +156,27 @@ public class AxiomOptimizationEnabler im
}
Object createSourceExtractionStrategyProxy(Object target, String beanName) {
- boolean hasStrategy;
SourceExtractionStrategy strategy;
if (strategyMap.containsKey(target.getClass())) {
- hasStrategy = true;
strategy = strategyMap.get(target.getClass());
} else {
- hasStrategy = false;
strategy = null;
for (Map.Entry<Class<?>,SourceExtractionStrategy> entry : strategyMap.entrySet()) {
if (entry.getKey().isInstance(target)) {
- hasStrategy = true;
strategy = entry.getValue();
// TODO: not correct: there may be a more specialized class/interface in the map
break;
}
}
}
- if (hasStrategy) {
- if (strategy == null) {
- if (log.isDebugEnabled()) {
- log.debug("No extraction strategy required for bean \"" + beanName + "\" (of type " + target.getClass().getName() + ")");
- }
- return target;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Creating proxy to associate extraction strategy " + strategy + " with bean " + beanName);
- }
- Set<Class<?>> ifaces = new HashSet<Class<?>>();
- collectInterfaces(target.getClass(), ifaces);
- return Proxy.newProxyInstance(AxiomOptimizationEnabler.class.getClassLoader(), ifaces.toArray(new Class<?>[ifaces.size()]),
- new SourceExtractionStrategyInvocationHandler(target, beanName, strategy, this));
+ if (strategy != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating proxy to associate extraction strategy " + strategy + " with bean " + beanName);
}
+ Set<Class<?>> ifaces = new HashSet<Class<?>>();
+ collectInterfaces(target.getClass(), ifaces);
+ return Proxy.newProxyInstance(AxiomOptimizationEnabler.class.getClassLoader(), ifaces.toArray(new Class<?>[ifaces.size()]),
+ new SourceExtractionStrategyInvocationHandler(target, beanName, strategy, this));
} else {
if (log.isWarnEnabled()) {
log.warn("No extraction strategy associated with bean \"" + beanName + "\" (of type " + target.getClass().getName() + ")");
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java?rev=1601682&r1=1601681&r2=1601682&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java Tue Jun 10 16:55:16 2014
@@ -72,6 +72,21 @@ import org.w3c.dom.Node;
*/
public interface SourceExtractionStrategy {
/**
+ * Pseudo extraction strategy that will throw an exception if the payload source is requested.
+ * This is for use with beans that are not expected to access the payload.
+ */
+ SourceExtractionStrategy NONE = new SourceExtractionStrategy() {
+ public Source getSource(OMContainer container) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ return "NONE";
+ }
+ };
+
+ /**
* Extraction strategy that creates a {@link StAXSource} using
* {@link OMContainer#getXMLStreamReader(boolean) with <code>cache</code> set to
* <code>true</code>.