camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r570024 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ components/camel-spring/src/main/java/org/apache/camel/spring/ components/camel-spring/src/main/java/org/apache/camel/spring/spi/ tests/camel-itest/src/test...
Date Mon, 27 Aug 2007 07:48:22 GMT
Author: jstrachan
Date: Mon Aug 27 00:48:21 2007
New Revision: 570024

URL: http://svn.apache.org/viewvc?rev=570024&view=rev
Log:
fixed the integration test; also ensured the component resolver works similarly against both
Spring and JNDI (and OSGi) namely that the registry is always used to try to resolve configured
components

Removed:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringComponentResolver.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
    activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java?rev=570024&r1=570023&r2=570024&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
Mon Aug 27 00:48:21 2007
@@ -22,6 +22,9 @@
 import org.apache.camel.spi.ComponentResolver;
 import org.apache.camel.util.FactoryFinder;
 import org.apache.camel.util.NoFactoryAvailableException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 
 /**
  * The default implementation of {@link ComponentResolver} which tries to find
@@ -32,10 +35,25 @@
  * @version $Revision$
  */
 public class DefaultComponentResolver<E extends Exchange> implements ComponentResolver<E>
{
+    private static final transient Log LOG = LogFactory.getLog(DefaultComponentResolver.class);
     protected static final FactoryFinder COMPONENT_FACTORY = 
         new FactoryFinder("META-INF/services/org/apache/camel/component/");
 
     public Component<E> resolveComponent(String name, CamelContext context) {
+        Object bean = null;
+        try {
+            bean = context.getRegistry().lookup(name);
+        }
+        catch (Exception e) {
+            LOG.debug("Ignored error looking up bean: " + name + ". Error: " + e);
+        }
+        if (bean != null) {
+            if (bean instanceof Component) {
+                return (Component)bean;
+            } else {
+                throw new IllegalArgumentException("Bean with name: " + name + " in registry
is not a Component: " + bean);
+            }
+        }
         Class type;
         try {
             type = COMPONENT_FACTORY.findClass(name);

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=570024&r1=570023&r2=570024&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Mon Aug 27 00:48:21 2007
@@ -24,11 +24,9 @@
 import org.apache.camel.component.event.EventEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.ProcessorEndpoint;
-import org.apache.camel.spi.ComponentResolver;
 import org.apache.camel.spi.Injector;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spring.spi.ApplicationContextRegistry;
-import org.apache.camel.spring.spi.SpringComponentResolver;
 import org.apache.camel.spring.spi.SpringInjector;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,7 +40,6 @@
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.context.support.AbstractRefreshableApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
@@ -160,12 +157,6 @@
             LOG.warn("Cannot use SpringInjector as applicationContext is not a ConfigurableApplicationContext
as its: " + applicationContext);
             return super.createInjector();
         }
-    }
-
-    @Override
-    protected ComponentResolver createComponentResolver() {
-        ComponentResolver defaultResolver = super.createComponentResolver();
-        return new SpringComponentResolver(getApplicationContext(), defaultResolver);
     }
 
     protected EventEndpoint createEventEndpoint() {

Modified: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java?rev=570024&r1=570023&r2=570024&view=diff
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
(original)
+++ activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
Mon Aug 27 00:48:21 2007
@@ -60,7 +60,7 @@
         answer.bind("myBean", myBean);
 
         // add ActiveMQ with embedded broker
-        answer.bind("activemq", ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
+        answer.bind("jms", ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
         return answer;
     }
 



Mime
View raw message