();
+// 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