init impl of camel bean:actor routing
This commit is contained in:
parent
d4eb763cd4
commit
b602a86eed
4 changed files with 101 additions and 107 deletions
74
akka.iws
74
akka.iws
|
|
@ -106,7 +106,7 @@
|
|||
<file leaf-file-name="ActiveObjectGuiceConfigurator.scala" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="118" column="40" selection-start="5650" selection-end="5650" vertical-scroll-proportion="0.0">
|
||||
<state line="159" column="23" selection-start="6771" selection-end="6771" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
<file leaf-file-name="CamelSpec.scala" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/test/scala/CamelSpec.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="92" column="0" selection-start="2771" selection-end="2771" vertical-scroll-proportion="0.3184584">
|
||||
<state line="53" column="51" selection-start="1756" selection-end="1756" vertical-scroll-proportion="0.74493927">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
@ -378,19 +378,19 @@
|
|||
</navigator>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="GoToClass.includeJavaFiles" value="false" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
<property name="GoToClass.includeJavaFiles" value="false" />
|
||||
<property name="MemberChooser.copyJavadoc" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder2" value="2" />
|
||||
<property name="options.splitter.main.proportions" value="0.3" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder2" value="2" />
|
||||
<property name="options.splitter.main.proportions" value="0.3" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth3" value="965" />
|
||||
<property name="GoToFile.includeJavaFiles" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="269" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth2" value="286" />
|
||||
<property name="options.splitter.details.proportions" value="0.2" />
|
||||
<property name="GoToClass.includeLibraries" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth2" value="293" />
|
||||
<property name="GoToClass.includeLibraries" value="false" />
|
||||
<property name="options.splitter.details.proportions" value="0.2" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder3" value="3" />
|
||||
<property name="MemberChooser.showClasses" value="true" />
|
||||
|
|
@ -402,12 +402,12 @@
|
|||
<property name="RunManagerConfig.showSettingsBeforeRunnig" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder0" value="0" />
|
||||
<property name="project.structure.last.edited" value="Modules" />
|
||||
<property name="MemberChooser.sorted" value="false" />
|
||||
<property name="options.searchVisible" value="true" />
|
||||
<property name="MemberChooser.sorted" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder1" value="1" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth1" value="301" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="972" />
|
||||
<property name="dynamic.classpath" value="false" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="972" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth1" value="308" />
|
||||
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder1" value="1" />
|
||||
</component>
|
||||
|
|
@ -535,7 +535,7 @@
|
|||
<option name="MAIN_CLASS_NAME" value="se.scalablesolutions.akka.kernel.CamelSpec" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="" />
|
||||
<option name="VM_PARAMETERS" value="-Djava.naming.factory.initial=org.apache.camel.util.jndi.CamelInitialContextFactory" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
|
|
@ -552,9 +552,9 @@
|
|||
</method>
|
||||
</configuration>
|
||||
<list size="3">
|
||||
<item index="0" class="java.lang.String" itemvalue="Scala Console.Scala Console" />
|
||||
<item index="1" class="java.lang.String" itemvalue="Application.Kernel" />
|
||||
<item index="2" class="java.lang.String" itemvalue="JUnit.CamelSpec" />
|
||||
<item index="0" class="java.lang.String" itemvalue="Application.Kernel" />
|
||||
<item index="1" class="java.lang.String" itemvalue="JUnit.CamelSpec" />
|
||||
<item index="2" class="java.lang.String" itemvalue="Scala Console.Scala Console" />
|
||||
</list>
|
||||
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
||||
<Host>localhost</Host>
|
||||
|
|
@ -601,7 +601,7 @@
|
|||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="4" y="22" width="1436" height="878" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<editor active="false" />
|
||||
<layout>
|
||||
<window_info id="Web Preview" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32976654" sideWeight="0.5" order="13" side_tool="false" />
|
||||
<window_info id="Dataflow to this" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="14" side_tool="false" />
|
||||
|
|
@ -609,16 +609,16 @@
|
|||
<window_info id="Data Sources" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3294881" sideWeight="0.6875" order="3" side_tool="false" />
|
||||
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32879376" sideWeight="0.5" order="6" side_tool="false" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24873829" sideWeight="0.68877554" order="1" side_tool="false" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24873829" sideWeight="0.690051" order="1" side_tool="false" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32879376" sideWeight="0.5" order="1" side_tool="false" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24945295" sideWeight="0.84143966" order="0" side_tool="false" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.30229592" sideWeight="0.5" order="11" side_tool="false" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3010204" sideWeight="0.5" order="11" side_tool="false" />
|
||||
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="12" side_tool="false" />
|
||||
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24945927" sideWeight="0.6875" order="1" side_tool="false" />
|
||||
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32879376" sideWeight="0.5" order="7" side_tool="false" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="true" internal_type="DOCKED" type="FLOATING" visible="false" weight="0.47276264" sideWeight="0.5" order="2" side_tool="false" x="16" y="22" width="1798" height="878" />
|
||||
<window_info id="Run" active="true" anchor="bottom" auto_hide="true" internal_type="DOCKED" type="FLOATING" visible="true" weight="0.47276264" sideWeight="0.5" order="2" side_tool="false" x="16" y="22" width="1798" height="878" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39989322" sideWeight="0.75" order="0" side_tool="false" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39980546" sideWeight="0.5" order="3" side_tool="false" />
|
||||
<window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" />
|
||||
|
|
@ -712,16 +712,16 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/test/scala/SupervisorSpec.scala">
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/ActiveObject.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="18" column="29" selection-start="528" selection-end="528" vertical-scroll-proportion="0.0">
|
||||
<state line="35" column="6" selection-start="1232" selection-end="1232" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/collection/Vector.scala">
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/GenericServer.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="298" column="1" selection-start="8660" selection-end="8660" vertical-scroll-proportion="0.0">
|
||||
<state line="14" column="11" selection-start="371" selection-end="371" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
@ -733,23 +733,9 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala">
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/test/scala/SupervisorSpec.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="118" column="40" selection-start="5650" selection-end="5650" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/ActiveObject.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="35" column="6" selection-start="1232" selection-end="1232" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/GenericServer.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="14" column="11" selection-start="371" selection-end="371" vertical-scroll-proportion="0.0">
|
||||
<state line="18" column="29" selection-start="528" selection-end="528" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
@ -768,9 +754,23 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/collection/Vector.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="298" column="1" selection-start="8660" selection-end="8660" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="159" column="23" selection-start="6771" selection-end="6771" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/kernel/src/test/scala/CamelSpec.scala">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="92" column="0" selection-start="2771" selection-end="2771" vertical-scroll-proportion="0.3184584">
|
||||
<state line="53" column="51" selection-start="1756" selection-end="1756" vertical-scroll-proportion="0.74493927">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
|||
|
|
@ -67,14 +67,19 @@ define 'akka' do
|
|||
|
||||
desc 'Akka Actor Kernel core implementation'
|
||||
define 'kernel' do
|
||||
compile.with(AKKA_UTIL_JAVA, GUICEYFRUIT, AOPALLIANCE, NETTY, JERSEY, GRIZZLY, CASSANDRA, THRIFT, FB303, CAMEL, SLF4J, GOOGLE_COLLECT, CGLIB, JSR_250, COMMONS_LOGGING, CONFIGGY, JUNIT4RUNNER, JUNIT4, SCALATEST)
|
||||
compile.with(
|
||||
AKKA_UTIL_JAVA, GUICEYFRUIT, AOPALLIANCE, NETTY, JERSEY, GRIZZLY,
|
||||
CASSANDRA, THRIFT, FB303, CAMEL, SLF4J, GOOGLE_COLLECT, CGLIB, JSR_250,
|
||||
COMMONS_LOGGING, CONFIGGY, JUNIT4RUNNER, JUNIT4, SCALATEST)
|
||||
test.using :junit
|
||||
package :jar
|
||||
end
|
||||
|
||||
desc 'Akka Java API'
|
||||
define 'api-java' do
|
||||
compile.with(AKKA_KERNEL, AKKA_UTIL_JAVA, NETTY, JERSEY, GRIZZLY, CASSANDRA, THRIFT, FB303, CAMEL, SLF4J, CONFIGGY, GUICEYFRUIT, SCALA, GOOGLE_COLLECT, AOPALLIANCE, CGLIB, JSR_250)
|
||||
compile.with(AKKA_KERNEL, AKKA_UTIL_JAVA, NETTY, JERSEY, GRIZZLY,
|
||||
CASSANDRA, THRIFT, FB303, CAMEL, SLF4J, CONFIGGY, GUICEYFRUIT, SCALA,
|
||||
GOOGLE_COLLECT, AOPALLIANCE, CGLIB, JSR_250)
|
||||
test.using :junit
|
||||
package :jar
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.google.inject.jsr250.ResourceProviderFactory
|
|||
import java.lang.reflect.Method
|
||||
import kernel.camel.ActiveObjectComponent
|
||||
import org.apache.camel.impl.{JndiRegistry, DefaultCamelContext}
|
||||
import org.apache.camel.{Endpoint, Routes}
|
||||
import org.apache.camel.{CamelContext, Endpoint, Routes}
|
||||
import scala.collection.mutable.HashMap
|
||||
import se.scalablesolutions.akka.kernel.ActiveObjectFactory
|
||||
import se.scalablesolutions.akka.kernel.ActiveObjectProxy
|
||||
|
|
@ -31,27 +31,10 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
private var configRegistry = new HashMap[Class[_], Component] // TODO is configRegistry needed?
|
||||
private var activeObjectRegistry = new HashMap[String, Tuple3[Class[_], Class[_], ActiveObjectProxy]]
|
||||
private var activeObjectFactory = new ActiveObjectFactory
|
||||
// private var camelContext = new DefaultCamelContext();
|
||||
private var camelContext = new DefaultCamelContext
|
||||
private var modules = new java.util.ArrayList[Module]
|
||||
private var methodToUriRegistry = new HashMap[Method, String]
|
||||
|
||||
def getExternalDependency[T](clazz: Class[T]): T = synchronized {
|
||||
injector.getInstance(clazz).asInstanceOf[T]
|
||||
}
|
||||
|
||||
/*
|
||||
def getRoutingEndpoint(uri: String): Endpoint = synchronized {
|
||||
camelContext.getEndpoint(uri)
|
||||
}
|
||||
|
||||
def getRoutingEndpoints: java.util.Collection[Endpoint] = synchronized {
|
||||
camelContext.getEndpoints
|
||||
}
|
||||
|
||||
def getRoutingEndpoints(uri: String): java.util.Collection[Endpoint] = synchronized {
|
||||
camelContext.getEndpoints(uri)
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Returns the active abject that has been put under supervision for the class specified.
|
||||
*
|
||||
|
|
@ -60,16 +43,14 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
*/
|
||||
def getActiveObject(name: String): AnyRef = synchronized {
|
||||
//def getActiveObject[T](name: String): T = synchronized {
|
||||
println("Looking up active object " + name)
|
||||
log.debug("Looking up active object [%s]", name)
|
||||
if (injector == null) throw new IllegalStateException("inject() and supervise() must be called before invoking newInstance(clazz)")
|
||||
if (injector == null) throw new IllegalStateException("inject() and/or supervise() must be called before invoking newInstance(clazz)")
|
||||
val activeObjectOption: Option[Tuple3[Class[_], Class[_], ActiveObjectProxy]] = activeObjectRegistry.get(name)
|
||||
if (activeObjectOption.isDefined) {
|
||||
val classInfo = activeObjectOption.get
|
||||
val intfClass = classInfo._1
|
||||
val implClass = classInfo._2
|
||||
val activeObjectProxy = classInfo._3
|
||||
//activeObjectProxy.setTargetInstance(injector.getInstance(clazz).asInstanceOf[AnyRef])
|
||||
val target = implClass.newInstance
|
||||
injector.injectMembers(target)
|
||||
activeObjectProxy.setTargetInstance(target.asInstanceOf[AnyRef])
|
||||
|
|
@ -85,6 +66,22 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
else throw new IllegalStateException("Class " + name + " has not been put under supervision (by passing in the config to the 'supervise') method")
|
||||
}
|
||||
|
||||
def getExternalDependency[T](clazz: Class[T]): T = synchronized {
|
||||
injector.getInstance(clazz).asInstanceOf[T]
|
||||
}
|
||||
|
||||
def getRoutingEndpoint(uri: String): Endpoint = synchronized {
|
||||
camelContext.getEndpoint(uri)
|
||||
}
|
||||
|
||||
def getRoutingEndpoints: java.util.Collection[Endpoint] = synchronized {
|
||||
camelContext.getEndpoints
|
||||
}
|
||||
|
||||
def getRoutingEndpoints(uri: String): java.util.Collection[Endpoint] = synchronized {
|
||||
camelContext.getEndpoints(uri)
|
||||
}
|
||||
|
||||
def configureActiveObjects(restartStrategy: RestartStrategy, components: List[Component]): ActiveObjectGuiceConfigurator = synchronized {
|
||||
this.restartStrategy = restartStrategy
|
||||
this.components = components.toArray.toList.asInstanceOf[List[Component]]
|
||||
|
|
@ -104,21 +101,20 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
|
||||
def supervise: ActiveObjectGuiceConfigurator = synchronized {
|
||||
if (injector == null) inject
|
||||
injector = Guice.createInjector(modules)
|
||||
var workers = new java.util.ArrayList[Worker]
|
||||
for (component <- components) {
|
||||
val activeObjectProxy = new ActiveObjectProxy(component.intf, component.target, component.timeout)
|
||||
workers.add(Worker(activeObjectProxy.server, component.lifeCycle))
|
||||
activeObjectRegistry.put(component.name, (component.intf, component.target, activeObjectProxy))
|
||||
// camelContext.getRegistry.asInstanceOf[JndiRegistry].bind(component.name, activeObjectProxy)
|
||||
// for (method <- component.intf.getDeclaredMethods.toList) {
|
||||
// registerMethodForUri(method, component.name)
|
||||
// }
|
||||
// log.debug("Registering active object in Camel context under the name [%s]", component.target.getName)
|
||||
camelContext.getRegistry.asInstanceOf[JndiRegistry].bind(component.name, activeObjectProxy)
|
||||
for (method <- component.intf.getDeclaredMethods.toList) {
|
||||
registerMethodForUri(method, component.name)
|
||||
}
|
||||
log.debug("Registering active object in Camel context under the name [%s]", component.target.getName)
|
||||
}
|
||||
supervisor = activeObjectFactory.supervise(restartStrategy, workers)
|
||||
// camelContext.addComponent(AKKA_CAMEL_ROUTING_SCHEME, new ActiveObjectComponent(this))
|
||||
// camelContext.start
|
||||
camelContext.addComponent(AKKA_CAMEL_ROUTING_SCHEME, new ActiveObjectComponent(this))
|
||||
camelContext.start
|
||||
this
|
||||
}
|
||||
|
||||
|
|
@ -153,13 +149,15 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
* }
|
||||
* }).inject().supervise();
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
def addRoutes(routes: Routes): ActiveObjectGuiceConfigurator = synchronized {
|
||||
camelContext.addRoutes(routes)
|
||||
this
|
||||
}
|
||||
*/
|
||||
def getGuiceModules = modules
|
||||
|
||||
def getCamelContext: CamelContext = camelContext
|
||||
|
||||
def getGuiceModules: java.util.List[Module] = modules
|
||||
|
||||
def reset = synchronized {
|
||||
modules = new java.util.ArrayList[Module]
|
||||
|
|
@ -168,11 +166,11 @@ class ActiveObjectGuiceConfigurator extends Logging {
|
|||
methodToUriRegistry = new HashMap[Method, String]
|
||||
injector = null
|
||||
restartStrategy = null
|
||||
// camelContext = new DefaultCamelContext
|
||||
camelContext = new DefaultCamelContext
|
||||
}
|
||||
|
||||
def stop = synchronized {
|
||||
// camelContext.stop
|
||||
camelContext.stop
|
||||
supervisor.stop
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import kernel.config.ScalaConfig._
|
|||
import com.google.inject.{AbstractModule, Scopes}
|
||||
import com.jteigen.scalatest.JUnit4Runner
|
||||
|
||||
import org.apache.camel.component.bean.ProxyHelper
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest._
|
||||
import org.scalatest.matchers._
|
||||
|
|
@ -26,6 +27,8 @@ import org.apache.camel.Producer
|
|||
import org.apache.camel.builder.RouteBuilder
|
||||
import org.apache.camel.impl.DefaultCamelContext
|
||||
|
||||
// REQUIRES: -Djava.naming.factory.initial=org.apache.camel.util.jndi.CamelInitialContextFactory
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
|
|
@ -33,10 +36,7 @@ import org.apache.camel.impl.DefaultCamelContext
|
|||
class CamelSpec extends Spec with ShouldMatchers {
|
||||
|
||||
describe("A Camel routing scheme") {
|
||||
it("dummy") {
|
||||
}
|
||||
/*
|
||||
it("should route message from actor A to actor B") {
|
||||
it("should route message from direct:test to actor A using @Bean endpoint") {
|
||||
val latch = new CountDownLatch(1);
|
||||
|
||||
val conf = new ActiveObjectGuiceConfigurator
|
||||
|
|
@ -48,17 +48,10 @@ class CamelSpec extends Spec with ShouldMatchers {
|
|||
classOf[CamelFooImpl],
|
||||
LifeCycle(Permanent, 1000),
|
||||
1000) ::
|
||||
Component(
|
||||
"camelbar",
|
||||
classOf[CamelBar],
|
||||
classOf[CamelBarImpl],
|
||||
LifeCycle(Permanent, 1000),
|
||||
1000) ::
|
||||
Nil
|
||||
).addRoutes(new RouteBuilder() {
|
||||
def configure = {
|
||||
from("akka:camelfoo.foo").to("akka:camelbar.bar")
|
||||
from("akka:camelbar.bar").process(new Processor() {
|
||||
from("direct:test").to("bean:camelfoo").process(new Processor() {
|
||||
def process(e: Exchange) = {
|
||||
println("Received exchange: " + e.getIn())
|
||||
latch.countDown
|
||||
|
|
@ -67,29 +60,27 @@ class CamelSpec extends Spec with ShouldMatchers {
|
|||
}}
|
||||
).supervise
|
||||
|
||||
//val endpoint = conf.getRoutingEndpoint("akka:camelfoo.foo")
|
||||
// println("----- " + endpoint)
|
||||
// val exchange = endpoint.createExchange
|
||||
// println("----- " + exchange)
|
||||
val endpoint = conf.getRoutingEndpoint("direct:test")
|
||||
val proxy = ProxyHelper.createProxy(endpoint, classOf[CamelFoo])
|
||||
|
||||
conf.getActiveObject(classOf[CamelFooImpl].getName).asInstanceOf[CamelFoo].foo("Hello Foo")
|
||||
|
||||
//
|
||||
// exchange.getIn().setHeader("cheese", 123)
|
||||
// exchange.getIn().setBody("body")
|
||||
//
|
||||
// val producer = endpoint.createProducer
|
||||
// println("----- " + producer)
|
||||
//
|
||||
// producer.process(exchange)
|
||||
//
|
||||
// // now lets sleep for a while
|
||||
// val received = latch.await(5, TimeUnit.SECONDS)
|
||||
// received should equal (true)
|
||||
//
|
||||
// conf.stop
|
||||
proxy.foo("hello there")
|
||||
/*
|
||||
val exchange = endpoint.createExchange
|
||||
println("----- " + exchange)
|
||||
|
||||
exchange.getIn().setBody("hello there")
|
||||
|
||||
val producer = endpoint.createProducer
|
||||
println("----- " + producer)
|
||||
|
||||
producer.process(exchange)
|
||||
|
||||
// now lets sleep for a while
|
||||
val received = latch.await(5, TimeUnit.SECONDS)
|
||||
received should equal (true)
|
||||
*/
|
||||
conf.stop
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue