From ffdda0a4235f51a8c38fa7d172b038a638770d4d Mon Sep 17 00:00:00 2001 From: Jonas Boner Date: Sat, 9 May 2009 20:40:36 +0200 Subject: [PATCH] commented out camel stuff for now --- akka.iws | 176 +++++++++++------- buildfile | 2 +- kernel/src/main/scala/ActiveObject.scala | 17 +- .../camel/SupervisorAwareCamelContext.scala | 3 +- .../ActiveObjectGuiceConfigurator.scala | 33 ++-- ...ActiveObjectGuiceConfiguratorForJava.scala | 22 +-- kernel/src/test/scala/CamelSpec.scala | 11 +- 7 files changed, 160 insertions(+), 104 deletions(-) diff --git a/akka.iws b/akka.iws index 32fd976706..9df14e5052 100644 --- a/akka.iws +++ b/akka.iws @@ -2,8 +2,8 @@ - + @@ -79,7 +79,16 @@ - + + + + + + + + + + @@ -88,16 +97,16 @@ - + - + - + @@ -112,10 +121,28 @@ - + - + + + + + + + + + + + + + + + + + + + @@ -279,6 +306,36 @@ - + - + - - + + @@ -345,12 +402,12 @@ - + - + @@ -495,9 +552,9 @@ - - - + + + localhost @@ -556,7 +613,7 @@ - + @@ -634,13 +691,6 @@ - - - - - - - @@ -648,27 +698,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -683,20 +712,6 @@ - - - - - - - - - - - - - - @@ -704,23 +719,58 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/buildfile b/buildfile index 77604cb51e..95e4d2512c 100644 --- a/buildfile +++ b/buildfile @@ -67,7 +67,7 @@ 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, 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 diff --git a/kernel/src/main/scala/ActiveObject.scala b/kernel/src/main/scala/ActiveObject.scala index 147c8a19fd..b6f7bd6dd8 100755 --- a/kernel/src/main/scala/ActiveObject.scala +++ b/kernel/src/main/scala/ActiveObject.scala @@ -56,8 +56,8 @@ object ActiveObject { proxy).asInstanceOf[T] } - def newInstance[T](intf: Class[_], target: AnyRef, timeout: Int, conf: ActiveObjectGuiceConfigurator): T = { - val proxy = new ActiveObjectProxy(intf, target.getClass, timeout, conf) + def newInstance[T](intf: Class[_], target: AnyRef, timeout: Int): T = { + val proxy = new ActiveObjectProxy(intf, target.getClass, timeout) proxy.setTargetInstance(target) supervise(proxy) newInstance(intf, proxy) @@ -85,7 +85,7 @@ object ActiveObject { * @author Jonas Bonér */ // FIXME: use interface for ActiveObjectGuiceConfigurator -class ActiveObjectProxy(val intf: Class[_], val target: Class[_], val timeout: Int, conf: ActiveObjectGuiceConfigurator) extends InvocationHandler { +class ActiveObjectProxy(val intf: Class[_], val target: Class[_], val timeout: Int) extends InvocationHandler { import ActiveObject.threadBoundTx private[this] var activeTx: Option[Transaction] = None @@ -131,10 +131,12 @@ class ActiveObjectProxy(val intf: Class[_], val target: Class[_], val timeout: I private def invoke(invocation: Invocation): AnyRef = { val result: AnyRef = +/* if (invocation.target.isInstanceOf[MessageDriven] && invocation.method.getName == "onMessage") { val m = invocation.method - val endpointName = m.getDeclaringClass.getName + "." + m.getName + + val endpointName = m.getDeclaringClass.getName + "." + m.getName val activeObjectName = m.getDeclaringClass.getName val endpoint = conf.getRoutingEndpoint(conf.lookupUriFor(m)) val producer = endpoint.createProducer @@ -147,7 +149,8 @@ class ActiveObjectProxy(val intf: Class[_], val target: Class[_], val timeout: I // FIXME: need some timeout and future here... exchange.getOut.getBody - } else if (invocation.method.isAnnotationPresent(Annotations.oneway)) { + } else */ + if (invocation.method.isAnnotationPresent(Annotations.oneway)) { server ! invocation } else { val result: ErrRef[AnyRef] = @@ -225,11 +228,11 @@ private[kernel] class Dispatcher(val targetName: String) extends GenericServer { case 'exit => exit; reply() - case exchange: Exchange => +/* case exchange: Exchange => println("=============> Exchange From Actor: " + exchange) val invocation = exchange.getIn.getBody.asInstanceOf[Invocation] invocation.invoke - +*/ case unexpected => throw new ActiveObjectException("Unexpected message [" + unexpected + "] to [" + this + "] from [" + sender + "]") } diff --git a/kernel/src/main/scala/camel/SupervisorAwareCamelContext.scala b/kernel/src/main/scala/camel/SupervisorAwareCamelContext.scala index 041bfd7048..36cc8a21fc 100644 --- a/kernel/src/main/scala/camel/SupervisorAwareCamelContext.scala +++ b/kernel/src/main/scala/camel/SupervisorAwareCamelContext.scala @@ -1,4 +1,4 @@ -//** +/** * Copyright (C) 2009 Scalable Solutions. */ @@ -6,6 +6,7 @@ package se.scalablesolutions.akka.kernel.camel import org.apache.camel.impl.{DefaultCamelContext, DefaultEndpoint, DefaultComponent} import se.scalablesolutions.akka.kernel.{Supervisor, Logging} + /** * @author Jonas Bonér */ diff --git a/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala b/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala index 14d8005ca5..4dde99f6e4 100644 --- a/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala +++ b/kernel/src/main/scala/config/ActiveObjectGuiceConfigurator.scala @@ -4,7 +4,6 @@ package se.scalablesolutions.akka.kernel.config - import com.google.inject._ import com.google.inject.jsr250.ResourceProviderFactory @@ -18,7 +17,6 @@ import se.scalablesolutions.akka.kernel.ActiveObjectProxy import se.scalablesolutions.akka.kernel.Supervisor import se.scalablesolutions.akka.kernel.config.ScalaConfig._ - /** * @author Jonas Bonér */ @@ -33,7 +31,7 @@ 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] @@ -41,10 +39,11 @@ class ActiveObjectGuiceConfigurator extends Logging { injector.getInstance(clazz).asInstanceOf[T] } +/* def getRoutingEndpoint(uri: String): Endpoint = synchronized { camelContext.getEndpoint(uri) } - + def getRoutingEndpoints: java.util.Collection[Endpoint] = synchronized { camelContext.getEndpoints } @@ -52,7 +51,7 @@ class ActiveObjectGuiceConfigurator extends Logging { 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. * @@ -108,18 +107,18 @@ class ActiveObjectGuiceConfigurator extends Logging { injector = Guice.createInjector(modules) var workers = new java.util.ArrayList[Worker] for (component <- components) { - val activeObjectProxy = new ActiveObjectProxy(component.intf, component.target, component.timeout, this) + 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 } @@ -154,12 +153,12 @@ class ActiveObjectGuiceConfigurator extends Logging { * } * }).inject().supervise(); * - */ + * def addRoutes(routes: Routes): ActiveObjectGuiceConfigurator = synchronized { camelContext.addRoutes(routes) this } - + */ def getGuiceModules = modules def reset = synchronized { @@ -169,11 +168,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 } diff --git a/kernel/src/main/scala/config/ActiveObjectGuiceConfiguratorForJava.scala b/kernel/src/main/scala/config/ActiveObjectGuiceConfiguratorForJava.scala index e3a7346806..847ebbe06c 100644 --- a/kernel/src/main/scala/config/ActiveObjectGuiceConfiguratorForJava.scala +++ b/kernel/src/main/scala/config/ActiveObjectGuiceConfiguratorForJava.scala @@ -27,12 +27,12 @@ class ActiveObjectGuiceConfiguratorForJava { private var configRegistry = new HashMap[Class[_], Component] // TODO is configRegistry needed? private var activeObjectRegistry = new HashMap[String, Tuple2[Class[_], ActiveObjectProxy]] private var activeObjectFactory = new ActiveObjectFactory - private var camelContext = new DefaultCamelContext(); + //private var camelContext = new DefaultCamelContext(); def getExternalDependency[T](clazz: Class[T]): T = synchronized { injector.getInstance(clazz).asInstanceOf[T] } - +/* def getRoutingEndpoint(uri: String): Endpoint = synchronized { camelContext.getEndpoint(uri) } @@ -44,7 +44,7 @@ class ActiveObjectGuiceConfiguratorForJava { def getRoutingEndpoints(uri: String): Collection[Endpoint] = synchronized { camelContext.getEndpoints(uri) } - +*/ /** * Returns the active abject that has been put under supervision for the class specified. * @@ -84,19 +84,18 @@ class ActiveObjectGuiceConfiguratorForJava { } def supervise: ActiveObjectGuiceConfiguratorForJava = synchronized { - /* if (injector == null) inject() injector = Guice.createInjector(modules) val workers = new java.util.ArrayList[se.scalablesolutions.akka.kernel.config.ScalaConfig.Worker] for (c <- components) { - val activeObjectProxy = new ActiveObjectProxy(c.intf, c.target, c.timeout, this) + val activeObjectProxy = new ActiveObjectProxy(c.intf, c.target, c.timeout) workers.add(c.newWorker(activeObjectProxy)) activeObjectRegistry.put(c.name, (c.intf, activeObjectProxy)) - camelContext.getRegistry.asInstanceOf[JndiRegistry].bind(c.intf.getName, activeObjectProxy) +// camelContext.getRegistry.asInstanceOf[JndiRegistry].bind(c.intf.getName, activeObjectProxy) } supervisor = activeObjectFactory.supervise(restartStrategy.transform, workers) - camelContext.start - */this +// camelContext.start + this } @@ -131,11 +130,12 @@ class ActiveObjectGuiceConfiguratorForJava { * } * }).inject().supervise(); * - */ + * def addRoutes(routes: Routes): ActiveObjectGuiceConfiguratorForJava = synchronized { camelContext.addRoutes(routes) this } + */ def getGuiceModules = modules @@ -145,11 +145,11 @@ class ActiveObjectGuiceConfiguratorForJava { activeObjectRegistry = new HashMap[String, Tuple2[Class[_], ActiveObjectProxy]] injector = null restartStrategy = null - camelContext = new DefaultCamelContext + //camelContext = new DefaultCamelContext } def stop = synchronized { - camelContext.stop + //camelContext.stop supervisor.stop } } diff --git a/kernel/src/test/scala/CamelSpec.scala b/kernel/src/test/scala/CamelSpec.scala index 1be2bd9925..b9a0cd5601 100644 --- a/kernel/src/test/scala/CamelSpec.scala +++ b/kernel/src/test/scala/CamelSpec.scala @@ -33,7 +33,9 @@ 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") { val latch = new CountDownLatch(1); @@ -62,10 +64,10 @@ class CamelSpec extends Spec with ShouldMatchers { latch.countDown } }) - } - }).supervise + }} + ).supervise - val endpoint = conf.getRoutingEndpoint("akka:camelfoo.foo") + //val endpoint = conf.getRoutingEndpoint("akka:camelfoo.foo") // println("----- " + endpoint) // val exchange = endpoint.createExchange // println("----- " + exchange) @@ -87,6 +89,7 @@ class CamelSpec extends Spec with ShouldMatchers { // // conf.stop } + */ } }