Author: davsclaus
Date: Sun May 27 10:48:45 2012
New Revision: 1343031
URL: http://svn.apache.org/viewvc?rev=1343031&view=rev
Log:
CAMEL-5308: Added createContext method to Main class, to allow using custom
camel context. Thanks to Daniel Martins for the patch.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java?rev=1343031&r1=1343030&r2=1343031&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java Sun
May 27 10:48:45 2012
@@ -33,8 +33,9 @@ import org.apache.camel.view.ModelFileGe
* @version
*/
public class Main extends MainSupport {
+
protected static Main instance;
- private final SimpleRegistry registery = new SimpleRegistry();
+ protected final SimpleRegistry registry = new SimpleRegistry();
public Main() {
}
@@ -64,7 +65,7 @@ public class Main extends MainSupport {
* @param bean the object to bind
*/
public void bind(String name, Object bean) {
- registery.put(name, bean);
+ registry.put(name, bean);
}
/**
@@ -74,7 +75,7 @@ public class Main extends MainSupport {
* @see Registry#lookup(String)
*/
public Object lookup(String name) {
- return registery.get(name);
+ return registry.get(name);
}
/**
@@ -85,7 +86,7 @@ public class Main extends MainSupport {
* @see Registry#lookup(String, Class)
*/
public <T> T lookup(String name, Class<T> type) {
- return registery.lookup(name, type);
+ return registry.lookup(name, type);
}
/**
@@ -95,7 +96,7 @@ public class Main extends MainSupport {
* @see Registry#lookupByType(Class)
*/
public <T> Map<String, T> lookupByType(Class<T> type) {
- return registery.lookupByType(type);
+ return registry.lookupByType(type);
}
// Implementation methods
@@ -120,16 +121,22 @@ public class Main extends MainSupport {
protected Map<String, CamelContext> getCamelContextMap() {
Map<String, CamelContext> answer = new HashMap<String, CamelContext>();
- CamelContext camelContext = new DefaultCamelContext();
- if (registery.size() > 0) {
+ CamelContext camelContext = createContext();
+ if (registry.size() > 0) {
// set the registry through which we've already bound some beans
- ((DefaultCamelContext) camelContext).setRegistry(registery);
+ if
(DefaultCamelContext.class.isAssignableFrom(camelContext.getClass())) {
+ ((DefaultCamelContext) camelContext).setRegistry(registry);
+ }
}
answer.put("camel-1", camelContext);
return answer;
}
+ protected CamelContext createContext() {
+ return new DefaultCamelContext();
+ }
+
protected ModelFileGenerator createModelFileGenerator() throws
JAXBException {
return null;
}