Removing akka-migration from 2.1-SNAPSHOT, welcome to the future.

This commit is contained in:
Viktor Klang 2012-05-10 17:51:43 +02:00
parent 4803889c16
commit cfbfa19e41
10 changed files with 3 additions and 752 deletions

View file

@ -1,71 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import java.io.File
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigParseOptions
import akka.util.Timeout
import akka.util.duration._
@deprecated("use ActorSystem instead", "2.0")
object GlobalActorSystem extends ActorSystemImpl("GlobalSystem", OldConfigurationLoader.defaultConfig, OldConfigurationLoader.oldClassLoader) {
start()
/**
* Timeout used in `OldFuture.get` and default implicit ask timeout.
* Hard coded since the migration kit is not intended to be used for production anyway.
*/
val AwaitTimeout = Timeout(5 seconds)
}
/**
* Loads configuration (akka.conf) from same location as Akka 1.x
*/
@deprecated("use default config location or write your own configuration loader", "2.0")
object OldConfigurationLoader {
val oldClassLoader: ClassLoader = ActorSystem.findClassLoader()
val defaultConfig: Config = {
val cfg = fromProperties orElse fromClasspath orElse fromHome getOrElse emptyConfig
val config = cfg.withFallback(ConfigFactory.defaultReference(oldClassLoader))
config.checkValid(ConfigFactory.defaultReference(oldClassLoader), "akka")
config
}
// file extensions (.conf, .json, .properties), are handled by parseFileAnySyntax
val defaultLocation: String = (systemMode orElse envMode).map("akka." + _).getOrElse("akka")
private def envMode = System.getenv("AKKA_MODE") match {
case null | "" None
case value Some(value)
}
private def systemMode = System.getProperty("akka.mode") match {
case null | "" None
case value Some(value)
}
private def configParseOptions = ConfigParseOptions.defaults.setAllowMissing(false)
private def fromProperties = try {
val property = Option(System.getProperty("akka.config"))
property.map(p
ConfigFactory.systemProperties.withFallback(
ConfigFactory.parseFileAnySyntax(new File(p), configParseOptions)))
} catch { case _ None }
private def fromClasspath = try {
Option(ConfigFactory.systemProperties.withFallback(
ConfigFactory.parseResourcesAnySyntax(ActorSystem.getClass, "/" + defaultLocation, configParseOptions)))
} catch { case _ None }
private def fromHome = try {
Option(ConfigFactory.systemProperties.withFallback(
ConfigFactory.parseFileAnySyntax(new File(ActorSystem.GlobalHome.get + "/config/" + defaultLocation), configParseOptions)))
} catch { case _ None }
private def emptyConfig = ConfigFactory.systemProperties
}

View file

