From d01a293fa7bf66ef2d94d4498063fe719b89a85c Mon Sep 17 00:00:00 2001 From: Jonas Boner Date: Mon, 16 Feb 2009 19:50:50 +0100 Subject: [PATCH] added Java compat API for defining up ActiveObjects --- api-java/pom.xml | 58 ++----- .../akka/api/Configurator.java | 133 +++++++++++++++ kernel/pom.xml | 87 ++-------- kernel/src/main/scala/ActiveObject.scala | 115 +++++++++++++ kernel/src/main/scala/Configuration.scala | 157 ++++++++++++++++++ kernel/src/main/scala/ErrRef.scala | 50 ++++++ kernel/src/main/scala/HashCode.scala | 48 ++++++ kernel/src/main/scala/Kernel.scala | 2 + kernel/src/test/scala/ActiveObjectSuite.scala | 139 ++++++++++++++++ pom.xml | 15 +- 10 files changed, 682 insertions(+), 122 deletions(-) create mode 100755 api-java/src/main/java/com/scalablesolutions/akka/api/Configurator.java create mode 100755 kernel/src/main/scala/ActiveObject.scala create mode 100755 kernel/src/main/scala/Configuration.scala create mode 100644 kernel/src/main/scala/ErrRef.scala create mode 100755 kernel/src/main/scala/HashCode.scala create mode 100755 kernel/src/test/scala/ActiveObjectSuite.scala diff --git a/api-java/pom.xml b/api-java/pom.xml index edb6fc4f35..a1e588111a 100755 --- a/api-java/pom.xml +++ b/api-java/pom.xml @@ -3,20 +3,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 + Akka Java API + akka-api-java + jar + - ${akka.groupId} akka + ${akka.groupId} ${akka.version} - Akka Java API - api-java - - com.scalablesolutions.akka - kernel + ${akka.groupId} + akka-kernel ${akka.version} @@ -48,29 +49,15 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - testng.xml - - - - - maven-clean-plugin - - - - ${basedir} - - derby.log - gps_db - - - - - + + + + + + + + + @@ -88,19 +75,6 @@ - - - - false - src/test/resources - - ** - - - **/*.java - - - diff --git a/api-java/src/main/java/com/scalablesolutions/akka/api/Configurator.java b/api-java/src/main/java/com/scalablesolutions/akka/api/Configurator.java new file mode 100755 index 0000000000..067982a2bc --- /dev/null +++ b/api-java/src/main/java/com/scalablesolutions/akka/api/Configurator.java @@ -0,0 +1,133 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.api; + +import com.google.inject.AbstractModule; +import com.google.inject.CreationException; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import com.google.inject.spi.CloseFailedException; + +import java.util.List; +import java.util.ArrayList; + +import javax.annotation.Resource; +import javax.naming.Context; + +import scala.actors.behavior.*; + +public class Configurator { + + static public Supervisor supervise(Configuration.RestartStrategy restartStrategy, List components) { + return null; + // SupervisorFactory factory = new SupervisorFactory() { + // @Override public SupervisorConfig getSupervisorConfig() { + // new SupervisorConfig(restartStrategy, components.map(c => Worker(c.component.server, c.lifeCycle))) + // } + // } + // val supervisor = factory.newSupervisor + // supervisor ! scala.actors.behavior.Start + // supervisor + } + + // private def supervise(proxy: ActiveObjectProxy): Supervisor = + // supervise( + // RestartStrategy(OneForOne, 5, 1000), + // Component( + // proxy, + // LifeCycle(Permanent, 100)) + // :: Nil) + + // val fooProxy = new ActiveObjectProxy(new FooImpl, 1000) + // val barProxy = new ActiveObjectProxy(new BarImpl, 1000) + + // val supervisor = + // ActiveObject.supervise( + // RestartStrategy(AllForOne, 3, 100), + // Component( + // fooProxy, + // LifeCycle(Permanent, 100)) :: + // Component( + // barProxy, + // LifeCycle(Permanent, 100)) + // :: Nil) + + // val foo = ActiveObject.newInstance[Foo](classOf[Foo], fooProxy) + // val bar = ActiveObject.newInstance[Bar](classOf[Bar], barProxy) + + + + // public void testResourceInjection() throws CreationException, CloseFailedException { + // Injector injector = Guice.createInjector(new AbstractModule() { + // protected void configure() { + // bind(ResourceProviderFactory.class); + // bind(MyBean.class).in(Singleton.class); + // } + + // @Provides + // public Context createJndiContext() throws Exception { + // Context answer = new JndiContext(); + // answer.bind("foo", new AnotherBean("Foo")); + // answer.bind("xyz", new AnotherBean("XYZ")); + // return answer; + // } + // }); + + // MyBean bean = injector.getInstance(MyBean.class); + // assertNotNull("Should have instantiated the bean", bean); + // assertNotNull("Should have injected a foo", bean.foo); + // assertNotNull("Should have injected a bar", bean.bar); + + // assertEquals("Should have injected correct foo", "Foo", bean.foo.name); + // assertEquals("Should have injected correct bar", "XYZ", bean.bar.name); + // } + + // public static class MyBean { + // @Resource + // public AnotherBean foo; + + // public AnotherBean bar; + + // @Resource(name = "xyz") + // public void bar(AnotherBean bar) { + // this.bar = bar; + // } + // } + + // static class AnotherBean { + // public String name = "undefined"; + + // AnotherBean(String name) { + // this.name = name; + // } + + // Injector injector = Guice.createInjector(new AbstractModule() { + // protected void configure() { + // Jsr250.bind(binder()); + + // bind(MyBean.class).in(Singleton.class); + // } + // }); + + // Injector injector = Guice.createInjector(new AbstractModule() { + // protected void configure() { + // bind(ResourceProviderFactory.class); + // bind(MyBean.class).in(Singleton.class); + // } + + // @Provides + // public Context createJndiContext() throws Exception { + // Context answer = new JndiContext(); + // answer.bind("foo", new AnotherBean("Foo")); + // answer.bind("xyz", new AnotherBean("XYZ")); + // return answer; + // } + // }); + + // MyBean bean = injector.getInstance(MyBean.class); +} + diff --git a/kernel/pom.xml b/kernel/pom.xml index fe5cbb33aa..58a19cb49f 100755 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -3,13 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - kernel - + akka-kernel Akka Kernel Module + jar + - ${akka.groupId} akka + ${akka.groupId} ${akka.version} @@ -29,6 +30,11 @@ Scala-Tools Maven2 Repository http://scala-tools.org/repo-releases + + lag + Configgy's' Repository + http://www.lag.net/repo + @@ -46,17 +52,17 @@ ${scala.version} - org.scala-tools + org.scala-libs scala-otp-behavior 0.1-SNAPSHOT - org.scala-tools + org.scala-libs scala-otp-component 0.1-SNAPSHOT - org.scala-tools + org.scala-libs scala-otp-util-java 0.1-SNAPSHOT @@ -65,7 +71,11 @@ configgy 1.2 - + + org.guiceyfruit + guice-core + 2.0-SNAPSHOT + org.specs specs @@ -104,37 +114,6 @@ 1.0 - - org.apache.maven.plugins - maven-surefire-plugin - - - testng.xml - - - - - org.mortbay.jetty - maven-jetty-plugin - - / - 5 - - - - net.sf.alchim - yuicompressor-maven-plugin - - - - compress - - - - - true - - org.apache.maven.plugins maven-eclipse-plugin @@ -171,20 +150,6 @@ - - maven-clean-plugin - - - - ${basedir} - - derby.log - gps_db - - - - - @@ -202,24 +167,8 @@ - - - false - src/test/resources - - - false - src/test/scala - - ** - - - **/*.scala - - - - + org.scala-tools diff --git a/kernel/src/main/scala/ActiveObject.scala b/kernel/src/main/scala/ActiveObject.scala new file mode 100755 index 0000000000..a90e41d234 --- /dev/null +++ b/kernel/src/main/scala/ActiveObject.scala @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.kernel + +import scala.actors.behavior._ + +import java.util.{List => JList, ArrayList} + +import java.lang.reflect.{Method, Field, InvocationHandler, Proxy, InvocationTargetException} +import java.lang.annotation.Annotation + +sealed class ActiveObjectException(msg: String) extends RuntimeException(msg) +class ActiveObjectInvocationTimeoutException(msg: String) extends ActiveObjectException(msg) + +/** + * @author Jonas Bonér + */ +object ActiveObject { + + def newInstance[T](intf: Class[T] forSome {type T}, target: AnyRef, timeout: Int): T = { + val proxy = new ActiveObjectProxy(target, timeout) + supervise(proxy) + newInstance(intf, proxy) + } + + def newInstance[T](intf: Class[T] forSome {type T}, proxy: ActiveObjectProxy): T = { + Proxy.newProxyInstance( + proxy.target.getClass.getClassLoader, + Array(intf), + proxy).asInstanceOf[T] + } + + def supervise(restartStrategy: RestartStrategy, components: List[Worker]): Supervisor = { + object factory extends SupervisorFactory { + override def getSupervisorConfig: SupervisorConfig = { + SupervisorConfig(restartStrategy, components) + } + } + val supervisor = factory.newSupervisor + supervisor ! scala.actors.behavior.Start + supervisor + } + + private def supervise(proxy: ActiveObjectProxy): Supervisor = + supervise( + RestartStrategy(OneForOne, 5, 1000), + Worker( + proxy.server, + LifeCycle(Permanent, 100)) + :: Nil) +} + +/** + * @author Jonas Bonér + */ +class ActiveObjectProxy(val target: AnyRef, val timeout: Int) extends InvocationHandler { + private val oneway = classOf[scala.actors.annotation.oneway] + + private[ActiveObjectProxy] object dispatcher extends GenericServer { + override def body: PartialFunction[Any, Unit] = { + case invocation: Invocation => + try { + reply(ErrRef(invocation.invoke)) + } catch { + case e: InvocationTargetException => reply(ErrRef({ throw e.getTargetException })) + case e => reply(ErrRef({ throw e })) + } + case 'exit => exit; reply() + case unexpected => throw new ActiveObjectException("Unexpected message to actor proxy: " + unexpected) + } + } + + private[kernel] val server = new GenericServerContainer(target.getClass.getName, () => dispatcher) + server.setTimeout(timeout) + + def invoke(proxy: AnyRef, m: Method, args: Array[AnyRef]): AnyRef = invoke(Invocation(m, args, target)) + + def invoke(invocation: Invocation): AnyRef = { + if (invocation.method.isAnnotationPresent(oneway)) server ! invocation + else { + val result: ErrRef[AnyRef] = server !!! (invocation, ErrRef({ throw new ActiveObjectInvocationTimeoutException("proxy invocation timed out after " + timeout + " milliseconds") })) + result() + } + } +} + +/** + * Represents a snapshot of the current invocation. + * + * @author Jonas Bonér + */ +case class Invocation(val method: Method, val args: Array[Object], val target: AnyRef) { + def invoke: AnyRef = method.invoke(target, args: _*) + + override def toString: String = "Invocation [method: " + method.getName + ", args: " + args + ", target: " + target + "]" + + override def hashCode(): Int = { + var result = HashCode.SEED + result = HashCode.hash(result, method) + result = HashCode.hash(result, args) + result = HashCode.hash(result, target) + result + } + + override def equals(that: Any): Boolean = { + that != null && + that.isInstanceOf[Invocation] && + that.asInstanceOf[Invocation].method == method && + that.asInstanceOf[Invocation].args == args + that.asInstanceOf[Invocation].target == target + } +} + diff --git a/kernel/src/main/scala/Configuration.scala b/kernel/src/main/scala/Configuration.scala new file mode 100755 index 0000000000..52f6a0c0ff --- /dev/null +++ b/kernel/src/main/scala/Configuration.scala @@ -0,0 +1,157 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.api + +import com.scalablesolutions.akka.kernel.ActiveObject + +import java.util.{List => JList} + +import scala.actors.behavior._ +import scala.reflect.BeanProperty + +sealed abstract class Configuration + +class RestartStrategy(@BeanProperty val scheme: FailOverScheme, @BeanProperty val maxNrOfRetries: Int, @BeanProperty val withinTimeRange: Int) extends Configuration { + def transform = scala.actors.behavior.RestartStrategy(scheme.transform, maxNrOfRetries, withinTimeRange) +} +class LifeCycle(@BeanProperty val scope: Scope, @BeanProperty val shutdownTime: Int) extends Configuration { + def transform = scala.actors.behavior.LifeCycle(scope.transform, shutdownTime) +} + +abstract class Scope extends Configuration { + def transform: scala.actors.behavior.Scope +} +class Permanent extends Scope { + override def transform = scala.actors.behavior.Permanent +} +class Transient extends Scope { + override def transform = scala.actors.behavior.Transient +} +class Temporary extends Scope { + override def transform = scala.actors.behavior.Temporary +} + +abstract class FailOverScheme extends Configuration { + def transform: scala.actors.behavior.FailOverScheme +} +class AllForOne extends FailOverScheme { + override def transform = scala.actors.behavior.AllForOne +} +class OneForOne extends FailOverScheme { + override def transform = scala.actors.behavior.OneForOne +} + +abstract class Server extends Configuration +class SupervisorConfig(@BeanProperty val restartStrategy: RestartStrategy, @BeanProperty val servers: JList[Server]) extends Server { + def transform = scala.actors.behavior.SupervisorConfig(restartStrategy.transform, servers.toArray.toList.asInstanceOf[List[Component]].map(_.transform)) +} +class Component(@BeanProperty val serverContainer: GenericServerContainer, @BeanProperty val lifeCycle: LifeCycle) extends Server { + def transform = scala.actors.behavior.Worker(serverContainer, lifeCycle.transform) +} + + +object Configuration { + def supervise(restartStrategy: RestartStrategy, components: JList[Component]): Supervisor = + ActiveObject.supervise( + restartStrategy.transform, + components.toArray.toList.asInstanceOf[List[Component]].map( + c => scala.actors.behavior.Worker(c.serverContainer, c.lifeCycle.transform))) +} + + + +// static class SupervisorConfig extends Server { +// private final RestartStrategy restartStrategy; +// private final List servers; +// public SupervisorConfig(RestartStrategy restartStrategy, List servers) { +// this.restartStrategy = restartStrategy; +// this.servers = servers; +// } +// public RestartStrategy getRestartStrategy() { +// return restartStrategy; +// } +// public List getServer() { +// return servers; +// } +// public scala.actors.behavior.SupervisorConfig scalaVersion() { +// List ss = new ArrayList(); +// for (Server s: servers) { +// ss.add(s.scalaVersion()); +// } +// return new scala.actors.behavior.SupervisorConfig(restartStrategy.scalaVersion(), ss); +// } +// } + +// static class Component extends Server { +// private final GenericServerContainer serverContainer; +// private final LifeCycle lifeCycle; +// public Component(GenericServerContainer serverContainer, LifeCycle lifeCycle) { +// this.serverContainer = serverContainer; +// this.lifeCycle = lifeCycle; +// } +// public GenericServerContainer getServerContainer() { +// return serverContainer; +// } +// public LifeCycle getLifeCycle() { +// return lifeCycle; +// } +// public scala.actors.behavior.Server scalaVersion() { +// return new scala.actors.behavior.Worker(serverContainer, lifeCycle.scalaVersion()); +// } +// } + +// static class RestartStrategy extends Configuration { +// private final FailOverScheme scheme; +// private final int maxNrOfRetries; +// private final int withinTimeRange; +// public RestartStrategy(FailOverScheme scheme, int maxNrOfRetries, int withinTimeRange) { +// this.scheme = scheme; +// this.maxNrOfRetries = maxNrOfRetries; +// this.withinTimeRange = withinTimeRange; +// } +// public FailOverScheme getFailOverScheme() { +// return scheme; +// } +// public int getMaxNrOfRetries() { +// return maxNrOfRetries; +// } +// public int getWithinTimeRange() { +// return withinTimeRange; +// } +// public scala.actors.behavior.RestartStrategy scalaVersion() { +// scala.actors.behavior.FailOverScheme fos; +// switch (scheme) { +// case AllForOne: fos = new scala.actors.behavior.AllForOne(); break; +// case OneForOne: fos = new scala.actors.behavior.OneForOne(); break; +// } +// return new scala.actors.behavior.RestartStrategy(fos, maxNrOfRetries, withinTimeRange); +// } +// } + +// static class LifeCycle extends Configuration { +// private final Scope scope; +// private final int shutdownTime; +// public LifeCycle(Scope scope, int shutdownTime) { +// this.scope = scope; +// this.shutdownTime = shutdownTime; +// } +// public Scope getScope() { +// return scope; +// } +// public int getShutdownTime() { +// return shutdownTime; +// } +// public scala.actors.behavior.LifeCycle scalaVersion() { +// scala.actors.behavior.Scope s; +// switch (scope) { +// case Permanent: s = new scala.actors.behavior.Permanent(); break; +// case Transient: s = new scala.actors.behavior.Transient(); break; +// case Temporary: s = new scala.actors.behavior.Temporary(); break; +// } +// return new scala.actors.behavior.LifeCycle(s, shutdownTime); +// } +// } +// } + diff --git a/kernel/src/main/scala/ErrRef.scala b/kernel/src/main/scala/ErrRef.scala new file mode 100644 index 0000000000..38cbc805b8 --- /dev/null +++ b/kernel/src/main/scala/ErrRef.scala @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.kernel + +/** + * Reference that can hold either a typed value or an exception. + * + * Usage: + *
+ * scala> ErrRef(1)
+ * res0: ErrRef[Int] = ErrRef@a96606
+ *  
+ * scala> res0()
+ * res1: Int = 1
+ *
+ * scala> res0() = 3
+ *
+ * scala> res0()
+ * res3: Int = 3
+ * 
+ * scala> res0() = { println("Hello world"); 3}
+ * Hello world
+ *
+ * scala> res0()
+ * res5: Int = 3
+ *  
+ * scala> res0() = error("Lets see what happens here...")
+ *
+ * scala> res0()
+ * java.lang.RuntimeException: Lets see what happens here...
+ * 	at ErrRef.apply(RefExcept.scala:11)
+ * 	at .(:6)
+ * 	at .()
+ * 	at Re...
+ * 
+ */ +class ErrRef[S](s: S){ + private[this] var contents: Either[Throwable, S] = Right(s) + def update(value: => S) = contents = try { Right(value) } catch { case (e : Throwable) => Left(e) } + def apply() = contents match { + case Right(s) => s + case Left(e) => throw e.fillInStackTrace + } + override def toString(): String = "ErrRef[" + contents + "]" +} +object ErrRef { + def apply[S](s: S) = new ErrRef(s) +} diff --git a/kernel/src/main/scala/HashCode.scala b/kernel/src/main/scala/HashCode.scala new file mode 100755 index 0000000000..d0cd5af2d3 --- /dev/null +++ b/kernel/src/main/scala/HashCode.scala @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.kernel + +import java.lang.reflect.{Array => JArray} +import java.lang.{Float => JFloat, Double => JDouble} + +/** + * Set of methods which allow easy implementation of hashCode. + * + * Example: + *
+ *  override def hashCode: Int = {
+ *    var result = HashCode.SEED
+ *    //collect the contributions of various fields
+ *    result = HashCode.hash(result, fPrimitive)
+ *    result = HashCode.hash(result, fObject)
+ *    result = HashCode.hash(result, fArray)
+ *    result
+ *  }
+ * 
+ * + * @author Jonas Bonér + */ +object HashCode { + val SEED = 23 + + def hash(seed: Int, value: Boolean): Int = firstTerm(seed) + (if (value) 1 else 0) + def hash(seed: Int, value: Char): Int = firstTerm(seed) + value.asInstanceOf[Int] + def hash(seed: Int, value: Int): Int = firstTerm(seed) + value + def hash(seed: Int, value: Long): Int = firstTerm(seed) + (value ^ (value >>> 32) ).asInstanceOf[Int] + def hash(seed: Int, value: Float): Int = hash(seed, JFloat.floatToIntBits(value)) + def hash(seed: Int, value: Double): Int = hash(seed, JDouble.doubleToLongBits(value)) + def hash(seed: Int, anyRef: AnyRef): Int = { + var result = seed + if (anyRef == null) result = hash(result, 0) + else if (!isArray(anyRef)) result = hash(result, anyRef.hashCode()) + else for (id <- 0 until JArray.getLength(anyRef)) result = hash(result, JArray.get(anyRef, id)) // is an array + result + } + + private def firstTerm(seed: Int): Int = PRIME * seed + private def isArray(anyRef: AnyRef): Boolean = anyRef.getClass.isArray + private val PRIME = 37 +} + diff --git a/kernel/src/main/scala/Kernel.scala b/kernel/src/main/scala/Kernel.scala index dc1868cbf5..6780aff372 100755 --- a/kernel/src/main/scala/Kernel.scala +++ b/kernel/src/main/scala/Kernel.scala @@ -4,3 +4,5 @@ package com.scalablesolutions.akka.kernel +object Kernel { +} diff --git a/kernel/src/test/scala/ActiveObjectSuite.scala b/kernel/src/test/scala/ActiveObjectSuite.scala new file mode 100755 index 0000000000..94bac74f4a --- /dev/null +++ b/kernel/src/test/scala/ActiveObjectSuite.scala @@ -0,0 +1,139 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package com.scalablesolutions.akka.kernel + +import scala.actors.behavior._ +import scala.actors.annotation.oneway + +/** + * @author Jonas Bonér + */ + + +// class ActiveObjectSuite extends TestNGSuite { + +// private var messageLog = "" + +// trait Foo { +// def foo(msg: String): String +// @oneway def bar(msg: String) +// def longRunning +// def throwsException +// } + +// class FooImpl extends Foo { +// val bar: Bar = new BarImpl +// def foo(msg: String): String = { +// messageLog += msg +// "return_foo " +// } +// def bar(msg: String) = bar.bar(msg) +// def longRunning = Thread.sleep(10000) +// def throwsException = error("expected") +// } + +// trait Bar { +// @oneway def bar(msg: String) +// } + +// class BarImpl extends Bar { +// def bar(msg: String) = { +// Thread.sleep(100) +// messageLog += msg +// } +// } + +// @BeforeMethod +// def setup = messageLog = "" + +// @Test { val groups=Array("unit") } +// def testCreateGenericServerBasedComponentUsingDefaultSupervisor = { +// val foo = ActiveObject.newInstance[Foo](classOf[Foo], new FooImpl, 1000) + +// val result = foo.foo("foo ") +// messageLog += result + +// foo.bar("bar ") +// messageLog += "before_bar " + +// Thread.sleep(500) +// assert(messageLog === "foo return_foo before_bar bar ") +// } + +// @Test { val groups=Array("unit") } +// def testCreateGenericServerBasedComponentUsingCustomSupervisorConfiguration = { +// val proxy = new ActiveObjectProxy(new FooImpl, 1000) + +// val supervisor = +// ActiveObject.supervise( +// RestartStrategy(AllForOne, 3, 100), +// Component( +// proxy, +// LifeCycle(Permanent, 100)) +// :: Nil) + +// val foo = ActiveObject.newInstance[Foo](classOf[Foo], proxy) + +// val result = foo.foo("foo ") +// messageLog += result + +// foo.bar("bar ") +// messageLog += "before_bar " + +// Thread.sleep(500) +// assert(messageLog === "foo return_foo before_bar bar ") + +// supervisor ! Stop +// } + +// @Test { val groups=Array("unit") } +// def testCreateTwoGenericServerBasedComponentUsingCustomSupervisorConfiguration = { +// val fooProxy = new ActiveObjectProxy(new FooImpl, 1000) +// val barProxy = new ActiveObjectProxy(new BarImpl, 1000) + +// val supervisor = +// ActiveObject.supervise( +// RestartStrategy(AllForOne, 3, 100), +// Component( +// fooProxy, +// LifeCycle(Permanent, 100)) :: +// Component( +// barProxy, +// LifeCycle(Permanent, 100)) +// :: Nil) + +// val foo = ActiveObject.newInstance[Foo](classOf[Foo], fooProxy) +// val bar = ActiveObject.newInstance[Bar](classOf[Bar], barProxy) + +// val result = foo.foo("foo ") +// messageLog += result + +// bar.bar("bar ") +// messageLog += "before_bar " + +// Thread.sleep(500) +// assert(messageLog === "foo return_foo before_bar bar ") + +// supervisor ! Stop +// } + +// @Test { val groups=Array("unit") } +// def testCreateGenericServerBasedComponentUsingDefaultSupervisorAndForcedTimeout = { +// val foo = ActiveObject.newInstance[Foo](classOf[Foo], new FooImpl, 1000) +// intercept(classOf[ActiveObjectInvocationTimeoutException]) { +// foo.longRunning +// } +// assert(true === true) +// } + +// @Test { val groups=Array("unit") } +// def testCreateGenericServerBasedComponentUsingDefaultSupervisorAndForcedException = { +// val foo = ActiveObject.newInstance[Foo](classOf[Foo], new FooImpl, 10000) +// intercept(classOf[RuntimeException]) { +// foo.throwsException +// } +// assert(true === true) +// } +// } diff --git a/pom.xml b/pom.xml index 0c6c343639..2075618ac8 100755 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - ${akka.groupId} - akka - Akka Actor Kernel + Akka Actor Kernel + akka + ${akka.groupId} ${akka.version} 2009 pom @@ -18,16 +18,9 @@ 2.7.3 - - - kernel - api-scala + api-java