Author: davsclaus
Date: Wed Jun 4 23:18:23 2008
New Revision: 663469
URL: http://svn.apache.org/viewvc?rev=663469&view=rev
Log:
CAMEL-579: Applied patch with thanks to William Tam
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
(with props)
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
(with props)
Modified:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Modified:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=663469&r1=663468&r2=663469&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Wed Jun 4 23:18:23 2008
@@ -40,6 +40,7 @@
import org.apache.camel.processor.interceptor.Debugger;
import org.apache.camel.spi.InstrumentationAgent;
import org.apache.camel.spi.LifecycleStrategy;
+import org.apache.camel.spi.Registry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.DisposableBean;
@@ -104,7 +105,6 @@
private BeanPostProcessor beanPostProcessor;
public CamelContextFactoryBean() {
-
// Lets keep track of the class loader for when we actually do start
things up
contextClassLoaderOnStart =
Thread.currentThread().getContextClassLoader();
}
@@ -124,18 +124,23 @@
public void afterPropertiesSet() throws Exception {
// lets see if we can find a debugger to add
// TODO there should be a neater way to do this!
- Debugger debugger = getBeanForType(Debugger.class);
-
+ Debugger debugger = getBeanForType(Debugger.class);
if (debugger != null) {
getContext().addInterceptStrategy(debugger);
}
+ // set the lifecycle strategy if defined
LifecycleStrategy lifecycleStrategy =
getBeanForType(LifecycleStrategy.class);
-
if (lifecycleStrategy != null) {
getContext().setLifecycleStrategy(lifecycleStrategy);
}
-
+
+ // set the strategy if defined
+ Registry registry = getBeanForType(Registry.class);
+ if (registry != null) {
+ getContext().setRegistry(registry);
+ }
+
// Set the application context and camelContext for the
beanPostProcessor
if (beanPostProcessor != null) {
if (beanPostProcessor instanceof ApplicationContextAware) {
@@ -144,14 +149,13 @@
if (beanPostProcessor instanceof CamelBeanPostProcessor) {
((CamelBeanPostProcessor)beanPostProcessor).setCamelContext(getContext());
}
-
}
+
// lets force any lazy creation
getContext().addRouteDefinitions(routes);
- // set the instrumentation agent here
-
- if (instrumentationAgent == null && isJmxEnabled()) {
-
+
+ // set the instrumentation agent here
+ if (instrumentationAgent == null && isJmxEnabled()) {
if (lifecycleStrategy != null) {
LOG.warn("lifecycleStrategy will be overriden by
InstrumentationLifecycleStrategy");
}
@@ -178,7 +182,9 @@
instrumentationAgent.start();
}
- LOG.debug("Found JAXB created routes: " + getRoutes());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Found JAXB created routes: " + getRoutes());
+ }
findRouteBuiders();
installRoutes();
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java?rev=663469&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
Wed Jun 4 23:18:23 2008
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.JndiRegistry;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Test for Registry injection.
+ *
+ * @version $Revision$
+ */
+public class RegistryInjectionTest extends SpringTestSupport {
+
+ @Override
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ setUseRouteBuilder(false);
+ return new
ClassPathXmlApplicationContext("org/apache/camel/spring/RegistryInjection.xml");
+ }
+
+ public void testInjectedStrategy() throws Exception {
+ CamelContext context = createCamelContext();
+ assertTrue(context.getRegistry() instanceof JndiRegistry);
+ }
+
+}
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RegistryInjectionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml?rev=663469&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
Wed Jun 4 23:18:23 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://activemq.apache.org/camel/schema/spring"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <bean id="registry" class="org.apache.camel.impl.JndiRegistry"/>
+
+ <camel:camelContext id="camel">
+ <camel:route>
+ <camel:from uri="seda:start"/>
+ <camel:to uri="mock:result"/>
+ </camel:route>
+ </camel:camelContext>
+
+</beans>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml