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/11/16 11:20:30 UTC
svn commit: r595616 -
/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Author: jstrachan
Date: Fri Nov 16 02:20:29 2007
New Revision: 595616
URL: http://svn.apache.org/viewvc?rev=595616&view=rev
Log:
added some helper methods
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=595616&r1=595615&r2=595616&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java Fri Nov 16 02:20:29 2007
@@ -26,10 +26,13 @@
import org.apache.camel.Component;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
+import org.apache.camel.spi.Injector;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.URISupport;
import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.camel.util.CamelContextHelper;
+import static org.apache.camel.util.ObjectHelper.notNull;
/**
* @version $Revision$
@@ -149,6 +152,33 @@
*/
protected boolean useIntrospectionOnEndpoint() {
return true;
+ }
+
+
+ // Some helper methods
+ //-------------------------------------------------------------------------
+
+ /**
+ * Converts the given value to the requested type
+ */
+ public <T> T convertTo(Class<T> type, Object value) {
+ return CamelContextHelper.convertTo(getCamelContext(), type, value);
+ }
+
+ /**
+ * Converts the given value to the specified type throwing an {@link IllegalArgumentException}
+ * if the value could not be converted to a non null value
+ */
+ public <T> T mandatoryConvertTo(Class<T> type, Object value) {
+ return CamelContextHelper.mandatoryConvertTo(getCamelContext(), type, value);
+ }
+
+ /**
+ * Creates a new instance of the given type using the {@link Injector} on the given
+ * {@link CamelContext}
+ */
+ public <T> T newInstance(Class<T> beanType) {
+ return getCamelContext().getInjector().newInstance(beanType);
}
}