You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/07/29 12:00:55 UTC
svn commit: r980384 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/impl/
camel-core/src/test/java/org/apache/camel/processor/enricher/
components/camel-spring/src/test/java/org/apache/camel/sprin...
Author: ningjiang
Date: Thu Jul 29 10:00:55 2010
New Revision: 980384
URL: http://svn.apache.org/viewvc?rev=980384&view=rev
Log:
CAMEL-2998 Endpoints looked up in the Registry should not be usable from another CamelContext
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/NoSuchEndpointException.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefTest.java
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/ApplicationContextClassLoaderTest.java
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpointReference.xml
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/NoSuchEndpointException.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/NoSuchEndpointException.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/NoSuchEndpointException.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/NoSuchEndpointException.java Thu Jul 29 10:00:55 2010
@@ -33,6 +33,12 @@ public class NoSuchEndpointException ext
+ ", please check your classpath contains the needed camel component jar.");
this.uri = uri;
}
+
+ public NoSuchEndpointException(String uri, String resolveMethod) {
+ super("No endpoint could be found for: " + uri
+ + ", please " + resolveMethod);
+ this.uri = uri;
+ }
public String getUri() {
return uri;
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java Thu Jul 29 10:00:55 2010
@@ -121,7 +121,11 @@ public class DefaultRouteContext impleme
if (ref != null) {
endpoint = lookup(ref, Endpoint.class);
if (endpoint == null) {
- throw new NoSuchEndpointException("ref:" + ref);
+ throw new NoSuchEndpointException("ref:" + ref, "check your camel registery with id " + ref);
+ }
+ // Check the endpoint has the right CamelContext
+ if (!this.getCamelContext().equals(endpoint.getCamelContext())) {
+ throw new NoSuchEndpointException("ref:" + ref, "make sure the endpoint has the same camel context as the route does.");
}
}
if (endpoint == null) {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefTest.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefTest.java Thu Jul 29 10:00:55 2010
@@ -40,7 +40,6 @@ public class EnricherRefTest extends Con
}
public void testEnrichRef() throws Exception {
- cool.setCamelContext(context);
cool.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("Bye World");
@@ -60,6 +59,7 @@ public class EnricherRefTest extends Con
@Override
public void configure() throws Exception {
cool.setEndpointUriIfNotSpecified("cool");
+ cool.setCamelContext(context);
from("direct:start").enrichRef("cool", "agg");
}
Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/ApplicationContextClassLoaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/ApplicationContextClassLoaderTest.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/ApplicationContextClassLoaderTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/ApplicationContextClassLoaderTest.java Thu Jul 29 10:00:55 2010
@@ -23,7 +23,7 @@ public class ApplicationContextClassLoad
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/spring/endpointReference.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/disableJmxConfig.xml");
}
public void testClassLoader() {
Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java Thu Jul 29 10:00:55 2010
@@ -16,8 +16,12 @@
*/
package org.apache.camel.spring;
+import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultRouteContext;
+import org.apache.camel.spi.RouteContext;
import org.apache.camel.spring.example.DummyBean;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -64,6 +68,16 @@ public class EndpointReferenceTest exten
testEndpointConfiguration();
}
+
+ public void testReferenceEndpointFromOtherCamelContext() throws Exception {
+ CamelContext context = (CamelContext)applicationContext.getBean("camel2");
+ RouteContext routeContext = new DefaultRouteContext(context);
+ try {
+ routeContext.resolveEndpoint(null, "endpoint1");
+ } catch (NoSuchEndpointException exception) {
+ assertTrue("Get a wrong exception message", exception.getMessage().contains("make sure the endpoint has the same camel context as the route does"));
+ }
+ }
protected AbstractXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/camel/spring/endpointReference.xml");
Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java Thu Jul 29 10:00:55 2010
@@ -16,8 +16,12 @@
*/
package org.apache.camel.spring.management;
+import org.apache.camel.CamelContext;
+import org.apache.camel.NoSuchEndpointException;
+import org.apache.camel.impl.DefaultRouteContext;
import org.apache.camel.management.DefaultManagementAgent;
import org.apache.camel.spi.ManagementAgent;
+import org.apache.camel.spi.RouteContext;
import org.apache.camel.spring.EndpointReferenceTest;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -44,4 +48,8 @@ public class JmxInstrumentationWithConne
public void testGetContext() {
assertNotNull(this.applicationContext.getBean("camel"));
}
+
+ public void testReferenceEndpointFromOtherCamelContext() throws Exception {
+ // don't run the test in this method
+ }
}
Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpointReference.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpointReference.xml?rev=980384&r1=980383&r2=980384&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpointReference.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpointReference.xml Thu Jul 29 10:00:55 2010
@@ -37,5 +37,10 @@
</route>
</camelContext>
<!-- END SNIPPET: example -->
+
+ <camelContext id="camel2" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ </route>
+ </camelContext>
</beans>