diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/ThaipedActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/actor/ThaipedActorSpec.scala similarity index 98% rename from akka-typed-actor/src/test/scala/actor/typed-actor/ThaipedActorSpec.scala rename to akka-actor-tests/src/test/scala/akka/actor/actor/ThaipedActorSpec.scala index 9706a9a1bb..c6717b24d1 100644 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/ThaipedActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/actor/ThaipedActorSpec.scala @@ -1,4 +1,4 @@ -package akka.thaipedactor +package akka.actor /** * Copyright (C) 2009-2011 Scalable Solutions AB @@ -8,7 +8,7 @@ import org.scalatest.matchers.MustMatchers import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith import org.scalatest.{ BeforeAndAfterAll, WordSpec, BeforeAndAfterEach } -import akka.thaipedactor.ThaipedActor._ +import akka.actor.ThaipedActor._ import akka.japi.{ Option ⇒ JOption } import akka.util.Duration import akka.dispatch.{ Dispatchers, Future, AlreadyCompletedFuture } @@ -96,7 +96,7 @@ object ThaipedActorSpec { @RunWith(classOf[JUnitRunner]) class ThaipedActorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach with BeforeAndAfterAll { - import akka.thaipedactor.ThaipedActorSpec._ + import akka.actor.ThaipedActorSpec._ def newFooBar: Foo = newFooBar(Duration(2, "s")) diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index 7da3f0ea85..0f1e74ba2c 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -459,7 +459,7 @@ object Actor extends ListenerManagement { */ - RemoteActorRef(address, Actor.TIMEOUT, None, ActorType.ScalaActor) + RemoteActorRef(address, Actor.TIMEOUT, None) case invalid ⇒ throw new IllegalActorStateException( "Could not create actor [" + clazz.getName + "] with address [" + address + @@ -733,15 +733,4 @@ private[actor] class AnyOptionAsTypedOption(anyOption: Option[Any]) { */ trait Proxyable { private[actor] def swapProxiedActor(newInstance: Actor) -} - -/** - * Represents the different Actor types. - * - * @author Jonas Bonér - */ -sealed trait ActorType -object ActorType { - case object ScalaActor extends ActorType - case object TypedActor extends ActorType -} +} \ No newline at end of file diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 132e8bd804..b4fbf81db2 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -988,8 +988,7 @@ object RemoteActorSystemMessage { private[akka] case class RemoteActorRef private[akka] ( val address: String, _timeout: Long, - loader: Option[ClassLoader], - val actorType: ActorType = ActorType.ScalaActor) + loader: Option[ClassLoader]) extends ActorRef with ScalaActorRef { ensureRemotingEnabled() @@ -1013,7 +1012,7 @@ private[akka] case class RemoteActorRef private[akka] ( start() def postMessageToMailbox(message: Any, senderOption: Option[ActorRef]) { - Actor.remote.send[Any](message, senderOption, None, remoteAddress, timeout, true, this, None, actorType, loader) + Actor.remote.send[Any](message, senderOption, None, remoteAddress, timeout, true, this, loader) } def postMessageToMailboxAndCreateFutureResultWithTimeout[T]( @@ -1023,8 +1022,7 @@ private[akka] case class RemoteActorRef private[akka] ( senderFuture: Option[CompletableFuture[T]]): CompletableFuture[T] = { val future = Actor.remote.send[T]( message, senderOption, senderFuture, - remoteAddress, timeout, false, this, None, - actorType, loader) + remoteAddress, timeout, false, this, loader) if (future.isDefined) future.get else throw new IllegalActorStateException("Expected a future from remote call to actor " + toString) } diff --git a/akka-typed-actor/src/main/scala/akka/actor/ThaipedActor.scala b/akka-actor/src/main/scala/akka/actor/ThaipedActor.scala similarity index 99% rename from akka-typed-actor/src/main/scala/akka/actor/ThaipedActor.scala rename to akka-actor/src/main/scala/akka/actor/ThaipedActor.scala index bfcf554fdc..329f4c2db7 100644 --- a/akka-typed-actor/src/main/scala/akka/actor/ThaipedActor.scala +++ b/akka-actor/src/main/scala/akka/actor/ThaipedActor.scala @@ -1,9 +1,9 @@ +package akka.actor + /** * Copyright (C) 2009-2011 Scalable Solutions AB */ -package akka.thaipedactor - import akka.japi.{ Creator, Option ⇒ JOption } import akka.actor.Actor.{ actorOf, futureToAnyOptionAsTypedOption } import akka.dispatch.{ MessageDispatcher, Dispatchers, AlreadyCompletedFuture, Future } diff --git a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala index 55b7bcb472..13311138a9 100644 --- a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala +++ b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala @@ -27,9 +27,6 @@ trait RemoteModule { private[akka] def actors: ConcurrentHashMap[String, ActorRef] private[akka] def actorsByUuid: ConcurrentHashMap[String, ActorRef] private[akka] def actorsFactories: ConcurrentHashMap[String, () ⇒ ActorRef] - private[akka] def typedActors: ConcurrentHashMap[String, AnyRef] - private[akka] def typedActorsByUuid: ConcurrentHashMap[String, AnyRef] - private[akka] def typedActorsFactories: ConcurrentHashMap[String, () ⇒ AnyRef] /** Lookup methods **/ @@ -39,25 +36,12 @@ trait RemoteModule { private[akka] def findActorFactory(address: String): () ⇒ ActorRef = actorsFactories.get(address) - private[akka] def findTypedActorByAddress(address: String): AnyRef = typedActors.get(address) - - private[akka] def findTypedActorFactory(address: String): () ⇒ AnyRef = typedActorsFactories.get(address) - - private[akka] def findTypedActorByUuid(uuid: String): AnyRef = typedActorsByUuid.get(uuid) - private[akka] def findActorByAddressOrUuid(address: String, uuid: String): ActorRef = { var actorRefOrNull = if (address.startsWith(UUID_PREFIX)) findActorByUuid(address.substring(UUID_PREFIX.length)) else findActorByAddress(address) if (actorRefOrNull eq null) actorRefOrNull = findActorByUuid(uuid) actorRefOrNull } - - private[akka] def findTypedActorByAddressOrUuid(address: String, uuid: String): AnyRef = { - var actorRefOrNull = if (address.startsWith(UUID_PREFIX)) findTypedActorByUuid(address.substring(UUID_PREFIX.length)) - else findTypedActorByAddress(address) - if (actorRefOrNull eq null) actorRefOrNull = findTypedActorByUuid(uuid) - actorRefOrNull - } } /** @@ -161,17 +145,11 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule private[akka] val actors = new ConcurrentHashMap[String, ActorRef] private[akka] val actorsByUuid = new ConcurrentHashMap[String, ActorRef] private[akka] val actorsFactories = new ConcurrentHashMap[String, () ⇒ ActorRef] - private[akka] val typedActors = new ConcurrentHashMap[String, AnyRef] - private[akka] val typedActorsByUuid = new ConcurrentHashMap[String, AnyRef] - private[akka] val typedActorsFactories = new ConcurrentHashMap[String, () ⇒ AnyRef] def clear { actors.clear actorsByUuid.clear - typedActors.clear - typedActorsByUuid.clear actorsFactories.clear - typedActorsFactories.clear } } @@ -234,44 +212,6 @@ trait RemoteServerModule extends RemoteModule { */ def shutdownServerModule(): Unit - /** - * Register typed actor by interface name. - */ - def registerTypedActor(intfClass: Class[_], typedActor: AnyRef): Unit = registerTypedActor(intfClass.getName, typedActor) - - /** - * Register remote typed actor by a specific id. - * @param address actor address - * @param typedActor typed actor to register - */ - def registerTypedActor(address: String, typedActor: AnyRef): Unit - - /** - * Register typed actor by interface name. - */ - def registerTypedPerSessionActor(intfClass: Class[_], factory: ⇒ AnyRef): Unit = registerTypedActor(intfClass.getName, factory) - - /** - * Register typed actor by interface name. - * Java API - */ - def registerTypedPerSessionActor(intfClass: Class[_], factory: Creator[AnyRef]): Unit = registerTypedActor(intfClass.getName, factory) - - /** - * Register remote typed actor by a specific id. - * @param address actor address - * @param typedActor typed actor to register - */ - def registerTypedPerSessionActor(address: String, factory: ⇒ AnyRef): Unit - - /** - * Register remote typed actor by a specific id. - * @param address actor address - * @param typedActor typed actor to register - * Java API - */ - def registerTypedPerSessionActor(address: String, factory: Creator[AnyRef]): Unit = registerTypedPerSessionActor(address, factory.create) - /** * Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already. */ @@ -323,20 +263,6 @@ trait RemoteServerModule extends RemoteModule { * NOTE: You need to call this method if you have registered an actor by a custom ID. */ def unregisterPerSession(address: String): Unit - - /** - * Unregister Remote Typed Actor by specific 'id'. - *

- * NOTE: You need to call this method if you have registered an actor by a custom ID. - */ - def unregisterTypedActor(address: String): Unit - - /** - * Unregister Remote Typed Actor by specific 'id'. - *

- * NOTE: You need to call this method if you have registered an actor by a custom ID. - */ - def unregisterTypedPerSessionActor(address: String): Unit } trait RemoteClientModule extends RemoteModule { self: RemoteModule ⇒ @@ -353,15 +279,6 @@ trait RemoteClientModule extends RemoteModule { self: RemoteModule ⇒ def actorFor(address: String, timeout: Long, hostname: String, port: Int, loader: ClassLoader): ActorRef = actorFor(address, timeout, hostname, port, Some(loader)) - def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, hostname: String, port: Int): T = - typedActorFor(intfClass, serviceIdOrClassName, Actor.TIMEOUT, hostname, port, None) - - def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, timeout: Long, hostname: String, port: Int): T = - typedActorFor(intfClass, serviceIdOrClassName, timeout, hostname, port, None) - - def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, timeout: Long, hostname: String, port: Int, loader: ClassLoader): T = - typedActorFor(intfClass, serviceIdOrClassName, timeout, hostname, port, Some(loader)) - /** * Clean-up all open connections. */ @@ -379,8 +296,6 @@ trait RemoteClientModule extends RemoteModule { self: RemoteModule ⇒ /** Methods that needs to be implemented by a transport **/ - protected[akka] def typedActorFor[T](intfClass: Class[T], serviceaddress: String, timeout: Long, host: String, port: Int, loader: Option[ClassLoader]): T - protected[akka] def actorFor(address: String, timeout: Long, hostname: String, port: Int, loader: Option[ClassLoader]): ActorRef protected[akka] def send[T](message: Any, @@ -390,7 +305,5 @@ trait RemoteClientModule extends RemoteModule { self: RemoteModule ⇒ timeout: Long, isOneWay: Boolean, actorRef: ActorRef, - typedActorInfo: Option[Tuple2[String, String]], - actorType: ActorType, loader: Option[ClassLoader]): Option[CompletableFuture[T]] } diff --git a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala index 58faa0fdd5..8feeb279a1 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala @@ -888,7 +888,6 @@ class ClusterNode private[akka] ( def ref(actorAddress: String, router: RouterType): ActorRef = if (isConnected.isOn) { val addresses = addressesForActor(actorAddress) - val actorType = ActorType.ScalaActor // FIXME later we also want to suppot TypedActor, then 'actorType' needs to be configurable EventHandler.debug(this, "Creating cluster actor ref with router [%s] for actors [%s]".format(router, addresses.mkString(", "))) @@ -903,7 +902,7 @@ class ClusterNode private[akka] ( def refByUuid(uuid: UUID): ActorRef = { val actor = Router newRouter (router, addresses, uuidToString(uuid), - Actor.TIMEOUT, actorType) + Actor.TIMEOUT) registerClusterActorRefForAddress(actor, addresses) actor } @@ -913,7 +912,7 @@ class ClusterNode private[akka] ( val uuids = uuidsForActorAddress(actorAddress) val actor = Router newRouter (router, addresses, actorAddress, - Actor.TIMEOUT, actorType) + Actor.TIMEOUT) registerClusterActorRefForAddress(actor, addresses) actor } diff --git a/akka-cluster/src/main/scala/akka/cluster/ClusterActorRef.scala b/akka-cluster/src/main/scala/akka/cluster/ClusterActorRef.scala index ec2060bfb5..ff6b89506d 100644 --- a/akka-cluster/src/main/scala/akka/cluster/ClusterActorRef.scala +++ b/akka-cluster/src/main/scala/akka/cluster/ClusterActorRef.scala @@ -22,9 +22,8 @@ class ClusterActorRef private[akka] ( actorAddresses: Array[Tuple2[UUID, InetSocketAddress]], address: String, timeout: Long, - actorType: ActorType, val replicationStrategy: ReplicationStrategy) - extends RemoteActorRef(address, timeout, None, actorType) { + extends RemoteActorRef(address, timeout, None) { this: ClusterActorRef with Router.Router ⇒ EventHandler.debug(this, "Creating a ClusterActorRef for actor with address [%s]".format(address)) @@ -67,6 +66,6 @@ class ClusterActorRef private[akka] ( private def createRemoteActorRef(uuid: UUID, address: InetSocketAddress) = { RemoteActorRef( UUID_PREFIX + uuidToString(uuid), // clustered refs are always registered and looked up by UUID - Actor.TIMEOUT, None, actorType) + Actor.TIMEOUT, None) } } diff --git a/akka-cluster/src/main/scala/akka/cluster/Routing.scala b/akka-cluster/src/main/scala/akka/cluster/Routing.scala index 3713766605..68a0a29d3e 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Routing.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Routing.scala @@ -26,21 +26,20 @@ object Router { addresses: Array[Tuple2[UUID, InetSocketAddress]], serviceId: String, timeout: Long, - actorType: ActorType, replicationStrategy: ReplicationStrategy = ReplicationStrategy.WriteThrough): ClusterActorRef = { routerType match { case Direct ⇒ new ClusterActorRef( addresses, serviceId, timeout, - actorType, replicationStrategy) with Direct + replicationStrategy) with Direct case Random ⇒ new ClusterActorRef( addresses, serviceId, timeout, - actorType, replicationStrategy) with Random + replicationStrategy) with Random case RoundRobin ⇒ new ClusterActorRef( addresses, serviceId, timeout, - actorType, replicationStrategy) with RoundRobin + replicationStrategy) with RoundRobin case LeastCPU ⇒ sys.error("Router LeastCPU not supported yet") case LeastRAM ⇒ sys.error("Router LeastRAM not supported yet") diff --git a/akka-remote/src/main/java/akka/remote/protocol/RemoteProtocol.java b/akka-remote/src/main/java/akka/remote/protocol/RemoteProtocol.java index 817582f4ec..4d2bdfdce1 100644 --- a/akka-remote/src/main/java/akka/remote/protocol/RemoteProtocol.java +++ b/akka-remote/src/main/java/akka/remote/protocol/RemoteProtocol.java @@ -73,75 +73,6 @@ public final class RemoteProtocol { // @@protoc_insertion_point(enum_scope:CommandType) } - public enum ActorType - implements com.google.protobuf.ProtocolMessageEnum { - SCALA_ACTOR(0, 1), - JAVA_ACTOR(1, 2), - TYPED_ACTOR(2, 3), - ; - - - public final int getNumber() { return value; } - - public static ActorType valueOf(int value) { - switch (value) { - case 1: return SCALA_ACTOR; - case 2: return JAVA_ACTOR; - case 3: return TYPED_ACTOR; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public ActorType findValueByNumber(int number) { - return ActorType.valueOf(number) - ; } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return akka.remote.protocol.RemoteProtocol.getDescriptor().getEnumTypes().get(1); - } - - private static final ActorType[] VALUES = { - SCALA_ACTOR, JAVA_ACTOR, TYPED_ACTOR, - }; - public static ActorType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - private final int index; - private final int value; - private ActorType(int index, int value) { - this.index = index; - this.value = value; - } - - static { - akka.remote.protocol.RemoteProtocol.getDescriptor(); - } - - // @@protoc_insertion_point(enum_scope:ActorType) - } - public enum SerializationSchemeType implements com.google.protobuf.ProtocolMessageEnum { JAVA(0, 1), @@ -187,7 +118,7 @@ public final class RemoteProtocol { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return akka.remote.protocol.RemoteProtocol.getDescriptor().getEnumTypes().get(2); + return akka.remote.protocol.RemoteProtocol.getDescriptor().getEnumTypes().get(1); } private static final SerializationSchemeType[] VALUES = { @@ -254,7 +185,7 @@ public final class RemoteProtocol { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return akka.remote.protocol.RemoteProtocol.getDescriptor().getEnumTypes().get(3); + return akka.remote.protocol.RemoteProtocol.getDescriptor().getEnumTypes().get(2); } private static final LifeCycleType[] VALUES = { @@ -2141,360 +2072,6 @@ public final class RemoteProtocol { // @@protoc_insertion_point(class_scope:RemoteActorRefProtocol) } - public static final class RemoteTypedActorRefProtocol extends - com.google.protobuf.GeneratedMessage { - // Use RemoteTypedActorRefProtocol.newBuilder() to construct. - private RemoteTypedActorRefProtocol() { - initFields(); - } - private RemoteTypedActorRefProtocol(boolean noInit) {} - - private static final RemoteTypedActorRefProtocol defaultInstance; - public static RemoteTypedActorRefProtocol getDefaultInstance() { - return defaultInstance; - } - - public RemoteTypedActorRefProtocol getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return akka.remote.protocol.RemoteProtocol.internal_static_RemoteTypedActorRefProtocol_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return akka.remote.protocol.RemoteProtocol.internal_static_RemoteTypedActorRefProtocol_fieldAccessorTable; - } - - // required .RemoteActorRefProtocol actorRef = 1; - public static final int ACTORREF_FIELD_NUMBER = 1; - private boolean hasActorRef; - private akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol actorRef_; - public boolean hasActorRef() { return hasActorRef; } - public akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol getActorRef() { return actorRef_; } - - // required string interfaceName = 2; - public static final int INTERFACENAME_FIELD_NUMBER = 2; - private boolean hasInterfaceName; - private java.lang.String interfaceName_ = ""; - public boolean hasInterfaceName() { return hasInterfaceName; } - public java.lang.String getInterfaceName() { return interfaceName_; } - - private void initFields() { - actorRef_ = akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.getDefaultInstance(); - } - public final boolean isInitialized() { - if (!hasActorRef) return false; - if (!hasInterfaceName) return false; - if (!getActorRef().isInitialized()) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasActorRef()) { - output.writeMessage(1, getActorRef()); - } - if (hasInterfaceName()) { - output.writeString(2, getInterfaceName()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasActorRef()) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getActorRef()); - } - if (hasInterfaceName()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(2, getInterfaceName()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol result; - - // Construct using akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol(); - return builder; - } - - protected akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.getDescriptor(); - } - - public akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol getDefaultInstanceForType() { - return akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol) { - return mergeFrom((akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol other) { - if (other == akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.getDefaultInstance()) return this; - if (other.hasActorRef()) { - mergeActorRef(other.getActorRef()); - } - if (other.hasInterfaceName()) { - setInterfaceName(other.getInterfaceName()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 10: { - akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.Builder subBuilder = akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.newBuilder(); - if (hasActorRef()) { - subBuilder.mergeFrom(getActorRef()); - } - input.readMessage(subBuilder, extensionRegistry); - setActorRef(subBuilder.buildPartial()); - break; - } - case 18: { - setInterfaceName(input.readString()); - break; - } - } - } - } - - - // required .RemoteActorRefProtocol actorRef = 1; - public boolean hasActorRef() { - return result.hasActorRef(); - } - public akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol getActorRef() { - return result.getActorRef(); - } - public Builder setActorRef(akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasActorRef = true; - result.actorRef_ = value; - return this; - } - public Builder setActorRef(akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.Builder builderForValue) { - result.hasActorRef = true; - result.actorRef_ = builderForValue.build(); - return this; - } - public Builder mergeActorRef(akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol value) { - if (result.hasActorRef() && - result.actorRef_ != akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.getDefaultInstance()) { - result.actorRef_ = - akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.newBuilder(result.actorRef_).mergeFrom(value).buildPartial(); - } else { - result.actorRef_ = value; - } - result.hasActorRef = true; - return this; - } - public Builder clearActorRef() { - result.hasActorRef = false; - result.actorRef_ = akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.getDefaultInstance(); - return this; - } - - // required string interfaceName = 2; - public boolean hasInterfaceName() { - return result.hasInterfaceName(); - } - public java.lang.String getInterfaceName() { - return result.getInterfaceName(); - } - public Builder setInterfaceName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasInterfaceName = true; - result.interfaceName_ = value; - return this; - } - public Builder clearInterfaceName() { - result.hasInterfaceName = false; - result.interfaceName_ = getDefaultInstance().getInterfaceName(); - return this; - } - - // @@protoc_insertion_point(builder_scope:RemoteTypedActorRefProtocol) - } - - static { - defaultInstance = new RemoteTypedActorRefProtocol(true); - akka.remote.protocol.RemoteProtocol.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:RemoteTypedActorRefProtocol) - } - public static final class SerializedActorRefProtocol extends com.google.protobuf.GeneratedMessage { // Use SerializedActorRefProtocol.newBuilder() to construct. @@ -4094,22 +3671,8 @@ public final class RemoteProtocol { public boolean hasTimeout() { return hasTimeout; } public long getTimeout() { return timeout_; } - // required .ActorType actorType = 3; - public static final int ACTORTYPE_FIELD_NUMBER = 3; - private boolean hasActorType; - private akka.remote.protocol.RemoteProtocol.ActorType actorType_; - public boolean hasActorType() { return hasActorType; } - public akka.remote.protocol.RemoteProtocol.ActorType getActorType() { return actorType_; } - - // optional .TypedActorInfoProtocol typedActorInfo = 4; - public static final int TYPEDACTORINFO_FIELD_NUMBER = 4; - private boolean hasTypedActorInfo; - private akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol typedActorInfo_; - public boolean hasTypedActorInfo() { return hasTypedActorInfo; } - public akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol getTypedActorInfo() { return typedActorInfo_; } - - // optional string address = 5; - public static final int ADDRESS_FIELD_NUMBER = 5; + // optional string address = 3; + public static final int ADDRESS_FIELD_NUMBER = 3; private boolean hasAddress; private java.lang.String address_ = ""; public boolean hasAddress() { return hasAddress; } @@ -4117,17 +3680,11 @@ public final class RemoteProtocol { private void initFields() { uuid_ = akka.remote.protocol.RemoteProtocol.UuidProtocol.getDefaultInstance(); - actorType_ = akka.remote.protocol.RemoteProtocol.ActorType.SCALA_ACTOR; - typedActorInfo_ = akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance(); } public final boolean isInitialized() { if (!hasUuid) return false; if (!hasTimeout) return false; - if (!hasActorType) return false; if (!getUuid().isInitialized()) return false; - if (hasTypedActorInfo()) { - if (!getTypedActorInfo().isInitialized()) return false; - } return true; } @@ -4140,14 +3697,8 @@ public final class RemoteProtocol { if (hasTimeout()) { output.writeUInt64(2, getTimeout()); } - if (hasActorType()) { - output.writeEnum(3, getActorType().getNumber()); - } - if (hasTypedActorInfo()) { - output.writeMessage(4, getTypedActorInfo()); - } if (hasAddress()) { - output.writeString(5, getAddress()); + output.writeString(3, getAddress()); } getUnknownFields().writeTo(output); } @@ -4166,17 +3717,9 @@ public final class RemoteProtocol { size += com.google.protobuf.CodedOutputStream .computeUInt64Size(2, getTimeout()); } - if (hasActorType()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(3, getActorType().getNumber()); - } - if (hasTypedActorInfo()) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getTypedActorInfo()); - } if (hasAddress()) { size += com.google.protobuf.CodedOutputStream - .computeStringSize(5, getAddress()); + .computeStringSize(3, getAddress()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -4342,12 +3885,6 @@ public final class RemoteProtocol { if (other.hasTimeout()) { setTimeout(other.getTimeout()); } - if (other.hasActorType()) { - setActorType(other.getActorType()); - } - if (other.hasTypedActorInfo()) { - mergeTypedActorInfo(other.getTypedActorInfo()); - } if (other.hasAddress()) { setAddress(other.getAddress()); } @@ -4389,26 +3926,7 @@ public final class RemoteProtocol { setTimeout(input.readUInt64()); break; } - case 24: { - int rawValue = input.readEnum(); - akka.remote.protocol.RemoteProtocol.ActorType value = akka.remote.protocol.RemoteProtocol.ActorType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(3, rawValue); - } else { - setActorType(value); - } - break; - } - case 34: { - akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.Builder subBuilder = akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.newBuilder(); - if (hasTypedActorInfo()) { - subBuilder.mergeFrom(getTypedActorInfo()); - } - input.readMessage(subBuilder, extensionRegistry); - setTypedActorInfo(subBuilder.buildPartial()); - break; - } - case 42: { + case 26: { setAddress(input.readString()); break; } @@ -4472,65 +3990,7 @@ public final class RemoteProtocol { return this; } - // required .ActorType actorType = 3; - public boolean hasActorType() { - return result.hasActorType(); - } - public akka.remote.protocol.RemoteProtocol.ActorType getActorType() { - return result.getActorType(); - } - public Builder setActorType(akka.remote.protocol.RemoteProtocol.ActorType value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasActorType = true; - result.actorType_ = value; - return this; - } - public Builder clearActorType() { - result.hasActorType = false; - result.actorType_ = akka.remote.protocol.RemoteProtocol.ActorType.SCALA_ACTOR; - return this; - } - - // optional .TypedActorInfoProtocol typedActorInfo = 4; - public boolean hasTypedActorInfo() { - return result.hasTypedActorInfo(); - } - public akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol getTypedActorInfo() { - return result.getTypedActorInfo(); - } - public Builder setTypedActorInfo(akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasTypedActorInfo = true; - result.typedActorInfo_ = value; - return this; - } - public Builder setTypedActorInfo(akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.Builder builderForValue) { - result.hasTypedActorInfo = true; - result.typedActorInfo_ = builderForValue.build(); - return this; - } - public Builder mergeTypedActorInfo(akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol value) { - if (result.hasTypedActorInfo() && - result.typedActorInfo_ != akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance()) { - result.typedActorInfo_ = - akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.newBuilder(result.typedActorInfo_).mergeFrom(value).buildPartial(); - } else { - result.typedActorInfo_ = value; - } - result.hasTypedActorInfo = true; - return this; - } - public Builder clearTypedActorInfo() { - result.hasTypedActorInfo = false; - result.typedActorInfo_ = akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance(); - return this; - } - - // optional string address = 5; + // optional string address = 3; public boolean hasAddress() { return result.hasAddress(); } @@ -4563,337 +4023,6 @@ public final class RemoteProtocol { // @@protoc_insertion_point(class_scope:ActorInfoProtocol) } - public static final class TypedActorInfoProtocol extends - com.google.protobuf.GeneratedMessage { - // Use TypedActorInfoProtocol.newBuilder() to construct. - private TypedActorInfoProtocol() { - initFields(); - } - private TypedActorInfoProtocol(boolean noInit) {} - - private static final TypedActorInfoProtocol defaultInstance; - public static TypedActorInfoProtocol getDefaultInstance() { - return defaultInstance; - } - - public TypedActorInfoProtocol getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return akka.remote.protocol.RemoteProtocol.internal_static_TypedActorInfoProtocol_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return akka.remote.protocol.RemoteProtocol.internal_static_TypedActorInfoProtocol_fieldAccessorTable; - } - - // required string interface = 1; - public static final int INTERFACE_FIELD_NUMBER = 1; - private boolean hasInterface; - private java.lang.String interface_ = ""; - public boolean hasInterface() { return hasInterface; } - public java.lang.String getInterface() { return interface_; } - - // required string method = 2; - public static final int METHOD_FIELD_NUMBER = 2; - private boolean hasMethod; - private java.lang.String method_ = ""; - public boolean hasMethod() { return hasMethod; } - public java.lang.String getMethod() { return method_; } - - private void initFields() { - } - public final boolean isInitialized() { - if (!hasInterface) return false; - if (!hasMethod) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasInterface()) { - output.writeString(1, getInterface()); - } - if (hasMethod()) { - output.writeString(2, getMethod()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasInterface()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(1, getInterface()); - } - if (hasMethod()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(2, getMethod()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol result; - - // Construct using akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol(); - return builder; - } - - protected akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDescriptor(); - } - - public akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol getDefaultInstanceForType() { - return akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol) { - return mergeFrom((akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol other) { - if (other == akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance()) return this; - if (other.hasInterface()) { - setInterface(other.getInterface()); - } - if (other.hasMethod()) { - setMethod(other.getMethod()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 10: { - setInterface(input.readString()); - break; - } - case 18: { - setMethod(input.readString()); - break; - } - } - } - } - - - // required string interface = 1; - public boolean hasInterface() { - return result.hasInterface(); - } - public java.lang.String getInterface() { - return result.getInterface(); - } - public Builder setInterface(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasInterface = true; - result.interface_ = value; - return this; - } - public Builder clearInterface() { - result.hasInterface = false; - result.interface_ = getDefaultInstance().getInterface(); - return this; - } - - // required string method = 2; - public boolean hasMethod() { - return result.hasMethod(); - } - public java.lang.String getMethod() { - return result.getMethod(); - } - public Builder setMethod(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasMethod = true; - result.method_ = value; - return this; - } - public Builder clearMethod() { - result.hasMethod = false; - result.method_ = getDefaultInstance().getMethod(); - return this; - } - - // @@protoc_insertion_point(builder_scope:TypedActorInfoProtocol) - } - - static { - defaultInstance = new TypedActorInfoProtocol(true); - akka.remote.protocol.RemoteProtocol.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:TypedActorInfoProtocol) - } - public static final class UuidProtocol extends com.google.protobuf.GeneratedMessage { // Use UuidProtocol.newBuilder() to construct. @@ -6524,11 +5653,6 @@ public final class RemoteProtocol { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_RemoteActorRefProtocol_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_RemoteTypedActorRefProtocol_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_RemoteTypedActorRefProtocol_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor internal_static_SerializedActorRefProtocol_descriptor; private static @@ -6549,11 +5673,6 @@ public final class RemoteProtocol { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_ActorInfoProtocol_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_TypedActorInfoProtocol_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_TypedActorInfoProtocol_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor internal_static_UuidProtocol_descriptor; private static @@ -6602,42 +5721,35 @@ public final class RemoteProtocol { "cookie\030\t \001(\t\"J\n\025RemoteControlProtocol\022\016\n" + "\006cookie\030\001 \001(\t\022!\n\013commandType\030\002 \002(\0162\014.Com" + "mandType\":\n\026RemoteActorRefProtocol\022\017\n\007ad" + - "dress\030\001 \002(\t\022\017\n\007timeout\030\002 \001(\004\"_\n\033RemoteTy" + - "pedActorRefProtocol\022)\n\010actorRef\030\001 \002(\0132\027." + - "RemoteActorRefProtocol\022\025\n\rinterfaceName\030" + - "\002 \002(\t\"\323\002\n\032SerializedActorRefProtocol\022\033\n\004" + - "uuid\030\001 \002(\0132\r.UuidProtocol\022\017\n\007address\030\002 \002" + - "(\t\022\026\n\016actorClassname\030\003 \002(\t\022\025\n\ractorInsta", - "nce\030\004 \001(\014\022\033\n\023serializerClassname\030\005 \001(\t\022\017" + - "\n\007timeout\030\006 \001(\004\022\026\n\016receiveTimeout\030\007 \001(\004\022" + - "%\n\tlifeCycle\030\010 \001(\0132\022.LifeCycleProtocol\022+" + - "\n\nsupervisor\030\t \001(\0132\027.RemoteActorRefProto" + - "col\022\024\n\014hotswapStack\030\n \001(\014\022(\n\010messages\030\013 " + - "\003(\0132\026.RemoteMessageProtocol\"g\n\037Serialize" + - "dTypedActorRefProtocol\022-\n\010actorRef\030\001 \002(\013" + - "2\033.SerializedActorRefProtocol\022\025\n\rinterfa" + - "ceName\030\002 \002(\t\"r\n\017MessageProtocol\0225\n\023seria" + - "lizationScheme\030\001 \002(\0162\030.SerializationSche", - "meType\022\017\n\007message\030\002 \002(\014\022\027\n\017messageManife" + - "st\030\003 \001(\014\"\242\001\n\021ActorInfoProtocol\022\033\n\004uuid\030\001" + - " \002(\0132\r.UuidProtocol\022\017\n\007timeout\030\002 \002(\004\022\035\n\t" + - "actorType\030\003 \002(\0162\n.ActorType\022/\n\016typedActo" + - "rInfo\030\004 \001(\0132\027.TypedActorInfoProtocol\022\017\n\007" + - "address\030\005 \001(\t\";\n\026TypedActorInfoProtocol\022" + - "\021\n\tinterface\030\001 \002(\t\022\016\n\006method\030\002 \002(\t\")\n\014Uu" + - "idProtocol\022\014\n\004high\030\001 \002(\004\022\013\n\003low\030\002 \002(\004\"3\n" + - "\025MetadataEntryProtocol\022\013\n\003key\030\001 \002(\t\022\r\n\005v" + - "alue\030\002 \002(\014\"6\n\021LifeCycleProtocol\022!\n\tlifeC", - "ycle\030\001 \002(\0162\016.LifeCycleType\"1\n\017AddressPro" + - "tocol\022\020\n\010hostname\030\001 \002(\t\022\014\n\004port\030\002 \002(\r\"7\n" + - "\021ExceptionProtocol\022\021\n\tclassname\030\001 \002(\t\022\017\n" + - "\007message\030\002 \002(\t*\033\n\013CommandType\022\014\n\010SHUTDOW" + - "N\020\001*=\n\tActorType\022\017\n\013SCALA_ACTOR\020\001\022\016\n\nJAV" + - "A_ACTOR\020\002\022\017\n\013TYPED_ACTOR\020\003*]\n\027Serializat" + - "ionSchemeType\022\010\n\004JAVA\020\001\022\013\n\007SBINARY\020\002\022\016\n\n" + - "SCALA_JSON\020\003\022\r\n\tJAVA_JSON\020\004\022\014\n\010PROTOBUF\020" + - "\005*-\n\rLifeCycleType\022\r\n\tPERMANENT\020\001\022\r\n\tTEM" + - "PORARY\020\002B\030\n\024akka.remote.protocolH\001" + "dress\030\001 \002(\t\022\017\n\007timeout\030\002 \001(\004\"\323\002\n\032Seriali" + + "zedActorRefProtocol\022\033\n\004uuid\030\001 \002(\0132\r.Uuid" + + "Protocol\022\017\n\007address\030\002 \002(\t\022\026\n\016actorClassn" + + "ame\030\003 \002(\t\022\025\n\ractorInstance\030\004 \001(\014\022\033\n\023seri" + + "alizerClassname\030\005 \001(\t\022\017\n\007timeout\030\006 \001(\004\022\026" + + "\n\016receiveTimeout\030\007 \001(\004\022%\n\tlifeCycle\030\010 \001(", + "\0132\022.LifeCycleProtocol\022+\n\nsupervisor\030\t \001(" + + "\0132\027.RemoteActorRefProtocol\022\024\n\014hotswapSta" + + "ck\030\n \001(\014\022(\n\010messages\030\013 \003(\0132\026.RemoteMessa" + + "geProtocol\"g\n\037SerializedTypedActorRefPro" + + "tocol\022-\n\010actorRef\030\001 \002(\0132\033.SerializedActo" + + "rRefProtocol\022\025\n\rinterfaceName\030\002 \002(\t\"r\n\017M" + + "essageProtocol\0225\n\023serializationScheme\030\001 " + + "\002(\0162\030.SerializationSchemeType\022\017\n\007message" + + "\030\002 \002(\014\022\027\n\017messageManifest\030\003 \001(\014\"R\n\021Actor" + + "InfoProtocol\022\033\n\004uuid\030\001 \002(\0132\r.UuidProtoco", + "l\022\017\n\007timeout\030\002 \002(\004\022\017\n\007address\030\003 \001(\t\")\n\014U" + + "uidProtocol\022\014\n\004high\030\001 \002(\004\022\013\n\003low\030\002 \002(\004\"3" + + "\n\025MetadataEntryProtocol\022\013\n\003key\030\001 \002(\t\022\r\n\005" + + "value\030\002 \002(\014\"6\n\021LifeCycleProtocol\022!\n\tlife" + + "Cycle\030\001 \002(\0162\016.LifeCycleType\"1\n\017AddressPr" + + "otocol\022\020\n\010hostname\030\001 \002(\t\022\014\n\004port\030\002 \002(\r\"7" + + "\n\021ExceptionProtocol\022\021\n\tclassname\030\001 \002(\t\022\017" + + "\n\007message\030\002 \002(\t*\033\n\013CommandType\022\014\n\010SHUTDO" + + "WN\020\001*]\n\027SerializationSchemeType\022\010\n\004JAVA\020" + + "\001\022\013\n\007SBINARY\020\002\022\016\n\nSCALA_JSON\020\003\022\r\n\tJAVA_J", + "SON\020\004\022\014\n\010PROTOBUF\020\005*-\n\rLifeCycleType\022\r\n\t" + + "PERMANENT\020\001\022\r\n\tTEMPORARY\020\002B\030\n\024akka.remot" + + "e.protocolH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -6676,16 +5788,8 @@ public final class RemoteProtocol { new java.lang.String[] { "Address", "Timeout", }, akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.class, akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.Builder.class); - internal_static_RemoteTypedActorRefProtocol_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_RemoteTypedActorRefProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_RemoteTypedActorRefProtocol_descriptor, - new java.lang.String[] { "ActorRef", "InterfaceName", }, - akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.class, - akka.remote.protocol.RemoteProtocol.RemoteTypedActorRefProtocol.Builder.class); internal_static_SerializedActorRefProtocol_descriptor = - getDescriptor().getMessageTypes().get(5); + getDescriptor().getMessageTypes().get(4); internal_static_SerializedActorRefProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_SerializedActorRefProtocol_descriptor, @@ -6693,7 +5797,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.class, akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.Builder.class); internal_static_SerializedTypedActorRefProtocol_descriptor = - getDescriptor().getMessageTypes().get(6); + getDescriptor().getMessageTypes().get(5); internal_static_SerializedTypedActorRefProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_SerializedTypedActorRefProtocol_descriptor, @@ -6701,7 +5805,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.SerializedTypedActorRefProtocol.class, akka.remote.protocol.RemoteProtocol.SerializedTypedActorRefProtocol.Builder.class); internal_static_MessageProtocol_descriptor = - getDescriptor().getMessageTypes().get(7); + getDescriptor().getMessageTypes().get(6); internal_static_MessageProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MessageProtocol_descriptor, @@ -6709,23 +5813,15 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.MessageProtocol.class, akka.remote.protocol.RemoteProtocol.MessageProtocol.Builder.class); internal_static_ActorInfoProtocol_descriptor = - getDescriptor().getMessageTypes().get(8); + getDescriptor().getMessageTypes().get(7); internal_static_ActorInfoProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_ActorInfoProtocol_descriptor, - new java.lang.String[] { "Uuid", "Timeout", "ActorType", "TypedActorInfo", "Address", }, + new java.lang.String[] { "Uuid", "Timeout", "Address", }, akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.class, akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.Builder.class); - internal_static_TypedActorInfoProtocol_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_TypedActorInfoProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_TypedActorInfoProtocol_descriptor, - new java.lang.String[] { "Interface", "Method", }, - akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.class, - akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.Builder.class); internal_static_UuidProtocol_descriptor = - getDescriptor().getMessageTypes().get(10); + getDescriptor().getMessageTypes().get(8); internal_static_UuidProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_UuidProtocol_descriptor, @@ -6733,7 +5829,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.UuidProtocol.class, akka.remote.protocol.RemoteProtocol.UuidProtocol.Builder.class); internal_static_MetadataEntryProtocol_descriptor = - getDescriptor().getMessageTypes().get(11); + getDescriptor().getMessageTypes().get(9); internal_static_MetadataEntryProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MetadataEntryProtocol_descriptor, @@ -6741,7 +5837,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.MetadataEntryProtocol.class, akka.remote.protocol.RemoteProtocol.MetadataEntryProtocol.Builder.class); internal_static_LifeCycleProtocol_descriptor = - getDescriptor().getMessageTypes().get(12); + getDescriptor().getMessageTypes().get(10); internal_static_LifeCycleProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_LifeCycleProtocol_descriptor, @@ -6749,7 +5845,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.class, akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.Builder.class); internal_static_AddressProtocol_descriptor = - getDescriptor().getMessageTypes().get(13); + getDescriptor().getMessageTypes().get(11); internal_static_AddressProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_AddressProtocol_descriptor, @@ -6757,7 +5853,7 @@ public final class RemoteProtocol { akka.remote.protocol.RemoteProtocol.AddressProtocol.class, akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder.class); internal_static_ExceptionProtocol_descriptor = - getDescriptor().getMessageTypes().get(14); + getDescriptor().getMessageTypes().get(12); internal_static_ExceptionProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_ExceptionProtocol_descriptor, diff --git a/akka-remote/src/main/protocol/RemoteProtocol.proto b/akka-remote/src/main/protocol/RemoteProtocol.proto index 8680cb2305..37dce1914e 100644 --- a/akka-remote/src/main/protocol/RemoteProtocol.proto +++ b/akka-remote/src/main/protocol/RemoteProtocol.proto @@ -55,15 +55,6 @@ message RemoteActorRefProtocol { optional uint64 timeout = 2; } -/** - * Defines a remote Typed ActorRef that "remembers" and uses its original typed Actor instance - * on the original node. - */ -message RemoteTypedActorRefProtocol { - required RemoteActorRefProtocol actorRef = 1; - required string interfaceName = 2; -} - /** * Defines a fully serialized remote ActorRef (with serialized Actor instance) * that is about to be instantiated on the remote node. It is fully disconnected @@ -108,17 +99,7 @@ message MessageProtocol { message ActorInfoProtocol { required UuidProtocol uuid = 1; required uint64 timeout = 2; - required ActorType actorType = 3; - optional TypedActorInfoProtocol typedActorInfo = 4; - optional string address = 5; -} - -/** - * Defines the typed actor extra info. - */ -message TypedActorInfoProtocol { - required string interface = 1; - required string method = 2; + optional string address = 3; } /** @@ -137,15 +118,6 @@ message MetadataEntryProtocol { required bytes value = 2; } -/** - * Defines the actor type. - */ -enum ActorType { - SCALA_ACTOR = 1; - JAVA_ACTOR = 2; - TYPED_ACTOR = 3; -} - /** * Defines the serialization scheme used to serialize the message and/or Actor instance. */ diff --git a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 33dc11382c..01a80fbc9b 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -7,7 +7,6 @@ package akka.remote.netty import akka.dispatch.{ DefaultCompletableFuture, CompletableFuture, Future } import akka.remote.{ MessageSerializer, RemoteClientSettings, RemoteServerSettings } import akka.remote.protocol.RemoteProtocol._ -import akka.remote.protocol.RemoteProtocol.ActorType._ import akka.serialization.RemoteActorSerialization import akka.serialization.RemoteActorSerialization._ import akka.remoteinterface._ @@ -17,15 +16,13 @@ import akka.actor.{ LocalActorRef, Actor, RemoteActorRef, - TypedActor, ActorRef, IllegalActorStateException, RemoteActorSystemMessage, uuidFrom, Uuid, Exit, - LifeCycleMessage, - ActorType ⇒ AkkaActorType + LifeCycleMessage } import akka.actor.Actor._ import akka.config.Config._ @@ -74,9 +71,6 @@ trait NettyRemoteClientModule extends RemoteClientModule { self: ListenerManagem private val remoteActors = new Index[Address, Uuid] private val lock = new ReadWriteGuard - protected[akka] def typedActorFor[T](intfClass: Class[T], serviceId: String, timeout: Long, hostname: String, port: Int, loader: Option[ClassLoader]): T = - TypedActor.createProxyForRemoteActorRef(intfClass, RemoteActorRef(serviceId, timeout, loader, AkkaActorType.TypedActor)) - protected[akka] def send[T](message: Any, senderOption: Option[ActorRef], senderFuture: Option[CompletableFuture[T]], @@ -84,10 +78,8 @@ trait NettyRemoteClientModule extends RemoteClientModule { self: ListenerManagem timeout: Long, isOneWay: Boolean, actorRef: ActorRef, - typedActorInfo: Option[Tuple2[String, String]], - actorType: AkkaActorType, loader: Option[ClassLoader]): Option[CompletableFuture[T]] = - withClientFor(remoteAddress, loader)(_.send[T](message, senderOption, senderFuture, remoteAddress, timeout, isOneWay, actorRef, typedActorInfo, actorType)) + withClientFor(remoteAddress, loader)(_.send[T](message, senderOption, senderFuture, remoteAddress, timeout, isOneWay, actorRef)) private[akka] def withClientFor[T]( address: InetSocketAddress, loader: Option[ClassLoader])(fun: RemoteClient ⇒ T): T = { @@ -204,9 +196,7 @@ abstract class RemoteClient private[akka] ( remoteAddress: InetSocketAddress, timeout: Long, isOneWay: Boolean, - actorRef: ActorRef, - typedActorInfo: Option[Tuple2[String, String]], - actorType: AkkaActorType): Option[CompletableFuture[T]] = synchronized { // FIXME: find better strategy to prevent race + actorRef: ActorRef): Option[CompletableFuture[T]] = synchronized { // FIXME: find better strategy to prevent race send(createRemoteMessageProtocolBuilder( Some(actorRef), @@ -216,8 +206,6 @@ abstract class RemoteClient private[akka] ( Right(message), isOneWay, senderOption, - typedActorInfo, - actorType, if (isAuthenticated.compareAndSet(false, true)) RemoteClientSettings.SECURE_COOKIE else None).build, senderFuture) } @@ -649,25 +637,6 @@ trait NettyRemoteServerModule extends RemoteServerModule { self: RemoteModule } } - /** - * Register remote typed actor by a specific id. - * @param id custom actor id - * @param typedActor typed actor to register - */ - def registerTypedActor(id: String, typedActor: AnyRef): Unit = guard withGuard { - if (id.startsWith(UUID_PREFIX)) registerTypedActor(id.substring(UUID_PREFIX.length), typedActor, typedActorsByUuid) - else registerTypedActor(id, typedActor, typedActors) - } - - /** - * Register remote typed actor by a specific id. - * @param id custom actor id - * @param typedActor typed actor to register - */ - def registerTypedPerSessionActor(id: String, factory: ⇒ AnyRef): Unit = guard withGuard { - registerTypedPerSessionActor(id, () ⇒ factory, typedActorsFactories) - } - /** * Register RemoteModule Actor by a specific 'id' passed as argument. *

@@ -703,16 +672,6 @@ trait NettyRemoteServerModule extends RemoteServerModule { self: RemoteModule registry.put(id, factory) //TODO change to putIfAbsent } - private def registerTypedActor[Key](id: Key, typedActor: AnyRef, registry: ConcurrentHashMap[Key, AnyRef]) { - if (_isRunning.isOn) - registry.put(id, typedActor) //TODO change to putIfAbsent - } - - private def registerTypedPerSessionActor[Key](id: Key, factory: () ⇒ AnyRef, registry: ConcurrentHashMap[Key, () ⇒ AnyRef]) { - if (_isRunning.isOn) - registry.put(id, factory) //TODO change to putIfAbsent - } - /** * Unregister RemoteModule Actor that is registered using its 'id' field (not custom ID). */ @@ -749,26 +708,6 @@ trait NettyRemoteServerModule extends RemoteServerModule { self: RemoteModule actorsFactories.remove(id) } } - - /** - * Unregister RemoteModule Typed Actor by specific 'id'. - *

- * NOTE: You need to call this method if you have registered an actor by a custom ID. - */ - def unregisterTypedActor(id: String): Unit = guard withGuard { - if (_isRunning.isOn) { - if (id.startsWith(UUID_PREFIX)) typedActorsByUuid.remove(id.substring(UUID_PREFIX.length)) - else typedActors.remove(id) - } - } - - /** - * Unregister RemoteModule Typed Actor by specific 'id'. - *

- * NOTE: You need to call this method if you have registered an actor by a custom ID. - */ - def unregisterTypedPerSessionActor(id: String): Unit = - if (_isRunning.isOn) typedActorsFactories.remove(id) } /** @@ -818,7 +757,6 @@ class RemoteServerHandler( applicationLoader.foreach(MessageSerializer.setClassLoader(_)) //TODO: REVISIT: THIS FEELS A BIT DODGY val sessionActors = new ChannelLocal[ConcurrentHashMap[String, ActorRef]]() - val typedSessionActors = new ChannelLocal[ConcurrentHashMap[String, AnyRef]]() //Writes the specified message to the specified channel and propagates write errors to listeners private def write(channel: Channel, payload: AkkaRemoteProtocol): Unit = { @@ -847,7 +785,6 @@ class RemoteServerHandler( override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val clientAddress = getClientAddress(ctx) sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]()) - typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]()) server.notifyListeners(RemoteServerClientConnected(server, clientAddress)) if (REQUIRE_COOKIE) ctx.setAttachment(CHANNEL_INIT) // signal that this is channel initialization, which will need authentication } @@ -863,15 +800,6 @@ class RemoteServerHandler( try { actor ! PoisonPill } catch { case e: Exception ⇒ } } - //FIXME switch approach or use other thread to execute this - // stop all typed session actors - for ( - map ← Option(typedSessionActors.remove(event.getChannel)); - actor ← collectionAsScalaIterable(map.values) - ) { - try { TypedActor.stop(actor) } catch { case e: Exception ⇒ } - } - server.notifyListeners(RemoteServerClientDisconnected(server, clientAddress)) } @@ -901,14 +829,8 @@ class RemoteServerHandler( case _ ⇒ None } - private def handleRemoteMessageProtocol(request: RemoteMessageProtocol, channel: Channel) = { - request.getActorInfo.getActorType match { - case SCALA_ACTOR ⇒ dispatchToActor(request, channel) - case TYPED_ACTOR ⇒ dispatchToTypedActor(request, channel) - case JAVA_ACTOR ⇒ throw new IllegalActorStateException("ActorType JAVA_ACTOR is currently not supported") - case other ⇒ throw new IllegalActorStateException("Unknown ActorType [" + other + "]") - } - } + private def handleRemoteMessageProtocol(request: RemoteMessageProtocol, channel: Channel) = + dispatchToActor(request, channel) private def dispatchToActor(request: RemoteMessageProtocol, channel: Channel) { val actorInfo = request.getActorInfo @@ -917,7 +839,7 @@ class RemoteServerHandler( try { createActor(actorInfo, channel) } catch { case e: SecurityException ⇒ EventHandler.error(e, this, e.getMessage) - write(channel, createErrorReplyMessage(e, request, AkkaActorType.ScalaActor)) + write(channel, createErrorReplyMessage(e, request)) server.notifyListeners(RemoteServerError(e, server)) return } @@ -943,7 +865,7 @@ class RemoteServerHandler( None, Some(new DefaultCompletableFuture[Any](request.getActorInfo.getTimeout). onComplete(_.value.get match { - case l: Left[Throwable, Any] ⇒ write(channel, createErrorReplyMessage(l.a, request, AkkaActorType.ScalaActor)) + case l: Left[Throwable, Any] ⇒ write(channel, createErrorReplyMessage(l.a, request)) case r: Right[Throwable, Any] ⇒ val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder( Some(actorRef), @@ -953,8 +875,6 @@ class RemoteServerHandler( r, true, Some(actorRef), - None, - AkkaActorType.ScalaActor, None) // FIXME lift in the supervisor uuid management into toh createRemoteMessageProtocolBuilder method @@ -965,116 +885,12 @@ class RemoteServerHandler( } } - private def dispatchToTypedActor(request: RemoteMessageProtocol, channel: Channel) = { - val actorInfo = request.getActorInfo - val typedActorInfo = actorInfo.getTypedActorInfo - /* TODO Implement sender references for remote TypedActor calls - if (request.hasSender) { - val iface = //TODO extrace the senderProxy interface from the request, load it as a class using the application loader - val ref = RemoteActorSerialization.fromProtobufToRemoteActorRef(request.getSender, applicationLoader) - val senderTA = TypedActor.createProxyForRemoteActorRef[AnyRef](iface, ref) - Some() - } else None - */ - - val typedActor = createTypedActor(actorInfo, channel) - //FIXME: Add ownerTypeHint and parameter types to the TypedActorInfo? - val (ownerTypeHint, argClasses, args) = - MessageSerializer - .deserialize(request.getMessage) - .asInstanceOf[Tuple3[String, Array[Class[_]], Array[AnyRef]]] - - def resolveMethod(bottomType: Class[_], - typeHint: String, - methodName: String, - methodSignature: Array[Class[_]]): java.lang.reflect.Method = { - var typeToResolve = bottomType - var targetMethod: java.lang.reflect.Method = null - var firstException: NoSuchMethodException = null - while ((typeToResolve ne null) && (targetMethod eq null)) { - - if ((typeHint eq null) || typeToResolve.getName.startsWith(typeHint)) { - try { - targetMethod = typeToResolve.getDeclaredMethod(methodName, methodSignature: _*) - targetMethod.setAccessible(true) - } catch { - case e: NoSuchMethodException ⇒ - if (firstException eq null) - firstException = e - - } - } - - typeToResolve = typeToResolve.getSuperclass - } - - if ((targetMethod eq null) && (firstException ne null)) - throw firstException - - targetMethod - } - - try { - val messageReceiver = resolveMethod(typedActor.getClass, ownerTypeHint, typedActorInfo.getMethod, argClasses) - //TODO SenderContextInfo.senderActorRef.value = sender - //TODO SenderContextInfo.senderProxy.value = senderProxy - if (request.getOneWay) messageReceiver.invoke(typedActor, args: _*) //FIXME execute in non-IO thread - else { - //Sends the response - def sendResponse(result: Either[Throwable, Any]): Unit = try { - val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder( - None, - Right(request.getUuid), - actorInfo.getAddress, - actorInfo.getTimeout, - result, - true, - None, - None, - AkkaActorType.TypedActor, - None) - if (request.hasSupervisorUuid) messageBuilder.setSupervisorUuid(request.getSupervisorUuid) - - write(channel, RemoteEncoder.encode(messageBuilder.build)) - } catch { - case e: Exception ⇒ - EventHandler.error(e, this, e.getMessage) - server.notifyListeners(RemoteServerError(e, server)) - } - - messageReceiver.invoke(typedActor, args: _*) match { //TODO execute in non-IO thread - //If it's a future, we can lift on that to defer the send to when the future is completed - case f: Future[_] ⇒ f.onComplete(future ⇒ sendResponse(future.value.get)) - case other ⇒ sendResponse(Right(other)) - } - } - } catch { - case e: Exception ⇒ - EventHandler.error(e, this, e.getMessage) - write(channel, createErrorReplyMessage(e match { - case e: InvocationTargetException ⇒ e.getCause - case e ⇒ e - }, request, AkkaActorType.TypedActor)) - server.notifyListeners(RemoteServerError(e, server)) - } - finally { - //TODO SenderContextInfo.senderActorRef.value = None ? - //TODO SenderContextInfo.senderProxy.value = None ? - } - } - private def findSessionActor(id: String, channel: Channel): ActorRef = sessionActors.get(channel) match { case null ⇒ null case map ⇒ map get id } - private def findTypedSessionActor(id: String, channel: Channel): AnyRef = - typedSessionActors.get(channel) match { - case null ⇒ null - case map ⇒ map get id - } - /** * gets the actor from the session, or creates one if there is a factory for it */ @@ -1114,34 +930,7 @@ class RemoteServerHandler( } } - /** - * gets the actor from the session, or creates one if there is a factory for it - */ - private def createTypedSessionActor(actorInfo: ActorInfoProtocol, channel: Channel): AnyRef = { - val address = actorInfo.getAddress - findTypedSessionActor(address, channel) match { - case null ⇒ - server.findTypedActorFactory(address) match { - case null ⇒ null - case factory ⇒ - val newInstance = factory() - typedSessionActors.get(channel).put(address, newInstance) - newInstance - } - case sessionActor ⇒ sessionActor - } - } - - private def createTypedActor(actorInfo: ActorInfoProtocol, channel: Channel): AnyRef = { - val uuid = actorInfo.getUuid - server.findTypedActorByAddressOrUuid(actorInfo.getAddress, parseUuid(uuid).toString) match { - // the actor has not been registered globally. See if we have it in the session - case null ⇒ createTypedSessionActor(actorInfo, channel) - case typedActor ⇒ typedActor - } - } - - private def createErrorReplyMessage(exception: Throwable, request: RemoteMessageProtocol, actorType: AkkaActorType): AkkaRemoteProtocol = { + private def createErrorReplyMessage(exception: Throwable, request: RemoteMessageProtocol): AkkaRemoteProtocol = { val actorInfo = request.getActorInfo val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder( None, @@ -1151,8 +940,6 @@ class RemoteServerHandler( Left(exception), true, None, - None, - actorType, None) if (request.hasSupervisorUuid) messageBuilder.setSupervisorUuid(request.getSupervisorUuid) RemoteEncoder.encode(messageBuilder.build) diff --git a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala index 4e65120b58..2da80050f3 100644 --- a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala +++ b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala @@ -5,9 +5,9 @@ package akka.serialization import akka.dispatch.MessageInvocation -import akka.remote.protocol.RemoteProtocol.{ ActorType ⇒ ActorTypeProtocol, _ } +import akka.remote.protocol.RemoteProtocol._ +import akka.remote.protocol.RemoteProtocol -import ActorTypeProtocol._ import akka.config.Supervision._ import akka.actor.{ uuidFrom, newUuid } import akka.actor._ @@ -76,8 +76,6 @@ object ActorSerialization { Right(m.message), false, actorRef.getSender, - None, - ActorType.ScalaActor, RemoteClientSettings.SECURE_COOKIE).build) requestProtocols.foreach(rp ⇒ builder.addMessages(rp)) @@ -201,8 +199,6 @@ object RemoteActorSerialization { message: Either[Throwable, Any], isOneWay: Boolean, senderOption: Option[ActorRef], - typedActorInfo: Option[Tuple2[String, String]], - actorType: ActorType, secureCookie: Option[String]): RemoteMessageProtocol.Builder = { val uuidProtocol = replyUuid match { @@ -215,18 +211,6 @@ object RemoteActorSerialization { .setAddress(actorAddress) .setTimeout(timeout) - typedActorInfo.foreach { typedActor ⇒ - actorInfoBuilder.setTypedActorInfo( - TypedActorInfoProtocol.newBuilder - .setInterface(typedActor._1) - .setMethod(typedActor._2) - .build) - } - - actorType match { - case ActorType.ScalaActor ⇒ actorInfoBuilder.setActorType(SCALA_ACTOR) - case ActorType.TypedActor ⇒ actorInfoBuilder.setActorType(TYPED_ACTOR) - } val actorInfo = actorInfoBuilder.build val messageBuilder = RemoteMessageProtocol.newBuilder .setUuid({ @@ -270,96 +254,3 @@ object RemoteActorSerialization { messageBuilder } } - -/** - * Module for local typed actor serialization. - */ -object TypedActorSerialization { - - def fromBinary[T <: Actor, U <: AnyRef](bytes: Array[Byte])(implicit format: Format[T]): U = - fromBinaryToLocalTypedActorRef(bytes, format) - - def toBinary[T <: Actor](proxy: AnyRef)(implicit format: Format[T]): Array[Byte] = { - toSerializedTypedActorRefProtocol(proxy, format).toByteArray - } - - // wrapper for implicits to be used by Java - def fromBinaryJ[T <: Actor, U <: AnyRef](bytes: Array[Byte], format: Format[T]): U = - fromBinary(bytes)(format) - - // wrapper for implicits to be used by Java - def toBinaryJ[T <: Actor](a: AnyRef, format: Format[T]): Array[Byte] = - toBinary(a)(format) - - private def toSerializedTypedActorRefProtocol[T <: Actor]( - proxy: AnyRef, format: Format[T]): SerializedTypedActorRefProtocol = { - - val init = AspectInitRegistry.initFor(proxy) - if (init eq null) throw new IllegalArgumentException("Proxy for typed actor could not be found in AspectInitRegistry.") - - SerializedTypedActorRefProtocol.newBuilder - .setActorRef(ActorSerialization.toSerializedActorRefProtocol(init.actorRef, format)) - .setInterfaceName(init.interfaceClass.getName) - .build - } - - private def fromBinaryToLocalTypedActorRef[T <: Actor, U <: AnyRef](bytes: Array[Byte], format: Format[T]): U = - fromProtobufToLocalTypedActorRef(SerializedTypedActorRefProtocol.newBuilder.mergeFrom(bytes).build, format, None) - - private def fromProtobufToLocalTypedActorRef[T <: Actor, U <: AnyRef]( - protocol: SerializedTypedActorRefProtocol, format: Format[T], loader: Option[ClassLoader]): U = { - val actorRef = ActorSerialization.fromProtobufToLocalActorRef(protocol.getActorRef, format, loader) - val intfClass = toClass(loader, protocol.getInterfaceName) - TypedActor.newInstance(intfClass, actorRef).asInstanceOf[U] - } - - private[akka] def toClass[U <: AnyRef](loader: Option[ClassLoader], name: String): Class[U] = { - val classLoader = loader.getOrElse(getClass.getClassLoader) - val clazz = classLoader.loadClass(name) - clazz.asInstanceOf[Class[U]] - } -} - -/** - * Module for remote typed actor serialization. - */ -object RemoteTypedActorSerialization { - /** - * Deserializes a byte array (Array[Byte]) into an RemoteActorRef instance. - */ - def fromBinaryToRemoteTypedActorRef[T <: AnyRef](bytes: Array[Byte]): T = - fromProtobufToRemoteTypedActorRef(RemoteTypedActorRefProtocol.newBuilder.mergeFrom(bytes).build, None) - - /** - * Deserializes a byte array (Array[Byte]) into a AW RemoteActorRef proxy. - */ - def fromBinaryToRemoteTypedActorRef[T <: AnyRef](bytes: Array[Byte], loader: ClassLoader): T = - fromProtobufToRemoteTypedActorRef(RemoteTypedActorRefProtocol.newBuilder.mergeFrom(bytes).build, Some(loader)) - - /** - * Serialize as AW RemoteActorRef proxy. - */ - def toBinary[T <: Actor](proxy: AnyRef): Array[Byte] = { - toRemoteTypedActorRefProtocol(proxy).toByteArray - } - - /** - * Deserializes a RemoteTypedActorRefProtocol Protocol Buffers (protobuf) Message into AW RemoteActorRef proxy. - */ - private[akka] def fromProtobufToRemoteTypedActorRef[T](protocol: RemoteTypedActorRefProtocol, loader: Option[ClassLoader]): T = { - val actorRef = RemoteActorSerialization.fromProtobufToRemoteActorRef(protocol.getActorRef, loader) - val intfClass = TypedActorSerialization.toClass(loader, protocol.getInterfaceName) - TypedActor.createProxyForRemoteActorRef(intfClass, actorRef).asInstanceOf[T] - } - - /** - * Serializes the AW TypedActor proxy into a Protocol Buffers (protobuf) Message. - */ - def toRemoteTypedActorRefProtocol(proxy: AnyRef): RemoteTypedActorRefProtocol = { - val init = AspectInitRegistry.initFor(proxy) - RemoteTypedActorRefProtocol.newBuilder - .setActorRef(RemoteActorSerialization.toRemoteActorRefProtocol(init.actorRef)) - .setInterfaceName(init.interfaceClass.getName) - .build - } -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedActorOne.java b/akka-remote/src/test/java/akka/actor/RemoteTypedActorOne.java deleted file mode 100644 index 83303d031a..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedActorOne.java +++ /dev/null @@ -1,6 +0,0 @@ -package akka.actor; - -public interface RemoteTypedActorOne { - public String requestReply(String s) throws Exception; - public void oneWay() throws Exception; -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedActorOneImpl.java b/akka-remote/src/test/java/akka/actor/RemoteTypedActorOneImpl.java deleted file mode 100644 index 41d4bbe395..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedActorOneImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package akka.actor.remote; - -import akka.actor.*; - -import java.util.concurrent.CountDownLatch; - -public class RemoteTypedActorOneImpl extends TypedActor implements RemoteTypedActorOne { - - public static CountDownLatch latch = new CountDownLatch(1); - - public String requestReply(String s) throws Exception { - if (s.equals("ping")) { - RemoteTypedActorLog.messageLog().put("ping"); - return "pong"; - } else if (s.equals("die")) { - throw new RuntimeException("Expected exception; to test fault-tolerance"); - } else return null; - } - - public void oneWay() throws Exception { - RemoteTypedActorLog.oneWayLog().put("oneway"); - } - - @Override - public void preRestart(Throwable e) { - try { RemoteTypedActorLog.messageLog().put(e.getMessage()); } catch(Exception ex) {} - latch.countDown(); - } -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwo.java b/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwo.java deleted file mode 100644 index 25da478284..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwo.java +++ /dev/null @@ -1,6 +0,0 @@ -package akka.actor; - -public interface RemoteTypedActorTwo { - public String requestReply(String s) throws Exception; - public void oneWay() throws Exception; -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwoImpl.java b/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwoImpl.java deleted file mode 100644 index d36deb8011..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedActorTwoImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package akka.actor.remote; - -import akka.actor.*; - -import java.util.concurrent.CountDownLatch; - -public class RemoteTypedActorTwoImpl extends TypedActor implements RemoteTypedActorTwo { - - public static CountDownLatch latch = new CountDownLatch(1); - - public String requestReply(String s) throws Exception { - if (s.equals("ping")) { - RemoteTypedActorLog.messageLog().put("ping"); - return "pong"; - } else if (s.equals("die")) { - throw new RuntimeException("Expected exception; to test fault-tolerance"); - } else return null; - } - - public void oneWay() throws Exception { - RemoteTypedActorLog.oneWayLog().put("oneway"); - } - - @Override - public void preRestart(Throwable e) { - try { RemoteTypedActorLog.messageLog().put(e.getMessage()); } catch(Exception ex) {} - latch.countDown(); - } -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActor.java b/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActor.java deleted file mode 100644 index 8a6c2e6373..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActor.java +++ /dev/null @@ -1,8 +0,0 @@ -package akka.actor; - -public interface RemoteTypedSessionActor { - - public void login(String user); - public String getUser(); - public void doSomethingFunny() throws Exception; -} diff --git a/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActorImpl.java b/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActorImpl.java deleted file mode 100644 index b4140f74ed..0000000000 --- a/akka-remote/src/test/java/akka/actor/RemoteTypedSessionActorImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package akka.actor.remote; - -import akka.actor.*; - -import java.util.Set; -import java.util.HashSet; - -import java.util.concurrent.CountDownLatch; - -public class RemoteTypedSessionActorImpl extends TypedActor implements RemoteTypedSessionActor { - - - private static Set instantiatedSessionActors = new HashSet(); - - public static Set getInstances() { - return instantiatedSessionActors; - } - - @Override - public void preStart() { - instantiatedSessionActors.add(this); - } - - @Override - public void postStop() { - instantiatedSessionActors.remove(this); - } - - - private String user="anonymous"; - - @Override - public void login(String user) { - this.user = user; - } - - @Override - public String getUser() - { - return this.user; - } - - @Override - public void doSomethingFunny() throws Exception - { - throw new Exception("Bad boy"); - } - -} diff --git a/akka-remote/src/test/java/akka/actor/ticket855/Ticket855Service.java b/akka-remote/src/test/java/akka/actor/ticket855/Ticket855Service.java deleted file mode 100644 index f997a77b13..0000000000 --- a/akka-remote/src/test/java/akka/actor/ticket855/Ticket855Service.java +++ /dev/null @@ -1,7 +0,0 @@ -package akka.actor.ticket855; - -import akka.dispatch.Future; - -public interface Ticket855Service { - Future callAndWait(String message, Long wait); -} diff --git a/akka-remote/src/test/java/akka/actor/ticket855/Ticket855ServiceImpl.java b/akka-remote/src/test/java/akka/actor/ticket855/Ticket855ServiceImpl.java deleted file mode 100644 index cca1a0e9f4..0000000000 --- a/akka-remote/src/test/java/akka/actor/ticket855/Ticket855ServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package akka.actor.ticket855; -import akka.actor.TypedActor; -import akka.dispatch.Future; - -public class Ticket855ServiceImpl extends TypedActor implements Ticket855Service { - - public Ticket855ServiceImpl() {} - - public Future callAndWait(final String message, final Long wait) { - try { - Thread.sleep(wait); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return future("x: " + message); - } -} diff --git a/akka-remote/src/test/scala/Issue855Spec.scala b/akka-remote/src/test/scala/Issue855Spec.scala deleted file mode 100644 index 53606f6e8c..0000000000 --- a/akka-remote/src/test/scala/Issue855Spec.scala +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import org.scalatest.matchers.MustMatchers -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith -import akka.config.TypedActorConfigurator -import akka.dispatch.Dispatchers -import ticket855.{ Ticket855ServiceImpl, Ticket855Service } -import akka.routing.CyclicIterator -import org.scalatest.{ BeforeAndAfterAll, WordSpec, BeforeAndAfterEach } -import akka.util.Duration - -@RunWith(classOf[JUnitRunner]) -class Issue855Spec extends WordSpec with MustMatchers with BeforeAndAfterEach with BeforeAndAfterAll { - - import akka.actor.Actor._ - - override def afterEach { - // registry.local.shutdownAll() - // remote.shutdown - } - - "TypedActors with Future return types" must { - "must work for Remote Typed Actors" in { - - /* remote.start - Thread.sleep(500) - - val configuration = new TypedActorConfiguration - - configuration.timeout(Duration(6600L,"ms")) - - configuration.dispatcher(Dispatchers.newExecutorBasedEventDrivenDispatcher("pooled-dispatcher") - .withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity - .setCorePoolSize(60) - .setMaxPoolSize(60) - .build) - - for(i <- 0 to 60) - remote.registerTypedActor("ticket855-" + i, - TypedActor.newInstance(classOf[Ticket855Service], classOf[Ticket855ServiceImpl], configuration)) - - val address = remote.address - - val iterator = new CyclicIterator(for(i <- 1 to 60) yield remote.typedActorFor(classOf[Ticket855Service], "ticket855-" + i, 6600L, address.getAddress.getHostName, address.getPort)) - - val results = for(i <- 1 to 120) yield (i, iterator.next.callAndWait("ping - " + i, 200L)) - - for((i,r) <- results) assert(r.get === "x: ping - " + i)*/ - } - - "must work for Local Typed Actors" in { - - /*val configuration = new TypedActorConfiguration - - configuration.timeout(Duration(6600L,"ms")) - - configuration.dispatcher(Dispatchers.newExecutorBasedEventDrivenDispatcher("pooled-dispatcher") - .withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity - .setCorePoolSize(60) - .setMaxPoolSize(60) - .build) - - val iterator = new CyclicIterator(for(i <- 1 to 60) yield TypedActor.newInstance(classOf[Ticket855Service], classOf[Ticket855ServiceImpl], configuration)) - - val results = for(i <- 1 to 120) yield (i, iterator.next.callAndWait("ping - " + i, 200L)) - - for((i,r) <- results) assert(r.get === "x: ping - " + i) */ - } - } -} diff --git a/akka-remote/src/test/scala/remote/RemoteTypedActorSpec.scala b/akka-remote/src/test/scala/remote/RemoteTypedActorSpec.scala deleted file mode 100644 index ac61ee79d5..0000000000 --- a/akka-remote/src/test/scala/remote/RemoteTypedActorSpec.scala +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor.remote - -import java.util.concurrent.{ LinkedBlockingQueue, TimeUnit, BlockingQueue } -import akka.config.{ RemoteAddress, Config, TypedActorConfigurator } - -object RemoteTypedActorLog { - val messageLog: BlockingQueue[String] = new LinkedBlockingQueue[String] - val oneWayLog = new LinkedBlockingQueue[String] - - def clearMessageLogs { - messageLog.clear - oneWayLog.clear - } -} - -class RemoteTypedActorSpec extends AkkaRemoteTest { - - "RemoteModule Typed Actor " should { - "have unit tests" in { - } - } -} diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedActorSpec.scala deleted file mode 100644 index 642d69aa9a..0000000000 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedActorSpec.scala +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor.remote - -import java.util.concurrent.TimeUnit - -import akka.actor._ -import RemoteTypedActorLog._ - -class ServerInitiatedRemoteTypedActorSpec extends AkkaRemoteTest { - - override def beforeEach = { - super.beforeEach - val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000) - remote.registerTypedActor("typed-actor-service", typedActor) - } - - override def afterEach { - super.afterEach - clearMessageLogs - } - - def createRemoteActorRef = remote.typedActorFor(classOf[RemoteTypedActorOne], "typed-actor-service", 5000L, host, port) - - "Server managed remote typed Actor " should { - /* - "receive one-way message" in { - val actor = createRemoteActorRef - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - } - - "should respond to request-reply message" in { - val actor = createRemoteActorRef - actor.requestReply("ping") must equal ("pong") - } - - "should not recreate registered actors" in { - val actor = createRemoteActorRef - val numberOfActorsInRegistry = Actor.registry.local.actors.length - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - numberOfActorsInRegistry must be (Actor.registry.local.actors.length) - } - - "should support multiple variants to get the actor from client side" in { - var actor = createRemoteActorRef - - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - - actor = remote.typedActorFor(classOf[RemoteTypedActorOne], "typed-actor-service", host, port) - - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - - actor = remote.typedActorFor(classOf[RemoteTypedActorOne], "typed-actor-service", 5000L, host, port, this.getClass().getClassLoader) - - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - } - - "should register and unregister typed actors" in { - val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000) - remote.registerTypedActor("my-test-service", typedActor) - remote.typedActors.get("my-test-service") must not be (null) - remote.unregisterTypedActor("my-test-service") - remote.typedActors.get("my-test-service") must be (null) - } - - "should register and unregister typed actors by uuid" in { - val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000) - val init = AspectInitRegistry.initFor(typedActor) - val uuid = "uuid:" + init.actorRef.uuid - - remote.registerTypedActor(uuid, typedActor) - remote.typedActorsByUuid.get(init.actorRef.uuid.toString) must not be (null) - - remote.unregisterTypedActor(uuid) - remote.typedActorsByUuid.get(init.actorRef.uuid.toString) must be (null) - } - - "should find typed actors by uuid" in { - val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000) - val init = AspectInitRegistry.initFor(typedActor) - val uuid = "uuid:" + init.actorRef.uuid - - remote.registerTypedActor(uuid, typedActor) - remote.typedActorsByUuid.get(init.actorRef.uuid.toString) must not be (null) - - val actor = remote.typedActorFor(classOf[RemoteTypedActorOne], uuid, host, port) - actor.oneWay - oneWayLog.poll(5, TimeUnit.SECONDS) must equal ("oneway") - } - */ - } -} - diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala deleted file mode 100644 index 4b48df60ef..0000000000 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor.remote - -import akka.actor._ -import RemoteTypedActorLog._ - -class ServerInitiatedRemoteTypedSessionActorSpec extends AkkaRemoteTest { - - override def beforeEach = { - super.beforeEach - - remote.registerTypedPerSessionActor("typed-session-actor-service", - TypedActor.newInstance(classOf[RemoteTypedSessionActor], classOf[RemoteTypedSessionActorImpl], 1000)) - } - - // make sure the servers shutdown cleanly after the test has finished - override def afterEach() { - super.afterEach() - clearMessageLogs - } - - "A remote session Actor" should { - /* - "create a new session actor per connection" in { - - val session1 = remote.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, host, port) - - session1.getUser() must equal ("anonymous") - session1.login("session[1]") - session1.getUser() must equal ("session[1]") - - remote.shutdownClientModule() - - val session2 = remote.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, host, port) - - session2.getUser() must equal ("anonymous") - - } - - "stop the actor when the client disconnects" in { - val session1 = remote.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, host, port) - - session1.getUser() must equal ("anonymous") - - RemoteTypedSessionActorImpl.getInstances() must have size (1) - remote.shutdownClientModule() - Thread.sleep(1000) - RemoteTypedSessionActorImpl.getInstances() must have size (0) - - } - - "stop the actor when there is an error" in { - val session1 = remote.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, host, port) - - session1.doSomethingFunny() - - remote.shutdownClientModule() - Thread.sleep(1000) - RemoteTypedSessionActorImpl.getInstances() must have size (0) - } - - - "be able to unregister" in { - remote.registerTypedPerSessionActor("my-service-1",TypedActor.newInstance(classOf[RemoteTypedSessionActor], classOf[RemoteTypedSessionActorImpl], 1000)) - - remote.typedActorsFactories.get("my-service-1") must not be (null) - remote.unregisterTypedPerSessionActor("my-service-1") - remote.typedActorsFactories.get("my-service-1") must be (null) - } - */ - } -} - diff --git a/akka-remote/src/test/scala/serialization/TypedActorSerializationSpec.scala b/akka-remote/src/test/scala/serialization/TypedActorSerializationSpec.scala deleted file mode 100644 index b241d9976f..0000000000 --- a/akka-remote/src/test/scala/serialization/TypedActorSerializationSpec.scala +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor.serialization - -import akka.serialization._ -import akka.actor._ - -import TypedActorSerialization._ -import Actor._ -import akka.actor.remote.ServerInitiatedRemoteActorSpec.RemoteActorSpecActorUnidirectional -import akka.actor.remote.AkkaRemoteTest - -class TypedActorSerializationSpec extends AkkaRemoteTest { - object MyTypedStatelessActorFormat extends StatelessActorFormat[MyStatelessTypedActorImpl] - - class MyTypedActorFormat extends Format[MyTypedActorImpl] { - def fromBinary(bytes: Array[Byte], act: MyTypedActorImpl) = { - val p = Serializers.Protobuf.fromBinary(bytes, Some(classOf[ProtobufProtocol.Counter])).asInstanceOf[ProtobufProtocol.Counter] - act.count = p.getCount - act - } - def toBinary(ac: MyTypedActorImpl) = - ProtobufProtocol.Counter.newBuilder.setCount(ac.count).build.toByteArray - } - - class MyTypedActorWithDualCounterFormat extends Format[MyTypedActorWithDualCounter] { - def fromBinary(bytes: Array[Byte], act: MyTypedActorWithDualCounter) = { - val p = Serializers.Protobuf.fromBinary(bytes, Some(classOf[ProtobufProtocol.DualCounter])).asInstanceOf[ProtobufProtocol.DualCounter] - act.count1 = p.getCount1 - act.count2 = p.getCount2 - act - } - def toBinary(ac: MyTypedActorWithDualCounter) = - ProtobufProtocol.DualCounter.newBuilder.setCount1(ac.count1).setCount2(ac.count2).build.toByteArray - } - - "Serializable typed actor" should { - /* - "should be able to serialize and de-serialize a stateless typed actor" in { - val typedActor1 = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyStatelessTypedActorImpl], 1000) - typedActor1.requestReply("hello") must equal("world") - typedActor1.requestReply("hello") must equal("world") - - val bytes = toBinaryJ(typedActor1, MyTypedStatelessActorFormat) - val typedActor2: MyTypedActor = fromBinaryJ(bytes, MyTypedStatelessActorFormat) - typedActor2.requestReply("hello") must equal("world") - } - - "should be able to serialize and de-serialize a stateful typed actor" in { - val typedActor1 = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyTypedActorImpl], 1000) - typedActor1.requestReply("hello") must equal("world 1") - typedActor1.requestReply("scala") must equal("hello scala 2") - - val f = new MyTypedActorFormat - val bytes = toBinaryJ(typedActor1, f) - val typedActor2: MyTypedActor = fromBinaryJ(bytes, f) - typedActor2.requestReply("hello") must equal("world 3") - } - - "should be able to serialize and de-serialize a stateful typed actor with compound state" in { - val typedActor1 = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyTypedActorWithDualCounter], 1000) - typedActor1.requestReply("hello") must equal("world 1 1") - typedActor1.requestReply("hello") must equal("world 2 2") - - val f = new MyTypedActorWithDualCounterFormat - val bytes = toBinaryJ(typedActor1, f) - val typedActor2: MyTypedActor = fromBinaryJ(bytes, f) - typedActor2.requestReply("hello") must equal("world 3 3") - } - - "should be able to serialize a local typed actor ref to a remote typed actor ref proxy" in { - val typedActor1 = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyStatelessTypedActorImpl], 1000) - typedActor1.requestReply("hello") must equal("world") - typedActor1.requestReply("hello") must equal("world") - - val bytes = RemoteTypedActorSerialization.toBinary(typedActor1) - val typedActor2: MyTypedActor = RemoteTypedActorSerialization.fromBinaryToRemoteTypedActorRef(bytes) - typedActor1.requestReply("hello") must equal("world") - } - */ - } -} - -trait MyTypedActor { - def requestReply(s: String): String - def oneWay(): Unit -} - -class MyTypedActorImpl extends TypedActor with MyTypedActor { - var count = 0 - - override def oneWay() { - println("got oneWay message") - } - - override def requestReply(message: String): String = { - count = count + 1 - if (message == "hello") { - "world " + count - } else ("hello " + message + " " + count) - } -} - -class MyTypedActorWithDualCounter extends TypedActor with MyTypedActor { - var count1 = 0 - var count2 = 0 - - override def oneWay() { - println("got oneWay message") - } - - override def requestReply(message: String): String = { - count1 = count1 + 1 - count2 = count2 + 1 - - if (message == "hello") { - "world " + count1 + " " + count2 - } else ("hello " + message + " " + count1 + " " + count2) - } -} - -class MyStatelessTypedActorImpl extends TypedActor with MyTypedActor { - - override def oneWay() { - println("got oneWay message") - } - - override def requestReply(message: String): String = { - if (message == "hello") "world" else ("hello " + message) - } -} diff --git a/akka-typed-actor/src/main/java/akka/config/DependencyBinding.java b/akka-typed-actor/src/main/java/akka/config/DependencyBinding.java deleted file mode 100644 index 5fd43d99e2..0000000000 --- a/akka-typed-actor/src/main/java/akka/config/DependencyBinding.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.config; - -/** - * @author Jonas Bonér - */ -public class DependencyBinding { - private final Class intf; - private final Object target; - - public DependencyBinding(final Class intf, final Object target) { - this.intf = intf; - this.target = target; - } - public Class getInterface() { - return intf; - } - public Object getTarget() { - return target; - } -} diff --git a/akka-typed-actor/src/main/java/akka/config/TypedActorGuiceModule.java b/akka-typed-actor/src/main/java/akka/config/TypedActorGuiceModule.java deleted file mode 100644 index 2452eeb706..0000000000 --- a/akka-typed-actor/src/main/java/akka/config/TypedActorGuiceModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.config; - -import java.util.List; - -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; -//import com.google.inject.jsr250.ResourceProviderFactory; - -/** - * @author Jonas Bonér - */ -public class TypedActorGuiceModule extends AbstractModule { - private final List bindings; - - public TypedActorGuiceModule(final List bindings) { - this.bindings = bindings; - } - - protected void configure() { - //bind(ResourceProviderFactory.class); - for (int i = 0; i < bindings.size(); i++) { - final DependencyBinding db = bindings.get(i); - //if (db.getInterface() ne null) bind((Class) db.getInterface()).to((Class) db.getTarget()).in(Singleton.class); - //else - - @SuppressWarnings("unchecked") - Class intf = db.getInterface(); - this.bind(intf).toInstance(db.getTarget()); - } - } -} diff --git a/akka-typed-actor/src/main/java/akka/transactor/annotation/Coordinated.java b/akka-typed-actor/src/main/java/akka/transactor/annotation/Coordinated.java deleted file mode 100644 index 326f45ae71..0000000000 --- a/akka-typed-actor/src/main/java/akka/transactor/annotation/Coordinated.java +++ /dev/null @@ -1,7 +0,0 @@ -package akka.transactor.annotation; - -import java.lang.annotation.*; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Coordinated { } diff --git a/akka-typed-actor/src/main/resources/META-INF/aop.xml b/akka-typed-actor/src/main/resources/META-INF/aop.xml deleted file mode 100644 index 85882c299d..0000000000 --- a/akka-typed-actor/src/main/resources/META-INF/aop.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala deleted file mode 100644 index 81e3de54b7..0000000000 --- a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala +++ /dev/null @@ -1,972 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import Actor._ -import akka.config.Supervision._ -import akka.util._ -import ReflectiveAccess._ -import akka.transactor.{ Coordinated, Coordination, CoordinateException } -import akka.transactor.annotation.{ Coordinated ⇒ CoordinatedAnnotation } - -import org.codehaus.aspectwerkz.joinpoint.{ MethodRtti, JoinPoint } -import org.codehaus.aspectwerkz.proxy.Proxy -import org.codehaus.aspectwerkz.annotation.{ Aspect, Around } - -import java.net.InetSocketAddress -import java.lang.reflect.{ Method, Field, InvocationHandler, Proxy ⇒ JProxy } - -import scala.reflect.BeanProperty -import akka.dispatch._ - -/** - * TypedActor is a type-safe actor made out of a POJO with interface. - * Void methods are turned into fire-forget messages. - * Non-void methods are turned into request-reply messages with the exception of methods returning - * a 'Future' which will be sent using request-reply-with-future semantics and need to return the - * result using the 'future(..)' method: 'return future(... future result ...);'. - * Methods returning akka.japi.Option will block until a timeout expires, - * if the implementation of the method returns "none", some(null) will be returned, "none" will only be - * returned when the method didn't respond within the timeout. - * - * Here is an example of usage (in Java): - *
- * class TestActorImpl extends TypedActor implements TestActor {
- *
- *   public void hit(int count) {
- *     Pong pong = (Pong) context().sender();
- *     pong.hit(count++);
- *   }
- *
- *   public Future square(int x) {
- *     return future(x * x);
- *   }
- *
- *   @Override
- *   public void preStart() {
- *     ... // optional initialization on start
- *   }
- *
- *   @Override
- *   public void postStop() {
- *     ... // optional cleanup on stop
- *   }
- *
- *   ... // more life-cycle callbacks if needed
- * }
- *
- * // create the ping actor
- * TestActor actor = TypedActor.newInstance(TestActor.class, TestActorImpl.class);
- *
- * actor.hit(1); // use the actor
- * actor.hit(1);
- *
- * // This method will return immediately when called, caller should wait on the Future for the result
- * Future future = actor.square(10);
- * future.await();
- * Integer result = future.get();
- *
- * // stop the actor
- * TypedActor.stop(actor);
- * 
- * - * Here is an example of usage (in Scala): - *
- * class TestActorImpl extends TypedActor with TestActor {
- *
- *   def hit(count: Int) = {
- *     val pong = context.sender.asInstanceOf[Pong]
- *     pong.hit(count += 1)
- *   }
- *
- *   def square(x: Int): Future[Integer] = future(x * x)
- *
- *   override def preStart() = {
- *     ... // optional initialization on start
- *   }
- *
- *   override def postStop() = {
- *     ... // optional cleanup on stop
- *   }
- *
- *   ... // more life-cycle callbacks if needed
- * }
- *
- * // create the ping actor
- * val ping = TypedActor.newInstance(classOf[Ping], classOf[PingImpl])
- *
- * ping.hit(1) // use the actor
- * ping.hit(1)
- *
- * // This method will return immediately when called, caller should wait on the Future for the result
- * val future = actor.square(10)
- * future.await
- * val result: Int = future.get
- *
- * // stop the actor
- * TypedActor.stop(ping)
- * 
- * - * @author Jonas Bonér - */ -abstract class TypedActor extends Actor with Proxyable { - val DELEGATE_FIELD_NAME = "DELEGATE_0".intern - - @volatile - private[akka] var proxy: AnyRef = _ - @volatile - private var proxyDelegate: Field = _ - - /** - * Holds RTTI (runtime type information) for the TypedActor, f.e. current 'sender' - * reference, the 'senderFuture' reference etc. - *

- * This class does not contain static information but is updated by the runtime system - * at runtime. - *

- * You can get a hold of the context using the 'context()' - * method from the 'TypedActor' base class. - *

- * - * Here is an example of usage (in Java): - *

-   * class PingImpl extends TypedActor implements Ping {
-   *   public void hit(int count) {
-   *     Pong pong = (Pong) context().sender();
-   *     pong.hit(count++);
-   *   }
-   * }
-   * 
- * - * Here is an example of usage (in Scala): - *
-   * class PingImpl extends TypedActor with Ping {
-   *   def hit(count: Int) = {
-   *     val pong = context.sender.asInstanceOf[Pong]
-   *     pong.hit(count += 1)
-   *   }
-   * }
-   * 
- */ - val context: TypedActorContext = new TypedActorContext(self) - - /** - * @deprecated 'getContext()' is deprecated use 'context()' - */ - def getContext: TypedActorContext = context - - /** - * User overridable callback. - *

- * Is called when an Actor is started by invoking 'actor.start()'. - */ - override def preStart() {} - - /** - * User overridable callback. - *

- * Is called when 'actor.stop()' is invoked. - */ - override def postStop() {} - - /** - * User overridable callback. - *

- * Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated. - */ - override def preRestart(reason: Throwable) {} - - /** - * User overridable callback. - *

- * Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash. - */ - override def postRestart(reason: Throwable) {} - - /** - * This method is used to resolve the Future for TypedActor methods that are defined to return a - * {@link akka.actor.dispatch.Future }. - *

- * Here is an example: - *

-   *   class MyTypedActorImpl extends TypedActor implements MyTypedActor {
-   *     public Future square(int x) {
-   *       return future(x * x);
-   *    }
-   *  }
-   *
-   *  MyTypedActor actor = TypedActor.actorOf(MyTypedActor.class, MyTypedActorImpl.class);
-   *
-   *  // This method will return immediately when called, caller should wait on the Future for the result
-   *  Future future = actor.square(10);
-   *  future.await();
-   *  Integer result = future.get();
-   * 
- */ - def future[T](value: T): Future[T] = - self.senderFuture.get.asInstanceOf[CompletableFuture[T]] completeWithResult value - - def receive = { - case joinPoint: JoinPoint ⇒ - SenderContextInfo.senderActorRef.withValue(self) { - SenderContextInfo.senderProxy.withValue(proxy) { - if (Actor.SERIALIZE_MESSAGES) serializeArguments(joinPoint) - if (TypedActor.isOneWay(joinPoint)) joinPoint.proceed - else if (TypedActor.returnsFuture_?(joinPoint)) { - joinPoint.proceed match { - case f: Future[Any] ⇒ self.senderFuture.get.completeWith(f) - case null ⇒ self.reply(null) - } - } else self.reply(joinPoint.proceed) - } - } - - case coordinated@Coordinated(joinPoint: JoinPoint) ⇒ - SenderContextInfo.senderActorRef.withValue(self) { - SenderContextInfo.senderProxy.withValue(proxy) { - if (Actor.SERIALIZE_MESSAGES) serializeArguments(joinPoint) - coordinated atomic { joinPoint.proceed } - } - } - - case Link(proxy) ⇒ self.link(proxy) - case Unlink(proxy) ⇒ self.unlink(proxy) - case unexpected ⇒ throw new IllegalActorStateException( - "Unexpected message [" + unexpected + "] sent to [" + this + "]") - } - - /** - * Rewrite target instance in AspectWerkz Proxy. - */ - private[actor] def swapProxiedActor(newInstance: Actor) = proxyDelegate.set(proxy, newInstance) - - private[akka] def initialize(typedActorProxy: AnyRef) = { - proxy = typedActorProxy - proxyDelegate = { - val field = proxy.getClass.getDeclaredField(DELEGATE_FIELD_NAME) - field.setAccessible(true) - field - } - } - - private def serializeArguments(joinPoint: JoinPoint) = { - val args = joinPoint.getRtti.asInstanceOf[MethodRtti].getParameterValues - var unserializable = false - var hasMutableArgument = false - for (arg ← args.toList) { - if (!arg.isInstanceOf[String] && - !arg.isInstanceOf[Byte] && - !arg.isInstanceOf[Int] && - !arg.isInstanceOf[Long] && - !arg.isInstanceOf[Float] && - !arg.isInstanceOf[Double] && - !arg.isInstanceOf[Boolean] && - !arg.isInstanceOf[Char] && - !arg.isInstanceOf[java.lang.Byte] && - !arg.isInstanceOf[java.lang.Integer] && - !arg.isInstanceOf[java.lang.Long] && - !arg.isInstanceOf[java.lang.Float] && - !arg.isInstanceOf[java.lang.Double] && - !arg.isInstanceOf[java.lang.Boolean] && - !arg.isInstanceOf[java.lang.Character]) hasMutableArgument = true - if (arg.getClass.getName.contains(TypedActor.AW_PROXY_PREFIX)) unserializable = true - } - if (!unserializable && hasMutableArgument) { - - //FIXME serializeArguments - // val copyOfArgs = Serializers.Java.deepClone(args) - // joinPoint.getRtti.asInstanceOf[MethodRtti].setParameterValues(copyOfArgs.asInstanceOf[Array[AnyRef]]) - joinPoint - } - } -} - -/** - * Holds RTTI (runtime type information) for the TypedActor, f.e. current 'sender' - * reference, the 'senderFuture' reference etc. - *

- * This class does not contain static information but is updated by the runtime system - * at runtime. - *

- * You can get a hold of the context using either the 'getContext()' or 'context' - * methods from the 'TypedActor' base class. - *

- * Here is an example of usage (from Java): - *

- * class PingImpl extends TypedActor implements Ping {
- *   public void hit(int count) {
- *     Pong pong = (Pong) context().sender();
- *     pong.hit(count++);
- *   }
- * }
- * 
- * - * Here is an example of usage (in Scala): - *
- * class PingImpl extends TypedActor with Ping {
- *   def hit(count: Int) = {
- *     val pong = context.sender.asInstanceOf[Pong]
- *     pong.hit(count += 1)
- *   }
- * }
- * 
- * - * @author Jonas Bonér - */ -final class TypedActorContext(private[akka] val actorRef: ActorRef) { - private[akka] var _sender: AnyRef = _ - - /** - * Returns the uuid for the actor. - */ - def uuid = actorRef.uuid - - def address = actorRef.address - - def receiveTimeout = actorRef.receiveTimeout - - def setReceiveTimeout(timeout: Long) = actorRef.setReceiveTimeout(timeout) - - def mailboxSize = actorRef.mailboxSize - - def dispatcher = actorRef.getDispatcher - - def lifeCycle = actorRef.getLifeCycle - - def isRunning: Boolean = actorRef.isRunning - def isShutdown: Boolean = actorRef.isShutdown - def isUnstarted: Boolean = actorRef.isUnstarted - def isBeingRestarted: Boolean = actorRef.isBeingRestarted - - def getSelfAs[T <: AnyRef](): T = TypedActor.proxyFor(actorRef).get.asInstanceOf[T] - def getSelf(): AnyRef = getSelfAs[AnyRef] - - /** - * Returns the current sender reference. - * Scala style getter. - */ - def sender: AnyRef = { - if (_sender eq null) throw new IllegalActorStateException("Sender reference should not be null.") - else _sender - } - - /** - * Returns the current sender future TypedActor reference. - * Scala style getter. - */ - def senderFuture: Option[CompletableFuture[Any]] = actorRef.senderFuture - - /** - * Returns the current sender reference. - * Java style getter. - * @deprecated use 'sender()' - */ - def getSender: AnyRef = { - if (_sender eq null) throw new IllegalActorStateException("Sender reference should not be null.") - else _sender - } - - /** - * Returns the current sender future TypedActor reference. - * Java style getter. - * This method returns 'null' if the sender future is not available. - * @deprecated use 'senderFuture()' - */ - def getSenderFuture = senderFuture -} - -object TypedActorConfiguration { - - def apply(): TypedActorConfiguration = { - new TypedActorConfiguration() - } - - def apply(timeoutMillis: Long): TypedActorConfiguration = { - new TypedActorConfiguration().timeout(Duration(timeoutMillis, "millis")) - } - - def apply(timeout: Duration): TypedActorConfiguration = { - new TypedActorConfiguration().timeout(timeout) - } -} - -/** - * Configuration factory for TypedActors. - * - * @author Jonas Bonér - */ -final class TypedActorConfiguration { - private[akka] var _timeout: Long = Actor.TIMEOUT - private[akka] var _messageDispatcher: Option[MessageDispatcher] = None - private[akka] var _threadBasedDispatcher: Option[Boolean] = None - - def timeout = _timeout - def timeout(timeout: Duration): TypedActorConfiguration = { - _timeout = timeout.toMillis - this - } - - def dispatcher(messageDispatcher: MessageDispatcher): TypedActorConfiguration = { - if (_threadBasedDispatcher.isDefined) throw new IllegalArgumentException( - "Cannot specify both 'threadBasedDispatcher()' and 'dispatcher()'") - _messageDispatcher = Some(messageDispatcher) - this - } - - def threadBasedDispatcher(): TypedActorConfiguration = { - if (_messageDispatcher.isDefined) throw new IllegalArgumentException( - "Cannot specify both 'threadBasedDispatcher()' and 'dispatcher()'") - _threadBasedDispatcher = Some(true) - this - } -} - -/** - * Factory closure for an TypedActor, to be used with 'TypedActor.newInstance(interface, factory)'. - * - * @author michaelkober - */ -trait TypedActorFactory { - def create: TypedActor -} - -/** - * Factory class for creating TypedActors out of plain POJOs and/or POJOs with interfaces. - * - * @author Jonas Bonér - */ -object TypedActor { - import Actor.actorOf - - val ZERO_ITEM_CLASS_ARRAY = Array[Class[_]]() - val ZERO_ITEM_OBJECT_ARRAY = Array[Object]() - - val AKKA_CAMEL_ROUTING_SCHEME = "akka".intern - val AW_PROXY_PREFIX = "$$ProxiedByAW".intern - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param targetClass implementation class of the typed actor - */ - def newInstance[T](intfClass: Class[T], targetClass: Class[_]): T = - newInstance(intfClass, targetClass, TypedActorConfiguration()) - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param factory factory method that constructs the typed actor - */ - def newInstance[T](intfClass: Class[T], factory: ⇒ AnyRef): T = { - newInstance(intfClass, factory, TypedActorConfiguration()) - } - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param factory factory method that constructs the typed actor - * @param config configuration object for the typed actor - */ - def newInstance[T](intfClass: Class[T], factory: ⇒ AnyRef, config: TypedActorConfiguration): T = - newInstance(intfClass, actorOf(newTypedActor(factory)), config) - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param targetClass implementation class of the typed actor - * @param config configuration object for the typed actor - */ - def newInstance[T](intfClass: Class[T], targetClass: Class[_], config: TypedActorConfiguration): T = - newInstance(intfClass, actorOf(newTypedActor(targetClass)), config) - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param targetClass implementation class of the typed actor - * @param timeout timeout for future - */ - def newInstance[T](intfClass: Class[T], targetClass: Class[_], timeout: Long): T = { - newInstance(intfClass, targetClass, TypedActorConfiguration(timeout)) - } - - /** - * Factory method for typed actor. - * @param intfClass interface the typed actor implements - * @param factory factory method that constructs the typed actor - * @param timeout timeout for future - */ - def newInstance[T](intfClass: Class[T], factory: ⇒ AnyRef, timeout: Long): T = { - newInstance(intfClass, factory, TypedActorConfiguration(timeout)) - } - - private[akka] def newInstance[T](intfClass: Class[T], actorRef: ActorRef): T = { - if (!actorRef.actorInstance.get.isInstanceOf[TypedActor]) throw new IllegalArgumentException("ActorRef is not a ref to a typed actor") - newInstance(intfClass, actorRef, TypedActorConfiguration()) - } - - private[akka] def newInstance[T](intfClass: Class[T], targetClass: Class[_], - remoteAddress: Option[InetSocketAddress], timeout: Long): T = - newInstance(intfClass, targetClass, TypedActorConfiguration(timeout)) - - private def newInstance[T](intfClass: Class[T], actorRef: ActorRef, config: TypedActorConfiguration): T = { - val typedActor = actorRef.actorInstance.get.asInstanceOf[TypedActor] - val proxy = Proxy.newInstance(Array(intfClass), Array(typedActor), true, false) - typedActor.initialize(proxy) - if (config._messageDispatcher.isDefined) actorRef.dispatcher = config._messageDispatcher.get - if (config._threadBasedDispatcher.isDefined) actorRef.dispatcher = Dispatchers.newThreadBasedDispatcher(actorRef) - - actorRef.timeout = config.timeout - - AspectInitRegistry.register(proxy, AspectInit(intfClass, typedActor, actorRef, actorRef.timeout)) - actorRef.start - proxy.asInstanceOf[T] - } - - /** - * Java API. - * NOTE: Use this convenience method with care, do NOT make it possible to get a reference to the - * TypedActor instance directly, but only through its 'ActorRef' wrapper reference. - *

- * Creates an ActorRef out of the Actor. Allows you to pass in the instance for the TypedActor. - * Only use this method when you need to pass in constructor arguments into the 'TypedActor'. - *

- * You use it by implementing the TypedActorFactory interface. - * Example in Java: - *

-   *   MyPojo pojo = TypedActor.newInstance(MyPojo.class, new TypedActorFactory() {
-   *     public TypedActor create() {
-   *       return new MyTypedActor("service:name", 5);
-   *     }
-   *   });
-   * 
- */ - def newInstance[T](intfClass: Class[T], factory: TypedActorFactory): T = - newInstance(intfClass, factory.create) - - /** - * Java API. - */ - // def newInstance[T](intfClass: Class[T], factory: TypedActorFactory, timeout: Long) : T = - // newInstance(intfClass, factory.create, timeout) - - /** - * Java API. - */ - def newInstance[T](intfClass: Class[T], factory: TypedActorFactory, config: TypedActorConfiguration): T = - newInstance(intfClass, factory.create, config) - - /** - * Create a proxy for a RemoteActorRef representing a server managed remote typed actor. - * - */ - private[akka] def createProxyForRemoteActorRef[T](intfClass: Class[T], actorRef: ActorRef): T = { - - class MyInvocationHandler extends InvocationHandler { - def invoke(proxy: AnyRef, method: Method, args: Array[AnyRef]): AnyRef = { - // do nothing, this is just a dummy - null - } - } - val handler = new MyInvocationHandler() - - val interfaces = Array(intfClass, classOf[ServerManagedTypedActor]).asInstanceOf[Array[java.lang.Class[_]]] - val jProxy = JProxy.newProxyInstance(intfClass.getClassLoader(), interfaces, handler) - val awProxy = Proxy.newInstance(interfaces, Array(jProxy, jProxy), true, false) - - AspectInitRegistry.register(awProxy, AspectInit(intfClass, null, actorRef, 5000L)) - awProxy.asInstanceOf[T] - } - - /* - // NOTE: currently not used - but keep it around - private[akka] def newInstance[T <: TypedActor](targetClass: Class[T], - remoteAddress: Option[InetSocketAddress], timeout: Long): T = { - val proxy = { - val instance = Proxy.newInstance(targetClass, true, false) - if (instance.isInstanceOf[TypedActor]) instance.asInstanceOf[TypedActor] - else throw new IllegalActorStateException("Actor [" + targetClass.getName + "] is not a sub class of 'TypedActor'") - } - val context = injectTypedActorContext(proxy) - actorRef.actor.asInstanceOf[Dispatcher].initialize(targetClass, proxy, proxy, context) - actorRef.timeout = timeout - if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get) - AspectInitRegistry.register(proxy, AspectInit(targetClass, proxy, actorRef, remoteAddress, timeout)) - actorRef.start() - proxy.asInstanceOf[T] - } - */ - - /** - * Stops the current Typed Actor. - */ - def stop(proxy: AnyRef): Unit = AspectInitRegistry.unregister(proxy) - - /** - * Get the underlying typed actor for the given Typed Actor. - */ - def actorFor(proxy: AnyRef): Option[ActorRef] = - Actor.registry.local find { - case a if a.actor.isInstanceOf[TypedActor] && a.actor.asInstanceOf[TypedActor].proxy == proxy ⇒ - a - } - - /** - * Get the typed actor proxy for the given Typed Actor. - */ - def proxyFor(actorRef: ActorRef): Option[AnyRef] = { - if (actorRef.actor.isInstanceOf[TypedActor]) { - Some(actorRef.actor.asInstanceOf[TypedActor].proxy) - } else { - None - } - } - - /** - * Links an other Typed Actor to this Typed Actor. - * - * Example linking another typed actor from within a typed actor: - *
-   *   TypedActor.link(TypedActor.proxyFor(this.getContext().actorRef()).get, child);
-   * 
- * - * @param supervisor the supervisor Typed Actor - * @param supervised the Typed Actor to link - */ - def link(supervisor: AnyRef, supervised: AnyRef) = { - val supervisorActor = actorFor(supervisor).getOrElse( - throw new IllegalActorStateException("Can't link when the supervisor is not an Typed Actor")) - val supervisedActor = actorFor(supervised).getOrElse( - throw new IllegalActorStateException("Can't link when the supervised is not an Typed Actor")) - supervisorActor.link(supervisedActor) - } - - /** - * Links an other Typed Actor to this Typed Actor and sets the fault handling for the supervisor. - * - * Example linking another typed actor from within a typed actor: - *
-   *   TypedActor.link(TypedActor.proxyFor(this.getContext().actorRef()).get, child, faultHandlingStrategy);
-   * 
- * - * @param supervisor the supervisor Typed Actor - * @param supervised the Typed Actor to link - * @param handler fault handling strategy - * @param trapExceptions array of exceptions that should be handled by the supervisor - */ - def link(supervisor: AnyRef, supervised: AnyRef, - handler: FaultHandlingStrategy) = { - val supervisorActor = actorFor(supervisor).getOrElse( - throw new IllegalActorStateException("Can't link when the supervisor is not an Typed Actor")) - val supervisedActor = actorFor(supervised).getOrElse( - throw new IllegalActorStateException("Can't link when the supervised is not an Typed Actor")) - supervisorActor.faultHandler = handler - supervisorActor.link(supervisedActor) - } - - /** - * Unlink the supervised Typed Actor from the supervisor. - * - * Example unlinking another typed actor from within a typed actor: - *
-   *   TypedActor.unlink(TypedActor.proxyFor(this.getContext().actorRef()).get, child);
-   * 
- * - * @param supervisor the supervisor Typed Actor - * @param supervised the Typed Actor to unlink - */ - def unlink(supervisor: AnyRef, supervised: AnyRef) = { - val supervisorActor = actorFor(supervisor).getOrElse( - throw new IllegalActorStateException("Can't unlink when the supervisor is not an Typed Actor")) - val supervisedActor = actorFor(supervised).getOrElse( - throw new IllegalActorStateException("Can't unlink when the supervised is not an Typed Actor")) - supervisorActor.unlink(supervisedActor) - } - - /** - * Sets the fault handling strategy for the given supervisor Typed Actor. - * @param supervisor the supervisor Typed Actor - * @param handler fault handling strategy - */ - def faultHandler(supervisor: AnyRef, handler: FaultHandlingStrategy) = { - val supervisorActor = actorFor(supervisor).getOrElse( - throw new IllegalActorStateException("Can't set fault handler when the supervisor is not an Typed Actor")) - supervisorActor.faultHandler = handler - this - } - - private[akka] def newTypedActor(targetClass: Class[_]): TypedActor = { - val instance = targetClass.newInstance - val typedActor = - if (instance.isInstanceOf[TypedActor]) instance.asInstanceOf[TypedActor] - else throw new IllegalArgumentException("Actor [" + targetClass.getName + "] is not a sub class of 'TypedActor'") - typedActor - } - - private[akka] def newTypedActor(factory: ⇒ AnyRef): TypedActor = { - val instance = factory - val typedActor = - if (instance.isInstanceOf[TypedActor]) instance.asInstanceOf[TypedActor] - else throw new IllegalArgumentException("Actor [" + instance.getClass.getName + "] is not a sub class of 'TypedActor'") - typedActor - } - - private[akka] def isOneWay(joinPoint: JoinPoint): Boolean = - isOneWay(joinPoint.getRtti.asInstanceOf[MethodRtti]) - - private[akka] def isOneWay(methodRtti: MethodRtti): Boolean = - methodRtti.getMethod.getReturnType == java.lang.Void.TYPE - - private[akka] def isCoordinated(joinPoint: JoinPoint): Boolean = - isCoordinated(joinPoint.getRtti.asInstanceOf[MethodRtti]) - - private[akka] def isCoordinated(methodRtti: MethodRtti): Boolean = - methodRtti.getMethod.isAnnotationPresent(classOf[CoordinatedAnnotation]) - - private[akka] def returnsFuture_?(joinPoint: JoinPoint): Boolean = - returnsFuture_?(joinPoint.getRtti.asInstanceOf[MethodRtti]) - - private[akka] def returnsFuture_?(methodRtti: MethodRtti): Boolean = - classOf[Future[_]].isAssignableFrom(methodRtti.getMethod.getReturnType) - - private[akka] def returnsOption_?(methodRtti: MethodRtti): Boolean = - classOf[akka.japi.Option[_]].isAssignableFrom(methodRtti.getMethod.getReturnType) - - private[akka] def supervise(faultHandlingStrategy: FaultHandlingStrategy, components: List[Supervise]): Supervisor = - Supervisor(SupervisorConfig(faultHandlingStrategy, components)) - - def isJoinPointAndOneWay(message: Any): Boolean = if (isJoinPoint(message)) - isOneWay(message.asInstanceOf[JoinPoint].getRtti.asInstanceOf[MethodRtti]) - else false - - private[akka] def isJoinPoint(message: Any): Boolean = message.isInstanceOf[JoinPoint] -} - -/** - * AspectWerkz Aspect that is turning POJO into proxy to a server managed remote TypedActor. - *

- * Is deployed on a 'perInstance' basis with the pointcut 'execution(* *.*(..))', - * e.g. all methods on the instance. - * - * @author Jonas Bonér - */ -@Aspect("perInstance") -private[akka] sealed class ServerManagedTypedActorAspect extends ActorAspect { - - @Around("execution(* *.*(..)) && this(akka.actor.ServerManagedTypedActor)") - def invoke(joinPoint: JoinPoint): AnyRef = { - initialize(joinPoint) - remoteDispatch(joinPoint) - } - - override def initialize(joinPoint: JoinPoint): Unit = { - super.initialize(joinPoint) - //remoteAddress = actorRef.remoteAddress //TODO: REVISIT: Fix Server managed Typed Actor - } -} - -/** - * AspectWerkz Aspect that is turning POJO into TypedActor. - *

- * Is deployed on a 'perInstance' basis with the pointcut 'execution(* *.*(..))', - * e.g. all methods on the instance. - * - * @author Jonas Bonér - */ -@Aspect("perInstance") -private[akka] sealed class TypedActorAspect extends ActorAspect { - - @Around("execution(* *.*(..)) && !this(akka.actor.ServerManagedTypedActor)") - def invoke(joinPoint: JoinPoint): AnyRef = { - initialize(joinPoint) - dispatch(joinPoint) - } - - private def dispatch(joinPoint: JoinPoint) = { - if (remoteAddress.isDefined) remoteDispatch(joinPoint) - else localDispatch(joinPoint) - } -} - -/** - * Base class for TypedActorAspect and ServerManagedTypedActorAspect to reduce code duplication. - */ -private[akka] abstract class ActorAspect { - protected val isInitialized = new Switch(false) - protected val isStopped = new Switch(false) - protected var interfaceClass: Class[_] = _ - protected var typedActor: TypedActor = _ - protected var actorRef: ActorRef = _ - protected var timeout: Long = _ - protected var uuid: Uuid = _ - protected var remoteAddress: Option[InetSocketAddress] = _ - - protected def localDispatch(joinPoint: JoinPoint): AnyRef = { - val methodRtti = joinPoint.getRtti.asInstanceOf[MethodRtti] - val isOneWay = TypedActor.isOneWay(methodRtti) - val senderActorRef = Option(SenderContextInfo.senderActorRef.value) - val senderProxy = Option(SenderContextInfo.senderProxy.value) - val isCoordinated = TypedActor.isCoordinated(methodRtti) - - typedActor.context._sender = senderProxy - - if (!isStopped.isOn && !actorRef.isRunning) { - isStopped switchOn { - val proxy = TypedActor.proxyFor(actorRef) - if (proxy ne null) - TypedActor.stop(proxy) - } - } - - if (isOneWay && isCoordinated) { - val coordinatedOpt = Option(Coordination.coordinated.value) - val coordinated = coordinatedOpt.map(coord ⇒ - if (Coordination.firstParty.value) { // already included in coordination - Coordination.firstParty.value = false - coord.noIncrement(joinPoint) - } else { - coord(joinPoint) - }).getOrElse(Coordinated(joinPoint)) - - actorRef.!(coordinated)(senderActorRef) - null.asInstanceOf[AnyRef] - - } else if (isCoordinated) { - throw new CoordinateException("Can't use @Coordinated annotation with non-void methods.") - } else if (isOneWay) { - actorRef.!(joinPoint)(senderActorRef) - null.asInstanceOf[AnyRef] - } else if (TypedActor.returnsFuture_?(methodRtti)) { - actorRef.!!!(joinPoint, timeout)(senderActorRef) - } else if (TypedActor.returnsOption_?(methodRtti)) { - import akka.japi.{ Option ⇒ JOption } - (actorRef.!!(joinPoint, timeout)(senderActorRef)).as[JOption[AnyRef]] match { - case None ⇒ JOption.none[AnyRef] - case Some(x) if ((x eq null) || x.isEmpty) ⇒ JOption.some[AnyRef](null) - case Some(x) ⇒ x - } - } else { - val result = (actorRef.!!(joinPoint, timeout)(senderActorRef)).as[AnyRef] - if (result.isDefined) result.get - else throw new ActorTimeoutException("Invocation to [" + joinPoint + "] timed out.") - } - } - - protected def remoteDispatch(joinPoint: JoinPoint): AnyRef = { - val methodRtti = joinPoint.getRtti.asInstanceOf[MethodRtti] - val isOneWay = TypedActor.isOneWay(methodRtti) - val senderActorRef = Option(SenderContextInfo.senderActorRef.value) - - def extractOwnerTypeHint(s: String) = - s.indexOf(TypedActor.AW_PROXY_PREFIX) match { - case -1 ⇒ s - case x ⇒ s.substring(0, x + TypedActor.AW_PROXY_PREFIX.length) - } - //TODO: Add ownerTypeHint and parameter types to the TypedActorInfo? - val message: Tuple3[String, Array[Class[_]], Array[AnyRef]] = - ((extractOwnerTypeHint(methodRtti.getMethod.getDeclaringClass.getName), - methodRtti.getParameterTypes, - methodRtti.getParameterValues)) - - //TODO send the interface name of the senderProxy in the TypedActorContext and assemble a context.sender with that interface on the server - //val senderProxy = Option(SenderContextInfo.senderProxy.value) - - val future_? = Actor.remote.send[AnyRef]( - message, - senderActorRef, - None, - remoteAddress.getOrElse(throw new IllegalStateException("No remote address specified")), - timeout, - isOneWay, - actorRef, - Some((interfaceClass.getName, methodRtti.getMethod.getName)), - ActorType.TypedActor, - None) //TODO: REVISIT: Use another classloader? - - if (isOneWay) null // for void methods - else if (future_?.isEmpty) throw new IllegalActorStateException("No future returned from call to [" + joinPoint + "]") - else if (TypedActor.returnsFuture_?(methodRtti)) future_?.get - else if (TypedActor.returnsOption_?(methodRtti)) { - import akka.japi.{ Option ⇒ JOption } - future_?.get.await.resultOrException.as[JOption[AnyRef]] match { - case None ⇒ JOption.none[AnyRef] - case Some(x) if ((x eq null) || x.isEmpty) ⇒ JOption.some[AnyRef](null) - case Some(x) ⇒ x - } - } else { - val result = future_?.get.await.resultOrException - if (result.isDefined) result.get - else throw new IllegalActorStateException("No result returned from call to [" + joinPoint + "]") - } - } - - protected def initialize(joinPoint: JoinPoint) { - isInitialized.switchOn { - val init = AspectInitRegistry.initFor(joinPoint.getThis) - interfaceClass = init.interfaceClass - typedActor = init.targetInstance - actorRef = init.actorRef - uuid = actorRef.uuid - timeout = init.timeout - remoteAddress = None //actorRef.remoteAddress - } - } -} - -/** - * Internal helper class to help pass the contextual information between threads. - * - * @author Jonas Bonér - */ -private[akka] object SenderContextInfo { - import scala.util.DynamicVariable - private[actor] val senderActorRef = new DynamicVariable[ActorRef](null) - private[actor] val senderProxy = new DynamicVariable[AnyRef](null) -} - -/** - * @author Jonas Bonér - */ -private[akka] object AspectInitRegistry extends ListenerManagement { - private val initializations = new java.util.concurrent.ConcurrentHashMap[AnyRef, AspectInit] - - def initFor(proxy: AnyRef) = initializations.get(proxy) - - def register(proxy: AnyRef, init: AspectInit) = { - val res = initializations.put(proxy, init) - notifyListeners(AspectInitRegistered(proxy, init)) - res - } - - /** - * Unregisters initialization and stops its ActorRef. - */ - def unregister(proxy: AnyRef): AspectInit = { - val init = if (proxy ne null) initializations.remove(proxy) else null - if (init ne null) { - notifyListeners(AspectInitUnregistered(proxy, init)) - init.actorRef.stop() - } - init - } -} - -private[akka] sealed trait AspectInitRegistryEvent -private[akka] case class AspectInitRegistered(proxy: AnyRef, init: AspectInit) extends AspectInitRegistryEvent -private[akka] case class AspectInitUnregistered(proxy: AnyRef, init: AspectInit) extends AspectInitRegistryEvent - -/** - * @author Jonas Bonér - */ -private[akka] sealed case class AspectInit( - interfaceClass: Class[_], - targetInstance: TypedActor, - actorRef: ActorRef, - timeout: Long) { -} - -/** - * Marker interface for server manager typed actors. - */ -private[akka] sealed trait ServerManagedTypedActor extends TypedActor diff --git a/akka-typed-actor/src/main/scala/akka/config/TypedActorConfigurator.scala b/akka-typed-actor/src/main/scala/akka/config/TypedActorConfigurator.scala deleted file mode 100644 index cfa937bb52..0000000000 --- a/akka-typed-actor/src/main/scala/akka/config/TypedActorConfigurator.scala +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.config - -import Supervision._ - -import java.util.{ List ⇒ JList } -import java.util.{ ArrayList } - -import com.google.inject._ - -/** - * Configurator for the TypedActors. Used to do declarative configuration of supervision. - * It also does dependency injection with and into TypedActors using dependency injection - * frameworks such as Google Guice or Spring. - *

- * If you don't want declarative configuration then you should use the TypedActor - * factory methods. - * - * @author Jonas Bonér - */ -class TypedActorConfigurator { - import scala.collection.JavaConversions._ - // TODO: make pluggable once we have f.e a SpringConfigurator - private val INSTANCE = new TypedActorGuiceConfigurator - - /** - * Returns the a list with all typed actors that has been put under supervision for the class specified. - * - * @param clazz the class for the typed actor - * @return a list with all the typed actors for the class - */ - def getInstances[T](clazz: Class[T]): JList[T] = - INSTANCE.getInstance(clazz).foldLeft(new ArrayList[T]) { (l, i) ⇒ l add i; l } - - /** - * Returns the first item in a list of all typed actors that has been put under supervision for the class specified. - * - * @param clazz the class for the typed actor - * @return the typed actor for the class - */ - def getInstance[T](clazz: Class[T]): T = INSTANCE.getInstance(clazz).head - - def configure(faultHandlingStrategy: FaultHandlingStrategy, components: Array[SuperviseTypedActor]): TypedActorConfigurator = { - INSTANCE.configure( - faultHandlingStrategy, - components.toList.asInstanceOf[scala.List[SuperviseTypedActor]]) - this - } - - def inject: TypedActorConfigurator = { - INSTANCE.inject - this - } - - def supervise: TypedActorConfigurator = { - INSTANCE.supervise - this - } - - def addExternalGuiceModule(module: Module): TypedActorConfigurator = { - INSTANCE.addExternalGuiceModule(module) - this - } - - def getComponentInterfaces: JList[Class[_]] = { - val al = new ArrayList[Class[_]] - for (c ← INSTANCE.getComponentInterfaces) al.add(c) - al - } - - def getExternalDependency[T](clazz: Class[T]): T = INSTANCE.getExternalDependency(clazz) - - // TODO: should this be exposed? - def getGuiceModules: JList[Module] = INSTANCE.getGuiceModules - - def reset = INSTANCE.reset - - def stop = INSTANCE.stop -} diff --git a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala b/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala deleted file mode 100644 index 6631888c0d..0000000000 --- a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.config - -import akka.actor._ -import akka.config.Supervision._ -import akka.util._ -import ReflectiveAccess._ - -import org.codehaus.aspectwerkz.proxy.Proxy - -import scala.collection.mutable.HashMap - -import java.net.InetSocketAddress -import java.lang.reflect.Method - -import com.google.inject._ - -/** - * This is an class for internal usage. Instead use the akka.config.TypedActorConfigurator - * class for creating TypedActors. - * - * @author Jonas Bonér - */ -private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBase { - private var injector: Injector = _ - private var supervisor: Option[Supervisor] = None - private var faultHandlingStrategy: FaultHandlingStrategy = NoFaultHandlingStrategy - private var components: List[SuperviseTypedActor] = _ - private var supervised: List[Supervise] = Nil - private var bindings: List[DependencyBinding] = Nil - private var typedActorRegistry = new HashMap[Class[_], Tuple3[AnyRef, AnyRef, SuperviseTypedActor]] - private var modules = new java.util.ArrayList[Module] - private var methodToUriRegistry = new HashMap[Method, String] - - /** - * Returns the active abject that has been put under supervision for the class specified. - * - * @param clazz the class for the typed actor - * @return the typed actors for the class - */ - def getInstance[T](clazz: Class[T]): List[T] = synchronized { - if (injector eq null) throw new IllegalActorStateException( - "inject() and/or supervise() must be called before invoking getInstance(clazz)") - val (proxy, targetInstance, component) = - typedActorRegistry.getOrElse(clazz, throw new IllegalActorStateException( - "Class [" + clazz.getName + "] has not been put under supervision" + - "\n(by passing in the config to the 'configure' and then invoking 'supervise') method")) - injector.injectMembers(targetInstance) - List(proxy.asInstanceOf[T]) - } - - def isDefined(clazz: Class[_]): Boolean = synchronized { - typedActorRegistry.get(clazz).isDefined - } - - override def getExternalDependency[T](clazz: Class[T]): T = synchronized { - injector.getInstance(clazz).asInstanceOf[T] - } - - def getComponentInterfaces: List[Class[_]] = - for (c ← components) yield { - if (c.intf.isDefined) c.intf.get - else c.target - } - - override def configure(faultHandlingStrategy: FaultHandlingStrategy, components: List[SuperviseTypedActor]): TypedActorConfiguratorBase = synchronized { - this.faultHandlingStrategy = faultHandlingStrategy - this.components = components.toArray.toList.asInstanceOf[List[SuperviseTypedActor]] - bindings = for (component ← this.components) yield { - newDelegatingProxy(component) - // if (component.intf.isDefined) newDelegatingProxy(component) - // else newSubclassingProxy(component) - } - val deps = new java.util.ArrayList[DependencyBinding](bindings.size) - for (b ← bindings) deps.add(b) - modules.add(new TypedActorGuiceModule(deps)) - this - } - - /* - private def newSubclassingProxy(component: SuperviseTypedActor): DependencyBinding = { - val targetClass = - if (component.target.isInstanceOf[Class[_ <: TypedActor]]) component.target.asInstanceOf[Class[_ <: TypedActor]] - else throw new IllegalArgumentException("TypedActor [" + component.target.getName + "] must be a subclass of TypedActor") - val actorRef = Actor.actorOf(new Dispatcher()) - if (component.dispatcher.isDefined) actorRef.dispatcher = component.dispatcher.get - val remoteAddress = - if (component.remoteAddress.isDefined) - Some(new InetSocketAddress(component.remoteAddress.get.hostname, component.remoteAddress.get.port)) - else None - val proxy = TypedActor.newInstance(targetClass, actorRef, remoteAddress, component.timeout).asInstanceOf[AnyRef] - remoteAddress.foreach(address => RemoteServer.registerTypedActor(address, targetClass.getName, proxy)) - supervised ::= Supervise(actorRef, component.lifeCycle) - typedActorRegistry.put(targetClass, (proxy, proxy, component)) - new DependencyBinding(targetClass, proxy) - } -*/ - private def newDelegatingProxy(component: SuperviseTypedActor): DependencyBinding = { - component.target.getConstructor(Array[Class[_]](): _*).setAccessible(true) - val interfaceClass = if (component.intf.isDefined) component.intf.get - else throw new IllegalActorStateException("No interface for TypedActor specified") - val implementationClass = component.target - val timeout = component.timeout - - val actorRef = Actor.actorOf(TypedActor.newTypedActor(implementationClass)) - - actorRef.timeout = timeout - if (component.dispatcher.isDefined) actorRef.dispatcher = component.dispatcher.get - val typedActor = actorRef.actorInstance.get.asInstanceOf[TypedActor] - - val proxy = Proxy.newInstance(Array(interfaceClass), Array(typedActor), true, false) - - AspectInitRegistry.register( - proxy, - AspectInit(interfaceClass, typedActor, actorRef, timeout)) - typedActor.initialize(proxy) - actorRef.start() - - supervised ::= Supervise(actorRef, component.lifeCycle) - - typedActorRegistry.put(interfaceClass, (proxy, typedActor, component)) - new DependencyBinding(interfaceClass, proxy) - } - - override def inject: TypedActorConfiguratorBase = synchronized { - if (injector ne null) throw new IllegalActorStateException("inject() has already been called on this configurator") - injector = Guice.createInjector(modules) - this - } - - override def supervise: TypedActorConfiguratorBase = synchronized { - if (injector eq null) inject - supervisor = Some(TypedActor.supervise(faultHandlingStrategy, supervised)) - this - } - - /** - * Add additional services to be wired in. - *

-   * typedActorConfigurator.addExternalGuiceModule(new AbstractModule {
-   *   protected void configure() {
-   *     bind(Foo.class).to(FooImpl.class).in(Scopes.SINGLETON);
-   *     bind(BarImpl.class);
-   *     link(Bar.class).to(BarImpl.class);
-   *     bindConstant(named("port")).to(8080);
-   *   }})
-   * 
- */ - def addExternalGuiceModule(module: Module): TypedActorConfiguratorBase = synchronized { - modules.add(module) - this - } - - def getGuiceModules: java.util.List[Module] = modules - - def reset = synchronized { - modules = new java.util.ArrayList[Module] - typedActorRegistry = new HashMap[Class[_], Tuple3[AnyRef, AnyRef, SuperviseTypedActor]] - methodToUriRegistry = new HashMap[Method, String] - injector = null - faultHandlingStrategy = NoFaultHandlingStrategy - } - - def stop = synchronized { - if (supervisor.isDefined) supervisor.get.shutdown() - } -} - diff --git a/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala b/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala deleted file mode 100644 index 716d70bc24..0000000000 --- a/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.transactor - -import akka.AkkaException -import akka.stm.Atomic - -import scala.util.DynamicVariable - -class CoordinateException private[akka] (message: String, cause: Throwable = null) extends AkkaException(message, cause) - -/** - * Coordinating transactions between typed actors. - * - * Example ''(in Scala)'' - * - * {{{ - * trait Counter { - * @Coordinated def increment: Unit - * def get: Int - * } - * - * class CounterImpl extends TypedActor with Counter { - * val ref = Ref(0) - * def increment = ref alter (_ + 1) - * def get = ref.get - * } - * - * - * val counter1 = TypedActor.newInstance(classOf[Counter], classOf[CounterImpl]) - * val counter2 = TypedActor.newInstance(classOf[Counter], classOf[CounterImpl]) - * - * coordinate { - * counter1.increment - * counter2.increment - * } - * }}} - */ -object Coordination { - private[akka] val coordinated = new DynamicVariable[Coordinated](null) - private[akka] val firstParty = new DynamicVariable[Boolean](false) - - /** - * For creating a coordination between typed actors that use - * the [[akka.transactor.annotation.Coordinated]] annotation. - * Coordinated transactions will wait for all other transactions in the coordination - * before committing. The timeout is specified by the default transaction factory. - * It's possible to specify whether or not this `coordinate` block waits for all of - * the transactions to complete - the default is that it does. - */ - def coordinate[U](wait: Boolean = true)(body: ⇒ U): Unit = { - firstParty.value = !wait - coordinated.withValue(Coordinated()) { - body - if (wait) coordinated.value.await - } - firstParty.value = false - } - - /** - * For creating a coordination between typed actors that use - * the [[akka.transactor.annotation.Coordinated]] annotation. - * Coordinated transactions will wait for all other transactions in the coordination - * before committing. The timeout is specified by the default transaction factory. - */ - def coordinate[U](body: ⇒ U): Unit = coordinate(true)(body) - - /** - * Java API: coordinate that accepts an [[akka.transactor.Atomically]]. - * For creating a coordination between typed actors that use - * the [[akka.transactor.annotation.Coordinated]] annotation. - * Coordinated transactions will wait for all other transactions in the coordination - * before committing. The timeout is specified by the default transaction factory. - * Use the `wait` parameter to specify whether or not this `coordinate` block - * waits for all of the transactions to complete. - */ - def coordinate(wait: Boolean, atomically: Atomically): Unit = coordinate(wait)(atomically.atomically) - - /** - * Java API: coordinate that accepts an [[akka.stm.Atomic]]. - * For creating a coordination between typed actors that use - * the [[akka.transactor.annotation.Coordinated]] annotation. - * Coordinated transactions will wait for all other transactions in the coordination - * before committing. The timeout is specified by the default transaction factory. - * Use the `wait` parameter to specify whether or not this `coordinate` block - * waits for all of the transactions to complete. - */ - def coordinate[U](wait: Boolean, atomic: Atomic[U]): Unit = coordinate(wait)(atomic.atomically) -} diff --git a/akka-typed-actor/src/test/java/akka/actor/Bar.java b/akka-typed-actor/src/test/java/akka/actor/Bar.java deleted file mode 100644 index 3ac5c51961..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/Bar.java +++ /dev/null @@ -1,6 +0,0 @@ -package akka.actor; - -public interface Bar { - void bar(String msg); - Ext getExt(); -} diff --git a/akka-typed-actor/src/test/java/akka/actor/BarImpl.java b/akka-typed-actor/src/test/java/akka/actor/BarImpl.java deleted file mode 100644 index e52a34a09d..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/BarImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package akka.actor; - -import com.google.inject.Inject; -import akka.actor.*; - -public class BarImpl extends TypedActor implements Bar { - @Inject - private Ext ext; - - public Ext getExt() { - return ext; - } - - public void bar(String msg) { - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/Ext.java b/akka-typed-actor/src/test/java/akka/actor/Ext.java deleted file mode 100644 index cb0d5ed279..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/Ext.java +++ /dev/null @@ -1,6 +0,0 @@ -package akka.actor; - -public interface Ext { - void ext(); -} - diff --git a/akka-typed-actor/src/test/java/akka/actor/ExtImpl.java b/akka-typed-actor/src/test/java/akka/actor/ExtImpl.java deleted file mode 100644 index 2180e9f440..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/ExtImpl.java +++ /dev/null @@ -1,6 +0,0 @@ -package akka.actor; - -public class ExtImpl implements Ext { - public void ext() { - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/Foo.java b/akka-typed-actor/src/test/java/akka/actor/Foo.java deleted file mode 100644 index 12b2ed2fbf..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/Foo.java +++ /dev/null @@ -1,14 +0,0 @@ -package akka.actor; - -public interface Foo { - public Foo body(); - public Bar getBar(); - - public String foo(String msg); - public void bar(String msg); - - public String longRunning(); - public String throwsException(); - - public int $tag() throws java.rmi.RemoteException; -} diff --git a/akka-typed-actor/src/test/java/akka/actor/FooImpl.java b/akka-typed-actor/src/test/java/akka/actor/FooImpl.java deleted file mode 100644 index d717c8cb01..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/FooImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package akka.actor; - -import com.google.inject.Inject; -import akka.actor.*; - -public class FooImpl extends TypedActor implements Foo { - @Inject - private Bar bar; - - public Foo body() { return this; } - - public Bar getBar() { - return bar; - } - - public String foo(String msg) { - return msg + "return_foo "; - } - - public void bar(String msg) { - bar.bar(msg); - } - - public String longRunning() { - try { - Thread.sleep(1200); - } catch (InterruptedException e) { - } - return "test"; - } - - public String throwsException() { - if (true) throw new RuntimeException("Expected exception; to test fault-tolerance"); - return "test"; - } - - public int $tag() throws java.rmi.RemoteException { - return 0; - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SamplePojo.java b/akka-typed-actor/src/test/java/akka/actor/SamplePojo.java deleted file mode 100644 index 5b9de51d44..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SamplePojo.java +++ /dev/null @@ -1,9 +0,0 @@ -package akka.actor; - -import akka.dispatch.Future; - -public interface SamplePojo { - public String greet(String s); - public String fail(); - public Future someFutureString(); -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SamplePojoImpl.java b/akka-typed-actor/src/test/java/akka/actor/SamplePojoImpl.java deleted file mode 100644 index b61fc2f366..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SamplePojoImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package akka.actor; - -import akka.actor.*; - -import java.util.concurrent.CountDownLatch; - -public class SamplePojoImpl extends TypedActor implements SamplePojo { - - public static CountDownLatch latch = new CountDownLatch(1); - - public static boolean _pre = false; - public static boolean _post = false; - public static boolean _down = false; - public static void reset() { - _pre = false; - _post = false; - _down = false; - } - - public String greet(String s) { - return "hello " + s; - } - - public String fail() { - throw new RuntimeException("expected"); - } - - public akka.dispatch.Future someFutureString() { - return future("foo"); - } - - @Override - public void preRestart(Throwable e) { - _pre = true; - latch.countDown(); - } - - @Override - public void postRestart(Throwable e) { - _post = true; - latch.countDown(); - } - - @Override - public void postStop() { - _down = true; - latch.countDown(); - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojo.java b/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojo.java deleted file mode 100644 index 061302126d..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojo.java +++ /dev/null @@ -1,17 +0,0 @@ -package akka.actor; - -import akka.dispatch.Future; -import akka.dispatch.CompletableFuture; -import akka.dispatch.Future; -import akka.japi.Option; - -public interface SimpleJavaPojo { - String hello(String name); - public Object getSender(); - public Object getSenderFuture(); - public Future square(int value); - public Option passThru(Option returnValue); - public void setName(String name); - public String getName(); - public void throwException(); -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCaller.java b/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCaller.java deleted file mode 100644 index f390c16364..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCaller.java +++ /dev/null @@ -1,9 +0,0 @@ -package akka.actor; - -import akka.dispatch.CompletableFuture; - -public interface SimpleJavaPojoCaller { - public void setPojo(SimpleJavaPojo pojo); - public Object getSenderFromSimpleJavaPojo(); - public Object getSenderFutureFromSimpleJavaPojo(); -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCallerImpl.java b/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCallerImpl.java deleted file mode 100644 index 9d7b4034ae..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoCallerImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package akka.actor; - -import akka.actor.*; -import akka.dispatch.Future; - -public class SimpleJavaPojoCallerImpl extends TypedActor implements SimpleJavaPojoCaller { - - SimpleJavaPojo pojo; - - public void setPojo(SimpleJavaPojo pojo) { - this.pojo = pojo; - } - - public Object getSenderFromSimpleJavaPojo() { - Object sender = pojo.getSender(); - return sender; - } - - public Object getSenderFutureFromSimpleJavaPojo() { - return pojo.getSenderFuture(); - } - - public Future square(int value) { - return future(value * value); - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoImpl.java b/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoImpl.java deleted file mode 100644 index 6c57e4c0cb..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/SimpleJavaPojoImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -package akka.actor; - -import akka.actor.*; -import akka.dispatch.Future; -import akka.dispatch.CompletableFuture; -import akka.japi.Option; - -public class SimpleJavaPojoImpl extends TypedActor implements SimpleJavaPojo { - - public static boolean _pre = false; - public static boolean _post = false; - public static boolean _down = false; - public static void reset() { - _pre = false; - _post = false; - _down = false; - } - - private String name; - - public String hello(String name) { - return "Hello " + name; - } - - public Future square(int value) { - return future(value * value); - } - - public Object getSender() { - return getContext().getSender(); - } - - public CompletableFuture getSenderFuture() { - return getContext().getSenderFuture().get(); - } - - public Option passThru(Option returnValue) { - return returnValue; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public void preRestart(Throwable e) { - _pre = true; - } - - @Override - public void postRestart(Throwable e) { - _post = true; - } - - public void throwException() { - throw new RuntimeException(); - } -} diff --git a/akka-typed-actor/src/test/java/akka/actor/TypedActorFailer.java b/akka-typed-actor/src/test/java/akka/actor/TypedActorFailer.java deleted file mode 100644 index 7722a6214c..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/TypedActorFailer.java +++ /dev/null @@ -1,5 +0,0 @@ -package akka.actor; - -public interface TypedActorFailer extends java.io.Serializable { - public int fail(); -} diff --git a/akka-typed-actor/src/test/java/akka/actor/TypedActorFailerImpl.java b/akka-typed-actor/src/test/java/akka/actor/TypedActorFailerImpl.java deleted file mode 100644 index 5a1a4d1e01..0000000000 --- a/akka-typed-actor/src/test/java/akka/actor/TypedActorFailerImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package akka.actor; - -import akka.actor.*; - -public class TypedActorFailerImpl extends TypedActor implements TypedActorFailer { - public int fail() { - throw new RuntimeException("expected"); - } -} diff --git a/akka-typed-actor/src/test/java/akka/transactor/test/FailerImpl.java b/akka-typed-actor/src/test/java/akka/transactor/test/FailerImpl.java deleted file mode 100644 index 018418f1f6..0000000000 --- a/akka-typed-actor/src/test/java/akka/transactor/test/FailerImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package akka.transactor.test; - -import akka.actor.TypedActor; -import akka.stm.Ref; - -public class FailerImpl extends TypedActor implements TypedCounter { - private Ref count = new Ref(0); - - public void increment() { - throw new RuntimeException("Expected failure"); - } - - public Integer get() { - return count.get(); - } -} \ No newline at end of file diff --git a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCoordinatedIncrementTest.java b/akka-typed-actor/src/test/java/akka/transactor/test/TypedCoordinatedIncrementTest.java deleted file mode 100644 index 4a838b2aa4..0000000000 --- a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCoordinatedIncrementTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package akka.transactor.test; - -import static org.junit.Assert.*; -import org.junit.Test; -import org.junit.Before; -import org.junit.After; - -import akka.actor.TypedActor; -import akka.transactor.Coordination; -import akka.transactor.Atomically; - -import java.util.ArrayList; -import java.util.List; - -public class TypedCoordinatedIncrementTest { - List counters; - TypedCounter failer; - - int numCounters = 5; - - @Before public void initialise() { - counters = new ArrayList(); - for (int i = 1; i <= numCounters; i++) { - TypedCounter counter = (TypedCounter) TypedActor.newInstance(TypedCounter.class, TypedCounterImpl.class); - counters.add(counter); - } - failer = (TypedCounter) TypedActor.newInstance(TypedCounter.class, FailerImpl.class); - } - - @Test public void incrementAllCountersWithSuccessfulTransaction() { - Coordination.coordinate(true, new Atomically() { - public void atomically() { - for (TypedCounter counter : counters) { - counter.increment(); - } - } - }); - for (TypedCounter counter : counters) { - int count = counter.get(); - assertEquals(1, count); - } - } - - @Test public void incrementNoCountersWithFailingTransaction() { - try { - Coordination.coordinate(true, new Atomically() { - public void atomically() { - for (TypedCounter counter : counters) { - counter.increment(); - } - failer.increment(); - } - }); - } catch (Exception e) { - // ignore - } - for (TypedCounter counter : counters) { - int count = counter.get(); - assertEquals(0, count); - } - } - - @After public void stop() { - for (TypedCounter counter : counters) { - TypedActor.stop(counter); - } - TypedActor.stop(failer); - } -} diff --git a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounter.java b/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounter.java deleted file mode 100644 index b1de7020f0..0000000000 --- a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounter.java +++ /dev/null @@ -1,8 +0,0 @@ -package akka.transactor.test; - -import akka.transactor.annotation.Coordinated; - -public interface TypedCounter { - @Coordinated public void increment(); - public Integer get(); -} diff --git a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounterImpl.java b/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounterImpl.java deleted file mode 100644 index 173bbcbc20..0000000000 --- a/akka-typed-actor/src/test/java/akka/transactor/test/TypedCounterImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package akka.transactor.test; - -import akka.actor.TypedActor; -import akka.stm.Ref; - -public class TypedCounterImpl extends TypedActor implements TypedCounter { - private Ref count = new Ref(0); - - public void increment() { - count.set(count.get() + 1); - } - - public Integer get() { - return count.get(); - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/Issue552Spec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/Issue552Spec.scala deleted file mode 100644 index 4f986f37db..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/Issue552Spec.scala +++ /dev/null @@ -1,105 +0,0 @@ -package akka.typed.actor - -import akka.actor.TypedActor -import org.scalatest.{ WordSpec } -import org.scalatest.matchers.{ MustMatchers } -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith - -object Ticket552Spec { - - trait Base { - val id: String - def getSomething(key: String): String = id + key - } - - trait MyBaseOne extends Base { - val id: String = "myBaseOne " - def getSomethingDifferent(key: Int): Int - } - - trait MyBaseTwo extends Base { - val id: String = "myBaseTwo " - } - - class MyBaseOneImpl extends TypedActor with MyBaseOne { - override def getSomethingDifferent(key: Int): Int = key + 2 - } - - class MyBaseTwoImpl extends TypedActor with MyBaseTwo - -} - -@RunWith(classOf[JUnitRunner]) -class Ticket552Spec extends WordSpec with MustMatchers { - import Ticket552Spec._ - - "TypedActor" should { - - "return int" in { - val myBaseOneActor: MyBaseOne = - TypedActor.newInstance[MyBaseOne](classOf[MyBaseOne], - classOf[MyBaseOneImpl], 3000) - - try { - myBaseOneActor.getSomethingDifferent(5) must be === 7 - } catch { - case e: Exception ⇒ println(e.toString) - } - finally { - TypedActor.stop(myBaseOneActor) - } - } - - "return string" in { - val myBaseOneActor: Base = - TypedActor.newInstance[Base](classOf[Base], - classOf[MyBaseOneImpl], 3000) - - try { - myBaseOneActor.getSomething("hello") must be === "myBaseOne hello" - } catch { - case e: Exception ⇒ println(e.toString) - } - finally { - TypedActor.stop(myBaseOneActor) - } - } - - "fail for myBaseTwo" in { - val myBaseTwoActor: MyBaseTwo = - TypedActor.newInstance[MyBaseTwo](classOf[MyBaseTwo], - classOf[MyBaseTwoImpl], 3000) - - try { - intercept[java.lang.AbstractMethodError] { - myBaseTwoActor.getSomething("hello") - } - } catch { - case e: java.lang.AbstractMethodError ⇒ e.printStackTrace - } - finally { - TypedActor.stop(myBaseTwoActor) - } - } - - "fail for myBaseOne inherited method" in { - val myBaseOneActor: MyBaseOne = - TypedActor.newInstance[MyBaseOne](classOf[MyBaseOne], - classOf[MyBaseOneImpl], 3000) - - try { - intercept[java.lang.AbstractMethodError] { - myBaseOneActor.getSomething("hello") - } - } catch { - case e: java.lang.AbstractMethodError ⇒ e.printStackTrace - } - finally { - TypedActor.stop(myBaseOneActor) - } - } - - } -} - diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/Issue675Spec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/Issue675Spec.scala deleted file mode 100644 index 07678fccf2..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/Issue675Spec.scala +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import org.scalatest.Spec -import org.scalatest.Assertions -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.BeforeAndAfterEach -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith - -import Issue675Spec._ - -object Issue675Spec { - var l = collection.mutable.ListBuffer.empty[String] - - trait RegistrationService { - def register(user: String, cred: String): Unit - } - - class RegistrationServiceImpl extends TypedActor with RegistrationService { - def register(user: String, cred: String): Unit = {} - - override def preStart() { - l += "RegistrationServiceImpl.preStart() called" - } - } -} - -@RunWith(classOf[JUnitRunner]) -class Issue675Spec extends Spec with ShouldMatchers with BeforeAndAfterEach { - - override def afterEach() { - Actor.registry.local.shutdownAll() - } - - describe("TypedActor preStart method") { - it("should be invoked once") { - import Issue675Spec._ - val simplePojo = TypedActor.newInstance(classOf[RegistrationService], classOf[RegistrationServiceImpl]) - l.size should equal(1) - } - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorContextSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorContextSpec.scala deleted file mode 100644 index ab873d7dcf..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorContextSpec.scala +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import org.scalatest.Spec -import org.scalatest.Assertions -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.BeforeAndAfterAll -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith - -import akka.dispatch.DefaultCompletableFuture; - -@RunWith(classOf[JUnitRunner]) -class TypedActorContextSpec extends Spec with ShouldMatchers with BeforeAndAfterAll { - - describe("TypedActorContext") { - it("context.sender should return the sender TypedActor reference") { - val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo], classOf[SimpleJavaPojoImpl]) - val pojoCaller = TypedActor.newInstance(classOf[SimpleJavaPojoCaller], classOf[SimpleJavaPojoCallerImpl]) - pojoCaller.setPojo(pojo) - pojoCaller.getSenderFromSimpleJavaPojo.isInstanceOf[Option[_]] should equal(true) - pojoCaller.getSenderFromSimpleJavaPojo.asInstanceOf[Option[_]].isDefined should equal(true) - pojoCaller.getSenderFromSimpleJavaPojo.asInstanceOf[Option[_]].get should equal(pojoCaller) - } - it("context.senderFuture should return the senderFuture TypedActor reference") { - val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo], classOf[SimpleJavaPojoImpl]) - val pojoCaller = TypedActor.newInstance(classOf[SimpleJavaPojoCaller], classOf[SimpleJavaPojoCallerImpl]) - pojoCaller.setPojo(pojo) - pojoCaller.getSenderFutureFromSimpleJavaPojo.getClass.getName should equal(classOf[DefaultCompletableFuture[_]].getName) - } - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorGuiceConfiguratorSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorGuiceConfiguratorSpec.scala deleted file mode 100644 index 05455132fa..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorGuiceConfiguratorSpec.scala +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import com.google.inject.AbstractModule -import com.google.inject.Scopes - -import org.scalatest.Spec -import org.scalatest.Assertions -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.BeforeAndAfterAll -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith - -import akka.config.Supervision._ -import akka.dispatch._ -import akka.dispatch.FutureTimeoutException -import akka.config.{ Config, TypedActorConfigurator } - -@RunWith(classOf[JUnitRunner]) -class TypedActorGuiceConfiguratorSpec extends Spec with ShouldMatchers with BeforeAndAfterAll { - - private val conf = new TypedActorConfigurator - private var messageLog = "" - - override def beforeAll { - Config.config - val dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test").build - - conf.addExternalGuiceModule(new AbstractModule { - def configure = bind(classOf[Ext]).to(classOf[ExtImpl]).in(Scopes.SINGLETON) - }).configure( - AllForOneStrategy(classOf[Exception] :: Nil, 3, 5000), - List( - new SuperviseTypedActor( - classOf[Foo], - classOf[FooImpl], - Permanent, - 1000, - dispatcher), - new SuperviseTypedActor( - classOf[Bar], - classOf[BarImpl], - Permanent, - 1000, - dispatcher)).toArray).inject.supervise - - } - - override def afterAll = conf.stop - - describe("TypedActorGuiceConfigurator") { - - it("should inject typed actor using guice") { - messageLog = "" - val foo = conf.getInstance(classOf[Foo]) - val bar = conf.getInstance(classOf[Bar]) - bar should equal(foo.getBar) - } - - it("should inject external dependency using guice") { - messageLog = "" - val bar = conf.getInstance(classOf[Bar]) - val ext = conf.getExternalDependency(classOf[Ext]) - ext.toString should equal(bar.getExt.toString) - } - - it("should lookup non-supervised instance") { - try { - val str = conf.getInstance(classOf[String]) - fail("exception should have been thrown") - } catch { - case e: Exception ⇒ - classOf[IllegalActorStateException] should equal(e.getClass) - } - } - - it("should be able to invoke typed actor") { - messageLog = "" - val foo = conf.getInstance(classOf[Foo]) - messageLog += foo.foo("foo ") - foo.bar("bar ") - messageLog += "before_bar " - Thread.sleep(500) - messageLog should equal("foo return_foo before_bar ") - } - - it("should be able to invoke typed actor's invocation") { - messageLog = "" - val foo = conf.getInstance(classOf[Foo]) - val bar = conf.getInstance(classOf[Bar]) - messageLog += foo.foo("foo ") - foo.bar("bar ") - messageLog += "before_bar " - Thread.sleep(500) - messageLog should equal("foo return_foo before_bar ") - } - - it("should throw FutureTimeoutException on time-out") { - messageLog = "" - val foo = conf.getInstance(classOf[Foo]) - try { - foo.longRunning - fail("exception should have been thrown") - } catch { - case e: FutureTimeoutException ⇒ - classOf[FutureTimeoutException] should equal(e.getClass) - } - } - - it("should propagate exception") { - messageLog = "" - val foo = conf.getInstance(classOf[Foo]) - try { - foo.throwsException - fail("exception should have been thrown") - } catch { - case e: RuntimeException ⇒ - classOf[RuntimeException] should equal(e.getClass) - } - } - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala deleted file mode 100644 index 7d68e27c47..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala +++ /dev/null @@ -1,155 +0,0 @@ -package akka.actor - -import org.junit.runner.RunWith -import org.scalatest.{ BeforeAndAfterAll, Spec } -import org.scalatest.junit.JUnitRunner -import org.scalatest.matchers.ShouldMatchers - -import akka.actor.TypedActor._ - -import akka.config.Supervision._ - -import akka.config.TypedActorConfigurator - -import akka.testing._ -import akka.util.duration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } - -/** - * @author Martin Krasser - */ -@RunWith(classOf[JUnitRunner]) -class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAfterAll { - var conf1: TypedActorConfigurator = _ - var conf2: TypedActorConfigurator = _ - - override protected def beforeAll() = { - val strategy = AllForOneStrategy(classOf[Exception] :: Nil, 3, 1000) - val comp3 = new SuperviseTypedActor(classOf[SamplePojo], classOf[SamplePojoImpl], permanent(), 1000) - val comp4 = new SuperviseTypedActor(classOf[SamplePojo], classOf[SamplePojoImpl], temporary(), 1000) - conf1 = new TypedActorConfigurator().configure(strategy, Array(comp3)).supervise - conf2 = new TypedActorConfigurator().configure(strategy, Array(comp4)).supervise - } - - override protected def afterAll() = { - conf1.stop - conf2.stop - } - - describe("TypedActor lifecycle management") { - it("should restart supervised, non-annotated typed actor on failure") { - SamplePojoImpl.reset - val obj = conf1.getInstance[SamplePojo](classOf[SamplePojo]) - val cdl = new CountDownLatch(2) - SamplePojoImpl.latch = cdl - assert(AspectInitRegistry.initFor(obj) ne null) - try { - obj.fail - fail("expected exception not thrown") - } catch { - case e: RuntimeException ⇒ { - cdl.await(10, TimeUnit.SECONDS) - assert(SamplePojoImpl._pre) - assert(SamplePojoImpl._post) - assert(!SamplePojoImpl._down) - // assert(AspectInitRegistry.initFor(obj) ne null) - } - } - } - - it("should shutdown supervised, non-annotated typed actor on failure") { - SamplePojoImpl.reset - val obj = conf2.getInstance[SamplePojo](classOf[SamplePojo]) - val cdl = new CountDownLatch(1) - SamplePojoImpl.latch = cdl - assert(AspectInitRegistry.initFor(obj) ne null) - try { - obj.fail - fail("expected exception not thrown") - } catch { - case e: RuntimeException ⇒ { - cdl.await - assert(!SamplePojoImpl._pre) - assert(!SamplePojoImpl._post) - assert(SamplePojoImpl._down) - // assert(AspectInitRegistry.initFor(obj) eq null) - } - } - } - - it("should shutdown non-supervised, non-initialized typed actor on TypedActor.stop") { - SamplePojoImpl.reset - val obj = TypedActor.newInstance(classOf[SamplePojo], classOf[SamplePojoImpl]) - TypedActor.stop(obj) - assert(!SamplePojoImpl._pre) - assert(!SamplePojoImpl._post) - assert(SamplePojoImpl._down) - } - - it("both preRestart and postRestart methods should be invoked when an actor is restarted") { - SamplePojoImpl.reset - val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo], classOf[SimpleJavaPojoImpl]) - val supervisor = TypedActor.newInstance(classOf[SimpleJavaPojo], classOf[SimpleJavaPojoImpl]) - link(supervisor, pojo, OneForOneStrategy(classOf[Throwable] :: Nil, 3, 2000)) - pojo.throwException - Thread.sleep(500) - SimpleJavaPojoImpl._pre should be(true) - SimpleJavaPojoImpl._post should be(true) - } - - it("should be stopped when supervision cannot handle the problem in") { - val actorSupervision = new SuperviseTypedActor(classOf[TypedActorFailer], classOf[TypedActorFailerImpl], permanent(), 30000) - val conf = new TypedActorConfigurator().configure(OneForOneStrategy(Nil, 3, 500000), Array(actorSupervision)).inject.supervise - try { - val first = conf.getInstance(classOf[TypedActorFailer]) - try { - first.fail - fail("shouldn't get here") - } catch { - case r: RuntimeException if r.getMessage == "expected" ⇒ //expected - } - - // allow some time for the actor to be stopped - Testing.sleepFor(3 seconds) - - val second = conf.getInstance(classOf[TypedActorFailer]) - first should be(second) - - try { - second.fail - fail("shouldn't get here") - } catch { - case r: ActorInitializationException if r.getMessage == "Actor has not been started, you need to invoke 'actor.start()' before using it" ⇒ //expected - } - } finally { - conf.stop - } - } - - it("should be restarted when supervision handles the problem in") { - val actorSupervision = new SuperviseTypedActor(classOf[TypedActorFailer], classOf[TypedActorFailerImpl], permanent(), 30000) - val conf = new TypedActorConfigurator().configure(OneForOneStrategy(classOf[Throwable] :: Nil, 3, 500000), Array(actorSupervision)).inject.supervise - try { - val first = conf.getInstance(classOf[TypedActorFailer]) - try { - first.fail - fail("shouldn't get here") - } catch { - case r: RuntimeException if r.getMessage == "expected" ⇒ //expected - } - val second = conf.getInstance(classOf[TypedActorFailer]) - - first should be(second) - - try { - second.fail - fail("shouldn't get here") - } catch { - case r: RuntimeException if r.getMessage == "expected" ⇒ //expected - } - } finally { - conf.stop - } - } - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorRegistrySpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorRegistrySpec.scala deleted file mode 100644 index e75ad5617a..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorRegistrySpec.scala +++ /dev/null @@ -1,19 +0,0 @@ -package akka.actor - -import org.scalatest.WordSpec -import org.scalatest.matchers.MustMatchers - -import akka.config.Supervision._ -import akka.config._ - -object TypedActorRegistrySpec { - trait My - class MyImpl extends TypedActor with My -} - -class TypedActorRegistrySpec extends WordSpec with MustMatchers { - import TypedActorRegistrySpec._ - - "Typed Actor" should { - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorSpec.scala deleted file mode 100644 index 9f0eadfbf8..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorSpec.scala +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.actor - -import org.scalatest.{ Spec, WordSpec } -import org.scalatest.Assertions -import org.scalatest.matchers.{ ShouldMatchers, MustMatchers } -import org.scalatest.BeforeAndAfterEach -import org.scalatest.junit.JUnitRunner -import org.junit.runner.RunWith -import akka.japi.Option; - -import akka.dispatch.DefaultCompletableFuture -import TypedActorSpec._ - -object TypedActorSpec { - trait MyTypedActor { - def sendOneWay(msg: String): Unit - def sendRequestReply(msg: String): String - } - - class MyTypedActorImpl extends TypedActor with MyTypedActor { - def sendOneWay(msg: String) { - println("got " + msg) - } - def sendRequestReply(msg: String): String = { - "got " + msg - } - } - - class MyTypedActorWithConstructorArgsImpl(aString: String, aLong: Long) extends TypedActor with MyTypedActor { - def sendOneWay(msg: String) { - println("got " + msg + " " + aString + " " + aLong) - } - - def sendRequestReply(msg: String): String = { - msg + " " + aString + " " + aLong - } - } - - class MyActor extends Actor { - def receive = { - case msg: String ⇒ println("got " + msg) - } - } - -} - -@RunWith(classOf[JUnitRunner]) -class TypedActorSpec extends Spec with ShouldMatchers with BeforeAndAfterEach { - - var simplePojo: SimpleJavaPojo = null - var pojo: MyTypedActor = null; - - override def beforeEach() { - simplePojo = TypedActor.newInstance(classOf[SimpleJavaPojo], classOf[SimpleJavaPojoImpl]) - pojo = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyTypedActorImpl]) - } - - override def afterEach() { - Actor.registry.local.shutdownAll - } - - describe("TypedActor") { - - it("should return POJO method return value when invoked") { - val result = simplePojo.hello("POJO") - result should equal("Hello POJO") - } - - it("should resolve Future return from method defined to return a Future") { - val future = simplePojo.square(10) - future.await - future.result.isDefined should equal(true) - future.result.get should equal(100) - } - - it("should return none instead of exception") { - val someVal = Option.some("foo") - val noneVal = Option.none[String] - val nullVal = null: Option[String] - - assert(simplePojo.passThru(someVal) === someVal) - assert(simplePojo.passThru(noneVal) === Option.some(null)) - assert(simplePojo.passThru(nullVal) === Option.some(null)) - } - - it("should accept constructor arguments") { - val pojo1 = TypedActor.newInstance(classOf[MyTypedActor], new MyTypedActorWithConstructorArgsImpl("test", 1L)) - assert(pojo1.sendRequestReply("hello") === "hello test 1") - - val pojo2 = TypedActor.newInstance(classOf[MyTypedActor], new MyTypedActorWithConstructorArgsImpl("test2", 2L), new TypedActorConfiguration()) - assert(pojo2.sendRequestReply("hello") === "hello test2 2") - - val pojo3 = TypedActor.newInstance(classOf[MyTypedActor], new MyTypedActorWithConstructorArgsImpl("test3", 3L), 5000L) - assert(pojo3.sendRequestReply("hello") === "hello test3 3") - } - } - - describe("TypedActor object") { - it("should support finding the underlying actor for a given proxy and the proxy for a given actor") { - val typedActorRef = TypedActor.actorFor(simplePojo).get - val typedActor = typedActorRef.actor.asInstanceOf[TypedActor] - assert(typedActor.proxy === simplePojo) - assert(TypedActor.proxyFor(typedActorRef).get === simplePojo) - } - } - - describe("ActorRegistry") { - it("should support finding a typed actor by uuid ") { - val typedActorRef = TypedActor.actorFor(simplePojo).get - val uuid = typedActorRef.uuid - assert(Actor.registry.local.typedActorFor(newUuid()) === None) - assert(Actor.registry.local.typedActorFor(uuid).isDefined) - assert(Actor.registry.local.typedActorFor(uuid).get === simplePojo) - } - - it("should support finding a typed actor by address ") { - val typedActorRef = TypedActor.actorFor(simplePojo).get - val address = typedActorRef.address - assert(Actor.registry.local.typedActorFor(newUuid().toString) === None) - assert(Actor.registry.local.typedActorFor(address).isDefined) - assert(Actor.registry.local.typedActorFor(address).get === simplePojo) - } - - it("should support to filter typed actors") { - val actors = Actor.registry.local.filterTypedActors(ta ⇒ ta.isInstanceOf[MyTypedActor]) - assert(actors.length === 1) - assert(actors.contains(pojo)) - } - - it("should support to get all typed actors") { - val actors = Actor.registry.local.typedActors - assert(actors.length === 2) - assert(actors.contains(pojo)) - assert(actors.contains(simplePojo)) - } - - it("should support foreach for typed actors") { - val actorRef = Actor.actorOf[MyActor].start - assert(Actor.registry.local.actors.size === 3) - assert(Actor.registry.local.typedActors.size === 2) - Actor.registry.local.foreachTypedActor(TypedActor.stop(_)) - assert(Actor.registry.local.actors.size === 1) - assert(Actor.registry.local.typedActors.size === 0) - } - - it("should shutdown all typed and untyped actors") { - val actorRef = Actor.actorOf[MyActor].start - assert(Actor.registry.local.actors.size === 3) - assert(Actor.registry.local.typedActors.size === 2) - Actor.registry.local.shutdownAll() - assert(Actor.registry.local.actors.size === 0) - assert(Actor.registry.local.typedActors.size === 0) - } - } -} diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorUtilFunctionsSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorUtilFunctionsSpec.scala deleted file mode 100644 index db6f86f0ca..0000000000 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorUtilFunctionsSpec.scala +++ /dev/null @@ -1,24 +0,0 @@ -package akka.actor - -import org.scalatest.Suite -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner -import org.scalatest.matchers.MustMatchers -import org.junit.{ Before, After, Test } -import java.util.concurrent.{ CountDownLatch, TimeUnit } - -@RunWith(classOf[JUnitRunner]) -class ActorObjectUtilFunctionsSpec extends junit.framework.TestCase with Suite with MustMatchers { - import Actor._ - @Test - def testSpawn = { - val latch = new CountDownLatch(1) - - spawn { - latch.countDown() - } - - val done = latch.await(10, TimeUnit.SECONDS) - done must be(true) - } -} diff --git a/akka-typed-actor/src/test/scala/transactor/JavaCoordinatedIncrementSpec.scala b/akka-typed-actor/src/test/scala/transactor/JavaCoordinatedIncrementSpec.scala deleted file mode 100644 index de4ba0741a..0000000000 --- a/akka-typed-actor/src/test/scala/transactor/JavaCoordinatedIncrementSpec.scala +++ /dev/null @@ -1,7 +0,0 @@ -package akka.transactor.test - -import org.scalatest.junit.JUnitWrapperSuite - -class JavaCoordinatedIncrementSpec extends JUnitWrapperSuite( - "akka.transactor.test.TypedCoordinatedIncrementTest", - Thread.currentThread.getContextClassLoader) diff --git a/akka-typed-actor/src/test/scala/transactor/TypedCoordinatedIncrementSpec.scala b/akka-typed-actor/src/test/scala/transactor/TypedCoordinatedIncrementSpec.scala deleted file mode 100644 index dc244c8165..0000000000 --- a/akka-typed-actor/src/test/scala/transactor/TypedCoordinatedIncrementSpec.scala +++ /dev/null @@ -1,84 +0,0 @@ -package akka.transactor.test - -import org.scalatest.WordSpec -import org.scalatest.matchers.MustMatchers - -import akka.actor.TypedActor -import akka.stm.Ref -import akka.transactor.annotation.Coordinated -import akka.transactor.CoordinateException -import akka.transactor.Coordination._ - -object TypedCoordinatedIncrement { - trait Counter { - @Coordinated - def increment: Unit - @Coordinated - def incrementAndGet: Int - def get: Int - } - - class CounterImpl extends TypedActor with Counter { - val ref = Ref(0) - def increment = ref alter (_ + 1) - def incrementAndGet = { ref alter (_ + 1); ref.get } - def get = ref.get - } - - class FailerImpl extends TypedActor with Counter { - val ref = Ref(0) - def increment = throw new RuntimeException("Expected failure") - def incrementAndGet = throw new RuntimeException("Expected failure") - def get = ref.get - } -} - -class TypedCoordinatedIncrementSpec extends WordSpec with MustMatchers { - import TypedCoordinatedIncrement._ - - val numCounters = 5 - - def createActors = { - def createCounter(i: Int) = TypedActor.newInstance(classOf[Counter], classOf[CounterImpl]) - val counters = (1 to numCounters) map createCounter - val failer = TypedActor.newInstance(classOf[Counter], classOf[FailerImpl]) - (counters, failer) - } - - "Coordinated typed actor increment" should { - "increment all counters by one with successful transactions" in { - val (counters, failer) = createActors - coordinate { - counters foreach (_.increment) - } - for (counter ← counters) { - counter.get must be === 1 - } - counters foreach (TypedActor.stop) - TypedActor.stop(failer) - } - - "increment no counters with a failing transaction" in { - val (counters, failer) = createActors - try { - coordinate { - counters foreach (_.increment) - failer.increment - } - } catch { - case _ ⇒ () - } - for (counter ← counters) { - counter.get must be === 0 - } - counters foreach (TypedActor.stop) - TypedActor.stop(failer) - } - - "fail when used with non-void methods" in { - val counter = TypedActor.newInstance(classOf[Counter], classOf[CounterImpl]) - evaluating { counter.incrementAndGet } must produce[CoordinateException] - TypedActor.stop(counter) - } - } -} diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index f58258079c..d15319c4a7 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -141,9 +141,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec lazy val akka_testkit = project("akka-testkit", "akka-testkit", new AkkaTestkitProject(_), akka_actor) lazy val akka_actor_tests = project("akka-actor-tests", "akka-actor-tests", new AkkaActorTestsProject(_), akka_testkit) lazy val akka_stm = project("akka-stm", "akka-stm", new AkkaStmProject(_), akka_actor) - lazy val akka_typed_actor = project("akka-typed-actor", "akka-typed-actor", new AkkaTypedActorProject(_), akka_stm, akka_actor_tests) - - lazy val akka_remote = project("akka-remote", "akka-remote", new AkkaRemoteProject(_), akka_typed_actor) + lazy val akka_remote = project("akka-remote", "akka-remote", new AkkaRemoteProject(_), akka_stm, akka_actor_tests) lazy val akka_cluster = project("akka-cluster", "akka-cluster", new AkkaClusterProject(_), akka_remote) lazy val akka_durable_mailboxes = project("akka-durable-mailboxes", "akka-durable-mailboxes", new AkkaDurableMailboxesParentProject(_), akka_remote) @@ -279,23 +277,6 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec val scalatest = Dependencies.scalatest } - // ------------------------------------------------------------------------------------------------------------------- - // akka-typed-actor subproject - // ------------------------------------------------------------------------------------------------------------------- - - class AkkaTypedActorProject(info: ProjectInfo) extends AkkaDefaultProject(info) { - val aopalliance = Dependencies.aopalliance - val aspectwerkz = Dependencies.aspectwerkz - val guicey = Dependencies.guicey - - // testing - val junit = Dependencies.junit - val scalatest = Dependencies.scalatest - - override def deliverProjectDependencies = - super.deliverProjectDependencies.toList - akka_actor_tests.projectID ++ Seq(akka_actor_tests.projectID % "test") - } - // ------------------------------------------------------------------------------------------------------------------- // akka-remote subproject // -------------------------------------------------------------------------------------------------------------------