Fixed bug in Active Object restart, had no default life-cycle defined + added tests
This commit is contained in:
parent
2541176559
commit
1f09e17d74
4 changed files with 25 additions and 17 deletions
|
|
@ -687,8 +687,6 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
|
|||
private var context: Option[ActiveObjectContext] = None
|
||||
private var targetClass:Class[_] = _
|
||||
|
||||
|
||||
|
||||
def this(transactionalRequired: Boolean) = this(transactionalRequired,None)
|
||||
|
||||
private[actor] def initialize(targetClass: Class[_], targetInstance: AnyRef, ctx: Option[ActiveObjectContext]) = {
|
||||
|
|
@ -701,6 +699,8 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
|
|||
context = ctx
|
||||
val methods = targetInstance.getClass.getDeclaredMethods.toList
|
||||
|
||||
if (self.lifeCycle.isEmpty) self.lifeCycle = Some(LifeCycle(Permanent))
|
||||
|
||||
// See if we have any config define restart callbacks
|
||||
restartCallbacks match {
|
||||
case None => {}
|
||||
|
|
|
|||
|
|
@ -215,11 +215,15 @@ class RemoteServer extends Logging {
|
|||
|
||||
def shutdown = synchronized {
|
||||
if (_isRunning) {
|
||||
try {
|
||||
RemoteServer.unregister(hostname, port)
|
||||
openChannels.disconnect
|
||||
openChannels.close.awaitUninterruptibly
|
||||
bootstrap.releaseExternalResources
|
||||
Cluster.deregisterLocalNode(hostname, port)
|
||||
} catch {
|
||||
case e: java.nio.channels.ClosedChannelException => log.warning("Could not close remote server channel in a graceful way")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import org.scalatest.{BeforeAndAfterAll, Spec}
|
|||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest.matchers.ShouldMatchers
|
||||
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator
|
||||
import se.scalablesolutions.akka.actor.ActiveObject._
|
||||
|
||||
import se.scalablesolutions.akka.config.{OneForOneStrategy, ActiveObjectConfigurator}
|
||||
import se.scalablesolutions.akka.config.JavaConfig._
|
||||
|
||||
/**
|
||||
|
|
@ -151,5 +153,15 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
|
|||
assert(!obj._post)
|
||||
assert(obj._down)
|
||||
}
|
||||
|
||||
it("both preRestart and postRestart methods should be invoked when an actor is restarted") {
|
||||
val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
|
||||
val supervisor = ActiveObject.newInstance(classOf[SimpleJavaPojo])
|
||||
link(supervisor,pojo, new OneForOneStrategy(3, 2000),Array(classOf[Throwable]))
|
||||
pojo.throwException
|
||||
Thread.sleep(500)
|
||||
pojo.pre should be(true)
|
||||
pojo.post should be(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,18 +17,11 @@ import se.scalablesolutions.akka.config.ActiveObjectConfigurator
|
|||
import se.scalablesolutions.akka.config.JavaConfig._
|
||||
import se.scalablesolutions.akka.actor._
|
||||
|
||||
/*
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class NestedTransactionalActiveObjectSpec extends
|
||||
<<<<<<< HEAD:akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala
|
||||
Spec with
|
||||
ShouldMatchers with
|
||||
BeforeAndAfterAll {
|
||||
=======
|
||||
Spec with
|
||||
ShouldMatchers with
|
||||
BeforeAndAfterAll {
|
||||
>>>>>>> 38e8bea3fe6a7e9fcc9c5f353124144739bdc234:akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala
|
||||
|
||||
private val conf = new ActiveObjectConfigurator
|
||||
private var messageLog = ""
|
||||
|
|
@ -165,4 +158,3 @@ class NestedTransactionalActiveObjectSpec extends
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue