camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1074849 - in /camel/trunk/components/camel-spring/src: main/java/org/apache/camel/spring/ main/java/org/apache/camel/spring/handler/ test/resources/org/apache/camel/spring/ test/resources/org/apache/camel/spring/config/scan/ test/resources...
Date Sat, 26 Feb 2011 14:08:03 GMT
Author: davsclaus
Date: Sat Feb 26 14:08:03 2011
New Revision: 1074849

URL: http://svn.apache.org/viewvc?rev=1074849&view=rev
Log:
CAMEL-3724: Removed <beanPostProcessor> from Spring XML as it had no use for end user.

Modified:
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/explicitlyDefinedRouteExclusion.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=1074849&r1=1074848&r2=1074849&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Sat Feb 26 14:08:03 2011
@@ -115,7 +115,6 @@ public class CamelContextFactoryBean ext
     @XmlElement(name = "jmxAgent", type = CamelJMXAgentDefinition.class, required = false)
     private CamelJMXAgentDefinition camelJMXAgent;
     @XmlElements({
-            @XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class,
required = false),
             @XmlElement(name = "template", type = CamelProducerTemplateFactoryBean.class,
required = false),
             @XmlElement(name = "consumerTemplate", type = CamelConsumerTemplateFactoryBean.class,
required = false),
             @XmlElement(name = "proxy", type = CamelProxyFactoryDefinition.class, required
= false),

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=1074849&r1=1074848&r2=1074849&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
Sat Feb 26 14:08:03 2011
@@ -148,17 +148,6 @@ public class CamelNamespaceHandler exten
         parserMap.put(elementName, parser);
     }
 
-    protected void createBeanPostProcessor(ParserContext parserContext, String contextId,
Element childElement, BeanDefinitionBuilder parentBuilder) {
-        String beanPostProcessorId = contextId + ":beanPostProcessor";
-        childElement.setAttribute("id", beanPostProcessorId);
-        BeanDefinition definition = beanPostProcessorParser.parse(childElement, parserContext);
-        // only register to camel context id as a String. Then we can look it up later
-        // otherwise we get a circular reference in spring and it will not allow custom bean
post processing
-        // see more at CAMEL-1663
-        definition.getPropertyValues().addPropertyValue("camelId", contextId);
-        parentBuilder.addPropertyReference("beanPostProcessor", beanPostProcessorId);
-    }
-
     protected void registerParser(String name, org.springframework.beans.factory.xml.BeanDefinitionParser
parser) {
         parserElementNames.add(name);
         registerBeanDefinitionParser(name, parser);
@@ -290,7 +279,6 @@ public class CamelNamespaceHandler exten
                 addDependsOn(factoryBean, builder);
             }
 
-            boolean createdBeanPostProcessor = false;
             NodeList list = element.getChildNodes();
             int size = list.getLength();
             for (int i = 0; i < size; i++) {
@@ -298,10 +286,7 @@ public class CamelNamespaceHandler exten
                 if (child instanceof Element) {
                     Element childElement = (Element) child;
                     String localName = child.getLocalName();
-                    if (localName.equals("beanPostProcessor")) {
-                        createBeanPostProcessor(parserContext, contextId, childElement, builder);
-                        createdBeanPostProcessor = true;
-                    } else if (localName.equals("endpoint")) {
+                    if (localName.equals("endpoint")) {
                         registerEndpoint(childElement, parserContext, contextId);
                     } else if (localName.equals("routeBuilder")) {
                         addDependsOnToRouteBuilder(childElement, parserContext, contextId);
@@ -332,12 +317,10 @@ public class CamelNamespaceHandler exten
 
             // lets inject the namespaces into any namespace aware POJOs
             injectNamespaces(element, binder);
-            if (!createdBeanPostProcessor) {
-                // no bean processor element so lets create it by our self
-                Element childElement = element.getOwnerDocument().createElement("beanPostProcessor");
-                element.appendChild(childElement);
-                createBeanPostProcessor(parserContext, contextId, childElement, builder);
-            }
+
+            // inject bean post processor so we can support @Produce etc.
+            // no bean processor element so lets create it by our self
+            injectBeanPostProcessor(element, parserContext, contextId, builder);
         }
     }
 
@@ -406,6 +389,20 @@ public class CamelNamespaceHandler exten
         }
     }
 
+    protected void injectBeanPostProcessor(Element element, ParserContext parserContext,
String contextId, BeanDefinitionBuilder builder) {
+        Element childElement = element.getOwnerDocument().createElement("beanPostProcessor");
+        element.appendChild(childElement);
+
+        String beanPostProcessorId = contextId + ":beanPostProcessor";
+        childElement.setAttribute("id", beanPostProcessorId);
+        BeanDefinition definition = beanPostProcessorParser.parse(childElement, parserContext);
+        // only register to camel context id as a String. Then we can look it up later
+        // otherwise we get a circular reference in spring and it will not allow custom bean
post processing
+        // see more at CAMEL-1663
+        definition.getPropertyValues().addPropertyValue("camelId", contextId);
+        builder.addPropertyReference("beanPostProcessor", beanPostProcessorId);
+    }
+
     /**
      * Used for auto registering endpoints from the <tt>from</tt> or <tt>to</tt>
DSL if they have an id attribute set
      */

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/explicitlyDefinedRouteExclusion.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/explicitlyDefinedRouteExclusion.xml?rev=1074849&r1=1074848&r2=1074849&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/explicitlyDefinedRouteExclusion.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/explicitlyDefinedRouteExclusion.xml
Sat Feb 26 14:08:03 2011
@@ -26,7 +26,6 @@
            http://www.springframework.org/schema/context/spring-context.xsd">
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <beanPostProcessor />
     <endpoint id="start" uri="direct:start"/>
     <endpoint id="result" uri="mock:end"/>
   </camelContext>
@@ -34,7 +33,6 @@
   <bean id="explicitlyDefinedRoute" class="org.apache.camel.spring.config.scan.route.MyRouteBuilder"
autowire="byType" />
   <bean id="explicitlyDefinedButExcludedRoute" class="org.apache.camel.spring.config.unscanned.MyExplicitlyDefinedButExcludedRouteBuilder"
/>
   
-  <context:component-scan
-    base-package="org.apache.camel.spring.config.scan.component" />
+  <context:component-scan base-package="org.apache.camel.spring.config.scan.component"
/>
 
 </beans>

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml?rev=1074849&r1=1074848&r2=1074849&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml
Sat Feb 26 14:08:03 2011
@@ -23,9 +23,7 @@
     ">
 
   <!-- START SNIPPET: example -->
-  <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <beanPostProcessor/>
-  </camelContext>
+  <camelContext xmlns="http://camel.apache.org/schema/spring"/>
   <!-- END SNIPPET: example -->
 
   <bean id="mySender" class="org.apache.camel.spring.example.MySender"/>

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml?rev=1074849&r1=1074848&r2=1074849&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
Sat Feb 26 14:08:03 2011
@@ -23,7 +23,6 @@
     ">
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <beanPostProcessor/>
     <endpoint id="namedEndpoint1" uri="direct:namedEndpoint1"/>
     <endpoint id="injectByFieldName" uri="direct:injectByFieldName"/>
     <endpoint id="injectByPropertyName" uri="direct:injectByPropertyName"/>



Mime
View raw message