diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/ActorRefResolver.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/ActorRefResolver.scala index 4d91187b51..fffcb13f83 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/ActorRefResolver.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/ActorRefResolver.scala @@ -5,21 +5,25 @@ package akka.actor.typed import akka.actor.ExtendedActorSystem +import akka.annotation.DoNotInherit +import akka.annotation.InternalApi object ActorRefResolver extends ExtensionId[ActorRefResolver] { def get(system: ActorSystem[_]): ActorRefResolver = apply(system) override def createExtension(system: ActorSystem[_]): ActorRefResolver = - new ActorRefResolver(system) + new ActorRefResolverImpl(system) } /** * Serialization and deserialization of `ActorRef`. + * + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ -class ActorRefResolver(system: ActorSystem[_]) extends Extension { - import akka.actor.typed.scaladsl.adapter._ - - private val untypedSystem = system.toUntyped.asInstanceOf[ExtendedActorSystem] +@DoNotInherit +abstract class ActorRefResolver extends Extension { /** * Generate full String representation including the uid for the actor cell @@ -28,13 +32,27 @@ class ActorRefResolver(system: ActorSystem[_]) extends Extension { * information. This representation should be used as serialized * representation. */ - def toSerializationFormat[T](ref: ActorRef[T]): String = - ref.path.toSerializationFormatWithAddress(untypedSystem.provider.getDefaultAddress) + def toSerializationFormat[T](ref: ActorRef[T]): String /** * Deserialize an `ActorRef` in the [[#toSerializationFormat]]. */ - def resolveActorRef[T](serializedActorRef: String): ActorRef[T] = + def resolveActorRef[T](serializedActorRef: String): ActorRef[T] + +} + +/** + * INTERNAL API + */ +@InternalApi private[akka] class ActorRefResolverImpl(system: ActorSystem[_]) extends ActorRefResolver { + import akka.actor.typed.scaladsl.adapter._ + + private val untypedSystem = system.toUntyped.asInstanceOf[ExtendedActorSystem] + + override def toSerializationFormat[T](ref: ActorRef[T]): String = + ref.path.toSerializationFormatWithAddress(untypedSystem.provider.getDefaultAddress) + + override def resolveActorRef[T](serializedActorRef: String): ActorRef[T] = untypedSystem.provider.resolveActorRef(serializedActorRef) } diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala index 092f3d34c1..d45d1d8fd8 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala @@ -69,7 +69,7 @@ trait ExtensionsImpl extends Extensions { self: ActorSystem[_] ⇒ final override def hasExtension(ext: ExtensionId[_ <: Extension]): Boolean = findExtension(ext) != null final override def extension[T <: Extension](ext: ExtensionId[T]): T = findExtension(ext) match { - case null ⇒ throw new IllegalArgumentException("Trying to get non-registered extension [" + ext + "]") + case null ⇒ throw new IllegalArgumentException(s"Trying to get non-registered extension [$ext]") case some ⇒ some.asInstanceOf[T] } @@ -88,7 +88,7 @@ trait ExtensionsImpl extends Extensions { self: ActorSystem[_] ⇒ case (_, extSetup: ExtensionSetup[_]) if extSetup.extId == ext ⇒ extSetup.createExtension(self) }.getOrElse(ext.createExtension(self)) instance match { - case null ⇒ throw new IllegalStateException("Extension instance created as 'null' for extension [" + ext + "]") + case null ⇒ throw new IllegalStateException(s"Extension instance created as 'null' for extension [$ext]") case instance: T @unchecked ⇒ // Replace our in process signal with the initialized extension extensions.replace(ext, inProcessOfRegistration, instance) diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/receptionist/Receptionist.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/receptionist/Receptionist.scala index c4cba544e7..fb431be32c 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/receptionist/Receptionist.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/receptionist/Receptionist.scala @@ -12,8 +12,22 @@ import scala.concurrent.duration._ import scala.reflect.ClassTag import akka.actor.typed.ExtensionSetup +import akka.annotation.InternalApi -class Receptionist(system: ActorSystem[_]) extends Extension { +/** + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. + */ +@DoNotInherit +abstract class Receptionist extends Extension { + def ref: ActorRef[Receptionist.Command] +} + +/** + * INTERNAL API + */ +@InternalApi private[akka] class ReceptionistImpl(system: ActorSystem[_]) extends Receptionist { private def hasCluster: Boolean = { // FIXME: replace with better indicator that cluster is enabled @@ -21,7 +35,7 @@ class Receptionist(system: ActorSystem[_]) extends Extension { provider == "akka.cluster.ClusterActorRefProvider" } - val ref: ActorRef[Receptionist.Command] = { + override val ref: ActorRef[Receptionist.Command] = { val provider: ReceptionistBehaviorProvider = if (hasCluster) { system.dynamicAccess @@ -99,7 +113,7 @@ abstract class ServiceKey[T] extends AbstractServiceKey { key ⇒ * The receptionist is easiest accessed through the system: [[ActorSystem.receptionist]] */ object Receptionist extends ExtensionId[Receptionist] { - def createExtension(system: ActorSystem[_]): Receptionist = new Receptionist(system) + def createExtension(system: ActorSystem[_]): Receptionist = new ReceptionistImpl(system) def get(system: ActorSystem[_]): Receptionist = apply(system) /** diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 30cef964fa..20b65221d7 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -911,7 +911,7 @@ private[akka] class ActorSystemImpl( extensions.putIfAbsent(ext, inProcessOfRegistration) match { // Signal that registration is in process case null ⇒ try { // Signal was successfully sent ext.createExtension(this) match { // Create and initialize the extension - case null ⇒ throw new IllegalStateException("Extension instance created as 'null' for extension [" + ext + "]") + case null ⇒ throw new IllegalStateException(s"Extension instance created as 'null' for extension [$ext]") case instance ⇒ extensions.replace(ext, inProcessOfRegistration, instance) //Replace our in process signal with the initialized extension instance //Profit! @@ -930,7 +930,7 @@ private[akka] class ActorSystemImpl( } def extension[T <: Extension](ext: ExtensionId[T]): T = findExtension(ext) match { - case null ⇒ throw new IllegalArgumentException("Trying to get non-registered extension [" + ext + "]") + case null ⇒ throw new IllegalArgumentException(s"Trying to get non-registered extension [$ext]") case some ⇒ some.asInstanceOf[T] } diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala index db2530a460..7b0a458867 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala @@ -136,6 +136,9 @@ object ClusterSharding { * between reception of `Passivate` and termination of the entity. Such buffered messages * are thereafter delivered to a new incarnation of the entity. * + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ @DoNotInherit abstract class ClusterSharding { diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala index bb0d7252ae..f91c84f983 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala @@ -138,6 +138,9 @@ object ClusterSharding extends ExtensionId[ClusterSharding] { * between reception of `Passivate` and termination of the entity. Such buffered messages * are thereafter delivered to a new incarnation of the entity. * + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ @DoNotInherit trait ClusterSharding extends Extension { javadslSelf: javadsl.ClusterSharding ⇒ diff --git a/akka-cluster-typed/src/main/scala/akka/cluster/ddata/typed/javadsl/DistributedData.scala b/akka-cluster-typed/src/main/scala/akka/cluster/ddata/typed/javadsl/DistributedData.scala index 6ed83bb7c7..ac9247aeb7 100644 --- a/akka-cluster-typed/src/main/scala/akka/cluster/ddata/typed/javadsl/DistributedData.scala +++ b/akka-cluster-typed/src/main/scala/akka/cluster/ddata/typed/javadsl/DistributedData.scala @@ -9,12 +9,14 @@ import akka.actor.typed.Extension import akka.actor.typed.ExtensionId import akka.actor.typed.ActorRef import akka.actor.typed.ExtensionSetup +import akka.annotation.DoNotInherit +import akka.annotation.InternalApi object DistributedData extends ExtensionId[DistributedData] { def get(system: ActorSystem[_]): DistributedData = apply(system) override def createExtension(system: ActorSystem[_]): DistributedData = - new DistributedData(system) + new DistributedDataImpl(system) } /** @@ -25,13 +27,25 @@ object DistributedData extends ExtensionId[DistributedData] { * This is using the same underlying `Replicator` instance as * [[akka.cluster.ddata.DistributedData]] and that means that typed * and untyped actors can share the same data. + * + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ -class DistributedData(system: ActorSystem[_]) extends Extension { - +@DoNotInherit +abstract class DistributedData extends Extension { /** * `ActorRef` of the [[Replicator]] . */ - val replicator: ActorRef[Replicator.Command] = + def replicator: ActorRef[Replicator.Command] +} + +/** + * INTERNAL API + */ +@InternalApi private[akka] class DistributedDataImpl(system: ActorSystem[_]) extends DistributedData { + + override val replicator: ActorRef[Replicator.Command] = akka.cluster.ddata.typed.scaladsl.DistributedData(system).replicator.narrow[Replicator.Command] } diff --git a/akka-cluster-typed/src/main/scala/akka/cluster/typed/Cluster.scala b/akka-cluster-typed/src/main/scala/akka/cluster/typed/Cluster.scala index 5e638e1fbe..2cf27f726b 100644 --- a/akka-cluster-typed/src/main/scala/akka/cluster/typed/Cluster.scala +++ b/akka-cluster-typed/src/main/scala/akka/cluster/typed/Cluster.scala @@ -159,7 +159,9 @@ object Cluster extends ExtensionId[Cluster] { } /** - * Not intended for user extension. + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ @DoNotInherit abstract class Cluster extends Extension { diff --git a/akka-cluster-typed/src/main/scala/akka/cluster/typed/ClusterSingleton.scala b/akka-cluster-typed/src/main/scala/akka/cluster/typed/ClusterSingleton.scala index 2c4bc2c3d7..7d5a0e5286 100644 --- a/akka-cluster-typed/src/main/scala/akka/cluster/typed/ClusterSingleton.scala +++ b/akka-cluster-typed/src/main/scala/akka/cluster/typed/ClusterSingleton.scala @@ -125,7 +125,9 @@ private[akka] object ClusterSingletonImpl { } /** - * Not intended for user extension. + * This class is not intended for user extension other than for test purposes (e.g. + * stub implementation). More methods may be added in the future and that may break + * such implementations. */ @DoNotInherit abstract class ClusterSingleton extends Extension {