cleaned up supervisor and actor api, breaking changes

This commit is contained in:
jboner 2009-11-20 08:29:31 +01:00
parent 50e73c2a9f
commit a1adfd42e8
51 changed files with 637 additions and 806 deletions

View file

@ -135,7 +135,7 @@ object ActiveObject {
private[akka] def supervise(restartStrategy: RestartStrategy, components: List[Supervise]): Supervisor = {
object factory extends SupervisorFactory {
val factory = SupervisorFactory {
override def getSupervisorConfig = SupervisorConfig(restartStrategy, components)
}
val supervisor = factory.newSupervisor
@ -333,7 +333,7 @@ private[akka] class Dispatcher(val callbacks: Option[RestartCallbacks]) extends
//if (initTxState.isDefined) initTxState.get.setAccessible(true)
}
override def receive: PartialFunction[Any, Unit] = {
def receive = {
case Invocation(joinPoint, isOneWay, _) =>
if (Actor.SERIALIZE_MESSAGES) serializeArguments(joinPoint)
if (isOneWay) joinPoint.proceed

View file

@ -158,7 +158,7 @@ trait Actor extends Logging with TransactionManagement {
* <p/>
* Example code:
* <pre>
* def receive: PartialFunction[Any, Unit] = {
* def receive = {
* case Ping =>
* println("got a ping")
* reply("pong")
@ -171,7 +171,7 @@ trait Actor extends Logging with TransactionManagement {
* }
* </pre>
*/
protected def receive: PartialFunction[Any, Unit]
protected def receive
/**
* User overridable callback/setting.

View file

@ -38,7 +38,7 @@ case class SchedulerException(msg: String, e: Throwable) extends RuntimeExceptio
class ScheduleActor(val receiver: Actor, val future: ScheduledFuture[AnyRef]) extends Actor with Logging {
lifeCycleConfig = Some(LifeCycle(Permanent))
def receive: PartialFunction[Any, Unit] = {
def receive = {
case UnSchedule =>
Scheduler.stopSupervising(this)
future.cancel(true)
@ -77,7 +77,7 @@ object Scheduler extends Actor {
service.shutdown
}
def receive: PartialFunction[Any, Unit] = {
def receive = {
case _ => {} // ignore all messages
}
}

View file

@ -133,7 +133,7 @@ class Supervisor private[akka] (handler: FaultHandlingStrategy) extends Actor wi
def stopSupervisor = this ! StopSupervisor
protected def receive: PartialFunction[Any, Unit] = {
protected def receive = {
case StartSupervisor =>
linkedActors.toArray.toList.asInstanceOf[List[Actor]].foreach { actor => actor.start; log.info("Starting actor: %s", actor) }

View file

@ -278,7 +278,7 @@
<p/>
Example code:
<pre>
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Ping =>
println("got a ping")
reply("pong")

View file

@ -287,7 +287,7 @@
<p/>
Example code:
<pre>
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Ping =>
println("got a ping")
reply("pong")

View file

@ -282,7 +282,7 @@
<p/>
Example code:
<pre>
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Ping =>
println("got a ping")
reply("pong")

View file

@ -311,7 +311,7 @@
<p/>
Example code:
<pre>
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Ping =>
println("got a ping")
reply("pong")

View file

@ -41,7 +41,7 @@ import java.io.IOException
* val consumer = AMQP.newConsumer(params, hostname, port, exchange, ExchangeType.Direct, Serializer.ScalaJSON, None, 100)
*
* consumer ! MessageConsumerListener(queue, routingKey, new Actor() {
* def receive: PartialFunction[Any, Unit] = {
* def receive = {
* case Message(payload, _, _, _, _) => log.debug("Received message: %s", payload)
* }
* })
@ -209,7 +209,7 @@ object AMQP extends Actor {
log.info("AMQP.Producer [%s] is started", toString)
def receive: PartialFunction[Any, Unit] = {
def receive = {
case message @ Message(payload, routingKey, mandatory, immediate, properties) =>
log.debug("Sending message [%s]", message)
channel.basicPublish(exchangeName, routingKey, mandatory, immediate, properties, serializer.out(payload))
@ -312,7 +312,7 @@ object AMQP extends Actor {
listener.tag = Some(listenerTag)
}
def receive: PartialFunction[Any, Unit] = {
def receive = {
case listener: MessageConsumerListener =>
startLink(listener.actor)
listeners.put(listener, listener)
@ -425,7 +425,7 @@ object AMQP extends Actor {
override def postRestart(reason: AnyRef, config: Option[AnyRef]) = reconnect(initReconnectDelay)
}
def receive: PartialFunction[Any, Unit] = {
def receive = {
case _ => {} // ignore all messages
}
}

View file

@ -40,7 +40,7 @@ object ExampleSession {
def direct = {
val consumer = AMQP.newConsumer(CONFIG, HOSTNAME, PORT, IM, ExchangeType.Direct, SERIALIZER, None, 100, false, false, Map[String, AnyRef]())
consumer ! MessageConsumerListener("@george_bush", "direct", new Actor() {
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Message(payload, _, _, _, _) => log.info("@george_bush received message from: %s", payload)
}
})
@ -51,12 +51,12 @@ object ExampleSession {
def fanout = {
val consumer = AMQP.newConsumer(CONFIG, HOSTNAME, PORT, CHAT, ExchangeType.Fanout, SERIALIZER, None, 100, false, false, Map[String, AnyRef]())
consumer ! MessageConsumerListener("@george_bush", "", new Actor() {
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Message(payload, _, _, _, _) => log.info("@george_bush received message from: %s", payload)
}
})
consumer ! MessageConsumerListener("@barack_obama", "", new Actor() {
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Message(payload, _, _, _, _) => log.info("@barack_obama received message from: %s", payload)
}
})

View file

@ -63,7 +63,7 @@
val consumer = AMQP.newConsumer(params, hostname, port, exchange, ExchangeType.Direct, Serializer.ScalaJSON, None, 100)
consumer ! MessageConsumerListener(queue, routingKey, new Actor() {
def receive: PartialFunction[Any, Unit] = {
def receive = {
case Message(payload, _, _, _, _) => log.debug("Received message: %s", payload)
}
})

View file

@ -211,7 +211,7 @@ trait AuthenticationActor[C &lt;: Credentials] extends Actor with Logging
}
}
override def receive: PartialFunction[Any, Unit] = authenticate
def receive = authenticate
//returns the string value of the "Authorization"-header of the request
def auth(r : Req) = r.getHeaderValue("Authorization")
@ -284,7 +284,7 @@ trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials]
Scheduler.schedule(this, InvalidateNonces, noncePurgeInterval, noncePurgeInterval, TimeUnit.MILLISECONDS )
//authenticate or invalidate nonces
override def receive: PartialFunction[Any, Unit] = authenticate orElse invalidateNonces
def receive = authenticate orElse invalidateNonces
override def unauthorized : Response =
{

View file

@ -253,7 +253,7 @@
<b>receive</b>..<a name="receive"></a>
</td>
<td class="signature">
<code class="signature">override def receive</code>
<code class="signature">def receive</code>
</td>

View file

@ -251,7 +251,7 @@
<b>receive</b>..<a name="receive"></a>
</td>
<td class="signature">
<code class="signature">override def receive</code>
<code class="signature">def receive</code>
</td>

View file

@ -321,7 +321,7 @@
<b>receive</b>..<a name="receive"></a>
</td>
<td class="signature">
<code class="signature">override def receive</code>
<code class="signature">def receive</code>
</td>

View file

@ -276,7 +276,7 @@
<b>receive</b>..<a name="receive"></a>
</td>
<td class="signature">
<code class="signature">override def receive</code>
<code class="signature">def receive</code>
</td>