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 2008/02/08 15:07:31 UTC
svn commit: r619892 -
/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
Author: jstrachan
Date: Fri Feb 8 06:07:29 2008
New Revision: 619892
URL: http://svn.apache.org/viewvc?rev=619892&view=rev
Log:
added a typesafe helper method to lookup an endpoint of a specific type
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java?rev=619892&r1=619891&r2=619892&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java Fri Feb 8 06:07:29 2008
@@ -22,6 +22,7 @@
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.NoSuchEndpointException;
+import org.apache.camel.util.ObjectHelper;
import org.apache.camel.processor.LoggingLevel;
import org.apache.camel.processor.SendProcessor;
import org.apache.commons.logging.Log;
@@ -135,10 +136,22 @@
* @throws NoSuchEndpointException if the endpoint URI could not be resolved
*/
public Endpoint endpoint(String uri) throws NoSuchEndpointException {
- if (uri == null) {
- throw new IllegalArgumentException("uri parameter cannot be null");
- }
+ ObjectHelper.notNull(uri, "uri");
Endpoint endpoint = getContext().getEndpoint(uri);
+ if (endpoint == null) {
+ throw new NoSuchEndpointException(uri);
+ }
+ return endpoint;
+ }
+
+ /**
+ * Resolves the given URI to an endpoint of the specified type
+ *
+ * @throws NoSuchEndpointException if the endpoint URI could not be resolved
+ */
+ public <T extends Endpoint> T endpoint(String uri, Class<T> type) throws NoSuchEndpointException {
+ ObjectHelper.notNull(uri, "uri");
+ T endpoint = getContext().getEndpoint(uri, type);
if (endpoint == null) {
throw new NoSuchEndpointException(uri);
}