@ -1,172 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import akka.japi.Creator
import akka.util.Timeout
import akka.dispatch.Future
import akka.dispatch.OldFuture
import akka.util.Duration
import java.util.concurrent.TimeUnit
import akka.migration.AskableActorRef
/**
* Migration replacement for `object akka.actor.Actor`.
*/
@deprecated("use ActorRefFactory (ActorSystem or ActorContext) to create actors", "2.0")
object OldActor {
/**
* Creates an ActorRef out of the Actor with type T.
* It will be automatically started, i.e. remove old call to `start()`.
*
*/
@deprecated("use ActorRefFactory (ActorSystem or ActorContext) to create actors", "2.0")
def actorOf[T <: Actor: Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
/**
* Creates an ActorRef out of the Actor of the specified Class.
* It will be automatically started, i.e. remove old call to `start()`.
*/
@deprecated("use ActorRefFactory (ActorSystem or ActorContext) to create actors", "2.0")
def actorOf(clazz: Class[_ <: Actor]): ActorRef = GlobalActorSystem.actorOf(Props(clazz))
/**
* Creates an ActorRef out of the Actor. Allows you to pass in a factory function
* that creates the Actor. Please note that this function can be invoked multiple
* times if for example the Actor is supervised and needs to be restarted.
*
* It will be automatically started, i.e. remove old call to `start()`.
*/
@deprecated("use ActorRefFactory (ActorSystem or ActorContext) to create actors", "2.0")
def actorOf(factory: Actor): ActorRef = GlobalActorSystem.actorOf(Props(factory))
/**
* Creates an ActorRef out of the Actor. Allows you to pass in a factory (Creator<Actor>)
* that creates the Actor. Please note that this function can be invoked multiple
* times if for example the Actor is supervised and needs to be restarted.
* <p/>
* JAVA API
*/
@deprecated("use ActorRefFactory (ActorSystem or ActorContext) to create actors", "2.0")
def actorOf(creator: Creator[Actor]): ActorRef = GlobalActorSystem.actorOf(Props(creator))
@deprecated("OldActor.remote should not be used", "2.0")
lazy val remote: OldRemoteSupport = new OldRemoteSupport
}
@deprecated("use Actor", "2.0")
abstract class OldActor extends Actor {
implicit def askTimeout: Timeout = akka.migration.askTimeout
implicit def future2OldFuture[T](future: Future[T]): OldFuture[T] = akka.migration.future2OldFuture(future)
implicit def actorRef2OldActorRef(actorRef: ActorRef) = new OldActorRef(actorRef)
implicit def askableActorRef(actorRef: ActorRef): AskableActorRef = new AskableActorRef(actorRef)
@deprecated("Use context.become instead", "2.0")
def become(behavior: Receive, discardOld: Boolean = true) = context.become(behavior, discardOld)
@deprecated("Use context.unbecome instead", "2.0")
def unbecome() = context.unbecome()
class OldActorRef(actorRef: ActorRef) {
@deprecated("Actors are automatically started when creatd, i.e. remove old call to start()", "2.0")
def start(): ActorRef = actorRef
@deprecated("Stop with ActorSystem or ActorContext instead", "2.0")
def exit() = stop()
@deprecated("Stop with ActorSystem or ActorContext instead", "2.0")
def stop(): Unit = context.stop(actorRef)
@deprecated("Use context.getReceiveTimeout instead", "2.0")
def getReceiveTimeout(): Option[Long] = context.receiveTimeout.map(_.toMillis)
@deprecated("Use context.setReceiveTimeout instead", "2.0")
def setReceiveTimeout(timeout: Long) = context.setReceiveTimeout(Duration(timeout, TimeUnit.MILLISECONDS))
@deprecated("Use context.getReceiveTimeout instead", "2.0")
def receiveTimeout: Option[Long] = getReceiveTimeout()
@deprecated("Use context.setReceiveTimeout instead", "2.0")
def receiveTimeout_=(timeout: Option[Long]) = setReceiveTimeout(timeout.getOrElse(0L))
@deprecated("Use self.isTerminated instead", "2.0")
def isShutdown: Boolean = self.isTerminated
@deprecated("Use sender instead", "2.0")
def channel() = context.sender
@deprecated("Use sender instead", "2.0")
def sender() = Some(context.sender)
@deprecated("Use sender ! instead", "2.0")
def reply(message: Any) = context.sender.!(message, context.self)
@deprecated("Use sender ! instead", "2.0")
def tryReply(message: Any): Boolean = {
reply(message)
true
}
@deprecated("Use sender ! instead", "2.0")
def tryTell(message: Any)(implicit sender: ActorRef = context.self): Boolean = {
actorRef.!(message)(sender)
true
}
@deprecated("Use sender ! akka.actor.Status.Failure(e) instead", "2.0")
def sendException(ex: Throwable): Boolean = {
context.sender.!(akka.actor.Status.Failure(ex), context.self)
true
}
}
}
class OldRemoteSupport {
@deprecated("remote.start is not needed", "2.0")
def start() {}
@deprecated("remote.start is not needed, use configuration to specify RemoteActorRefProvider, host and port", "2.0")
def start(host: String, port: Int) {}
@deprecated("remote.start is not needed, use configuration to specify RemoteActorRefProvider, host and port", "2.0")
def start(host: String, port: Int, loader: ClassLoader) {}
@deprecated("remote.shutdown is not needed", "2.0")
def shutdown() {}
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(classNameOrServiceId: String, hostname: String, port: Int): ActorRef =
GlobalActorSystem.actorFor("akka://%s@%s:%s/user/%s".format(GlobalActorSystem.name, hostname, port, classNameOrServiceId))
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(classNameOrServiceId: String, hostname: String, port: Int, loader: ClassLoader): ActorRef =
actorFor(classNameOrServiceId, hostname, port)
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(serviceId: String, className: String, hostname: String, port: Int): ActorRef =
actorFor(serviceId, hostname, port)
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(serviceId: String, className: String, hostname: String, port: Int, loader: ClassLoader): ActorRef =
actorFor(serviceId, hostname, port)
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(classNameOrServiceId: String, timeout: Long, hostname: String, port: Int): ActorRef =
actorFor(classNameOrServiceId, hostname, port)
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(classNameOrServiceId: String, timeout: Long, hostname: String, port: Int, loader: ClassLoader): ActorRef =
actorFor(classNameOrServiceId, hostname, port)
@deprecated("use actorFor in ActorRefProvider (ActorSystem or ActorContext) instead", "2.0")
def actorFor(serviceId: String, className: String, timeout: Long, hostname: String, port: Int): ActorRef =
actorFor(serviceId, hostname, port)
}

View file

@ -1,75 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import java.util.concurrent.TimeUnit
import akka.util.Duration
/**
* Migration replacement for `object akka.actor.Scheduler`.
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
object OldScheduler {
/**
* Schedules to send the specified message to the receiver after initialDelay and then repeated after delay
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def schedule(receiver: ActorRef, message: Any, initialDelay: Long, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.schedule(
Duration(initialDelay, timeUnit),
Duration(delay, timeUnit),
receiver,
message)
/**
* Schedules to run specified function to the receiver after initialDelay and then repeated after delay
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def schedule(f: () Unit, initialDelay: Long, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.schedule(
Duration(initialDelay, timeUnit),
Duration(delay, timeUnit),
new Runnable { def run = f() })
/**
* Schedules to run specified runnable to the receiver after initialDelay and then repeated after delay.
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def schedule(runnable: Runnable, initialDelay: Long, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.schedule(
Duration(initialDelay, timeUnit),
Duration(delay, timeUnit),
runnable)
/**
* Schedules to send the specified message to the receiver after delay
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def scheduleOnce(receiver: ActorRef, message: Any, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.scheduleOnce(
Duration(delay, timeUnit),
receiver,
message)
/**
* Schedules a function to be run after delay.
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def scheduleOnce(f: () Unit, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.scheduleOnce(
Duration(delay, timeUnit),
new Runnable { def run = f() })
/**
* Schedules a runnable to be run after delay,
*/
@deprecated("use ActorSystem.scheduler instead", "2.0")
def scheduleOnce(runnable: Runnable, delay: Long, timeUnit: TimeUnit): Cancellable =
GlobalActorSystem.scheduler.scheduleOnce(
Duration(delay, timeUnit),
runnable)
}

