]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java
slc flow namespace extended (flow:variables, list, map, etc. in flow:arg and spec...
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / xml / ExecutionScopeDecorator.java
index e5738b16878d30c9efb8956e77ac156c5cbc94a5..726f342302ae9e257527e93b057cf97f8963cc05 100644 (file)
@@ -1,44 +1,36 @@
 package org.argeo.slc.core.execution.xml;\r
 \r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
 import org.springframework.aop.scope.ScopedProxyUtils;\r
 import org.springframework.beans.factory.config.BeanDefinitionHolder;\r
 import org.springframework.beans.factory.parsing.BeanComponentDefinition;\r
 import org.springframework.beans.factory.xml.BeanDefinitionDecorator;\r
 import org.springframework.beans.factory.xml.ParserContext;\r
+import org.w3c.dom.Element;\r
 import org.w3c.dom.Node;\r
 \r
 /**\r
- * Inspired by org.springframework.aop.config.AopNamespaceHandler\r
- * Conceived to replace Element "aop:scoped-proxy" by an attribute.\r
- * Does not work correctly with other attribute decorators (e.g. \r
- * p namespace) since this decorator needs to be called after all\r
- * properties have been set on target bean. \r
+ * Inspired by org.springframework.aop.config.ScopedProxyBeanDefinitionDecorator\r
  */\r
-public class ExecutionScopeDecorator implements BeanDefinitionDecorator {\r
-       private Log log = LogFactory.getLog(ExecutionScopeDecorator.class);\r
+public class ExecutionScopeDecorator implements BeanDefinitionDecorator {      \r
+       private static final String PROXY_TARGET_CLASS = "proxy-target-class";  \r
        \r
        public BeanDefinitionHolder decorate(Node node,\r
                        BeanDefinitionHolder definition, ParserContext parserContext) {\r
                \r
-               Boolean isVar = Boolean.valueOf(node.getNodeValue());\r
-                               \r
-               if(isVar) {\r
-                       definition.getBeanDefinition().setScope("execution");\r
-                       \r
-                       boolean proxyTargetClass = true;\r
-                       \r
-                       // Register the original bean definition as it will be referenced by the scoped proxy and is relevant for tooling (validation, navigation).\r
-                       String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());\r
-                       parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));\r
-                       \r
-                       log.debug("Decorating bean " + definition.getBeanName());\r
-                       \r
-                       return ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);           \r
-               }\r
-               else {\r
-                       return definition;\r
+               definition.getBeanDefinition().setScope("execution");\r
+               \r
+               boolean proxyTargetClass = true;\r
+               if (node instanceof Element) {\r
+                       Element ele = (Element) node;\r
+                       if (ele.hasAttribute(PROXY_TARGET_CLASS)) {\r
+                               proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)).booleanValue();\r
+                       }\r
                }\r
+               \r
+               // Register the original bean definition as it will be referenced by the scoped proxy and is relevant for tooling (validation, navigation).\r
+               String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());\r
+               parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));\r
+               \r
+               return ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);           \r
        }\r
 }\r