diff --git a/akka-core/src/main/scala/actor/ActiveObject.scala b/akka-core/src/main/scala/actor/ActiveObject.scala index 6cace70ec5..a5a81fe40c 100644 --- a/akka-core/src/main/scala/actor/ActiveObject.scala +++ b/akka-core/src/main/scala/actor/ActiveObject.scala @@ -185,8 +185,8 @@ object ActiveObject { val proxy = Proxy.newInstance(target, false, true) actor.initialize(target, proxy) actor.timeout = timeout - actor.start AspectInitRegistry.register(proxy, AspectInit(target, actor, remoteAddress, timeout)) + actor.start proxy.asInstanceOf[T] } @@ -194,8 +194,8 @@ object ActiveObject { val proxy = Proxy.newInstance(Array(intf), Array(target), false, true) actor.initialize(target.getClass, target) actor.timeout = timeout - actor.start AspectInitRegistry.register(proxy, AspectInit(intf, actor, remoteAddress, timeout)) + actor.start proxy.asInstanceOf[T] } @@ -408,9 +408,9 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Op if (postRestart.isDefined) postRestart.get.setAccessible(true) // see if we have a method annotated with @inittransactionalstate, if so invoke it - //initTxState = methods.find(m => m.isAnnotationPresent(Annotations.inittransactionalstate)) - //if (initTxState.isDefined && initTxState.get.getParameterTypes.length != 0) throw new IllegalStateException("Method annotated with @inittransactionalstate must have a zero argument definition") - //if (initTxState.isDefined) initTxState.get.setAccessible(true) + initTxState = methods.find(m => m.isAnnotationPresent(Annotations.inittransactionalstate)) + if (initTxState.isDefined && initTxState.get.getParameterTypes.length != 0) throw new IllegalStateException("Method annotated with @inittransactionalstate must have a zero argument definition") + if (initTxState.isDefined) initTxState.get.setAccessible(true) } def receive = { @@ -434,11 +434,11 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Op } catch { case e: InvocationTargetException => throw e.getCause } } - //override protected def initTransactionalState = { - // try { - // if (initTxState.isDefined && target.isDefined) initTxState.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) - // } catch { case e: InvocationTargetException => throw e.getCause } - //} + override protected def initTransactionalState = { + try { + if (initTxState.isDefined && target.isDefined) initTxState.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) + } catch { case e: InvocationTargetException => throw e.getCause } + } private def serializeArguments(joinPoint: JoinPoint) = { val args = joinPoint.getRtti.asInstanceOf[MethodRtti].getParameterValues diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala index 51fb20c87b..c4c0f60429 100644 --- a/akka-core/src/main/scala/actor/Actor.scala +++ b/akka-core/src/main/scala/actor/Actor.scala @@ -458,6 +458,7 @@ trait Actor extends TransactionManagement with Logging { messageDispatcher.start _isRunning = true init + initTransactionalState } Actor.log.debug("[%s] has started", toString) ActorRegistry.register(this) diff --git a/akka-core/src/main/scala/config/SupervisionConfig.scala b/akka-core/src/main/scala/config/SupervisionConfig.scala index e993573972..5672ee3695 100644 --- a/akka-core/src/main/scala/config/SupervisionConfig.scala +++ b/akka-core/src/main/scala/config/SupervisionConfig.scala @@ -59,7 +59,7 @@ object ScalaConfig { class Component(_intf: Class[_], val target: Class[_], val lifeCycle: LifeCycle, - val timeout: Int, + val timeout: Long, val transactionRequired: Boolean, _dispatcher: MessageDispatcher, // optional _remoteAddress: RemoteAddress // optional @@ -69,52 +69,52 @@ object ScalaConfig { val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress) } object Component { - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long) = new Component(intf, target, lifeCycle, timeout, false, null, null) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long) = new Component(null, target, lifeCycle, timeout, false, null, null) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher) = new Component(intf, target, lifeCycle, timeout, false, dispatcher, null) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher) = new Component(null, target, lifeCycle, timeout, false, dispatcher, null) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, remoteAddress: RemoteAddress) = new Component(intf, target, lifeCycle, timeout, false, null, remoteAddress) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, remoteAddress: RemoteAddress) = new Component(null, target, lifeCycle, timeout, false, null, remoteAddress) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = new Component(intf, target, lifeCycle, timeout, false, dispatcher, remoteAddress) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = new Component(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean) = new Component(intf, target, lifeCycle, timeout, transactionRequired, null, null) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean) = new Component(null, target, lifeCycle, timeout, transactionRequired, null, null) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher) = new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher) = new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, remoteAddress: RemoteAddress) = new Component(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, remoteAddress: RemoteAddress) = new Component(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress) - def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress) - def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress) } } @@ -174,52 +174,52 @@ object JavaConfig { class Component(@BeanProperty val intf: Class[_], @BeanProperty val target: Class[_], @BeanProperty val lifeCycle: LifeCycle, - @BeanProperty val timeout: Int, + @BeanProperty val timeout: Long, @BeanProperty val transactionRequired: Boolean, // optional @BeanProperty val dispatcher: MessageDispatcher, // optional @BeanProperty val remoteAddress: RemoteAddress // optional ) extends Server { - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long) = this(intf, target, lifeCycle, timeout, false, null, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long) = this(null, target, lifeCycle, timeout, false, null, null) - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, remoteAddress: RemoteAddress) = this(intf, target, lifeCycle, timeout, false, null, remoteAddress) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, remoteAddress: RemoteAddress) = this(null, target, lifeCycle, timeout, false, null, remoteAddress) - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher) = this(intf, target, lifeCycle, timeout, false, dispatcher, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher) = this(null, target, lifeCycle, timeout, false, dispatcher, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = this(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress) - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean) = this(intf, target, lifeCycle, timeout, transactionRequired, null, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean) = this(null, target, lifeCycle, timeout, transactionRequired, null, null) - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, remoteAddress: RemoteAddress) = this(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, remoteAddress: RemoteAddress) = this(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress) - def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) = + def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher) = this(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher) = this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null) - def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = + def this(target: Class[_], lifeCycle: LifeCycle, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) = this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress) def transform = diff --git a/akka-spring/akka-spring-test-java/pom.xml b/akka-spring/akka-spring-test-java/pom.xml index e6eac986bc..e3cd95d74f 100644 --- a/akka-spring/akka-spring-test-java/pom.xml +++ b/akka-spring/akka-spring-test-java/pom.xml @@ -6,11 +6,11 @@ Akka Spring Tests in Java akka-spring-test-java se.scalablesolutions.akka - 0.7 + 0.8 jar - 2.7.7 + 2.8.0.Beta1 0.5.2 1.1.5 1.9.18-i @@ -131,26 +131,38 @@ + + + org.scala-lang + scala-compiler + 2.8.0.Beta1 + + + org.scala-lang + scala-library + 2.8.0.Beta1 + + se.scalablesolutions.akka - akka-core_2.7.7 - 0.7 + akka-core_2.8.0.Beta1 + 0.8 se.scalablesolutions.akka - akka-util_2.7.7 - 0.7 + akka-util_2.8.0.Beta1 + 0.8 se.scalablesolutions.akka - akka-util-java_2.7.7 - 0.7 + akka-util-java_2.8.0.Beta1 + 0.8 se.scalablesolutions.akka - akka-spring_2.7.7 - 0.7 + akka-spring_2.8.0.Beta1 + 0.8 org.springframework @@ -173,7 +185,7 @@ net.lag configgy - 1.4.7 + 2.8.0.Beta1-1.5-SNAPSHOT org.codehaus.aspectwerkz @@ -217,24 +229,24 @@ net.databinder - dispatch-json_2.7.7 - 0.6.4 + dispatch-json_2.8.0.Beta1 + 0.6.6 net.databinder - dispatch-http_2.7.7 - 0.6.4 + dispatch-http_2.8.0.Beta1 + 0.6.6 sjson.json sjson - 0.4 + 0.5-SNAPSHOT-2.8.Beta1 sbinary sbinary - 0.3 + 2.8.0.Beta1-2.8.0.Beta1-0.3.1-SNAPSHOT org.codehaus.jackson @@ -251,22 +263,8 @@ h2-lzf 1.0 - - org.scala-tools - javautils - 2.7.4-0.1 - - - org.scala-lang - scala-library - 2.7.7 - - - org.scala-lang - scala-library - 2.7.7 - - + + junit diff --git a/akka-spring/akka-spring-test-java/src/main/java/se/scalablesolutions/akka/spring/foo/StatefulPojo.java b/akka-spring/akka-spring-test-java/src/main/java/se/scalablesolutions/akka/spring/foo/StatefulPojo.java index 7db06c9a65..7ee334548c 100644 --- a/akka-spring/akka-spring-test-java/src/main/java/se/scalablesolutions/akka/spring/foo/StatefulPojo.java +++ b/akka-spring/akka-spring-test-java/src/main/java/se/scalablesolutions/akka/spring/foo/StatefulPojo.java @@ -1,5 +1,6 @@ package se.scalablesolutions.akka.spring.foo; +import se.scalablesolutions.akka.actor.annotation.inittransactionalstate; import se.scalablesolutions.akka.stm.TransactionalMap; import se.scalablesolutions.akka.stm.TransactionalVector; import se.scalablesolutions.akka.stm.TransactionalRef; @@ -11,15 +12,17 @@ public class StatefulPojo { private TransactionalRef refState; private boolean isInitialized = false; - public void init() { + @inittransactionalstate + public void init() { if (!isInitialized) { - mapState = TransactionalState.newMap(); + mapState = TransactionalState.newMap(); vectorState = TransactionalState.newVector(); refState = TransactionalState.newRef(); isInitialized = true; } } + public String getMapState(String key) { return (String)mapState.get(key).get(); } @@ -44,4 +47,8 @@ public class StatefulPojo { refState.swap(msg); } + public boolean isInitialized() { + return isInitialized; + } + } diff --git a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/dispatcher-config.xml b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/dispatcher-config.xml index fc069ffd71..3339b07199 100644 --- a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/dispatcher-config.xml +++ b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/dispatcher-config.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.akkasource.org/schema/akka - file:////Users/michaelkober/akka/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd"> + http://scalablesolutions.se/akka/akka.xsd"> + keep-alive="3000" + rejection-policy="caller-runs-policy"/> @@ -51,7 +52,7 @@ - + @@ -76,6 +77,6 @@ - + \ No newline at end of file diff --git a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/supervisor-config.xml b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/supervisor-config.xml index c763bf47d1..9f3b78d740 100644 --- a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/supervisor-config.xml +++ b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/supervisor-config.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.akkasource.org/schema/akka - file:////Users/michaelkober/akka/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd"> + http://scalablesolutions.se/akka/akka.xsd"> diff --git a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml index 7e0c212382..ef9dce1930 100644 --- a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml +++ b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.akkasource.org/schema/akka - file:////Users/michaelkober/akka/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd"> + http://scalablesolutions.se/akka/akka.xsd">