View file

@ -1,162 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.config
import akka.actor.GlobalActorSystem
import com.typesafe.config.Config
/**
* Migration replacement for `object akka.config.Config`.
*/
@deprecated("use ActorSystem.settings.config instead", "2.0")
object OldConfig {
val config = new OldConfiguration(GlobalActorSystem.settings.config)
}
/**
* Migration adapter for `akka.config.Configuration`
*/
@deprecated("use ActorSystem.settings.config (com.typesafe.config.Config) instead", "2.0")
class OldConfiguration(config: Config) {
import scala.collection.JavaConverters._
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def contains(key: String): Boolean = config.hasPath(key)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def keys: Iterable[String] = config.root.keySet.asScala
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getAny(key: String): Option[Any] = {
try {
Option(config.getAnyRef(key))
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getAny(key: String, defaultValue: Any): Any = getAny(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getSeqAny(key: String): Seq[Any] = {
try {
config.getAnyRefList(key).asScala
} catch {
case _ Seq.empty[Any]
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getString(key: String): Option[String] =
try {
Option(config.getString(key))
} catch {
case _ None
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getString(key: String, defaultValue: String): String = getString(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getList(key: String): Seq[String] = {
try {
config.getStringList(key).asScala
} catch {
case _ Seq.empty[String]
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getInt(key: String): Option[Int] = {
try {
Option(config.getInt(key))
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getInt(key: String, defaultValue: Int): Int = getInt(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getLong(key: String): Option[Long] = {
try {
Option(config.getLong(key))
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getLong(key: String, defaultValue: Long): Long = getLong(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getFloat(key: String): Option[Float] = {
try {
Option(config.getDouble(key).toFloat)
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getFloat(key: String, defaultValue: Float): Float = getFloat(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getDouble(key: String): Option[Double] = {
try {
Option(config.getDouble(key))
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getDouble(key: String, defaultValue: Double): Double = getDouble(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getBoolean(key: String): Option[Boolean] = {
try {
Option(config.getBoolean(key))
} catch {
case _ None
}
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getBoolean(key: String, defaultValue: Boolean): Boolean = getBoolean(key).getOrElse(defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getBool(key: String): Option[Boolean] = getBoolean(key)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getBool(key: String, defaultValue: Boolean): Boolean = getBoolean(key, defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def apply(key: String): String = getString(key) match {
case None throw new ConfigurationException("undefined config: " + key)
case Some(v) v
}
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def apply(key: String, defaultValue: String) = getString(key, defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def apply(key: String, defaultValue: Int) = getInt(key, defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def apply(key: String, defaultValue: Long) = getLong(key, defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def apply(key: String, defaultValue: Boolean) = getBool(key, defaultValue)
@deprecated("use new com.typesafe.config.Config API instead", "2.0")
def getSection(name: String): Option[OldConfiguration] = {
try {
Option(new OldConfiguration(config.getConfig(name)))
} catch {
case _ None
}
}
}

View file

@ -1,64 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.dispatch
import java.util.concurrent.TimeoutException
import akka.AkkaException
import akka.util.BoxedType
import akka.util.Duration
import akka.actor.GlobalActorSystem
/**
* Some old methods made available through implicit conversion in
* [[akka.migration]].
*/
@deprecated("use new Future api instead", "2.0")
class OldFuture[T](future: Future[T]) {
@deprecated("use akka.dispatch.Await.result instead", "2.0")
def get: T = try {
Await.result(future, GlobalActorSystem.AwaitTimeout.duration)
} catch {
case e: TimeoutException throw new FutureTimeoutException(e.getMessage, e)
}
@deprecated("use akka.dispatch.Await.ready instead", "2.0")
def await: Future[T] = await(GlobalActorSystem.AwaitTimeout.duration)
@deprecated("use akka.dispatch.Await.ready instead", "2.0")
def await(atMost: Duration) = try {
Await.ready(future, atMost)
future
} catch {
case e: TimeoutException throw new FutureTimeoutException(e.getMessage, e)
}
@deprecated("use new Future api instead", "2.0")
def as[A](implicit m: Manifest[A]): Option[A] = {
try await catch { case _: FutureTimeoutException }
future.value match {
case None None
case Some(Left(ex)) throw ex
case Some(Right(v)) Some(BoxedType(m.erasure).cast(v).asInstanceOf[A])
}
}
@deprecated("use new Future api instead", "2.0")
def asSilently[A](implicit m: Manifest[A]): Option[A] = {
try await catch { case _: FutureTimeoutException }
future.value match {
case None None
case Some(Left(ex)) throw ex
case Some(Right(v))
try Some(BoxedType(m.erasure).cast(v).asInstanceOf[A])
catch { case _: ClassCastException None }
}
}
}
@deprecated("Await throws java.util.concurrent.TimeoutException", "2.0")
class FutureTimeoutException(message: String, cause: Throwable = null) extends AkkaException(message, cause) {
def this(message: String) = this(message, null)
}

View file

@ -1,81 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.event
import akka.actor.GlobalActorSystem
/**
* Migration replacement for `akka.event.EventHandler`
*/
@deprecated("use Logging instead", "2.0")
object OldEventHandler {
@deprecated("use Logging instead", "2.0")
def error(cause: Throwable, instance: AnyRef, message: String) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isErrorEnabled) log.error(cause, message)
}
@deprecated("use Logging instead", "2.0")
def error(cause: Throwable, instance: AnyRef, message: Any) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isErrorEnabled) log.error(cause, message.toString)
}
@deprecated("use Logging instead", "2.0")
def error(instance: AnyRef, message: String) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isErrorEnabled) log.error(message.toString)
}
@deprecated("use Logging instead", "2.0")
def error(instance: AnyRef, message: Any) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isErrorEnabled) log.error(message.toString)
}
@deprecated("use Logging instead", "2.0")
def warning(instance: AnyRef, message: String) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isWarningEnabled) log.warning(message)
}
@deprecated("use Logging instead", "2.0")
def warning(instance: AnyRef, message: Any) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isWarningEnabled) log.warning(message.toString)
}
@deprecated("use Logging instead", "2.0")
def info(instance: AnyRef, message: String) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isInfoEnabled) log.info(message)
}
@deprecated("use Logging instead", "2.0")
def info(instance: AnyRef, message: Any) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isInfoEnabled) log.info(message.toString)
}
@deprecated("use Logging instead", "2.0")
def debug(instance: AnyRef, message: String) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isDebugEnabled) log.debug(message)
}
@deprecated("use Logging instead", "2.0")
def debug(instance: AnyRef, message: Any) {
val log = Logging.getLogger(GlobalActorSystem, instance)
if (log.isDebugEnabled) log.debug(message.toString)
}
@deprecated("use Logging instead", "2.0")
def isInfoEnabled = Logging.getLogger(GlobalActorSystem, this).isInfoEnabled
@deprecated("use Logging instead", "2.0")
def isDebugEnabled = Logging.getLogger(GlobalActorSystem, this).isDebugEnabled
}

View file

@ -1,80 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.migration
import akka.actor.ActorRef
import akka.dispatch.Future
import akka.util.Timeout
/**
* Implementation detail of the ask pattern enrichment of ActorRef
*/
private[akka] final class AskableActorRef(val actorRef: ActorRef) {
/**
* Sends a message asynchronously and returns a [[akka.dispatch.Future]]
* holding the eventual reply message; this means that the target actor
* needs to send the result to the `sender` reference provided. The Future
* will be completed with an [[akka.actor.AskTimeoutException]] after the
* given timeout has expired; this is independent from any timeout applied
* while awaiting a result for this future (i.e. in
* `Await.result(..., timeout)`).
*
* <b>Warning:</b>
* When using future callbacks, inside actors you need to carefully avoid closing over
* the containing actors object, i.e. do not call methods or access mutable state
* on the enclosing actor from within the callback. This would break the actor
* encapsulation and may introduce synchronization bugs and race conditions because
* the callback will be scheduled concurrently to the enclosing actor. Unfortunately
* there is not yet a way to detect these illegal accesses at compile time.
*
* <b>Recommended usage:</b>
*
* {{{
* flow {
* val f = worker.ask(request)(timeout)
* EnrichedRequest(request, f())
* } pipeTo nextActor
* }}}
*
* [see the [[akka.dispatch.Future]] companion object for a description of `flow`]
*/
def ask(message: Any)(implicit timeout: Timeout): Future[Any] = akka.pattern.ask(actorRef, message)(timeout)
/**
* Sends a message asynchronously and returns a [[akka.dispatch.Future]]
* holding the eventual reply message; this means that the target actor
* needs to send the result to the `sender` reference provided. The Future
* will be completed with an [[akka.actor.AskTimeoutException]] after the
* given timeout has expired; this is independent from any timeout applied
* while awaiting a result for this future (i.e. in
* `Await.result(..., timeout)`).
*
* <b>Warning:</b>
* When using future callbacks, inside actors you need to carefully avoid closing over
* the containing actors object, i.e. do not call methods or access mutable state
* on the enclosing actor from within the callback. This would break the actor
* encapsulation and may introduce synchronization bugs and race conditions because
* the callback will be scheduled concurrently to the enclosing actor. Unfortunately
* there is not yet a way to detect these illegal accesses at compile time.
*
* <b>Recommended usage:</b>
*
* {{{
* flow {
* val f = worker ? request
* EnrichedRequest(request, f())
* } pipeTo nextActor
* }}}
*
* [see the [[akka.dispatch.Future]] companion object for a description of `flow`]
*/
def ?(message: Any)(implicit timeout: Timeout): Future[Any] = akka.pattern.ask(actorRef, message)(timeout)
/**
* This method is just there to catch 2.0-unsupported usage and print deprecation warnings for it.
*/
@deprecated("use ?(msg)(timeout), this method has dangerous ambiguity", "2.0-migration")
def ?(message: Any, timeout: Timeout)(i: Int = 0): Future[Any] = this.?(message)(timeout)
}

View file

@ -1,37 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka
import akka.dispatch.Future
import akka.dispatch.OldFuture
import akka.util.Timeout
import akka.actor.GlobalActorSystem
import akka.dispatch.MessageDispatcher
import akka.actor.ActorRef
package object migration {
implicit def future2OldFuture[T](future: Future[T]): OldFuture[T] = new OldFuture[T](future)
implicit def askTimeout: Timeout = GlobalActorSystem.AwaitTimeout
implicit def defaultDispatcher: MessageDispatcher = GlobalActorSystem.dispatcher
implicit def actorRef2OldActorRef(actorRef: ActorRef) = new OldActorRef(actorRef)
class OldActorRef(actorRef: ActorRef) {
@deprecated("Actors are automatically started when created, i.e. remove old call to start()", "2.0")
def start(): ActorRef = actorRef
@deprecated("Stop with ActorSystem or ActorContext instead", "2.0")
def exit() = stop()
@deprecated("Stop with ActorSystem or ActorContext instead", "2.0")
def stop(): Unit = GlobalActorSystem.stop(actorRef)
}
implicit def ask(actorRef: ActorRef) = new akka.migration.AskableActorRef(actorRef)
def ask(actorRef: ActorRef, message: Any)(implicit timeout: Timeout = null): Future[Any] = akka.pattern.ask(actorRef, message)(timeout)
}

View file

@ -194,7 +194,7 @@ trait Actor {
/**
* Stores the context for this actor, including self, and sender.
* It is implicit to support operations such as `forward`.
*
*
* WARNING: Only valid within the Actor itself, so do not close over it and
* publish it to other threads!
*
@ -233,7 +233,7 @@ trait Actor {
* The reference sender Actor of the last received message.
* Is defined if the message was sent from another Actor,
* else `deadLetters` in [[akka.actor.ActorSystem]].
*
*
* WARNING: Only valid within the Actor itself, so do not close over it and
* publish it to other threads!
*/

View file

@ -39,7 +39,7 @@ object AkkaBuild extends Build {
sphinxLatex <<= sphinxLatex in LocalProject(docs.id),
sphinxPdf <<= sphinxPdf in LocalProject(docs.id)
),
aggregate = Seq(actor, testkit, actorTests, remote, camel, cluster, slf4j, agent, transactor, mailboxes, zeroMQ, kernel, akkaSbtPlugin, actorMigration, samples, tutorials, docs)
aggregate = Seq(actor, testkit, actorTests, remote, camel, cluster, slf4j, agent, transactor, mailboxes, zeroMQ, kernel, akkaSbtPlugin, samples, tutorials, docs)
)
lazy val actor = Project(
@ -194,13 +194,6 @@ object AkkaBuild extends Build {
)
)
lazy val actorMigration = Project(
id = "akka-actor-migration",
base = file("akka-actor-migration"),
dependencies = Seq(actor, testkit % "test->test"),
settings = defaultSettings
)
lazy val akkaSbtPlugin = Project(
id = "akka-sbt-plugin",
base = file("akka-sbt-plugin"),