You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/07/25 19:38:39 UTC
svn commit: r559531 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/impl/
camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/
components/camel-spring/src/test/java/org/apache/camel/spring/
Author: jstrachan
Date: Wed Jul 25 10:38:38 2007
New Revision: 559531
URL: http://svn.apache.org/viewvc?view=rev&rev=559531
Log:
fixed a bunch more excluded test cases
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
activemq/camel/trunk/components/camel-spring/pom.xml
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java Wed Jul 25 10:38:38 2007
@@ -19,6 +19,7 @@
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.Processor;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.model.FromType;
import org.apache.camel.model.ProcessorType;
import org.apache.camel.model.RouteType;
@@ -35,15 +36,17 @@
public class RouteContext {
private final RouteType route;
private final FromType from;
- private final Endpoint endpoint;
+ private Endpoint endpoint;
- public RouteContext(RouteType route, FromType from, Endpoint endpoint) {
+ public RouteContext(RouteType route, FromType from) {
this.route = route;
this.from = from;
- this.endpoint = endpoint;
}
public Endpoint getEndpoint() {
+ if (endpoint == null) {
+ endpoint = from.resolveEndpoint(this);
+ }
return endpoint;
}
@@ -81,6 +84,31 @@
public Endpoint resolveEndpoint(String uri) {
return route.resolveEndpoint(uri);
+ }
+
+ /**
+ * Resolves an endpoint from either a URI or a named reference
+ */
+ public Endpoint resolveEndpoint(String uri, String ref) {
+ Endpoint endpoint = null;
+ if (uri != null) {
+ endpoint = resolveEndpoint(uri);
+ if (endpoint == null) {
+ throw new NoSuchEndpointException(uri);
+ }
+ }
+ if (ref != null) {
+ endpoint = lookup(ref, Endpoint.class);
+ if (endpoint == null) {
+ throw new NoSuchEndpointException("ref:" + ref);
+ }
+ }
+ if (endpoint == null) {
+ throw new IllegalArgumentException("Either 'uri' or 'ref' must be specified on: " + this);
+ }
+ else {
+ return endpoint;
+ }
}
/**
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java Wed Jul 25 10:38:38 2007
@@ -16,11 +16,14 @@
*/
package org.apache.camel.model;
+import org.apache.camel.Endpoint;
+import org.apache.camel.NoSuchEndpointException;
+import org.apache.camel.impl.RouteContext;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlIDREF;
/**
* Represents an XML <to/> element
@@ -44,7 +47,11 @@
@Override
public String toString() {
- return "From[" + uri + "]";
+ return "From[" + description(getUri(), getRef()) + "]";
+ }
+
+ public Endpoint resolveEndpoint(RouteContext context) {
+ return context.resolveEndpoint(getUri(), getRef());
}
// Properties
@@ -53,6 +60,11 @@
return uri;
}
+ /**
+ * Sets the URI of the endpoint to use
+ *
+ * @param uri the endpoint URI to use
+ */
public void setUri(String uri) {
this.uri = uri;
}
@@ -61,7 +73,26 @@
return ref;
}
+ /**
+ * Sets the name of the endpoint within the registry (such as the Spring ApplicationContext or JNDI) to use
+ *
+ * @param ref the reference name to use
+ */
public void setRef(String ref) {
this.ref = ref;
+ }
+
+ // Implementation methods
+ //-----------------------------------------------------------------------
+ protected static String description(String uri, String ref) {
+ if (uri != null) {
+ return uri;
+ }
+ else if (ref != null) {
+ return "ref:" + ref;
+ }
+ else {
+ return "no uri or ref supplied!";
+ }
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Wed Jul 25 10:38:38 2007
@@ -20,6 +20,7 @@
import org.apache.camel.CamelContextAware;
import org.apache.camel.Endpoint;
import org.apache.camel.Route;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.impl.RouteContext;
import javax.xml.bind.annotation.XmlElement;
@@ -120,8 +121,9 @@
}
protected void addRoutes(Collection<Route> routes, FromType fromType) throws Exception {
- Endpoint endpoint = resolveEndpoint(fromType.getUri());
- RouteContext routeContext = new RouteContext(this, fromType, endpoint);
+ RouteContext routeContext = new RouteContext(this, fromType);
+ Endpoint endpoint = routeContext.getEndpoint();
+
for (ProcessorType output : outputs) {
output.addRoutes(routeContext, routes);
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java Wed Jul 25 10:38:38 2007
@@ -17,9 +17,12 @@
package org.apache.camel.model;
import org.apache.camel.Processor;
+import org.apache.camel.Endpoint;
import org.apache.camel.impl.RouteContext;
import org.apache.camel.processor.SendProcessor;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -32,36 +35,62 @@
* @version $Revision: $
*/
@XmlRootElement(name = "to")
+@XmlAccessorType(XmlAccessType.FIELD)
public class ToType extends ProcessorType {
+ @XmlAttribute
private String uri;
+ @XmlAttribute
+ private String ref;
+ @XmlElement(required = false)
private List<InterceptorRef> interceptors;
@Override
public String toString() {
- return "To[" + uri + "]";
+ return "To[" + FromType.description(getUri(), getRef()) + "]";
}
@Override
public Processor createProcessor(RouteContext routeContext) {
- return new SendProcessor(routeContext.resolveEndpoint(getUri()));
+ Endpoint endpoint = resolveEndpoint(routeContext);
+ return new SendProcessor(endpoint);
+ }
+
+ public Endpoint resolveEndpoint(RouteContext context) {
+ return context.resolveEndpoint(getUri(), getRef());
}
// Properties
//-----------------------------------------------------------------------
- @XmlAttribute
public String getUri() {
return uri;
}
+ /**
+ * Sets the URI of the endpoint to use
+ *
+ * @param uri the endpoint URI to use
+ */
public void setUri(String uri) {
this.uri = uri;
}
+ public String getRef() {
+ return ref;
+ }
+
+ /**
+ * Sets the name of the endpoint within the registry (such as the Spring ApplicationContext or JNDI) to use
+ *
+ * @param ref the reference name to use
+ */
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+
public List<ProcessorType> getOutputs() {
return Collections.EMPTY_LIST;
}
- @XmlElement(required = false)
public List<InterceptorRef> getInterceptors() {
return interceptors;
}
Modified: activemq/camel/trunk/components/camel-spring/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/pom.xml?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/components/camel-spring/pom.xml (original)
+++ activemq/camel/trunk/components/camel-spring/pom.xml Wed Jul 25 10:38:38 2007
@@ -116,7 +116,6 @@
<excludes>
<!-- TODO - FIXME ASAP -->
<exclude>**/SpringXmlRouteBuilderTest.*</exclude>
- <exclude>**/EndpointReferenceTest.*</exclude>
</excludes>
</configuration>
</plugin>
Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java?view=diff&rev=559531&r1=559530&r2=559531
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/EndpointReferenceTest.java Wed Jul 25 10:38:38 2007
@@ -65,9 +65,6 @@
log.debug("Found bean name: " + name);
}
- // internally used by the Spring 2 XML
- getMandatoryBean(StatementRouteBuilder.class, "camel:routes");
-
testEndpointConfiguration();
}