Upgraded to AspectWerkz 2.2 + merged in patch for using Actor.isDefinedAt for akka-patterns stuff
This commit is contained in:
parent
04dfc5b003
commit
d95079300b
6 changed files with 68 additions and 5 deletions
|
|
@ -505,6 +505,11 @@ trait Actor extends Logging {
|
|||
*/
|
||||
def reply_?(message: Any): Boolean = self.reply_?(message)
|
||||
|
||||
/**
|
||||
* Is the actor able to handle the message passed in as arguments?
|
||||
*/
|
||||
def isDefinedAt(message: Any): Boolean = base.isDefinedAt(message)
|
||||
|
||||
// =========================================
|
||||
// ==== INTERNAL IMPLEMENTATION DETAILS ====
|
||||
// =========================================
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ trait ActorRef extends TransactionManagement {
|
|||
/**
|
||||
* Is the actor able to handle the message passed in as arguments?
|
||||
*/
|
||||
def isDefinedAt(message: Any): Boolean = actor.base.isDefinedAt(message)
|
||||
def isDefinedAt(message: Any): Boolean = actor.isDefinedAt(message)
|
||||
|
||||
/**
|
||||
* Is the actor is serializable?
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ class CyclicIterator[T](items: List[T]) extends InfiniteIterator[T] {
|
|||
current = nc.tail
|
||||
nc.head
|
||||
}
|
||||
|
||||
override def exists(f: T => Boolean): Boolean = items.exists(f)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -32,4 +35,7 @@ class SmallestMailboxFirstIterator(items : List[ActorRef]) extends InfiniteItera
|
|||
def hasNext = items != Nil
|
||||
|
||||
def next = items.reduceLeft((a1, a2) => if (a1.mailboxSize < a2.mailboxSize) a1 else a2)
|
||||
|
||||
override def exists(f: ActorRef => Boolean): Boolean = items.exists(f)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,7 @@ trait LoadBalancer extends Dispatcher { self: Actor =>
|
|||
protected def seq: InfiniteIterator[ActorRef]
|
||||
|
||||
protected def routes = { case x if seq.hasNext => seq.next }
|
||||
|
||||
override def isDefinedAt(msg: Any) = seq.exists( _.isDefinedAt(msg) )
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,4 +116,53 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat
|
|||
num.get must be (2)
|
||||
for(a <- List(i,a1,a2,a3)) a.stop
|
||||
}
|
||||
|
||||
@Test def testIsDefinedAt = {
|
||||
import se.scalablesolutions.akka.actor.ActorRef
|
||||
|
||||
val (testMsg1,testMsg2,testMsg3,testMsg4) = ("test1","test2","test3","test4")
|
||||
|
||||
val t1 = actorOf( new Actor() {
|
||||
def receive = {
|
||||
case `testMsg1` => self.reply(3)
|
||||
case `testMsg2` => self.reply(7)
|
||||
}
|
||||
} ).start
|
||||
|
||||
val t2 = actorOf( new Actor() {
|
||||
def receive = {
|
||||
case `testMsg1` => self.reply(3)
|
||||
case `testMsg2` => self.reply(7)
|
||||
}
|
||||
} ).start
|
||||
|
||||
val t3 = actorOf( new Actor() {
|
||||
def receive = {
|
||||
case `testMsg1` => self.reply(3)
|
||||
case `testMsg2` => self.reply(7)
|
||||
}
|
||||
} ).start
|
||||
|
||||
val t4 = actorOf( new Actor() {
|
||||
def receive = {
|
||||
case `testMsg1` => self.reply(3)
|
||||
case `testMsg2` => self.reply(7)
|
||||
}
|
||||
} ).start
|
||||
|
||||
val d1 = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil))
|
||||
val d2 = loadBalancerActor(new CyclicIterator[ActorRef](t3 :: t4 :: Nil))
|
||||
|
||||
t1.isDefinedAt(testMsg1) must be (true)
|
||||
t1.isDefinedAt(testMsg3) must be (false)
|
||||
t2.isDefinedAt(testMsg1) must be (true)
|
||||
t2.isDefinedAt(testMsg3) must be (false)
|
||||
d1.isDefinedAt(testMsg1) must be (true)
|
||||
d1.isDefinedAt(testMsg3) must be (false)
|
||||
d2.isDefinedAt(testMsg1) must be (true)
|
||||
d2.isDefinedAt(testMsg3) must be (false)
|
||||
|
||||
for(a <- List(t1,t2,d1,d2)) a.stop
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
|
|||
" dist/akka-jta_%s-%s.jar".format(buildScalaVersion, version)
|
||||
)
|
||||
|
||||
//Exclude slf4j1.5.11 from the classpath, it's conflicting...
|
||||
// Exclude slf4j1.5.11 from the classpath, it's conflicting...
|
||||
override def runClasspath = super.runClasspath --- (super.runClasspath ** "slf4j*1.5.11.jar")
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
|
@ -187,8 +187,8 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
|
|||
val h2_lzf = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile"
|
||||
val jsr166x = "jsr166x" % "jsr166x" % "1.0" % "compile"
|
||||
val jta_1_1 = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile" intransitive()
|
||||
val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.1" % "compile"
|
||||
val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.1" % "compile"
|
||||
val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.2" % "compile"
|
||||
val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.2" % "compile"
|
||||
val configgy = "net.lag" % "configgy" % "2.8.0.RC3-1.5.2-SNAPSHOT" % "compile"
|
||||
val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile"
|
||||
val aopalliance = "aopalliance" % "aopalliance" % "1.0" % "compile"
|
||||
|
|
@ -298,7 +298,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
|
|||
}
|
||||
|
||||
// ================= TEST ==================
|
||||
class AkkaActiveObjectTestProject(info: ProjectInfo) extends DefaultProject(info) {
|
||||
class AkkaActiveObjectTestProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
|
||||
// testing
|
||||
val junit = "junit" % "junit" % "4.5" % "test"
|
||||
val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue