{
+ private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol result;
+
+ // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.newBuilder()
+ private Builder() {}
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol();
+ return builder;
+ }
+
+ protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException(
+ "Cannot call clear() after build().");
+ }
+ result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDescriptor();
+ }
+
+ public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol getDefaultInstanceForType() {
+ return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+ public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException(
+ "build() has already been called on this Builder.");
+ }
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol) {
+ return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol other) {
+ if (other == se.scalablesolutions.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);
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:TypedActorInfoProtocol)
+ }
+
public static final class RemoteRequestProtocol extends
com.google.protobuf.GeneratedMessage {
// Use RemoteRequestProtocol.newBuilder() to construct.
@@ -1911,64 +2799,29 @@ public final class RemoteProtocol {
public boolean hasMessage() { return hasMessage; }
public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.MessageProtocol getMessage() { return message_; }
- // optional string method = 3;
- public static final int METHOD_FIELD_NUMBER = 3;
- private boolean hasMethod;
- private java.lang.String method_ = "";
- public boolean hasMethod() { return hasMethod; }
- public java.lang.String getMethod() { return method_; }
+ // required .ActorInfoProtocol actorInfo = 3;
+ public static final int ACTORINFO_FIELD_NUMBER = 3;
+ private boolean hasActorInfo;
+ private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol actorInfo_;
+ public boolean hasActorInfo() { return hasActorInfo; }
+ public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol getActorInfo() { return actorInfo_; }
- // required string target = 4;
- public static final int TARGET_FIELD_NUMBER = 4;
- private boolean hasTarget;
- private java.lang.String target_ = "";
- public boolean hasTarget() { return hasTarget; }
- public java.lang.String getTarget() { return target_; }
-
- // required string uuid = 5;
- public static final int UUID_FIELD_NUMBER = 5;
- private boolean hasUuid;
- private java.lang.String uuid_ = "";
- public boolean hasUuid() { return hasUuid; }
- public java.lang.String getUuid() { return uuid_; }
-
- // required uint64 timeout = 6;
- public static final int TIMEOUT_FIELD_NUMBER = 6;
- private boolean hasTimeout;
- private long timeout_ = 0L;
- public boolean hasTimeout() { return hasTimeout; }
- public long getTimeout() { return timeout_; }
-
- // optional string supervisorUuid = 7;
- public static final int SUPERVISORUUID_FIELD_NUMBER = 7;
- private boolean hasSupervisorUuid;
- private java.lang.String supervisorUuid_ = "";
- public boolean hasSupervisorUuid() { return hasSupervisorUuid; }
- public java.lang.String getSupervisorUuid() { return supervisorUuid_; }
-
- // required bool isActor = 8;
- public static final int ISACTOR_FIELD_NUMBER = 8;
- private boolean hasIsActor;
- private boolean isActor_ = false;
- public boolean hasIsActor() { return hasIsActor; }
- public boolean getIsActor() { return isActor_; }
-
- // required bool isOneWay = 9;
- public static final int ISONEWAY_FIELD_NUMBER = 9;
+ // required bool isOneWay = 4;
+ public static final int ISONEWAY_FIELD_NUMBER = 4;
private boolean hasIsOneWay;
private boolean isOneWay_ = false;
public boolean hasIsOneWay() { return hasIsOneWay; }
public boolean getIsOneWay() { return isOneWay_; }
- // required bool isEscaped = 10;
- public static final int ISESCAPED_FIELD_NUMBER = 10;
- private boolean hasIsEscaped;
- private boolean isEscaped_ = false;
- public boolean hasIsEscaped() { return hasIsEscaped; }
- public boolean getIsEscaped() { return isEscaped_; }
+ // optional string supervisorUuid = 5;
+ public static final int SUPERVISORUUID_FIELD_NUMBER = 5;
+ private boolean hasSupervisorUuid;
+ private java.lang.String supervisorUuid_ = "";
+ public boolean hasSupervisorUuid() { return hasSupervisorUuid; }
+ public java.lang.String getSupervisorUuid() { return supervisorUuid_; }
- // optional .RemoteActorRefProtocol sender = 11;
- public static final int SENDER_FIELD_NUMBER = 11;
+ // optional .RemoteActorRefProtocol sender = 6;
+ public static final int SENDER_FIELD_NUMBER = 6;
private boolean hasSender;
private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol sender_;
public boolean hasSender() { return hasSender; }
@@ -1976,18 +2829,16 @@ public final class RemoteProtocol {
private void initFields() {
message_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.MessageProtocol.getDefaultInstance();
+ actorInfo_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.getDefaultInstance();
sender_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.getDefaultInstance();
}
public final boolean isInitialized() {
if (!hasId) return false;
if (!hasMessage) return false;
- if (!hasTarget) return false;
- if (!hasUuid) return false;
- if (!hasTimeout) return false;
- if (!hasIsActor) return false;
+ if (!hasActorInfo) return false;
if (!hasIsOneWay) return false;
- if (!hasIsEscaped) return false;
if (!getMessage().isInitialized()) return false;
+ if (!getActorInfo().isInitialized()) return false;
if (hasSender()) {
if (!getSender().isInitialized()) return false;
}
@@ -2003,32 +2854,17 @@ public final class RemoteProtocol {
if (hasMessage()) {
output.writeMessage(2, getMessage());
}
- if (hasMethod()) {
- output.writeString(3, getMethod());
- }
- if (hasTarget()) {
- output.writeString(4, getTarget());
- }
- if (hasUuid()) {
- output.writeString(5, getUuid());
- }
- if (hasTimeout()) {
- output.writeUInt64(6, getTimeout());
- }
- if (hasSupervisorUuid()) {
- output.writeString(7, getSupervisorUuid());
- }
- if (hasIsActor()) {
- output.writeBool(8, getIsActor());
+ if (hasActorInfo()) {
+ output.writeMessage(3, getActorInfo());
}
if (hasIsOneWay()) {
- output.writeBool(9, getIsOneWay());
+ output.writeBool(4, getIsOneWay());
}
- if (hasIsEscaped()) {
- output.writeBool(10, getIsEscaped());
+ if (hasSupervisorUuid()) {
+ output.writeString(5, getSupervisorUuid());
}
if (hasSender()) {
- output.writeMessage(11, getSender());
+ output.writeMessage(6, getSender());
}
getUnknownFields().writeTo(output);
}
@@ -2047,41 +2883,21 @@ public final class RemoteProtocol {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(2, getMessage());
}
- if (hasMethod()) {
+ if (hasActorInfo()) {
size += com.google.protobuf.CodedOutputStream
- .computeStringSize(3, getMethod());
- }
- if (hasTarget()) {
- size += com.google.protobuf.CodedOutputStream
- .computeStringSize(4, getTarget());
- }
- if (hasUuid()) {
- size += com.google.protobuf.CodedOutputStream
- .computeStringSize(5, getUuid());
- }
- if (hasTimeout()) {
- size += com.google.protobuf.CodedOutputStream
- .computeUInt64Size(6, getTimeout());
- }
- if (hasSupervisorUuid()) {
- size += com.google.protobuf.CodedOutputStream
- .computeStringSize(7, getSupervisorUuid());
- }
- if (hasIsActor()) {
- size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(8, getIsActor());
+ .computeMessageSize(3, getActorInfo());
}
if (hasIsOneWay()) {
size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(9, getIsOneWay());
+ .computeBoolSize(4, getIsOneWay());
}
- if (hasIsEscaped()) {
+ if (hasSupervisorUuid()) {
size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(10, getIsEscaped());
+ .computeStringSize(5, getSupervisorUuid());
}
if (hasSender()) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(11, getSender());
+ .computeMessageSize(6, getSender());
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -2247,29 +3063,14 @@ public final class RemoteProtocol {
if (other.hasMessage()) {
mergeMessage(other.getMessage());
}
- if (other.hasMethod()) {
- setMethod(other.getMethod());
- }
- if (other.hasTarget()) {
- setTarget(other.getTarget());
- }
- if (other.hasUuid()) {
- setUuid(other.getUuid());
- }
- if (other.hasTimeout()) {
- setTimeout(other.getTimeout());
- }
- if (other.hasSupervisorUuid()) {
- setSupervisorUuid(other.getSupervisorUuid());
- }
- if (other.hasIsActor()) {
- setIsActor(other.getIsActor());
+ if (other.hasActorInfo()) {
+ mergeActorInfo(other.getActorInfo());
}
if (other.hasIsOneWay()) {
setIsOneWay(other.getIsOneWay());
}
- if (other.hasIsEscaped()) {
- setIsEscaped(other.getIsEscaped());
+ if (other.hasSupervisorUuid()) {
+ setSupervisorUuid(other.getSupervisorUuid());
}
if (other.hasSender()) {
mergeSender(other.getSender());
@@ -2313,38 +3114,23 @@ public final class RemoteProtocol {
break;
}
case 26: {
- setMethod(input.readString());
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.Builder subBuilder = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.newBuilder();
+ if (hasActorInfo()) {
+ subBuilder.mergeFrom(getActorInfo());
+ }
+ input.readMessage(subBuilder, extensionRegistry);
+ setActorInfo(subBuilder.buildPartial());
break;
}
- case 34: {
- setTarget(input.readString());
- break;
- }
- case 42: {
- setUuid(input.readString());
- break;
- }
- case 48: {
- setTimeout(input.readUInt64());
- break;
- }
- case 58: {
- setSupervisorUuid(input.readString());
- break;
- }
- case 64: {
- setIsActor(input.readBool());
- break;
- }
- case 72: {
+ case 32: {
setIsOneWay(input.readBool());
break;
}
- case 80: {
- setIsEscaped(input.readBool());
+ case 42: {
+ setSupervisorUuid(input.readString());
break;
}
- case 90: {
+ case 50: {
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.Builder subBuilder = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.newBuilder();
if (hasSender()) {
subBuilder.mergeFrom(getSender());
@@ -2413,88 +3199,62 @@ public final class RemoteProtocol {
return this;
}
- // optional string method = 3;
- public boolean hasMethod() {
- return result.hasMethod();
+ // required .ActorInfoProtocol actorInfo = 3;
+ public boolean hasActorInfo() {
+ return result.hasActorInfo();
}
- public java.lang.String getMethod() {
- return result.getMethod();
+ public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol getActorInfo() {
+ return result.getActorInfo();
}
- public Builder setMethod(java.lang.String value) {
+ public Builder setActorInfo(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol value) {
if (value == null) {
- throw new NullPointerException();
- }
- result.hasMethod = true;
- result.method_ = value;
+ throw new NullPointerException();
+ }
+ result.hasActorInfo = true;
+ result.actorInfo_ = value;
return this;
}
- public Builder clearMethod() {
- result.hasMethod = false;
- result.method_ = getDefaultInstance().getMethod();
+ public Builder setActorInfo(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.Builder builderForValue) {
+ result.hasActorInfo = true;
+ result.actorInfo_ = builderForValue.build();
+ return this;
+ }
+ public Builder mergeActorInfo(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol value) {
+ if (result.hasActorInfo() &&
+ result.actorInfo_ != se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.getDefaultInstance()) {
+ result.actorInfo_ =
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.newBuilder(result.actorInfo_).mergeFrom(value).buildPartial();
+ } else {
+ result.actorInfo_ = value;
+ }
+ result.hasActorInfo = true;
+ return this;
+ }
+ public Builder clearActorInfo() {
+ result.hasActorInfo = false;
+ result.actorInfo_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.getDefaultInstance();
return this;
}
- // required string target = 4;
- public boolean hasTarget() {
- return result.hasTarget();
+ // required bool isOneWay = 4;
+ public boolean hasIsOneWay() {
+ return result.hasIsOneWay();
}
- public java.lang.String getTarget() {
- return result.getTarget();
+ public boolean getIsOneWay() {
+ return result.getIsOneWay();
}
- public Builder setTarget(java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- result.hasTarget = true;
- result.target_ = value;
+ public Builder setIsOneWay(boolean value) {
+ result.hasIsOneWay = true;
+ result.isOneWay_ = value;
return this;
}
- public Builder clearTarget() {
- result.hasTarget = false;
- result.target_ = getDefaultInstance().getTarget();
+ public Builder clearIsOneWay() {
+ result.hasIsOneWay = false;
+ result.isOneWay_ = false;
return this;
}
- // required string uuid = 5;
- public boolean hasUuid() {
- return result.hasUuid();
- }
- public java.lang.String getUuid() {
- return result.getUuid();
- }
- public Builder setUuid(java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- result.hasUuid = true;
- result.uuid_ = value;
- return this;
- }
- public Builder clearUuid() {
- result.hasUuid = false;
- result.uuid_ = getDefaultInstance().getUuid();
- return this;
- }
-
- // required uint64 timeout = 6;
- public boolean hasTimeout() {
- return result.hasTimeout();
- }
- public long getTimeout() {
- return result.getTimeout();
- }
- public Builder setTimeout(long value) {
- result.hasTimeout = true;
- result.timeout_ = value;
- return this;
- }
- public Builder clearTimeout() {
- result.hasTimeout = false;
- result.timeout_ = 0L;
- return this;
- }
-
- // optional string supervisorUuid = 7;
+ // optional string supervisorUuid = 5;
public boolean hasSupervisorUuid() {
return result.hasSupervisorUuid();
}
@@ -2515,61 +3275,7 @@ public final class RemoteProtocol {
return this;
}
- // required bool isActor = 8;
- public boolean hasIsActor() {
- return result.hasIsActor();
- }
- public boolean getIsActor() {
- return result.getIsActor();
- }
- public Builder setIsActor(boolean value) {
- result.hasIsActor = true;
- result.isActor_ = value;
- return this;
- }
- public Builder clearIsActor() {
- result.hasIsActor = false;
- result.isActor_ = false;
- return this;
- }
-
- // required bool isOneWay = 9;
- public boolean hasIsOneWay() {
- return result.hasIsOneWay();
- }
- public boolean getIsOneWay() {
- return result.getIsOneWay();
- }
- public Builder setIsOneWay(boolean value) {
- result.hasIsOneWay = true;
- result.isOneWay_ = value;
- return this;
- }
- public Builder clearIsOneWay() {
- result.hasIsOneWay = false;
- result.isOneWay_ = false;
- return this;
- }
-
- // required bool isEscaped = 10;
- public boolean hasIsEscaped() {
- return result.hasIsEscaped();
- }
- public boolean getIsEscaped() {
- return result.getIsEscaped();
- }
- public Builder setIsEscaped(boolean value) {
- result.hasIsEscaped = true;
- result.isEscaped_ = value;
- return this;
- }
- public Builder clearIsEscaped() {
- result.hasIsEscaped = false;
- result.isEscaped_ = false;
- return this;
- }
-
- // optional .RemoteActorRefProtocol sender = 11;
+ // optional .RemoteActorRefProtocol sender = 6;
public boolean hasSender() {
return result.hasSender();
}
@@ -3207,6 +3913,20 @@ public final class RemoteProtocol {
public boolean hasPostRestart() { return hasPostRestart; }
public java.lang.String getPostRestart() { return postRestart_; }
+ // optional string init = 4;
+ public static final int INIT_FIELD_NUMBER = 4;
+ private boolean hasInit;
+ private java.lang.String init_ = "";
+ public boolean hasInit() { return hasInit; }
+ public java.lang.String getInit() { return init_; }
+
+ // optional string shutdown = 5;
+ public static final int SHUTDOWN_FIELD_NUMBER = 5;
+ private boolean hasShutdown;
+ private java.lang.String shutdown_ = "";
+ public boolean hasShutdown() { return hasShutdown; }
+ public java.lang.String getShutdown() { return shutdown_; }
+
private void initFields() {
lifeCycle_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.PERMANENT;
}
@@ -3227,6 +3947,12 @@ public final class RemoteProtocol {
if (hasPostRestart()) {
output.writeString(3, getPostRestart());
}
+ if (hasInit()) {
+ output.writeString(4, getInit());
+ }
+ if (hasShutdown()) {
+ output.writeString(5, getShutdown());
+ }
getUnknownFields().writeTo(output);
}
@@ -3248,6 +3974,14 @@ public final class RemoteProtocol {
size += com.google.protobuf.CodedOutputStream
.computeStringSize(3, getPostRestart());
}
+ if (hasInit()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeStringSize(4, getInit());
+ }
+ if (hasShutdown()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeStringSize(5, getShutdown());
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -3415,6 +4149,12 @@ public final class RemoteProtocol {
if (other.hasPostRestart()) {
setPostRestart(other.getPostRestart());
}
+ if (other.hasInit()) {
+ setInit(other.getInit());
+ }
+ if (other.hasShutdown()) {
+ setShutdown(other.getShutdown());
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -3458,6 +4198,14 @@ public final class RemoteProtocol {
setPostRestart(input.readString());
break;
}
+ case 34: {
+ setInit(input.readString());
+ break;
+ }
+ case 42: {
+ setShutdown(input.readString());
+ break;
+ }
}
}
}
@@ -3526,6 +4274,48 @@ public final class RemoteProtocol {
return this;
}
+ // optional string init = 4;
+ public boolean hasInit() {
+ return result.hasInit();
+ }
+ public java.lang.String getInit() {
+ return result.getInit();
+ }
+ public Builder setInit(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasInit = true;
+ result.init_ = value;
+ return this;
+ }
+ public Builder clearInit() {
+ result.hasInit = false;
+ result.init_ = getDefaultInstance().getInit();
+ return this;
+ }
+
+ // optional string shutdown = 5;
+ public boolean hasShutdown() {
+ return result.hasShutdown();
+ }
+ public java.lang.String getShutdown() {
+ return result.getShutdown();
+ }
+ public Builder setShutdown(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasShutdown = true;
+ result.shutdown_ = value;
+ return this;
+ }
+ public Builder clearShutdown() {
+ result.hasShutdown = false;
+ result.shutdown_ = getDefaultInstance().getShutdown();
+ return this;
+ }
+
// @@protoc_insertion_point(builder_scope:LifeCycleProtocol)
}
@@ -4212,6 +5002,16 @@ public final class RemoteProtocol {
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_MessageProtocol_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_ActorInfoProtocol_descriptor;
+ 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_RemoteRequestProtocol_descriptor;
private static
@@ -4262,27 +5062,33 @@ public final class RemoteProtocol {
"tProtocol\"r\n\017MessageProtocol\0225\n\023serializ" +
"ationScheme\030\001 \002(\0162\030.SerializationSchemeT" +
"ype\022\017\n\007message\030\002 \002(\014\022\027\n\017messageManifest\030" +
- "\003 \001(\014\"\374\001\n\025RemoteRequestProtocol\022\n\n\002id\030\001 " +
- "\002(\004\022!\n\007message\030\002 \002(\0132\020.MessageProtocol\022\016" +
- "\n\006method\030\003 \001(\t\022\016\n\006target\030\004 \002(\t\022\014\n\004uuid\030\005" +
- " \002(\t\022\017\n\007timeout\030\006 \002(\004\022\026\n\016supervisorUuid\030",
- "\007 \001(\t\022\017\n\007isActor\030\010 \002(\010\022\020\n\010isOneWay\030\t \002(\010" +
- "\022\021\n\tisEscaped\030\n \002(\010\022\'\n\006sender\030\013 \001(\0132\027.Re" +
- "moteActorRefProtocol\"\252\001\n\023RemoteReplyProt" +
- "ocol\022\n\n\002id\030\001 \002(\004\022!\n\007message\030\002 \001(\0132\020.Mess" +
- "ageProtocol\022%\n\texception\030\003 \001(\0132\022.Excepti" +
- "onProtocol\022\026\n\016supervisorUuid\030\004 \001(\t\022\017\n\007is" +
- "Actor\030\005 \002(\010\022\024\n\014isSuccessful\030\006 \002(\010\"_\n\021Lif" +
- "eCycleProtocol\022!\n\tlifeCycle\030\001 \002(\0162\016.Life" +
- "CycleType\022\022\n\npreRestart\030\002 \001(\t\022\023\n\013postRes" +
- "tart\030\003 \001(\t\"1\n\017AddressProtocol\022\020\n\010hostnam",
- "e\030\001 \002(\t\022\014\n\004port\030\002 \002(\r\"7\n\021ExceptionProtoc" +
- "ol\022\021\n\tclassname\030\001 \002(\t\022\017\n\007message\030\002 \002(\t*]" +
- "\n\027SerializationSchemeType\022\010\n\004JAVA\020\001\022\013\n\007S" +
- "BINARY\020\002\022\016\n\nSCALA_JSON\020\003\022\r\n\tJAVA_JSON\020\004\022" +
- "\014\n\010PROTOBUF\020\005*-\n\rLifeCycleType\022\r\n\tPERMAN" +
- "ENT\020\001\022\r\n\tTEMPORARY\020\002B-\n)se.scalablesolut" +
- "ions.akka.remote.protocolH\001"
+ "\003 \001(\014\"\222\001\n\021ActorInfoProtocol\022\014\n\004uuid\030\001 \002(" +
+ "\t\022\016\n\006target\030\002 \002(\t\022\017\n\007timeout\030\003 \002(\004\022\035\n\tac" +
+ "torType\030\004 \002(\0162\n.ActorType\022/\n\016typedActorI" +
+ "nfo\030\005 \001(\0132\027.TypedActorInfoProtocol\";\n\026Ty",
+ "pedActorInfoProtocol\022\021\n\tinterface\030\001 \002(\t\022" +
+ "\016\n\006method\030\002 \002(\t\"\300\001\n\025RemoteRequestProtoco" +
+ "l\022\n\n\002id\030\001 \002(\004\022!\n\007message\030\002 \002(\0132\020.Message" +
+ "Protocol\022%\n\tactorInfo\030\003 \002(\0132\022.ActorInfoP" +
+ "rotocol\022\020\n\010isOneWay\030\004 \002(\010\022\026\n\016supervisorU" +
+ "uid\030\005 \001(\t\022\'\n\006sender\030\006 \001(\0132\027.RemoteActorR" +
+ "efProtocol\"\252\001\n\023RemoteReplyProtocol\022\n\n\002id" +
+ "\030\001 \002(\004\022!\n\007message\030\002 \001(\0132\020.MessageProtoco" +
+ "l\022%\n\texception\030\003 \001(\0132\022.ExceptionProtocol" +
+ "\022\026\n\016supervisorUuid\030\004 \001(\t\022\017\n\007isActor\030\005 \002(",
+ "\010\022\024\n\014isSuccessful\030\006 \002(\010\"\177\n\021LifeCycleProt" +
+ "ocol\022!\n\tlifeCycle\030\001 \002(\0162\016.LifeCycleType\022" +
+ "\022\n\npreRestart\030\002 \001(\t\022\023\n\013postRestart\030\003 \001(\t" +
+ "\022\014\n\004init\030\004 \001(\t\022\020\n\010shutdown\030\005 \001(\t\"1\n\017Addr" +
+ "essProtocol\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*=\n\tActorType\022\017\n\013SCA" +
+ "LA_ACTOR\020\001\022\016\n\nJAVA_ACTOR\020\002\022\017\n\013TYPED_ACTO" +
+ "R\020\003*]\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_JS",
+ "ON\020\004\022\014\n\010PROTOBUF\020\005*-\n\rLifeCycleType\022\r\n\tP" +
+ "ERMANENT\020\001\022\r\n\tTEMPORARY\020\002B-\n)se.scalable" +
+ "solutions.akka.remote.protocolH\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -4313,16 +5119,32 @@ public final class RemoteProtocol {
new java.lang.String[] { "SerializationScheme", "Message", "MessageManifest", },
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.MessageProtocol.class,
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.MessageProtocol.Builder.class);
- internal_static_RemoteRequestProtocol_descriptor =
+ internal_static_ActorInfoProtocol_descriptor =
getDescriptor().getMessageTypes().get(3);
+ internal_static_ActorInfoProtocol_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_ActorInfoProtocol_descriptor,
+ new java.lang.String[] { "Uuid", "Target", "Timeout", "ActorType", "TypedActorInfo", },
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.class,
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ActorInfoProtocol.Builder.class);
+ internal_static_TypedActorInfoProtocol_descriptor =
+ getDescriptor().getMessageTypes().get(4);
+ internal_static_TypedActorInfoProtocol_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_TypedActorInfoProtocol_descriptor,
+ new java.lang.String[] { "Interface", "Method", },
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.class,
+ se.scalablesolutions.akka.remote.protocol.RemoteProtocol.TypedActorInfoProtocol.Builder.class);
+ internal_static_RemoteRequestProtocol_descriptor =
+ getDescriptor().getMessageTypes().get(5);
internal_static_RemoteRequestProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RemoteRequestProtocol_descriptor,
- new java.lang.String[] { "Id", "Message", "Method", "Target", "Uuid", "Timeout", "SupervisorUuid", "IsActor", "IsOneWay", "IsEscaped", "Sender", },
+ new java.lang.String[] { "Id", "Message", "ActorInfo", "IsOneWay", "SupervisorUuid", "Sender", },
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteRequestProtocol.class,
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteRequestProtocol.Builder.class);
internal_static_RemoteReplyProtocol_descriptor =
- getDescriptor().getMessageTypes().get(4);
+ getDescriptor().getMessageTypes().get(6);
internal_static_RemoteReplyProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RemoteReplyProtocol_descriptor,
@@ -4330,15 +5152,15 @@ public final class RemoteProtocol {
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteReplyProtocol.class,
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteReplyProtocol.Builder.class);
internal_static_LifeCycleProtocol_descriptor =
- getDescriptor().getMessageTypes().get(5);
+ getDescriptor().getMessageTypes().get(7);
internal_static_LifeCycleProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_LifeCycleProtocol_descriptor,
- new java.lang.String[] { "LifeCycle", "PreRestart", "PostRestart", },
+ new java.lang.String[] { "LifeCycle", "PreRestart", "PostRestart", "Init", "Shutdown", },
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.class,
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.Builder.class);
internal_static_AddressProtocol_descriptor =
- getDescriptor().getMessageTypes().get(6);
+ getDescriptor().getMessageTypes().get(8);
internal_static_AddressProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_AddressProtocol_descriptor,
@@ -4346,7 +5168,7 @@ public final class RemoteProtocol {
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.class,
se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder.class);
internal_static_ExceptionProtocol_descriptor =
- getDescriptor().getMessageTypes().get(7);
+ getDescriptor().getMessageTypes().get(9);
internal_static_ExceptionProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_ExceptionProtocol_descriptor,
diff --git a/akka-core/src/main/protocol/RemoteProtocol.proto b/akka-core/src/main/protocol/RemoteProtocol.proto
index c4e5a8157e..0417251d55 100644
--- a/akka-core/src/main/protocol/RemoteProtocol.proto
+++ b/akka-core/src/main/protocol/RemoteProtocol.proto
@@ -52,21 +52,35 @@ message MessageProtocol {
optional bytes messageManifest = 3;
}
+/**
+ * Defines the actor info.
+ */
+message ActorInfoProtocol {
+ required string uuid = 1;
+ required string target = 2;
+ required uint64 timeout = 3;
+ required ActorType actorType = 4;
+ optional TypedActorInfoProtocol typedActorInfo = 5;
+}
+
+/**
+ * Defines the typed actor extra info.
+ */
+message TypedActorInfoProtocol {
+ required string interface = 1;
+ required string method = 2;
+}
+
/**
* Defines a remote message request.
*/
message RemoteRequestProtocol {
required uint64 id = 1;
required MessageProtocol message = 2;
- optional string method = 3;
- required string target = 4;
- required string uuid = 5;
- required uint64 timeout = 6;
- optional string supervisorUuid = 7;
- required bool isActor = 8;
- required bool isOneWay = 9;
- required bool isEscaped = 10;
- optional RemoteActorRefProtocol sender = 11;
+ required ActorInfoProtocol actorInfo = 3;
+ required bool isOneWay = 4;
+ optional string supervisorUuid = 5;
+ optional RemoteActorRefProtocol sender = 6;
}
/**
@@ -81,6 +95,15 @@ message RemoteReplyProtocol {
required bool isSuccessful = 6;
}
+/**
+ * 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.
*/
@@ -117,6 +140,8 @@ message LifeCycleProtocol {
required LifeCycleType lifeCycle = 1;
optional string preRestart = 2;
optional string postRestart = 3;
+ optional string init = 4;
+ optional string shutdown = 5;
}
/**
diff --git a/akka-core/src/main/resources/META-INF/aop.xml b/akka-core/src/main/resources/META-INF/aop.xml
index 2f8d5159a8..bdc167ca54 100644
--- a/akka-core/src/main/resources/META-INF/aop.xml
+++ b/akka-core/src/main/resources/META-INF/aop.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/akka-core/src/main/scala/actor/ActorRef.scala b/akka-core/src/main/scala/actor/ActorRef.scala
index 9824e8b2b6..3d01ec7886 100644
--- a/akka-core/src/main/scala/actor/ActorRef.scala
+++ b/akka-core/src/main/scala/actor/ActorRef.scala
@@ -291,15 +291,15 @@ trait ActorRef extends TransactionManagement {
def !!(message: Any, timeout: Long = this.timeout)(implicit sender: Option[ActorRef] = None): Option[Any] = {
if (isRunning) {
val future = postMessageToMailboxAndCreateFutureResultWithTimeout[Any](message, timeout, sender, None)
- val isActiveObject = message.isInstanceOf[Invocation]
- if (isActiveObject && message.asInstanceOf[Invocation].isVoid) {
+ val isTypedActor = message.isInstanceOf[Invocation]
+ if (isTypedActor && message.asInstanceOf[Invocation].isVoid) {
future.asInstanceOf[CompletableFuture[Option[_]]].completeWithResult(None)
}
try {
future.await
} catch {
case e: FutureTimeoutException =>
- if (isActiveObject) throw e
+ if (isTypedActor) throw e
else None
}
if (future.exception.isDefined) throw future.exception.get._2
@@ -347,7 +347,7 @@ trait ActorRef extends TransactionManagement {
"\n\tNo sender in scope, can't reply. " +
"\n\tYou have probably: " +
"\n\t\t1. Sent a message to an Actor from an instance that is NOT an Actor." +
- "\n\t\t2. Invoked a method on an Active Object from an instance NOT an Active Object." +
+ "\n\t\t2. Invoked a method on an TypedActor from an instance NOT an TypedActor." +
"\n\tElse you might want to use 'reply_?' which returns Boolean(true) if succes and Boolean(false) if no sender in scope")
/**
diff --git a/akka-core/src/main/scala/actor/SerializationProtocol.scala b/akka-core/src/main/scala/actor/SerializationProtocol.scala
index 13e8230638..3897d3abda 100644
--- a/akka-core/src/main/scala/actor/SerializationProtocol.scala
+++ b/akka-core/src/main/scala/actor/SerializationProtocol.scala
@@ -122,7 +122,8 @@ object ActorSerialization {
private def fromBinaryToLocalActorRef[T <: Actor](bytes: Array[Byte], format: Format[T]): ActorRef =
fromProtobufToLocalActorRef(SerializedActorRefProtocol.newBuilder.mergeFrom(bytes).build, format, None)
- private def fromProtobufToLocalActorRef[T <: Actor](protocol: SerializedActorRefProtocol, format: Format[T], loader: Option[ClassLoader]): ActorRef = {
+ private def fromProtobufToLocalActorRef[T <: Actor](
+ protocol: SerializedActorRefProtocol, format: Format[T], loader: Option[ClassLoader]): ActorRef = {
Actor.log.debug("Deserializing SerializedActorRefProtocol to LocalActorRef:\n" + protocol)
val serializer =
@@ -225,26 +226,30 @@ object RemoteActorSerialization {
.build
}
- def createRemoteRequestProtocolBuilder(ar: ActorRef,
- message: Any, isOneWay: Boolean, senderOption: Option[ActorRef]): RemoteRequestProtocol.Builder = {
- import ar._
- val protocol = RemoteRequestProtocol.newBuilder
- .setId(RemoteRequestProtocolIdFactory.nextId)
- .setMessage(MessageSerializer.serialize(message))
+ def createRemoteRequestProtocolBuilder(actorRef: ActorRef, message: Any, isOneWay: Boolean, senderOption: Option[ActorRef]):
+ RemoteRequestProtocol.Builder = {
+ import actorRef._
+
+ val actorInfo = ActorInfoProtocol.newBuilder
+ .setUuid(uuid)
.setTarget(actorClassName)
.setTimeout(timeout)
- .setUuid(uuid)
- .setIsActor(true)
+ .setActorType(ActorType.SCALA_ACTOR)
+ .build
+
+ val request = RemoteRequestProtocol.newBuilder
+ .setId(RemoteRequestProtocolIdFactory.nextId)
+ .setMessage(MessageSerializer.serialize(message))
+ .setActorInfo(actorInfo)
.setIsOneWay(isOneWay)
- .setIsEscaped(false)
val id = registerSupervisorAsRemoteActor
- if (id.isDefined) protocol.setSupervisorUuid(id.get)
+ if (id.isDefined) request.setSupervisorUuid(id.get)
senderOption.foreach { sender =>
RemoteServer.getOrCreateServer(sender.homeAddress).register(sender.uuid, sender)
- protocol.setSender(toRemoteActorRefProtocol(sender))
+ request.setSender(toRemoteActorRefProtocol(sender))
}
- protocol
+ request
}
}
diff --git a/akka-core/src/main/scala/actor/ActiveObject.scala b/akka-core/src/main/scala/actor/TypedActor.scala
similarity index 50%
rename from akka-core/src/main/scala/actor/ActiveObject.scala
rename to akka-core/src/main/scala/actor/TypedActor.scala
index 83ac1fc924..bd5235242b 100644
--- a/akka-core/src/main/scala/actor/ActiveObject.scala
+++ b/akka-core/src/main/scala/actor/TypedActor.scala
@@ -6,12 +6,13 @@ package se.scalablesolutions.akka.actor
import Actor._
import se.scalablesolutions.akka.config.FaultHandlingStrategy
-import se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteRequestProtocol
+import se.scalablesolutions.akka.remote.protocol.RemoteProtocol._
import se.scalablesolutions.akka.remote.{MessageSerializer, RemoteClient, RemoteRequestProtocolIdFactory}
import se.scalablesolutions.akka.dispatch.{MessageDispatcher, Future, CompletableFuture}
import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.serialization.Serializer
import se.scalablesolutions.akka.util._
+import se.scalablesolutions.akka.actor.annotation._
import org.codehaus.aspectwerkz.joinpoint.{MethodRtti, JoinPoint}
import org.codehaus.aspectwerkz.proxy.Proxy
@@ -20,21 +21,111 @@ import org.codehaus.aspectwerkz.annotation.{Aspect, Around}
import java.net.InetSocketAddress
import java.lang.reflect.{InvocationTargetException, Method}
-object Annotations {
- import se.scalablesolutions.akka.actor.annotation._
- val transactionrequired = classOf[transactionrequired]
- val prerestart = classOf[prerestart]
- val postrestart = classOf[postrestart]
- val shutdown = classOf[shutdown]
- val inittransactionalstate = classOf[inittransactionalstate]
+import scala.reflect.BeanProperty
+
+/**
+ * FIXME: document TypedActor
+ *
+ * @author Jonas Bonér
+ */
+abstract class TypedActor extends Logging {
+
+ /**
+ * 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.
+ *
+ * Here is an example of usage (in Java):
+ *
+ * class PingImpl exends TypedActor implements Ping {
+ * public void hit(int count) {
+ * Pong pong = (Pong) getContext().getSender();
+ * pong.hit(count++)
+ * }
+ * }
+ *
+ */
+ @BeanProperty protected var context: TypedActorContext = _
+
+ /**
+ * The uuid for the typed actor.
+ */
+ @BeanProperty @volatile var uuid = UUID.newUuid.toString
+
+ /**
+ * Identifier for actor, does not have to be a unique one. Default is the 'uuid'.
+ *
+ * This field is used for logging, AspectRegistry.actorsFor(id), identifier for remote
+ * actor in RemoteServer etc.But also as the identifier for persistence, which means
+ * that you can use a custom name to be able to retrieve the "correct" persisted state
+ * upon restart, remote restart etc.
+ *
+ * This property can be set to a custom ID.
+ */
+ @BeanProperty @volatile protected var id: String = uuid
+
+ /**
+ * Defines the default timeout for '!!' and '!!!' invocations,
+ * e.g. the timeout for the future returned by the call to '!!' and '!!!'.
+ *
+ * This property can be set to a custom timeout.
+ */
+ @BeanProperty @volatile protected var timeout: Long = Actor.TIMEOUT
+
+ /**
+ * User overridable callback.
+ *
+ * Is called when an Actor is started by invoking 'actor.start'.
+ */
+ def init {}
+
+ /**
+ * User overridable callback.
+ *
+ * Is called when 'actor.stop' is invoked.
+ */
+ def shutdown {}
+
+ /**
+ * User overridable callback.
+ *
+ * Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.
+ */
+ def preRestart(reason: Throwable) {}
+
+ /**
+ * User overridable callback.
+ *
+ * Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
+ */
+ def postRestart(reason: Throwable) {}
+
+ /**
+ * User overridable callback.
+ *
+ * Is called during initialization. Can be used to initialize transactional state. Will be invoked within a transaction.
+ */
+ def initTransactionalState {}
}
/**
- * Configuration factory for Active Objects.
+ * FIXME: document TypedTransactor
*
- * FIXDOC: document ActiveObjectConfiguration
+ * @author Jonas Bonér
*/
-final class ActiveObjectConfiguration {
+@transactionrequired
+abstract class TypedTransactor extends TypedActor
+
+/**
+ * Configuration factory for TypedActors.
+ *
+ * FIXDOC: document TypedActorConfiguration
+ *
+ * @author Jonas Bonér
+ */
+final class TypedActorConfiguration {
private[akka] var _timeout: Long = Actor.TIMEOUT
private[akka] var _restartCallbacks: Option[RestartCallbacks] = None
private[akka] var _shutdownCallback: Option[ShutdownCallback] = None
@@ -43,57 +134,49 @@ final class ActiveObjectConfiguration {
private[akka] var _messageDispatcher: Option[MessageDispatcher] = None
def timeout = _timeout
- def timeout(timeout: Duration) : ActiveObjectConfiguration = {
+ def timeout(timeout: Duration) : TypedActorConfiguration = {
_timeout = timeout.toMillis
this
}
- def restartCallbacks(pre: String, post: String) : ActiveObjectConfiguration = {
+ def restartCallbacks(pre: String, post: String) : TypedActorConfiguration = {
_restartCallbacks = Some(new RestartCallbacks(pre, post))
this
}
- def shutdownCallback(down: String) : ActiveObjectConfiguration = {
+ def shutdownCallback(down: String) : TypedActorConfiguration = {
_shutdownCallback = Some(new ShutdownCallback(down))
this
}
- def makeTransactionRequired() : ActiveObjectConfiguration = {
+ def makeTransactionRequired() : TypedActorConfiguration = {
_transactionRequired = true;
this
}
- def makeRemote(hostname: String, port: Int) : ActiveObjectConfiguration = {
+ def makeRemote(hostname: String, port: Int) : TypedActorConfiguration = {
_host = Some(new InetSocketAddress(hostname, port))
this
}
- def dispatcher(messageDispatcher: MessageDispatcher) : ActiveObjectConfiguration = {
+ def dispatcher(messageDispatcher: MessageDispatcher) : TypedActorConfiguration = {
_messageDispatcher = Some(messageDispatcher)
this
}
}
/**
- * Holds RTTI (runtime type information) for the Active Object, f.e. current 'sender'
+ * Holds RTTI (runtime type information) for the TypedActor, f.e. current 'sender'
* reference, the 'senderFuture' reference etc.
*
- * In order to make use of this context you have to create a member field in your
- * Active Object that has the type 'ActiveObjectContext', then an instance will
- * be injected for you to use.
- *
* This class does not contain static information but is updated by the runtime system
* at runtime.
*
- * Here is an example of usage:
+ * Here is an example of usage (from Java):
*
- * class Ping {
- * // This context will be injected, holds RTTI (runtime type information)
- * // for the current message send
- * private ActiveObjectContext context = null;
- *
+ * class PingImpl exends TypedActor implements Ping {
* public void hit(int count) {
- * Pong pong = (Pong) context.getSender();
+ * Pong pong = (Pong) getContext().getSender();
* pong.hit(count++)
* }
* }
@@ -101,12 +184,12 @@ final class ActiveObjectConfiguration {
*
* @author Jonas Bonér
*/
-final class ActiveObjectContext {
+final class TypedActorContext {
private[akka] var _sender: AnyRef = _
private[akka] var _senderFuture: CompletableFuture[Any] = _
/**
- * Returns the current sender Active Object reference.
+ * Returns the current sender reference.
* Scala style getter.
*/
def sender: AnyRef = {
@@ -115,7 +198,7 @@ final class ActiveObjectContext {
}
/**
- * Returns the current sender Active Object reference.
+ * Returns the current sender reference.
* Java style getter.
*/
def getSender: AnyRef = {
@@ -124,13 +207,13 @@ final class ActiveObjectContext {
}
/**
- * Returns the current sender future Active Object reference.
+ * Returns the current sender future TypedActor reference.
* Scala style getter.
*/
def senderFuture: Option[CompletableFuture[Any]] = if (_senderFuture eq null) None else Some(_senderFuture)
/**
- * Returns the current sender future Active Object reference.
+ * Returns the current sender future TypedActor reference.
* Java style getter.
* This method returns 'null' if the sender future is not available.
*/
@@ -138,249 +221,63 @@ final class ActiveObjectContext {
}
/**
- * Internal helper class to help pass the contextual information between threads.
+ * Factory class for creating TypedActors out of plain POJOs and/or POJOs with interfaces.
*
* @author Jonas Bonér
*/
-private[akka] object ActiveObjectContext {
- import scala.util.DynamicVariable
- private[actor] val sender = new DynamicVariable[AnyRef](null)
- private[actor] val senderFuture = new DynamicVariable[CompletableFuture[Any]](null)
-}
-
-/**
- * Factory class for creating Active Objects out of plain POJOs and/or POJOs with interfaces.
- *
- * @author Jonas Bonér
- */
-object ActiveObject extends Logging {
+object TypedActor extends Logging {
import Actor.actorOf
- val AKKA_CAMEL_ROUTING_SCHEME = "akka"
+ val AKKA_CAMEL_ROUTING_SCHEME = "akka".intern
private[actor] val AW_PROXY_PREFIX = "$$ProxiedByAW".intern
- def newInstance[T](target: Class[T], timeout: Long): T =
- newInstance(target, actorOf(new Dispatcher(false)), None, timeout)
+ def newInstance[T](intfClass: Class[T], targetClass: Class[_], timeout: Long): T = {
+ newInstance(intfClass, newTypedActor(targetClass), actorOf(new Dispatcher(false)), None, timeout)
+ }
- def newInstance[T](target: Class[T]): T =
- newInstance(target, actorOf(new Dispatcher(false)), None, Actor.TIMEOUT)
+ def newInstance[T](intfClass: Class[T], targetClass: Class[_]): T = {
+ newInstance(intfClass, newTypedActor(targetClass), actorOf(new Dispatcher(false)), None, Actor.TIMEOUT)
+ }
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long): T =
- newInstance(intf, target, actorOf(new Dispatcher(false)), None, timeout)
+ def newRemoteInstance[T](intfClass: Class[T], targetClass: Class[_], timeout: Long, hostname: String, port: Int): T = {
+ newInstance(intfClass, newTypedActor(targetClass), actorOf(new Dispatcher(false)), Some(new InetSocketAddress(hostname, port)), timeout)
+ }
- def newInstance[T](intf: Class[T], target: AnyRef): T =
- newInstance(intf, target, actorOf(new Dispatcher(false)), None, Actor.TIMEOUT)
+ def newRemoteInstance[T](intfClass: Class[T], targetClass: Class[_], hostname: String, port: Int): T = {
+ newInstance(intfClass, newTypedActor(targetClass), actorOf(new Dispatcher(false)), Some(new InetSocketAddress(hostname, port)), Actor.TIMEOUT)
+ }
- def newRemoteInstance[T](target: Class[T], timeout: Long, hostname: String, port: Int): T =
- newInstance(target, actorOf(new Dispatcher(false)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- def newRemoteInstance[T](target: Class[T], hostname: String, port: Int): T =
- newInstance(target, actorOf(new Dispatcher(false)), Some(new InetSocketAddress(hostname, port)), Actor.TIMEOUT)
-
- def newInstance[T](target: Class[T], config: ActiveObjectConfiguration): T = {
+ def newInstance[T](intfClass: Class[T], targetClass: Class[_], config: TypedActorConfiguration): T = {
val actor = actorOf(new Dispatcher(config._transactionRequired, config._restartCallbacks, config._shutdownCallback))
- if (config._messageDispatcher.isDefined) {
- actor.dispatcher = config._messageDispatcher.get
- }
- newInstance(target, actor, config._host, config.timeout)
+ if (config._messageDispatcher.isDefined) actor.dispatcher = config._messageDispatcher.get
+ newInstance(intfClass, newTypedActor(targetClass), actor, config._host, config.timeout)
}
- def newInstance[T](intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration): T = {
- val actor = actorOf(new Dispatcher(config._transactionRequired, config._restartCallbacks, config._shutdownCallback))
- if (config._messageDispatcher.isDefined) {
- actor.dispatcher = config._messageDispatcher.get
- }
- newInstance(intf, target, actor, config._host, config.timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(target, actorOf(new Dispatcher(false, restartCallbacks)), None, timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(intf, target, actorOf(new Dispatcher(false, restartCallbacks)), None, timeout)
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean): T =
- newInstance(target, actorOf(new Dispatcher(transactionRequired, None)), None, timeout)
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(target, actorOf(new Dispatcher(transactionRequired, restartCallbacks)), None, timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean): T =
- newInstance(intf, target, actorOf(new Dispatcher(transactionRequired, None)), None, timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(intf, target, actorOf(new Dispatcher(transactionRequired, restartCallbacks)), None, timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, hostname: String, port: Int): T =
- newInstance(intf, target, actorOf(new Dispatcher(false, None)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(intf, target, actorOf(new Dispatcher(false, restartCallbacks)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean, hostname: String, port: Int): T =
- newInstance(target, actorOf(new Dispatcher(transactionRequired, None)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean, hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(target, actorOf(new Dispatcher(transactionRequired, restartCallbacks)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean, hostname: String, port: Int): T =
- newInstance(intf, target, actorOf(new Dispatcher(transactionRequired, None)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean, hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T =
- newInstance(intf, target, actorOf(new Dispatcher(transactionRequired, restartCallbacks)), Some(new InetSocketAddress(hostname, port)), timeout)
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, dispatcher: MessageDispatcher): T = {
- val actor = actorOf(new Dispatcher(false, None))
- actor.dispatcher = dispatcher
- newInstance(target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, dispatcher: MessageDispatcher, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(false, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, dispatcher: MessageDispatcher): T = {
- val actor = actorOf(new Dispatcher(false, None))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long,
- dispatcher: MessageDispatcher, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(false, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, None))
- actor.dispatcher = dispatcher
- newInstance(target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean,
- dispatcher: MessageDispatcher, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, None))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean,
- dispatcher: MessageDispatcher, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, None, timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, dispatcher: MessageDispatcher, hostname: String, port: Int): T = {
- val actor = actorOf(new Dispatcher(false, None))
- actor.dispatcher = dispatcher
- newInstance(target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, dispatcher: MessageDispatcher,
- hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(false, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, dispatcher: MessageDispatcher, hostname: String, port: Int): T = {
- val actor = actorOf(new Dispatcher(false, None))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, dispatcher: MessageDispatcher,
- hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(false, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean,
- dispatcher: MessageDispatcher, hostname: String, port: Int): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, None))
- actor.dispatcher = dispatcher
- newInstance(target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(target: Class[T], config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](target: Class[T], timeout: Long, transactionRequired: Boolean, dispatcher: MessageDispatcher,
- hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean,
- dispatcher: MessageDispatcher, hostname: String, port: Int): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, None))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- @deprecated("use newInstance(intf: Class[T], target: AnyRef, config: ActiveObjectConfiguration) instead")
- def newRemoteInstance[T](intf: Class[T], target: AnyRef, timeout: Long, transactionRequired: Boolean,
- dispatcher: MessageDispatcher, hostname: String, port: Int, restartCallbacks: Option[RestartCallbacks]): T = {
- val actor = actorOf(new Dispatcher(transactionRequired, restartCallbacks))
- actor.dispatcher = dispatcher
- newInstance(intf, target, actor, Some(new InetSocketAddress(hostname, port)), timeout)
- }
-
- private[akka] def newInstance[T](target: Class[T], actorRef: ActorRef, remoteAddress: Option[InetSocketAddress], timeout: Long): T = {
- val proxy = Proxy.newInstance(target, true, false)
- val context = injectActiveObjectContext(proxy)
- actorRef.actor.asInstanceOf[Dispatcher].initialize(target, proxy, context)
+ private[akka] def newInstance[T](intfClass: Class[T], targetInstance: TypedActor, actorRef: ActorRef,
+ remoteAddress: Option[InetSocketAddress], timeout: Long): T = {
+ val context = injectTypedActorContext(targetInstance)
+ val proxy = Proxy.newInstance(Array(intfClass), Array(targetInstance), true, false)
+ actorRef.actor.asInstanceOf[Dispatcher].initialize(targetInstance.getClass, targetInstance, context)
actorRef.timeout = timeout
if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get)
- AspectInitRegistry.register(proxy, AspectInit(target, actorRef, remoteAddress, timeout))
+ AspectInitRegistry.register(proxy, AspectInit(intfClass, targetInstance, actorRef, remoteAddress, timeout))
actorRef.start
proxy.asInstanceOf[T]
}
- private[akka] def newInstance[T](intf: Class[T], target: AnyRef, actorRef: ActorRef,
- remoteAddress: Option[InetSocketAddress], timeout: Long): T = {
- val context = injectActiveObjectContext(target)
- val proxy = Proxy.newInstance(Array(intf), Array(target), true, false)
- actorRef.actor.asInstanceOf[Dispatcher].initialize(target.getClass, target, context)
+ // NOTE: currently not used - but keep it around
+ private[akka] def newInstance[T <: TypedActor](
+ targetClass: Class[T], actorRef: ActorRef, 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, context)
actorRef.timeout = timeout
if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get)
- AspectInitRegistry.register(proxy, AspectInit(intf, actorRef, remoteAddress, timeout))
+ AspectInitRegistry.register(proxy, AspectInit(targetClass, proxy, actorRef, remoteAddress, timeout))
actorRef.start
proxy.asInstanceOf[T]
}
@@ -391,120 +288,150 @@ object ActiveObject extends Logging {
}
/**
- * Get the underlying dispatcher actor for the given active object.
+ * Get the underlying dispatcher actor for the given typed actor.
*/
def actorFor(obj: AnyRef): Option[ActorRef] =
ActorRegistry.actorsFor(classOf[Dispatcher]).find(a => a.actor.asInstanceOf[Dispatcher].target == Some(obj))
/**
- * Links an other active object to this active object.
- * @param supervisor the supervisor active object
- * @param supervised the active object to link
+ * Links an other typed actor to this typed actor.
+ * @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 active object"))
+ 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 active object"))
+ throw new IllegalActorStateException("Can't link when the supervised is not an typed actor"))
supervisorActor.link(supervisedActor)
}
/**
- * Links an other active object to this active object and sets the fault handling for the supervisor.
- * @param supervisor the supervisor active object
- * @param supervised the active object to link
+ * Links an other typed actor to this typed actor and sets the fault handling for the supervisor.
+ * @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, trapExceptions: Array[Class[_ <: Throwable]]) = {
+ def link(supervisor: AnyRef, supervised: AnyRef,
+ handler: FaultHandlingStrategy, trapExceptions: Array[Class[_ <: Throwable]]) = {
val supervisorActor = actorFor(supervisor).getOrElse(
- throw new IllegalActorStateException("Can't link when the supervisor is not an active object"))
+ 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 active object"))
+ throw new IllegalActorStateException("Can't link when the supervised is not an typed actor"))
supervisorActor.trapExit = trapExceptions.toList
supervisorActor.faultHandler = Some(handler)
supervisorActor.link(supervisedActor)
}
/**
- * Unlink the supervised active object from the supervisor.
- * @param supervisor the supervisor active object
- * @param supervised the active object to unlink
+ * Unlink the supervised typed actor from the supervisor.
+ * @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 active object"))
+ 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 active object"))
+ throw new IllegalActorStateException("Can't unlink when the supervised is not an typed actor"))
supervisorActor.unlink(supervisedActor)
}
/**
- * Sets the trap exit for the given supervisor active object.
- * @param supervisor the supervisor active object
+ * Sets the trap exit for the given supervisor typed actor.
+ * @param supervisor the supervisor typed actor
* @param trapExceptions array of exceptions that should be handled by the supervisor
*/
def trapExit(supervisor: AnyRef, trapExceptions: Array[Class[_ <: Throwable]]) = {
val supervisorActor = actorFor(supervisor).getOrElse(
- throw new IllegalActorStateException("Can't set trap exceptions when the supervisor is not an active object"))
+ throw new IllegalActorStateException("Can't set trap exceptions when the supervisor is not an typed actor"))
supervisorActor.trapExit = trapExceptions.toList
this
}
/**
- * Sets the fault handling strategy for the given supervisor active object.
- * @param supervisor the supervisor active object
+ * 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 active object"))
+ throw new IllegalActorStateException("Can't set fault handler when the supervisor is not an typed actor"))
supervisorActor.faultHandler = Some(handler)
this
}
- private def injectActiveObjectContext(activeObject: AnyRef): Option[ActiveObjectContext] = {
- def injectActiveObjectContext0(activeObject: AnyRef, clazz: Class[_]): Option[ActiveObjectContext] = {
- val contextField = clazz.getDeclaredFields.toList.find(_.getType == classOf[ActiveObjectContext])
+ private def injectTypedActorContext(activeObject: AnyRef): Option[TypedActorContext] = {
+ def injectTypedActorContext0(activeObject: AnyRef, clazz: Class[_]): Option[TypedActorContext] = {
+ val contextField = clazz.getDeclaredFields.toList.find(_.getType == classOf[TypedActorContext])
if (contextField.isDefined) {
contextField.get.setAccessible(true)
- val context = new ActiveObjectContext
+ val context = new TypedActorContext
contextField.get.set(activeObject, context)
Some(context)
} else {
val parent = clazz.getSuperclass
- if (parent != null) injectActiveObjectContext0(activeObject, parent)
+ if (parent != null) injectTypedActorContext0(activeObject, parent)
else {
- log.ifTrace("Can't set 'ActiveObjectContext' for ActiveObject [" +
+ log.ifTrace("Can't set 'TypedActorContext' for TypedActor [" +
activeObject.getClass.getName +
"] since no field of this type could be found.")
None
}
}
}
- injectActiveObjectContext0(activeObject, activeObject.getClass)
+ injectTypedActorContext0(activeObject, activeObject.getClass)
+ }
+
+ private[akka] def newTypedActor(targetClass: Class[_]): TypedActor = {
+ val instance = targetClass.newInstance
+ if (instance.isInstanceOf[TypedActor]) instance.asInstanceOf[TypedActor]
+ else throw new IllegalArgumentException("Actor [" + targetClass.getName + "] is not a sub class of 'TypedActor'")
}
private[akka] def supervise(restartStrategy: RestartStrategy, components: List[Supervise]): Supervisor =
Supervisor(SupervisorConfig(restartStrategy, components))
}
+/**
+ * Internal helper class to help pass the contextual information between threads.
+ *
+ * @author Jonas Bonér
+ */
+private[akka] object TypedActorContext {
+ import scala.util.DynamicVariable
+ private[actor] val sender = new DynamicVariable[AnyRef](null)
+ private[actor] val senderFuture = new DynamicVariable[CompletableFuture[Any]](null)
+}
+
+/**
+ * @author Jonas Bonér
+ */
+object Annotations {
+ val transactionrequired = classOf[transactionrequired]
+ val prerestart = classOf[prerestart]
+ val postrestart = classOf[postrestart]
+ val shutdown = classOf[shutdown]
+ val inittransactionalstate = classOf[inittransactionalstate]
+}
+
+/**
+ * @author Jonas Bonér
+ */
private[akka] object AspectInitRegistry extends ListenerManagement {
private val initializations = new java.util.concurrent.ConcurrentHashMap[AnyRef, AspectInit]
- def initFor(target: AnyRef) = {
- initializations.get(target)
- }
+ def initFor(proxy: AnyRef) = initializations.get(proxy)
- def register(target: AnyRef, init: AspectInit) = {
- val res = initializations.put(target, init)
- foreachListener(_ ! AspectInitRegistered(target, init))
+ def register(proxy: AnyRef, init: AspectInit) = {
+ val res = initializations.put(proxy, init)
+ foreachListener(_ ! AspectInitRegistered(proxy, init))
res
}
- def unregister(target: AnyRef) = {
- val res = initializations.remove(target)
- foreachListener(_ ! AspectInitUnregistered(target, res))
+ def unregister(proxy: AnyRef) = {
+ val res = initializations.remove(proxy)
+ foreachListener(_ ! AspectInitUnregistered(proxy, res))
res
}
}
@@ -513,40 +440,50 @@ 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(
- val target: Class[_],
+ val interfaceClass: Class[_],
+ val targetInstance: TypedActor,
val actorRef: ActorRef,
val remoteAddress: Option[InetSocketAddress],
val timeout: Long) {
- def this(target: Class[_], actorRef: ActorRef, timeout: Long) = this(target, actorRef, None, timeout)
+ def this(interfaceClass: Class[_], targetInstance: TypedActor, actorRef: ActorRef, timeout: Long) =
+ this(interfaceClass, targetInstance, actorRef, None, timeout)
}
/**
- * AspectWerkz Aspect that is turning POJOs into Active Object.
- * Is deployed on a 'per-instance' basis.
+ * 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 ActiveObjectAspect {
+private[akka] sealed class TypedActorAspect {
@volatile private var isInitialized = false
@volatile private var isStopped = false
- private var target: Class[_] = _
+ private var interfaceClass: Class[_] = _
+ private var targetInstance: TypedActor = _
private var actorRef: ActorRef = _
private var remoteAddress: Option[InetSocketAddress] = _
private var timeout: Long = _
- @volatile private var instance: AnyRef = _
+ private var uuid: String = _
+ @volatile private var instance: TypedActor = _
@Around("execution(* *.*(..))")
def invoke(joinPoint: JoinPoint): AnyRef = {
if (!isInitialized) {
val init = AspectInitRegistry.initFor(joinPoint.getThis)
- target = init.target
+ interfaceClass = init.interfaceClass
+ targetInstance = init.targetInstance
+ uuid = targetInstance.uuid
actorRef = init.actorRef
remoteAddress = init.remoteAddress
timeout = init.timeout
isInitialized = true
-
}
dispatch(joinPoint)
}
@@ -559,15 +496,17 @@ private[akka] sealed class ActiveObjectAspect {
private def localDispatch(joinPoint: JoinPoint): AnyRef = {
val rtti = joinPoint.getRtti.asInstanceOf[MethodRtti]
val isOneWay = isVoid(rtti)
- val sender = ActiveObjectContext.sender.value
- val senderFuture = ActiveObjectContext.senderFuture.value
+ val sender = TypedActorContext.sender.value
+ val senderFuture = TypedActorContext.senderFuture.value
if (!actorRef.isRunning && !isStopped) {
isStopped = true
joinPoint.proceed
+
} else if (isOneWay) {
actorRef ! Invocation(joinPoint, true, true, sender, senderFuture)
null.asInstanceOf[AnyRef]
+
} else {
val result = (actorRef !! (Invocation(joinPoint, false, isOneWay, sender, senderFuture), timeout)).as[AnyRef]
if (result.isDefined) result.get
@@ -579,20 +518,32 @@ private[akka] sealed class ActiveObjectAspect {
val rtti = joinPoint.getRtti.asInstanceOf[MethodRtti]
val isOneWay = isVoid(rtti)
val (message: Array[AnyRef], isEscaped) = escapeArguments(rtti.getParameterValues)
+
+ val typedActorInfo = TypedActorInfoProtocol.newBuilder
+ .setInterface(interfaceClass.getName)
+ .setMethod(rtti.getMethod.getName)
+ .build
+
+ val actorInfo = ActorInfoProtocol.newBuilder
+ .setUuid(uuid)
+ .setTarget(targetInstance.getClass.getName)
+ .setTimeout(timeout)
+ .setActorType(ActorType.TYPED_ACTOR)
+ .build
+
val requestBuilder = RemoteRequestProtocol.newBuilder
.setId(RemoteRequestProtocolIdFactory.nextId)
.setMessage(MessageSerializer.serialize(message))
- .setMethod(rtti.getMethod.getName)
- .setTarget(target.getName)
- .setUuid(actorRef.uuid)
- .setTimeout(timeout)
- .setIsActor(false)
+ .setActorInfo(actorInfo)
.setIsOneWay(isOneWay)
- .setIsEscaped(false)
+
val id = actorRef.registerSupervisorAsRemoteActor
if (id.isDefined) requestBuilder.setSupervisorUuid(id.get)
+
val remoteMessage = requestBuilder.build
+
val future = RemoteClient.clientFor(remoteAddress.get).send(remoteMessage, None)
+
if (isOneWay) null // for void methods
else {
if (future.isDefined) {
@@ -616,9 +567,9 @@ private[akka] sealed class ActiveObjectAspect {
var isEscaped = false
val escapedArgs = for (arg <- args) yield {
val clazz = arg.getClass
- if (clazz.getName.contains(ActiveObject.AW_PROXY_PREFIX)) {
+ if (clazz.getName.contains(TypedActor.AW_PROXY_PREFIX)) {
isEscaped = true
- ActiveObject.AW_PROXY_PREFIX + clazz.getSuperclass.getName
+ TypedActor.AW_PROXY_PREFIX + clazz.getSuperclass.getName
} else arg
}
(escapedArgs, isEscaped)
@@ -685,20 +636,21 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
private var preRestart: Option[Method] = None
private var postRestart: Option[Method] = None
private var initTxState: Option[Method] = None
- private var context: Option[ActiveObjectContext] = None
- private var targetClass:Class[_] = _
+ private var context: Option[TypedActorContext] = None
+ private var targetClass: Class[_] = _
def this(transactionalRequired: Boolean) = this(transactionalRequired,None)
- private[actor] def initialize(targetClass: Class[_], targetInstance: AnyRef, ctx: Option[ActiveObjectContext]) = {
+ private[actor] def initialize(targetClass: Class[_], proxy: AnyRef, ctx: Option[TypedActorContext]) = {
if (transactionalRequired || targetClass.isAnnotationPresent(Annotations.transactionrequired))
self.makeTransactionRequired
self.id = targetClass.getName
this.targetClass = targetClass
- target = Some(targetInstance)
+ target = Some(proxy)
context = ctx
- val methods = targetInstance.getClass.getDeclaredMethods.toList
+ val proxyClass = proxy.getClass
+ val methods = proxyClass.getDeclaredMethods.toList
if (self.lifeCycle.isEmpty) self.lifeCycle = Some(LifeCycle(Permanent))
@@ -707,12 +659,12 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
case None => {}
case Some(RestartCallbacks(pre, post)) =>
preRestart = Some(try {
- targetInstance.getClass.getDeclaredMethod(pre, ZERO_ITEM_CLASS_ARRAY: _*)
+ proxyClass.getDeclaredMethod(pre, ZERO_ITEM_CLASS_ARRAY: _*)
} catch { case e => throw new IllegalActorStateException(
"Could not find pre restart method [" + pre + "] \nin [" +
targetClass.getName + "]. \nIt must have a zero argument definition.") })
postRestart = Some(try {
- targetInstance.getClass.getDeclaredMethod(post, ZERO_ITEM_CLASS_ARRAY: _*)
+ proxyClass.getDeclaredMethod(post, ZERO_ITEM_CLASS_ARRAY: _*)
} catch { case e => throw new IllegalActorStateException(
"Could not find post restart method [" + post + "] \nin [" +
targetClass.getName + "]. \nIt must have a zero argument definition.") })
@@ -722,7 +674,7 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
case None => {}
case Some(ShutdownCallback(down)) =>
zhutdown = Some(try {
- targetInstance.getClass.getDeclaredMethod(down, ZERO_ITEM_CLASS_ARRAY: _*)
+ proxyClass.getDeclaredMethod(down, ZERO_ITEM_CLASS_ARRAY: _*)
} catch { case e => throw new IllegalStateException(
"Could not find shutdown method [" + down + "] \nin [" +
targetClass.getName + "]. \nIt must have a zero argument definition.") })
@@ -760,13 +712,13 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
def receive = {
case invocation @ Invocation(joinPoint, isOneWay, _, sender, senderFuture) =>
- ActiveObject.log.ifTrace("Invoking active object with message:\n" + invocation)
+ TypedActor.log.ifTrace("Invoking typed actor with message:\n" + invocation)
context.foreach { ctx =>
if (sender ne null) ctx._sender = sender
if (senderFuture ne null) ctx._senderFuture = senderFuture
}
- ActiveObjectContext.sender.value = joinPoint.getThis // set next sender
- self.senderFuture.foreach(ActiveObjectContext.senderFuture.value = _)
+ TypedActorContext.sender.value = joinPoint.getThis // set next sender
+ self.senderFuture.foreach(TypedActorContext.senderFuture.value = _)
if (Actor.SERIALIZE_MESSAGES) serializeArguments(joinPoint)
if (isOneWay) joinPoint.proceed
else self.reply(joinPoint.proceed)
@@ -843,7 +795,7 @@ private[akka] class Dispatcher(transactionalRequired: Boolean,
!arg.isInstanceOf[java.lang.Character]) {
hasMutableArgument = true
}
- if (arg.getClass.getName.contains(ActiveObject.AW_PROXY_PREFIX)) unserializable = true
+ if (arg.getClass.getName.contains(TypedActor.AW_PROXY_PREFIX)) unserializable = true
}
if (!unserializable && hasMutableArgument) {
val copyOfArgs = Serializer.Java.deepClone(args)
diff --git a/akka-core/src/main/scala/config/Configuration.scala b/akka-core/src/main/scala/config/Configuration.scala
index faa5c912f1..e257c739a9 100644
--- a/akka-core/src/main/scala/config/Configuration.scala
+++ b/akka-core/src/main/scala/config/Configuration.scala
@@ -5,7 +5,7 @@
package se.scalablesolutions.akka.config
/*
-import se.scalablesolutions.akka.kernel.{ActiveObject, ActiveObjectProxy}
+import se.scalablesolutions.akka.kernel.{TypedActor, TypedActorProxy}
import com.google.inject.{AbstractModule}
import java.util.{List => JList, ArrayList}
import scala.reflect.BeanProperty
@@ -55,6 +55,6 @@ class Component(@BeanProperty val intf: Class[_],
@BeanProperty val target: Class[_],
@BeanProperty val lifeCycle: LifeCycle,
@BeanProperty val timeout: Int) extends Server {
- def newWorker(proxy: ActiveObjectProxy) = se.scalablesolutions.akka.kernel.Supervise(proxy.server, lifeCycle.transform)
+ def newWorker(proxy: TypedActorProxy) = se.scalablesolutions.akka.kernel.Supervise(proxy.server, lifeCycle.transform)
}
*/
diff --git a/akka-core/src/main/scala/config/Configurator.scala b/akka-core/src/main/scala/config/Configurator.scala
index db92c5f35b..ba7e1f35f2 100644
--- a/akka-core/src/main/scala/config/Configurator.scala
+++ b/akka-core/src/main/scala/config/Configurator.scala
@@ -6,14 +6,14 @@ package se.scalablesolutions.akka.config
import ScalaConfig.{RestartStrategy, Component}
-private[akka] trait ActiveObjectConfiguratorBase {
+private[akka] trait TypedActorConfiguratorBase {
def getExternalDependency[T](clazz: Class[T]): T
- def configure(restartStrategy: RestartStrategy, components: List[Component]): ActiveObjectConfiguratorBase
+ def configure(restartStrategy: RestartStrategy, components: List[Component]): TypedActorConfiguratorBase
- def inject: ActiveObjectConfiguratorBase
+ def inject: TypedActorConfiguratorBase
- def supervise: ActiveObjectConfiguratorBase
+ def supervise: TypedActorConfiguratorBase
def reset
diff --git a/akka-core/src/main/scala/config/ActiveObjectConfigurator.scala b/akka-core/src/main/scala/config/TypedActorConfigurator.scala
similarity index 56%
rename from akka-core/src/main/scala/config/ActiveObjectConfigurator.scala
rename to akka-core/src/main/scala/config/TypedActorConfigurator.scala
index 88e495bbd0..797d52cd70 100644
--- a/akka-core/src/main/scala/config/ActiveObjectConfigurator.scala
+++ b/akka-core/src/main/scala/config/TypedActorConfigurator.scala
@@ -12,54 +12,55 @@ import java.util.{ArrayList}
import com.google.inject._
/**
- * Configurator for the Active Objects. Used to do declarative configuration of supervision.
- * It also does dependency injection with and into Active Objects using dependency injection
+ * 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 ActiveObject
+ * If you don't want declarative configuration then you should use the TypedActor
* factory methods.
*
* @author Jonas Bonér
*/
-class ActiveObjectConfigurator {
+class TypedActorConfigurator {
import scala.collection.JavaConversions._
// TODO: make pluggable once we have f.e a SpringConfigurator
- private val INSTANCE = new ActiveObjectGuiceConfigurator
+ private val INSTANCE = new TypedActorGuiceConfigurator
/**
- * Returns the a list with all active objects that has been put under supervision for the class specified.
+ * Returns the a list with all typed actors that has been put under supervision for the class specified.
*
- * @param clazz the class for the active object
- * @return a list with all the active objects for the class
+ * @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 }
+ 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 active objects that has been put under supervision for the class specified.
+ * 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 active object
- * @return the active object for the class
+ * @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(restartStrategy: RestartStrategy, components: Array[Component]): ActiveObjectConfigurator = {
+ def configure(restartStrategy: RestartStrategy, components: Array[Component]): TypedActorConfigurator = {
INSTANCE.configure(
restartStrategy.transform,
components.toList.asInstanceOf[scala.List[Component]].map(_.transform))
this
}
- def inject: ActiveObjectConfigurator = {
+ def inject: TypedActorConfigurator = {
INSTANCE.inject
this
}
- def supervise: ActiveObjectConfigurator = {
+ def supervise: TypedActorConfigurator = {
INSTANCE.supervise
this
}
- def addExternalGuiceModule(module: Module): ActiveObjectConfigurator = {
+ def addExternalGuiceModule(module: Module): TypedActorConfigurator = {
INSTANCE.addExternalGuiceModule(module)
this
}
diff --git a/akka-core/src/main/scala/config/ActiveObjectGuiceConfigurator.scala b/akka-core/src/main/scala/config/TypedActorGuiceConfigurator.scala
similarity index 73%
rename from akka-core/src/main/scala/config/ActiveObjectGuiceConfigurator.scala
rename to akka-core/src/main/scala/config/TypedActorGuiceConfigurator.scala
index 54174b6030..f6c78a6a30 100644
--- a/akka-core/src/main/scala/config/ActiveObjectGuiceConfigurator.scala
+++ b/akka-core/src/main/scala/config/TypedActorGuiceConfigurator.scala
@@ -7,7 +7,7 @@ package se.scalablesolutions.akka.config
import com.google.inject._
import se.scalablesolutions.akka.config.ScalaConfig._
-import se.scalablesolutions.akka.actor.{Supervisor, ActiveObject, Dispatcher, ActorRef, Actor, IllegalActorStateException}
+import se.scalablesolutions.akka.actor.{Supervisor, TypedActor, Dispatcher, ActorRef, Actor, IllegalActorStateException}
import se.scalablesolutions.akka.remote.RemoteServer
import se.scalablesolutions.akka.util.Logging
@@ -17,12 +17,12 @@ import java.net.InetSocketAddress
import java.lang.reflect.Method
/**
- * This is an class for internal usage. Instead use the se.scalablesolutions.akka.config.ActiveObjectConfigurator
- * class for creating ActiveObjects.
+ * This is an class for internal usage. Instead use the se.scalablesolutions.akka.config.TypedActorConfigurator
+ * class for creating TypedActors.
*
* @author Jonas Bonér
*/
-private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfiguratorBase with Logging {
+private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBase with Logging {
private var injector: Injector = _
private var supervisor: Option[Supervisor] = None
private var restartStrategy: RestartStrategy = _
@@ -37,11 +37,11 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
/**
* Returns the active abject that has been put under supervision for the class specified.
*
- * @param clazz the class for the active object
- * @return the active objects for the class
+ * @param clazz the class for the typed actor
+ * @return the typed actors for the class
*/
def getInstance[T](clazz: Class[T]): List[T] = synchronized {
- log.debug("Retrieving active object [%s]", clazz.getName)
+ log.debug("Retrieving typed actor [%s]", clazz.getName)
if (injector eq null) throw new IllegalActorStateException(
"inject() and/or supervise() must be called before invoking getInstance(clazz)")
val (proxy, targetInstance, component) =
@@ -67,7 +67,7 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
}
override def configure(restartStrategy: RestartStrategy, components: List[Component]):
- ActiveObjectConfiguratorBase = synchronized {
+ TypedActorConfiguratorBase = synchronized {
this.restartStrategy = restartStrategy
this.components = components.toArray.toList.asInstanceOf[List[Component]]
bindings = for (component <- this.components) yield {
@@ -76,12 +76,14 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
}
val deps = new java.util.ArrayList[DependencyBinding](bindings.size)
for (b <- bindings) deps.add(b)
- modules.add(new ActiveObjectGuiceModule(deps))
+ modules.add(new TypedActorGuiceModule(deps))
this
}
private def newSubclassingProxy(component: Component): DependencyBinding = {
- val targetClass = component.target
+ 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(component.transactionRequired,
component.lifeCycle.restartCallbacks,
component.lifeCycle.shutdownCallback))
@@ -90,8 +92,8 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
if (component.remoteAddress.isDefined)
Some(new InetSocketAddress(component.remoteAddress.get.hostname, component.remoteAddress.get.port))
else None
- val proxy = ActiveObject.newInstance(targetClass, actorRef, remoteAddress, component.timeout).asInstanceOf[AnyRef]
- remoteAddress.foreach(address => RemoteServer.registerActiveObject(address, targetClass.getName, proxy))
+ 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)
activeObjectRegistry.put(targetClass, (proxy, proxy, component))
new DependencyBinding(targetClass, proxy)
@@ -99,7 +101,12 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
private def newDelegatingProxy(component: Component): DependencyBinding = {
val targetClass = component.intf.get
- val targetInstance = component.target.newInstance.asInstanceOf[AnyRef] // TODO: perhaps need to put in registry
+ val instance = component.target.newInstance.asInstanceOf[AnyRef] // TODO: perhaps need to put in registry
+ val targetInstance =
+ if (instance.isInstanceOf[TypedActor]) component.target.asInstanceOf[TypedActor]
+ else throw new IllegalArgumentException("TypedActor [" + component.target.getName + "] must be a subclass of TypedActor")
+ if (!component.target.isInstanceOf[TypedActor]) throw new IllegalArgumentException(
+ "TypedActor [" + component.target + "] must be a subclass of TypedActor")
component.target.getConstructor(Array[Class[_]](): _*).setAccessible(true)
val actorRef = Actor.actorOf(new Dispatcher(component.transactionRequired,
component.lifeCycle.restartCallbacks,
@@ -109,23 +116,23 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
if (component.remoteAddress.isDefined)
Some(new InetSocketAddress(component.remoteAddress.get.hostname, component.remoteAddress.get.port))
else None
- val proxy = ActiveObject.newInstance(
+ val proxy = TypedActor.newInstance(
targetClass, targetInstance, actorRef, remoteAddress, component.timeout).asInstanceOf[AnyRef]
- remoteAddress.foreach(address => RemoteServer.registerActiveObject(address, targetClass.getName, proxy))
+ remoteAddress.foreach(address => RemoteServer.registerTypedActor(address, targetClass.getName, proxy))
supervised ::= Supervise(actorRef, component.lifeCycle)
activeObjectRegistry.put(targetClass, (proxy, targetInstance, component))
new DependencyBinding(targetClass, proxy)
}
- override def inject: ActiveObjectConfiguratorBase = synchronized {
+ 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: ActiveObjectConfiguratorBase = synchronized {
+ override def supervise: TypedActorConfiguratorBase = synchronized {
if (injector eq null) inject
- supervisor = Some(ActiveObject.supervise(restartStrategy, supervised))
+ supervisor = Some(TypedActor.supervise(restartStrategy, supervised))
this
}
@@ -141,7 +148,7 @@ private[akka] class ActiveObjectGuiceConfigurator extends ActiveObjectConfigurat
* }})
*
*/
- def addExternalGuiceModule(module: Module): ActiveObjectConfiguratorBase = synchronized {
+ def addExternalGuiceModule(module: Module): TypedActorConfiguratorBase = synchronized {
modules.add(module)
this
}
diff --git a/akka-core/src/main/scala/remote/RemoteClient.scala b/akka-core/src/main/scala/remote/RemoteClient.scala
index 2936b73b67..a08348e461 100644
--- a/akka-core/src/main/scala/remote/RemoteClient.scala
+++ b/akka-core/src/main/scala/remote/RemoteClient.scala
@@ -137,7 +137,7 @@ object RemoteClient extends Logging {
actorsFor(RemoteServer.Address(hostname, port)) += uuid
}
- // TODO: add RemoteClient.unregister for ActiveObject, but first need a @shutdown callback
+ // TODO: add RemoteClient.unregister for TypedActor, but first need a @shutdown callback
private[akka] def unregister(hostname: String, port: Int, uuid: String) = synchronized {
val set = actorsFor(RemoteServer.Address(hostname, port))
set -= uuid
@@ -217,7 +217,7 @@ class RemoteClient private[akka] (val hostname: String, val port: Int, loader: O
} else {
futures.synchronized {
val futureResult = if (senderFuture.isDefined) senderFuture.get
- else new DefaultCompletableFuture[T](request.getTimeout)
+ else new DefaultCompletableFuture[T](request.getActorInfo.getTimeout)
futures.put(request.getId, futureResult)
connection.getChannel.write(request)
Some(futureResult)
@@ -230,11 +230,13 @@ class RemoteClient private[akka] (val hostname: String, val port: Int, loader: O
}
private[akka] def registerSupervisorForActor(actorRef: ActorRef) =
- if (!actorRef.supervisor.isDefined) throw new IllegalActorStateException("Can't register supervisor for " + actorRef + " since it is not under supervision")
+ if (!actorRef.supervisor.isDefined) throw new IllegalActorStateException(
+ "Can't register supervisor for " + actorRef + " since it is not under supervision")
else supervisors.putIfAbsent(actorRef.supervisor.get.uuid, actorRef)
private[akka] def deregisterSupervisorForActor(actorRef: ActorRef) =
- if (!actorRef.supervisor.isDefined) throw new IllegalActorStateException("Can't unregister supervisor for " + actorRef + " since it is not under supervision")
+ if (!actorRef.supervisor.isDefined) throw new IllegalActorStateException(
+ "Can't unregister supervisor for " + actorRef + " since it is not under supervision")
else supervisors.remove(actorRef.supervisor.get.uuid)
}
diff --git a/akka-core/src/main/scala/remote/RemoteServer.scala b/akka-core/src/main/scala/remote/RemoteServer.scala
index c3f5cc4f0a..e93fc4db48 100644
--- a/akka-core/src/main/scala/remote/RemoteServer.scala
+++ b/akka-core/src/main/scala/remote/RemoteServer.scala
@@ -55,7 +55,7 @@ object RemoteNode extends RemoteServer
/**
* For internal use only.
- * Holds configuration variables, remote actors, remote active objects and remote servers.
+ * Holds configuration variables, remote actors, remote typed actors and remote servers.
*
* @author Jonas Bonér
*/
@@ -104,7 +104,7 @@ object RemoteServer {
actorsFor(RemoteServer.Address(address.getHostName, address.getPort)).actors.put(uuid, actor)
}
- private[akka] def registerActiveObject(address: InetSocketAddress, name: String, activeObject: AnyRef) = guard.withWriteGuard {
+ private[akka] def registerTypedActor(address: InetSocketAddress, name: String, activeObject: AnyRef) = guard.withWriteGuard {
actorsFor(RemoteServer.Address(address.getHostName, address.getPort)).activeObjects.put(name, activeObject)
}
@@ -228,7 +228,7 @@ class RemoteServer extends Logging {
}
}
- // TODO: register active object in RemoteServer as well
+ // TODO: register typed actor in RemoteServer as well
/**
* Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already.
@@ -360,139 +360,88 @@ class RemoteServerHandler(
private def handleRemoteRequestProtocol(request: RemoteRequestProtocol, channel: Channel) = {
log.debug("Received RemoteRequestProtocol[\n%s]", request.toString)
- if (request.getIsActor) dispatchToActor(request, channel)
- else dispatchToActiveObject(request, channel)
+ val actorType = request.getActorInfo.getActorType
+ if (actorType == ActorType.SCALA_ACTOR) dispatchToActor(request, channel)
+ else if (actorType == ActorType.JAVA_ACTOR) throw new IllegalActorStateException("ActorType JAVA_ACTOR is currently not supported")
+ else if (actorType == ActorType.TYPED_ACTOR) dispatchToTypedActor(request, channel)
+ else throw new IllegalActorStateException("Unknown ActorType [" + actorType + "]")
}
private def dispatchToActor(request: RemoteRequestProtocol, channel: Channel) = {
- log.debug("Dispatching to remote actor [%s:%s]", request.getTarget, request.getUuid)
- val actorRef = createActor(request.getTarget, request.getUuid, request.getTimeout)
+ val actorInfo = request.getActorInfo
+ log.debug("Dispatching to remote actor [%s:%s]", actorInfo.getTarget, actorInfo.getUuid)
+
+ val actorRef = createActor(actorInfo)
actorRef.start
+
val message = MessageSerializer.deserialize(request.getMessage)
val sender =
if (request.hasSender) Some(RemoteActorSerialization.fromProtobufToRemoteActorRef(request.getSender, applicationLoader))
else None
+
if (request.getIsOneWay) actorRef.!(message)(sender)
else {
try {
val resultOrNone = (actorRef.!!(message)(sender)).as[AnyRef]
val result = if (resultOrNone.isDefined) resultOrNone.get else null
+
log.debug("Returning result from actor invocation [%s]", result)
val replyBuilder = RemoteReplyProtocol.newBuilder
.setId(request.getId)
.setMessage(MessageSerializer.serialize(result))
.setIsSuccessful(true)
.setIsActor(true)
+
if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
- val replyMessage = replyBuilder.build
- channel.write(replyMessage)
+ channel.write(replyBuilder.build)
+
} catch {
- case e: Throwable =>
- log.error(e, "Could not invoke remote actor [%s]", request.getTarget)
- val replyBuilder = RemoteReplyProtocol.newBuilder
- .setId(request.getId)
- .setException(ExceptionProtocol.newBuilder.setClassname(e.getClass.getName).setMessage(e.getMessage).build)
- .setIsSuccessful(false)
- .setIsActor(true)
- if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
- val replyMessage = replyBuilder.build
- channel.write(replyMessage)
+ case e: Throwable => channel.write(createErrorReplyMessage(e, request, true))
}
}
}
- private def dispatchToActiveObject(request: RemoteRequestProtocol, channel: Channel) = {
- log.debug("Dispatching to remote active object [%s :: %s]", request.getMethod, request.getTarget)
- val activeObject = createActiveObject(request.getTarget, request.getTimeout)
+ private def dispatchToTypedActor(request: RemoteRequestProtocol, channel: Channel) = {
+ val actorInfo = request.getActorInfo
+ val typedActorInfo = actorInfo.getTypedActorInfo
+ log.debug("Dispatching to remote typed actor [%s :: %s]", typedActorInfo.getMethod, typedActorInfo.getInterface)
+ val activeObject = createTypedActor(actorInfo)
val args = MessageSerializer.deserialize(request.getMessage).asInstanceOf[Array[AnyRef]].toList
val argClasses = args.map(_.getClass)
- val (unescapedArgs, unescapedArgClasses) = unescapeArgs(args, argClasses, request.getTimeout)
try {
- val messageReceiver = activeObject.getClass.getDeclaredMethod(
- request.getMethod, unescapedArgClasses: _*)
- if (request.getIsOneWay) messageReceiver.invoke(activeObject, unescapedArgs: _*)
+ val messageReceiver = activeObject.getClass.getDeclaredMethod(typedActorInfo.getMethod, argClasses: _*)
+ if (request.getIsOneWay) messageReceiver.invoke(activeObject, args: _*)
else {
- val result = messageReceiver.invoke(activeObject, unescapedArgs: _*)
- log.debug("Returning result from remote active object invocation [%s]", result)
+ val result = messageReceiver.invoke(activeObject, args: _*)
+ log.debug("Returning result from remote typed actor invocation [%s]", result)
val replyBuilder = RemoteReplyProtocol.newBuilder
.setId(request.getId)
.setMessage(MessageSerializer.serialize(result))
.setIsSuccessful(true)
.setIsActor(false)
if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
- val replyMessage = replyBuilder.build
- channel.write(replyMessage)
+ channel.write(replyBuilder.build)
}
} catch {
- case e: InvocationTargetException =>
- log.error(e.getCause, "Could not invoke remote active object [%s :: %s]", request.getMethod, request.getTarget)
- val replyBuilder = RemoteReplyProtocol.newBuilder
- .setId(request.getId)
- .setException(ExceptionProtocol.newBuilder.setClassname(e.getCause.getClass.getName).setMessage(e.getCause.getMessage).build)
- .setIsSuccessful(false)
- .setIsActor(false)
- if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
- val replyMessage = replyBuilder.build
- channel.write(replyMessage)
- case e: Throwable =>
- log.error(e, "Could not invoke remote active object [%s :: %s]", request.getMethod, request.getTarget)
- val replyBuilder = RemoteReplyProtocol.newBuilder
- .setId(request.getId)
- .setException(ExceptionProtocol.newBuilder.setClassname(e.getClass.getName).setMessage(e.getMessage).build)
- .setIsSuccessful(false)
- .setIsActor(false)
- if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
- val replyMessage = replyBuilder.build
- channel.write(replyMessage)
+ case e: InvocationTargetException => channel.write(createErrorReplyMessage(e.getCause, request, false))
+ case e: Throwable => channel.write(createErrorReplyMessage(e, request, false))
}
}
- private def unescapeArgs(args: scala.List[AnyRef], argClasses: scala.List[Class[_]], timeout: Long) = {
- val unescapedArgs = new Array[AnyRef](args.size)
- val unescapedArgClasses = new Array[Class[_]](args.size)
-
- val escapedArgs = for (i <- 0 until args.size) {
- val arg = args(i)
- if (arg.isInstanceOf[String] && arg.asInstanceOf[String].startsWith(AW_PROXY_PREFIX)) {
- val argString = arg.asInstanceOf[String]
- val proxyName = argString.replace(AW_PROXY_PREFIX, "")
- val activeObject = createActiveObject(proxyName, timeout)
- unescapedArgs(i) = activeObject
- unescapedArgClasses(i) = Class.forName(proxyName)
- } else {
- unescapedArgs(i) = args(i)
- unescapedArgClasses(i) = argClasses(i)
- }
- }
- (unescapedArgs, unescapedArgClasses)
- }
-
- private def createActiveObject(name: String, timeout: Long): AnyRef = {
- val activeObjectOrNull = activeObjects.get(name)
- if (activeObjectOrNull eq null) {
- try {
- log.info("Creating a new remote active object [%s]", name)
- val clazz = if (applicationLoader.isDefined) applicationLoader.get.loadClass(name)
- else Class.forName(name)
- val newInstance = ActiveObject.newInstance(clazz, timeout).asInstanceOf[AnyRef]
- activeObjects.put(name, newInstance)
- newInstance
- } catch {
- case e =>
- log.error(e, "Could not create remote active object instance")
- throw e
- }
- } else activeObjectOrNull
- }
-
/**
* Creates a new instance of the actor with name, uuid and timeout specified as arguments.
+ *
* If actor already created then just return it from the registry.
+ *
* Does not start the actor.
*/
- private def createActor(name: String, uuid: String, timeout: Long): ActorRef = {
+ private def createActor(actorInfo: ActorInfoProtocol): ActorRef = {
+ val name = actorInfo.getTarget
+ val uuid = actorInfo.getUuid
+ val timeout = actorInfo.getTimeout
+
val actorRefOrNull = actors.get(uuid)
if (actorRefOrNull eq null) {
try {
@@ -512,4 +461,43 @@ class RemoteServerHandler(
}
} else actorRefOrNull
}
+
+ private def createTypedActor(actorInfo: ActorInfoProtocol): AnyRef = {
+ val uuid = actorInfo.getUuid
+ val activeObjectOrNull = activeObjects.get(uuid)
+
+ if (activeObjectOrNull eq null) {
+ val typedActorInfo = actorInfo.getTypedActorInfo
+ val interfaceClassname = typedActorInfo.getInterface
+ val targetClassname = actorInfo.getTarget
+
+ try {
+ log.info("Creating a new remote typed actor:\n\t[%s :: %s]", interfaceClassname, targetClassname)
+
+ val (interfaceClass, targetClass) =
+ if (applicationLoader.isDefined) (applicationLoader.get.loadClass(interfaceClassname),
+ applicationLoader.get.loadClass(targetClassname))
+ else (Class.forName(interfaceClassname), Class.forName(targetClassname))
+
+ val newInstance = TypedActor.newInstance(
+ interfaceClass, targetClass.asInstanceOf[Class[_ <: TypedActor]], actorInfo.getTimeout).asInstanceOf[AnyRef]
+ activeObjects.put(uuid, newInstance)
+ newInstance
+ } catch {
+ case e => log.error(e, "Could not create remote typed actor instance"); throw e
+ }
+ } else activeObjectOrNull
+ }
+
+ private def createErrorReplyMessage(e: Throwable, request: RemoteRequestProtocol, isActor: Boolean): RemoteReplyProtocol = {
+ val actorInfo = request.getActorInfo
+ log.error(e, "Could not invoke remote typed actor [%s :: %s]", actorInfo.getTypedActorInfo.getMethod, actorInfo.getTarget)
+ val replyBuilder = RemoteReplyProtocol.newBuilder
+ .setId(request.getId)
+ .setException(ExceptionProtocol.newBuilder.setClassname(e.getClass.getName).setMessage(e.getMessage).build)
+ .setIsSuccessful(false)
+ .setIsActor(isActor)
+ if (request.hasSupervisorUuid) replyBuilder.setSupervisorUuid(request.getSupervisorUuid)
+ replyBuilder.build
+ }
}
diff --git a/akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalActiveObject.java b/akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalTypedActor.java
similarity index 89%
rename from akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalActiveObject.java
rename to akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalTypedActor.java
index af6bb8245c..fa13417f8b 100644
--- a/akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalActiveObject.java
+++ b/akka-core/src/test/java/se/scalablesolutions/akka/actor/NestedTransactionalTypedActor.java
@@ -5,7 +5,7 @@ import se.scalablesolutions.akka.actor.annotation.inittransactionalstate;
import se.scalablesolutions.akka.stm.*;
@transactionrequired
-public class NestedTransactionalActiveObject {
+public class NestedTransactionalTypedActor {
private TransactionalMap mapState;
private TransactionalVector vectorState;
private Ref refState;
@@ -58,7 +58,7 @@ public class NestedTransactionalActiveObject {
}
- public String failure(String key, String msg, ActiveObjectFailer failer) {
+ public String failure(String key, String msg, TypedActorFailer failer) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
@@ -67,7 +67,7 @@ public class NestedTransactionalActiveObject {
}
- public void thisMethodHangs(String key, String msg, ActiveObjectFailer failer) {
+ public void thisMethodHangs(String key, String msg, TypedActorFailer failer) {
setMapState(key, msg);
}
diff --git a/akka-core/src/test/java/se/scalablesolutions/akka/actor/SimpleJavaPojo.java b/akka-core/src/test/java/se/scalablesolutions/akka/actor/SimpleJavaPojo.java
index 31f22c217f..b068af4f12 100644
--- a/akka-core/src/test/java/se/scalablesolutions/akka/actor/SimpleJavaPojo.java
+++ b/akka-core/src/test/java/se/scalablesolutions/akka/actor/SimpleJavaPojo.java
@@ -2,12 +2,12 @@ package se.scalablesolutions.akka.actor;
import se.scalablesolutions.akka.actor.annotation.prerestart;
import se.scalablesolutions.akka.actor.annotation.postrestart;
-import se.scalablesolutions.akka.actor.ActiveObjectContext;
+import se.scalablesolutions.akka.actor.TypedActorContext;
import se.scalablesolutions.akka.dispatch.CompletableFuture;
public class SimpleJavaPojo {
- ActiveObjectContext context;
+ TypedActorContext context;
public boolean pre = false;
public boolean post = false;
diff --git a/akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalActiveObject.java b/akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalTypedActor.java
similarity index 88%
rename from akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalActiveObject.java
rename to akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalTypedActor.java
index 515f4fafee..222a8c82fa 100644
--- a/akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalActiveObject.java
+++ b/akka-core/src/test/java/se/scalablesolutions/akka/actor/TransactionalTypedActor.java
@@ -7,7 +7,7 @@ import se.scalablesolutions.akka.actor.annotation.inittransactionalstate;
import se.scalablesolutions.akka.stm.*;
@transactionrequired
-public class TransactionalActiveObject {
+public class TransactionalTypedActor {
private TransactionalMap mapState;
private TransactionalVector vectorState;
private Ref refState;
@@ -53,14 +53,14 @@ public class TransactionalActiveObject {
refState.swap(msg);
}
- public void success(String key, String msg, NestedTransactionalActiveObject nested) {
+ public void success(String key, String msg, NestedTransactionalTypedActor nested) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
nested.success(key, msg);
}
- public String failure(String key, String msg, ActiveObjectFailer failer) {
+ public String failure(String key, String msg, TypedActorFailer failer) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
@@ -68,7 +68,7 @@ public class TransactionalActiveObject {
return msg;
}
- public String failure(String key, String msg, NestedTransactionalActiveObject nested, ActiveObjectFailer failer) {
+ public String failure(String key, String msg, NestedTransactionalTypedActor nested, TypedActorFailer failer) {
mapState.put(key, msg);
vectorState.add(msg);
refState.swap(msg);
@@ -76,7 +76,7 @@ public class TransactionalActiveObject {
return msg;
}
- public void thisMethodHangs(String key, String msg, ActiveObjectFailer failer) {
+ public void thisMethodHangs(String key, String msg, TypedActorFailer failer) {
setMapState(key, msg);
}
diff --git a/akka-core/src/test/java/se/scalablesolutions/akka/actor/ActiveObjectFailer.java b/akka-core/src/test/java/se/scalablesolutions/akka/actor/TypedAcotrFailer.java
similarity index 62%
rename from akka-core/src/test/java/se/scalablesolutions/akka/actor/ActiveObjectFailer.java
rename to akka-core/src/test/java/se/scalablesolutions/akka/actor/TypedAcotrFailer.java
index 6e30a1a971..311e959527 100644
--- a/akka-core/src/test/java/se/scalablesolutions/akka/actor/ActiveObjectFailer.java
+++ b/akka-core/src/test/java/se/scalablesolutions/akka/actor/TypedAcotrFailer.java
@@ -1,6 +1,6 @@
package se.scalablesolutions.akka.actor;
-public class ActiveObjectFailer implements java.io.Serializable {
+public class TypedActorFailer implements java.io.Serializable {
public int fail() {
throw new RuntimeException("expected");
}
diff --git a/akka-core/src/test/resources/META-INF/aop.xml b/akka-core/src/test/resources/META-INF/aop.xml
index 2f8d5159a8..bdc167ca54 100644
--- a/akka-core/src/test/resources/META-INF/aop.xml
+++ b/akka-core/src/test/resources/META-INF/aop.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala b/akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala
index afb9f9523e..c1dde6a582 100644
--- a/akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala
+++ b/akka-core/src/test/scala/NestedTransactionalActiveObjectSpec.scala
@@ -1,4 +1,4 @@
-/**
+ /**
* Copyright (C) 2009-2010 Scalable Solutions AB
*/
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith
import se.scalablesolutions.akka.actor._
@RunWith(classOf[JUnitRunner])
-class NestedTransactionalActiveObjectSpec extends
+class NestedTransactionalTypedActorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
@@ -25,13 +25,13 @@ class NestedTransactionalActiveObjectSpec extends
// ActorRegistry.shutdownAll
}
- describe("Declaratively nested supervised transactional in-memory Active Object") {
+ describe("Declaratively nested supervised transactional in-memory TypedActor") {
it("map should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested) // transactionrequired
@@ -40,13 +40,13 @@ class NestedTransactionalActiveObjectSpec extends
}
it("map should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
fail("should have thrown an exception")
@@ -56,10 +56,10 @@ class NestedTransactionalActiveObjectSpec extends
}
it("vector should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setVectorState("init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state", nested) // transactionrequired
@@ -68,13 +68,13 @@ class NestedTransactionalActiveObjectSpec extends
}
it("vector should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setVectorState("init") // set init state
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
fail("should have thrown an exception")
@@ -84,9 +84,9 @@ class NestedTransactionalActiveObjectSpec extends
}
it("ref should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
stateful.setRefState("init") // set init state
nested.setRefState("init") // set init state
@@ -96,13 +96,13 @@ class NestedTransactionalActiveObjectSpec extends
}
it("ref should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
- val nested = ActiveObject.newInstance(classOf[NestedTransactionalActiveObject])
+ val nested = TypedActor.newInstance(classOf[NestedTransactionalTypedActor])
nested.init
stateful.setRefState("init") // set init state
nested.setRefState("init") // set init state
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
fail("should have thrown an exception")
diff --git a/akka-core/src/test/scala/RemoteTransactionalActiveObjectSpec.scala b/akka-core/src/test/scala/RemoteTransactionalActiveObjectSpec.scala
index 897318ce7d..71d44fd4bd 100644
--- a/akka-core/src/test/scala/RemoteTransactionalActiveObjectSpec.scala
+++ b/akka-core/src/test/scala/RemoteTransactionalActiveObjectSpec.scala
@@ -13,25 +13,25 @@ import org.junit.runner.RunWith
import org.junit.{Test, Before, After}
import se.scalablesolutions.akka.config.Config
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator
+import se.scalablesolutions.akka.config.TypedActorConfigurator
import se.scalablesolutions.akka.remote.{RemoteNode, RemoteServer, RemoteClient}
-object RemoteTransactionalActiveObjectSpec {
+object RemoteTransactionalTypedActorSpec {
val HOSTNAME = "localhost"
val PORT = 9988
var server: RemoteServer = null
}
@RunWith(classOf[JUnitRunner])
-class RemoteTransactionalActiveObjectSpec extends
+class RemoteTransactionalTypedActorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
- import RemoteTransactionalActiveObjectSpec._
+ import RemoteTransactionalTypedActorSpec._
Config.config
- private val conf = new ActiveObjectConfigurator
+ private val conf = new TypedActorConfigurator
private var messageLog = ""
override def beforeAll = {
@@ -51,19 +51,19 @@ class RemoteTransactionalActiveObjectSpec extends
}
}
- describe("Remote transactional in-memory Active Object ") {
+ describe("Remote transactional in-memory TypedActor ") {
/*
it("map should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess") should equal("new state")
}
it("map should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- val failer =ActiveObject.newRemoteInstance(classOf[ActiveObjectFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[ActiveObjectFailer])
+ val failer =TypedActor.newRemoteInstance(classOf[TypedActorFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
@@ -72,16 +72,16 @@ class RemoteTransactionalActiveObjectSpec extends
}
it("vector should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setVectorState("init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
stateful.getVectorState should equal("new state")
}
it("vector should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setVectorState("init") // set init state
- val failer =ActiveObject.newRemoteInstance(classOf[ActiveObjectFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[ActiveObjectFailer])
+ val failer =TypedActor.newRemoteInstance(classOf[TypedActorFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
@@ -90,16 +90,16 @@ class RemoteTransactionalActiveObjectSpec extends
}
it("ref should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setRefState("init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
stateful.getRefState should equal("new state")
}
it("ref should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newRemoteInstance(classOf[TransactionalActiveObject], 1000, HOSTNAME, PORT)
+ val stateful = TypedActor.newRemoteInstance(classOf[TransactionalTypedActor], 1000, HOSTNAME, PORT)
stateful.setRefState("init") // set init state
- val failer =ActiveObject.newRemoteInstance(classOf[ActiveObjectFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[ActiveObjectFailer])
+ val failer =TypedActor.newRemoteInstance(classOf[TypedActorFailer], 1000, HOSTNAME, PORT) //conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
diff --git a/akka-core/src/test/scala/RestartNestedTransactionalActiveObjectSpec.scala b/akka-core/src/test/scala/RestartNestedTransactionalActiveObjectSpec.scala
index 67076aff7c..7e23b00957 100644
--- a/akka-core/src/test/scala/RestartNestedTransactionalActiveObjectSpec.scala
+++ b/akka-core/src/test/scala/RestartNestedTransactionalActiveObjectSpec.scala
@@ -13,17 +13,17 @@ import org.junit.runner.RunWith
import se.scalablesolutions.akka.config.Config
import se.scalablesolutions.akka.config._
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator
+import se.scalablesolutions.akka.config.TypedActorConfigurator
import se.scalablesolutions.akka.config.JavaConfig._
import se.scalablesolutions.akka.actor._
@RunWith(classOf[JUnitRunner])
-class RestartNestedTransactionalActiveObjectSpec extends
+class RestartNestedTransactionalTypedActorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
- private val conf = new ActiveObjectConfigurator
+ private val conf = new TypedActorConfigurator
private var messageLog = ""
override def beforeAll {
@@ -31,13 +31,13 @@ class RestartNestedTransactionalActiveObjectSpec extends
conf.configure(
new RestartStrategy(new AllForOne, 3, 5000, List(classOf[Exception]).toArray),
List(
- new Component(classOf[TransactionalActiveObject],
+ new Component(classOf[TransactionalTypedActor],
new LifeCycle(new Permanent),
10000),
- new Component(classOf[NestedTransactionalActiveObject],
+ new Component(classOf[NestedTransactionalTypedActor],
new LifeCycle(new Permanent),
10000),
- new Component(classOf[ActiveObjectFailer],
+ new Component(classOf[TypedActorFailer],
new LifeCycle(new Permanent),
10000)
).toArray).supervise
@@ -51,15 +51,15 @@ class RestartNestedTransactionalActiveObjectSpec extends
describe("Restart nested supervised transactional Active Object") {
/*
it("map should rollback state for stateful server in case of failure") {
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- val nested = conf.getInstance(classOf[NestedTransactionalActiveObject])
+ val nested = conf.getInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
@@ -71,15 +71,15 @@ class RestartNestedTransactionalActiveObjectSpec extends
}
it("vector should rollback state for stateful server in case of failure") {
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
- val nested = conf.getInstance(classOf[NestedTransactionalActiveObject])
+ val nested = conf.getInstance(classOf[NestedTransactionalTypedActor])
nested.init
nested.setVectorState("init") // set init state
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
@@ -91,15 +91,15 @@ class RestartNestedTransactionalActiveObjectSpec extends
}
it("ref should rollback state for stateful server in case of failure") {
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
- val nested = conf.getInstance(classOf[NestedTransactionalActiveObject])
+ val nested = conf.getInstance(classOf[NestedTransactionalTypedActor])
nested.init
stateful.setRefState("init") // set init state
nested.setRefState("init") // set init state
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", nested, failer)
diff --git a/akka-core/src/test/scala/RestartTransactionalActiveObjectSpec.scala b/akka-core/src/test/scala/RestartTransactionalActiveObjectSpec.scala
index a1a2f8b507..a4f9c61f59 100644
--- a/akka-core/src/test/scala/RestartTransactionalActiveObjectSpec.scala
+++ b/akka-core/src/test/scala/RestartTransactionalActiveObjectSpec.scala
@@ -13,17 +13,17 @@ import org.junit.runner.RunWith
import se.scalablesolutions.akka.config.Config
import se.scalablesolutions.akka.config._
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator
+import se.scalablesolutions.akka.config.TypedActorConfigurator
import se.scalablesolutions.akka.config.JavaConfig._
import se.scalablesolutions.akka.actor._
@RunWith(classOf[JUnitRunner])
-class RestartTransactionalActiveObjectSpec extends
+class RestartTransactionalTypedActorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
- private val conf = new ActiveObjectConfigurator
+ private val conf = new TypedActorConfigurator
private var messageLog = ""
def before {
@@ -32,11 +32,11 @@ class RestartTransactionalActiveObjectSpec extends
new RestartStrategy(new AllForOne, 3, 5000, List(classOf[Exception]).toArray),
List(
new Component(
- classOf[TransactionalActiveObject],
+ classOf[TransactionalTypedActor],
new LifeCycle(new Temporary),
10000),
new Component(
- classOf[ActiveObjectFailer],
+ classOf[TypedActorFailer],
new LifeCycle(new Temporary),
10000)
).toArray).supervise
@@ -51,10 +51,10 @@ class RestartTransactionalActiveObjectSpec extends
/*
it("map should rollback state for stateful server in case of failure") {
before
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init")
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
@@ -65,10 +65,10 @@ class RestartTransactionalActiveObjectSpec extends
it("vector should rollback state for stateful server in case of failure") {
before
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
@@ -78,10 +78,10 @@ class RestartTransactionalActiveObjectSpec extends
}
it("ref should rollback state for stateful server in case of failure") {
- val stateful = conf.getInstance(classOf[TransactionalActiveObject])
+ val stateful = conf.getInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setRefState("init") // set init state
- val failer = conf.getInstance(classOf[ActiveObjectFailer])
+ val failer = conf.getInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
diff --git a/akka-core/src/test/scala/TransactionalActiveObjectSpec.scala b/akka-core/src/test/scala/TransactionalActiveObjectSpec.scala
index 1225df9a92..280c6df652 100644
--- a/akka-core/src/test/scala/TransactionalActiveObjectSpec.scala
+++ b/akka-core/src/test/scala/TransactionalActiveObjectSpec.scala
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith
import se.scalablesolutions.akka.actor._
@RunWith(classOf[JUnitRunner])
-class TransactionalActiveObjectSpec extends
+class TransactionalTypedActorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
@@ -27,7 +27,7 @@ class TransactionalActiveObjectSpec extends
describe("Declaratively supervised transactional in-memory Active Object ") {
it("map should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init")
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state")
@@ -35,10 +35,10 @@ class TransactionalActiveObjectSpec extends
}
it("map should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init")
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
@@ -47,7 +47,7 @@ class TransactionalActiveObjectSpec extends
}
it("vector should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state")
@@ -55,10 +55,10 @@ class TransactionalActiveObjectSpec extends
}
it("vector should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setVectorState("init") // set init state
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
@@ -67,7 +67,7 @@ class TransactionalActiveObjectSpec extends
}
it("ref should not rollback state for stateful server in case of success") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setRefState("init") // set init state
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state")
@@ -75,10 +75,10 @@ class TransactionalActiveObjectSpec extends
}
it("ref should rollback state for stateful server in case of failure") {
- val stateful = ActiveObject.newInstance(classOf[TransactionalActiveObject])
+ val stateful = TypedActor.newInstance(classOf[TransactionalTypedActor])
stateful.init
stateful.setRefState("init") // set init state
- val failer = ActiveObject.newInstance(classOf[ActiveObjectFailer])
+ val failer = TypedActor.newInstance(classOf[TypedActorFailer])
try {
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer)
fail("should have thrown an exception")
diff --git a/akka-core/src/test/scala/ActiveObjectContextSpec.scala b/akka-core/src/test/scala/TypedActorContextSpec.scala
similarity index 64%
rename from akka-core/src/test/scala/ActiveObjectContextSpec.scala
rename to akka-core/src/test/scala/TypedActorContextSpec.scala
index 5a54f0a505..b83da59206 100644
--- a/akka-core/src/test/scala/ActiveObjectContextSpec.scala
+++ b/akka-core/src/test/scala/TypedActorContextSpec.scala
@@ -14,15 +14,15 @@ import org.junit.runner.RunWith
import se.scalablesolutions.akka.dispatch.DefaultCompletableFuture;
@RunWith(classOf[JUnitRunner])
-class ActiveObjectContextSpec extends
+class TypedActorContextSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
- describe("ActiveObjectContext") {
- it("context.sender should return the sender Active Object reference") {
- val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
- val pojoCaller = ActiveObject.newInstance(classOf[SimpleJavaPojoCaller])
+ describe("TypedActorContext") {
+ it("context.sender should return the sender TypedActor reference") {
+ val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo])
+ val pojoCaller = TypedActor.newInstance(classOf[SimpleJavaPojoCaller])
pojoCaller.setPojo(pojo)
try {
pojoCaller.getSenderFromSimpleJavaPojo should equal (pojoCaller)
@@ -31,9 +31,9 @@ class ActiveObjectContextSpec extends
}
}
- it("context.senderFuture should return the senderFuture Active Object reference") {
- val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
- val pojoCaller = ActiveObject.newInstance(classOf[SimpleJavaPojoCaller])
+ it("context.senderFuture should return the senderFuture TypedActor reference") {
+ val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo])
+ val pojoCaller = TypedActor.newInstance(classOf[SimpleJavaPojoCaller])
pojoCaller.setPojo(pojo)
try {
pojoCaller.getSenderFutureFromSimpleJavaPojo.getClass.getName should equal (classOf[DefaultCompletableFuture[_]].getName)
diff --git a/akka-core/src/test/scala/ActiveObjectGuiceConfiguratorSpec.scala b/akka-core/src/test/scala/TypedActorGuiceConfiguratorSpec.scala
similarity index 90%
rename from akka-core/src/test/scala/ActiveObjectGuiceConfiguratorSpec.scala
rename to akka-core/src/test/scala/TypedActorGuiceConfiguratorSpec.scala
index 3cb871d0d8..b43609a4f5 100644
--- a/akka-core/src/test/scala/ActiveObjectGuiceConfiguratorSpec.scala
+++ b/akka-core/src/test/scala/TypedActorGuiceConfiguratorSpec.scala
@@ -15,18 +15,18 @@ import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import se.scalablesolutions.akka.config.Config
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator
+import se.scalablesolutions.akka.config.TypedActorConfigurator
import se.scalablesolutions.akka.config.JavaConfig._
import se.scalablesolutions.akka.dispatch._
import se.scalablesolutions.akka.dispatch.FutureTimeoutException
@RunWith(classOf[JUnitRunner])
-class ActiveObjectGuiceConfiguratorSpec extends
+class TypedActorGuiceConfiguratorSpec extends
Spec with
ShouldMatchers with
BeforeAndAfterAll {
- private val conf = new ActiveObjectConfigurator
+ private val conf = new TypedActorConfigurator
private var messageLog = ""
override def beforeAll {
@@ -55,9 +55,9 @@ class ActiveObjectGuiceConfiguratorSpec extends
override def afterAll = conf.stop
- describe("ActiveObjectGuiceConfigurator") {
+ describe("TypedActorGuiceConfigurator") {
/*
- it("should inject active object using guice") {
+ it("should inject typed actor using guice") {
messageLog = ""
val foo = conf.getInstance(classOf[Foo])
val bar = conf.getInstance(classOf[Bar])
@@ -81,7 +81,7 @@ class ActiveObjectGuiceConfiguratorSpec extends
}
}
- it("should be able to invoke active object") {
+ it("should be able to invoke typed actor") {
messageLog = ""
val foo = conf.getInstance(classOf[Foo])
messageLog += foo.foo("foo ")
@@ -91,7 +91,7 @@ class ActiveObjectGuiceConfiguratorSpec extends
messageLog should equal("foo return_foo before_bar ")
}
- it("should be able to invoke active object's invocation") {
+ it("should be able to invoke typed actor's invocation") {
messageLog = ""
val foo = conf.getInstance(classOf[Foo])
val bar = conf.getInstance(classOf[Bar])
diff --git a/akka-core/src/test/scala/ActiveObjectLifecycleSpec.scala b/akka-core/src/test/scala/TypedActorLifecycleSpec.scala
similarity index 68%
rename from akka-core/src/test/scala/ActiveObjectLifecycleSpec.scala
rename to akka-core/src/test/scala/TypedActorLifecycleSpec.scala
index 2b8e4d502f..b250e3da37 100644
--- a/akka-core/src/test/scala/ActiveObjectLifecycleSpec.scala
+++ b/akka-core/src/test/scala/TypedActorLifecycleSpec.scala
@@ -5,20 +5,20 @@ import org.scalatest.{BeforeAndAfterAll, Spec}
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
-import se.scalablesolutions.akka.actor.ActiveObject._
+import se.scalablesolutions.akka.actor.TypedActor._
-import se.scalablesolutions.akka.config.{OneForOneStrategy, ActiveObjectConfigurator}
+import se.scalablesolutions.akka.config.{OneForOneStrategy, TypedActorConfigurator}
import se.scalablesolutions.akka.config.JavaConfig._
/**
* @author Martin Krasser
*/
@RunWith(classOf[JUnitRunner])
-class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAfterAll {
- var conf1: ActiveObjectConfigurator = _
- var conf2: ActiveObjectConfigurator = _
- var conf3: ActiveObjectConfigurator = _
- var conf4: ActiveObjectConfigurator = _
+class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAfterAll {
+ var conf1: TypedActorConfigurator = _
+ var conf2: TypedActorConfigurator = _
+ var conf3: TypedActorConfigurator = _
+ var conf4: TypedActorConfigurator = _
override protected def beforeAll() = {
val strategy = new RestartStrategy(new AllForOne(), 3, 1000, Array(classOf[Exception]))
@@ -26,10 +26,10 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
val comp2 = new Component(classOf[SamplePojoAnnotated], new LifeCycle(new Temporary()), 1000)
val comp3 = new Component(classOf[SamplePojo], new LifeCycle(new Permanent(), new RestartCallbacks("pre", "post")), 1000)
val comp4 = new Component(classOf[SamplePojo], new LifeCycle(new Temporary(), new ShutdownCallback("down")), 1000)
- conf1 = new ActiveObjectConfigurator().configure(strategy, Array(comp1)).supervise
- conf2 = new ActiveObjectConfigurator().configure(strategy, Array(comp2)).supervise
- conf3 = new ActiveObjectConfigurator().configure(strategy, Array(comp3)).supervise
- conf4 = new ActiveObjectConfigurator().configure(strategy, Array(comp4)).supervise
+ conf1 = new TypedActorConfigurator().configure(strategy, Array(comp1)).supervise
+ conf2 = new TypedActorConfigurator().configure(strategy, Array(comp2)).supervise
+ conf3 = new TypedActorConfigurator().configure(strategy, Array(comp3)).supervise
+ conf4 = new TypedActorConfigurator().configure(strategy, Array(comp4)).supervise
}
override protected def afterAll() = {
@@ -39,8 +39,8 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
conf4.stop
}
- describe("ActiveObject lifecycle management") {
- it("should restart supervised, annotated active object on failure") {
+ describe("TypedActor lifecycle management") {
+ it("should restart supervised, annotated typed actor on failure") {
val obj = conf1.getInstance[SamplePojoAnnotated](classOf[SamplePojoAnnotated])
val cdl = obj.newCountdownLatch(2)
assert(AspectInitRegistry.initFor(obj) ne null)
@@ -58,7 +58,7 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
}
}
- it("should shutdown supervised, annotated active object on failure") {
+ it("should shutdown supervised, annotated typed actor on failure") {
val obj = conf2.getInstance[SamplePojoAnnotated](classOf[SamplePojoAnnotated])
val cdl = obj.newCountdownLatch(1)
assert(AspectInitRegistry.initFor(obj) ne null)
@@ -76,7 +76,7 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
}
}
- it("should restart supervised, non-annotated active object on failure") {
+ it("should restart supervised, non-annotated typed actor on failure") {
val obj = conf3.getInstance[SamplePojo](classOf[SamplePojo])
val cdl = obj.newCountdownLatch(2)
assert(AspectInitRegistry.initFor(obj) ne null)
@@ -94,7 +94,7 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
}
}
- it("should shutdown supervised, non-annotated active object on failure") {
+ it("should shutdown supervised, non-annotated typed actor on failure") {
val obj = conf4.getInstance[SamplePojo](classOf[SamplePojo])
val cdl = obj.newCountdownLatch(1)
assert(AspectInitRegistry.initFor(obj) ne null)
@@ -112,25 +112,25 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
}
}
- it("should shutdown non-supervised, annotated active object on ActiveObject.stop") {
- val obj = ActiveObject.newInstance(classOf[SamplePojoAnnotated])
+ it("should shutdown non-supervised, annotated typed actor on TypedActor.stop") {
+ val obj = TypedActor.newInstance(classOf[SamplePojoAnnotated])
assert(AspectInitRegistry.initFor(obj) ne null)
assert("hello akka" === obj.greet("akka"))
- ActiveObject.stop(obj)
+ TypedActor.stop(obj)
assert(AspectInitRegistry.initFor(obj) eq null)
assert(!obj._pre)
assert(!obj._post)
assert(obj._down)
try {
obj.greet("akka")
- fail("access to stopped active object")
+ fail("access to stopped typed actor")
} catch {
case e: Exception => { /* test passed */ }
}
}
- it("should shutdown non-supervised, annotated active object on ActorRegistry.shutdownAll") {
- val obj = ActiveObject.newInstance(classOf[SamplePojoAnnotated])
+ it("should shutdown non-supervised, annotated typed actor on ActorRegistry.shutdownAll") {
+ val obj = TypedActor.newInstance(classOf[SamplePojoAnnotated])
assert(AspectInitRegistry.initFor(obj) ne null)
assert("hello akka" === obj.greet("akka"))
ActorRegistry.shutdownAll
@@ -140,23 +140,23 @@ class ActiveObjectLifecycleSpec extends Spec with ShouldMatchers with BeforeAndA
assert(obj._down)
try {
obj.greet("akka")
- fail("access to stopped active object")
+ fail("access to stopped typed actor")
} catch {
case e: Exception => { /* test passed */ }
}
}
- it("should shutdown non-supervised, non-initialized active object on ActiveObject.stop") {
- val obj = ActiveObject.newInstance(classOf[SamplePojoAnnotated])
- ActiveObject.stop(obj)
+ it("should shutdown non-supervised, non-initialized typed actor on TypedActor.stop") {
+ val obj = TypedActor.newInstance(classOf[SamplePojoAnnotated])
+ TypedActor.stop(obj)
assert(!obj._pre)
assert(!obj._post)
assert(obj._down)
}
it("both preRestart and postRestart methods should be invoked when an actor is restarted") {
- val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
- val supervisor = ActiveObject.newInstance(classOf[SimpleJavaPojo])
+ val pojo = TypedActor.newInstance(classOf[SimpleJavaPojo])
+ val supervisor = TypedActor.newInstance(classOf[SimpleJavaPojo])
link(supervisor,pojo, new OneForOneStrategy(3, 2000),Array(classOf[Throwable]))
pojo.throwException
Thread.sleep(500)
diff --git a/akka-core/src/test/scala/ActorObjectUtilFunctionsSpec.scala b/akka-core/src/test/scala/TypedActorUtilFunctionsSpec.scala
similarity index 100%
rename from akka-core/src/test/scala/ActorObjectUtilFunctionsSpec.scala
rename to akka-core/src/test/scala/TypedActorUtilFunctionsSpec.scala
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/BeanImpl.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/BeanImpl.java
index 10437e7624..5fa9e8c599 100644
--- a/akka-samples/akka-sample-camel/src/main/java/sample/camel/BeanImpl.java
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/BeanImpl.java
@@ -1,9 +1,10 @@
package sample.camel;
+import se.scalablesolutions.akka.actor.TypedActor;
/**
* @author Martin Krasser
*/
-public class BeanImpl implements BeanIntf {
+public class BeanImpl extends TypedActor implements BeanIntf {
public String foo(String s) {
return "hello " + s;
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1.java
index ed29ac30e6..d099816161 100644
--- a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1.java
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1.java
@@ -8,17 +8,10 @@ import se.scalablesolutions.akka.actor.annotation.consume;
/**
* @author Martin Krasser
*/
-public class ConsumerPojo1 {
-
+public interface ConsumerPojo1 {
@consume("file:data/input/pojo")
- public void foo(String body) {
- System.out.println("Received message:");
- System.out.println(body);
- }
-
+ public void foo(String body);
+
@consume("jetty:http://0.0.0.0:8877/camel/pojo")
- public String bar(@Body String body, @Header("name") String header) {
- return String.format("body=%s header=%s", body, header);
- }
-
+ public String bar(@Body String body, @Header("name") String header);
}
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1Impl.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1Impl.java
new file mode 100644
index 0000000000..8f3ca9625d
--- /dev/null
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo1Impl.java
@@ -0,0 +1,24 @@
+package sample.camel;
+
+import org.apache.camel.Body;
+import org.apache.camel.Header;
+
+import se.scalablesolutions.akka.actor.annotation.consume;
+import se.scalablesolutions.akka.actor.TypedActor;
+
+/**
+ * @author Martin Krasser
+ */
+public class ConsumerPojo1Impl extends TypedActor implements ConsumerPojo1 {
+
+ @consume("file:data/input/pojo")
+ public void foo(String body) {
+ System.out.println("Received message:");
+ System.out.println(body);
+ }
+
+ @consume("jetty:http://0.0.0.0:8877/camel/pojo")
+ public String bar(@Body String body, @Header("name") String header) {
+ return String.format("body=%s header=%s", body, header);
+ }
+}
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2.java
index 429e6043ad..c0ef7a6798 100644
--- a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2.java
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2.java
@@ -7,11 +7,8 @@ import se.scalablesolutions.akka.actor.annotation.consume;
/**
* @author Martin Krasser
*/
-public class ConsumerPojo2 {
+public interface ConsumerPojo2 {
@consume("direct:default")
- public String foo(String body) {
- return String.format("default: %s", body);
- }
-
+ public String foo(String body);
}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2Impl.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2Impl.java
new file mode 100644
index 0000000000..eeca816d1b
--- /dev/null
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/ConsumerPojo2Impl.java
@@ -0,0 +1,18 @@
+package sample.camel;
+
+import org.apache.camel.Body;
+import org.apache.camel.Header;
+
+import se.scalablesolutions.akka.actor.TypedActor;
+import se.scalablesolutions.akka.actor.annotation.consume;
+
+/**
+ * @author Martin Krasser
+ */
+public class ConsumerPojo2Impl extends TypedActor implements ConsumerPojo2 {
+
+ @consume("direct:default")
+ public String foo(String body) {
+ return String.format("default: %s", body);
+ }
+}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1.java
index ab7e878b0d..929a82b65d 100644
--- a/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1.java
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1.java
@@ -8,11 +8,8 @@ import se.scalablesolutions.akka.actor.annotation.consume;
/**
* @author Martin Krasser
*/
-public class RemoteConsumerPojo1 {
+public interface RemoteConsumerPojo1 {
@consume("jetty:http://localhost:6644/camel/remote-active-object-1")
- public String foo(@Body String body, @Header("name") String header) {
- return String.format("remote1: body=%s header=%s", body, header);
- }
-
+ public String foo(@Body String body, @Header("name") String header);
}
diff --git a/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1Impl.java b/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1Impl.java
new file mode 100644
index 0000000000..858afcdbeb
--- /dev/null
+++ b/akka-samples/akka-sample-camel/src/main/java/sample/camel/RemoteConsumerPojo1Impl.java
@@ -0,0 +1,18 @@
+package sample.camel;
+
+import org.apache.camel.Body;
+import org.apache.camel.Header;
+
+import se.scalablesolutions.akka.actor.annotation.consume;
+import se.scalablesolutions.akka.actor.TypedActor;
+
+/**
+ * @author Martin Krasser
+ */
+public class RemoteConsumerPojo1Impl extends TypedActor implements RemoteConsumerPojo1 {
+
+ @consume("jetty:http://localhost:6644/camel/remote-active-object-1")
+ public String foo(@Body String body, @Header("name") String header) {
+ return String.format("remote1: body=%s header=%s", body, header);
+ }
+}
diff --git a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
index bcb884d186..3b733fa988 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
@@ -7,7 +7,7 @@ import org.apache.camel.spring.spi.ApplicationContextRegistry
import org.springframework.context.support.ClassPathXmlApplicationContext
import se.scalablesolutions.akka.actor.Actor._
-import se.scalablesolutions.akka.actor.{ActiveObject, Supervisor}
+import se.scalablesolutions.akka.actor.{TypedActor, Supervisor}
import se.scalablesolutions.akka.camel.CamelContextManager
import se.scalablesolutions.akka.config.ScalaConfig._
@@ -89,7 +89,7 @@ class Boot {
// Active object example
// -----------------------------------------------------------------------
- ActiveObject.newInstance(classOf[ConsumerPojo1])
+ TypedActor.newInstance(classOf[ConsumerPojo1], classOf[ConsumerPojo1Impl])
}
/**
diff --git a/akka-samples/akka-sample-camel/src/main/scala/ClientApplication.scala b/akka-samples/akka-sample-camel/src/main/scala/ClientApplication.scala
index 467d715360..5be24f1c8f 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/ClientApplication.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/ClientApplication.scala
@@ -1,7 +1,7 @@
package sample.camel
import se.scalablesolutions.akka.actor.Actor._
-import se.scalablesolutions.akka.actor.{ActiveObject, Actor, ActorRef}
+import se.scalablesolutions.akka.actor.{TypedActor, Actor, ActorRef}
import se.scalablesolutions.akka.camel.Message
import se.scalablesolutions.akka.remote.RemoteClient
@@ -18,15 +18,15 @@ object ClientApplication {
val actor1 = actorOf[RemoteActor1]
val actor2 = RemoteClient.actorFor("remote2", "localhost", 7777)
- val actobj1 = ActiveObject.newRemoteInstance(classOf[RemoteConsumerPojo1], "localhost", 7777)
- //val actobj2 = TODO: create reference to server-managed active object (RemoteConsumerPojo2)
+ val actobj1 = TypedActor.newRemoteInstance(classOf[RemoteConsumerPojo1], classOf[RemoteConsumerPojo1Impl], "localhost", 7777)
+ //val actobj2 = TODO: create reference to server-managed typed actor (RemoteConsumerPojo2)
actor1.start
println(actor1 !! Message("actor1")) // activates and publishes actor remotely
println(actor2 !! Message("actor2")) // actor already activated and published remotely
- println(actobj1.foo("x", "y")) // activates and publishes active object methods remotely
+ println(actobj1.foo("x", "y")) // activates and publishes typed actor methods remotely
// ...
}
diff --git a/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala b/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala
index 941da479b3..6584651f68 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala
@@ -5,7 +5,7 @@ import org.apache.camel.builder.RouteBuilder
import org.apache.camel.spring.spi.ApplicationContextRegistry
import org.springframework.context.support.ClassPathXmlApplicationContext
-import se.scalablesolutions.akka.actor.{Actor, ActorRegistry, ActiveObject}
+import se.scalablesolutions.akka.actor.{Actor, ActorRegistry, TypedActor}
import se.scalablesolutions.akka.camel._
import se.scalablesolutions.akka.util.Logging
@@ -16,10 +16,9 @@ object StandaloneApplication {
def main(args: Array[String]) {
import CamelContextManager.context
- // 'externally' register active objects
+ // 'externally' register typed actors
val registry = new SimpleRegistry
- registry.put("pojo1", ActiveObject.newInstance(classOf[BeanIntf], new BeanImpl))
- registry.put("pojo2", ActiveObject.newInstance(classOf[BeanImpl]))
+ registry.put("pojo1", TypedActor.newInstance(classOf[BeanIntf], classOf[BeanImpl]))
// customize CamelContext
CamelContextManager.init(new DefaultCamelContext(registry))
@@ -28,12 +27,12 @@ object StandaloneApplication {
// start CamelService
val camelService = CamelService.newInstance.load
- // access 'externally' registered active objects
+ // access 'externally' registered typed actors
assert("hello msg1" == context.createProducerTemplate.requestBody("direct:test1", "msg1"))
assert("hello msg2" == context.createProducerTemplate.requestBody("direct:test2", "msg2"))
- // 'internally' register active object (requires CamelService)
- ActiveObject.newInstance(classOf[ConsumerPojo2])
+ // 'internally' register typed actor (requires CamelService)
+ TypedActor.newInstance(classOf[ConsumerPojo2], classOf[ConsumerPojo2Impl])
// internal registration is done in background. Wait a bit ...
Thread.sleep(1000)
@@ -52,7 +51,7 @@ object StandaloneApplication {
class StandaloneApplicationRoute extends RouteBuilder {
def configure = {
- // routes to active objects (in SimpleRegistry)
+ // routes to typed actors (in SimpleRegistry)
from("direct:test1").to("active-object:pojo1?method=foo")
from("direct:test2").to("active-object:pojo2?method=foo")
}
@@ -65,7 +64,7 @@ object StandaloneSpringApplication {
// load Spring application context
val appctx = new ClassPathXmlApplicationContext("/context-standalone.xml")
- // access 'externally' registered active objects with active-object component
+ // access 'externally' registered typed actors with active-object component
assert("hello msg3" == template.requestBody("direct:test3", "msg3"))
// destroy Spring application context
@@ -78,7 +77,7 @@ object StandaloneSpringApplication {
class StandaloneSpringApplicationRoute extends RouteBuilder {
def configure = {
- // routes to active object (in ApplicationContextRegistry)
+ // routes to typed actor (in ApplicationContextRegistry)
from("direct:test3").to("active-object:pojo3?method=foo")
}
}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java
index 60eb4f11af..cd382ae6ec 100644
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java
@@ -4,11 +4,11 @@
package sample.rest.java;
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
+import se.scalablesolutions.akka.config.TypedActorConfigurator;
import static se.scalablesolutions.akka.config.JavaConfig.*;
public class Boot {
- public final static ActiveObjectConfigurator configurator = new ActiveObjectConfigurator();
+ public final static TypedActorConfigurator configurator = new TypedActorConfigurator();
static {
configurator.configure(
new RestartStrategy(new OneForOne(), 3, 5000, new Class[]{Exception.class}),
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java
index 1108fcdb63..67368ceedd 100644
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java
@@ -4,42 +4,6 @@
package sample.rest.java;
-import se.scalablesolutions.akka.actor.annotation.transactionrequired;
-import se.scalablesolutions.akka.actor.annotation.prerestart;
-import se.scalablesolutions.akka.actor.annotation.postrestart;
-import se.scalablesolutions.akka.persistence.common.PersistentMap;
-import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage;
-
-import java.nio.ByteBuffer;
-
-@transactionrequired
-public class PersistentSimpleService {
- private String KEY = "COUNTER";
-
- private boolean hasStartedTicking = false;
- private PersistentMap storage;
-
- public String count() {
- if (storage == null) storage = CassandraStorage.newMap();
- if (!hasStartedTicking) {
- storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(0).array());
- hasStartedTicking = true;
- return "Tick: 0\n";
- } else {
- byte[] bytes = (byte[])storage.get(KEY.getBytes()).get();
- int counter = ByteBuffer.wrap(bytes).getInt();
- storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(counter + 1).array());
- return "Tick: " + counter + "\n";
- }
- }
-
- @prerestart
- public void preRestart() {
- System.out.println("Prepare for restart by supervisor");
- }
-
- @postrestart
- public void postRestart() {
- System.out.println("Reinitialize after restart by supervisor");
- }
+public interface PersistentSimpleService {
+ public String count();
}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java
new file mode 100644
index 0000000000..2b83f4acbb
--- /dev/null
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2009-2010 Scalable Solutions AB
+ */
+
+package sample.rest.java;
+
+import se.scalablesolutions.akka.actor.TypedTransactor;
+import se.scalablesolutions.akka.persistence.common.PersistentMap;
+import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage;
+
+import java.nio.ByteBuffer;
+
+public class PersistentSimpleServiceImpl extends TypedTransactor implements PersistentSimpleService {
+ private String KEY = "COUNTER";
+
+ private boolean hasStartedTicking = false;
+ private PersistentMap storage;
+
+ public String count() {
+ if (storage == null) storage = CassandraStorage.newMap();
+ if (!hasStartedTicking) {
+ storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(0).array());
+ hasStartedTicking = true;
+ return "Tick: 0\n";
+ } else {
+ byte[] bytes = (byte[])storage.get(KEY.getBytes()).get();
+ int counter = ByteBuffer.wrap(bytes).getInt();
+ storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(counter + 1).array());
+ return "Tick: " + counter + "\n";
+ }
+ }
+
+ @Override
+ public void preRestart(Throwable cause) {
+ System.out.println("Prepare for restart by supervisor");
+ }
+
+ @Override
+ public void postRestart(Throwable cause) {
+ System.out.println("Reinitialize after restart by supervisor");
+ }
+}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java
index 06631659a2..4c60e44ae6 100644
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java
@@ -4,17 +4,6 @@
package sample.rest.java;
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-
-import se.scalablesolutions.akka.actor.ActiveObject;
-import se.scalablesolutions.akka.actor.ActiveObjectContext;
-
-public class Receiver {
- private ActiveObjectContext context = null;
- public SimpleService receive() {
- System.out.println("------ RECEIVE");
- return (SimpleService) context.getSender();
- }
+public interface Receiver {
+ SimpleService receive();
}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java
new file mode 100644
index 0000000000..c46042a848
--- /dev/null
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java
@@ -0,0 +1,14 @@
+/**
+ * Copyright (C) 2009-2010 Scalable Solutions AB
+ */
+
+package sample.rest.java;
+
+import se.scalablesolutions.akka.actor.TypedActorContext;
+import se.scalablesolutions.akka.actor.TypedActor;
+
+public class ReceiverImpl extends TypedActor implements Receiver {
+ public SimpleService receive() {
+ return (SimpleService) getContext().getSender();
+ }
+}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java
index 097ba810b5..8055b3383a 100644
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java
@@ -4,43 +4,6 @@
package sample.rest.java;
-import se.scalablesolutions.akka.actor.ActiveObject;
-import se.scalablesolutions.akka.actor.ActiveObjectContext;
-import se.scalablesolutions.akka.actor.annotation.transactionrequired;
-import se.scalablesolutions.akka.actor.annotation.prerestart;
-import se.scalablesolutions.akka.actor.annotation.postrestart;
-import se.scalablesolutions.akka.stm.TransactionalMap;
-
-@transactionrequired
-public class SimpleService {
- private String KEY = "COUNTER";
-
- private boolean hasStartedTicking = false;
- private TransactionalMap storage;
- private Receiver receiver = ActiveObject.newInstance(Receiver.class);
-
- public String count() {
- if (storage == null) storage = new TransactionalMap();
- if (!hasStartedTicking) {
- storage.put(KEY, 0);
- hasStartedTicking = true;
- return "Tick: 0\n";
- } else {
- // Grabs the sender address and returns it
- //SimpleService sender = receiver.receive();
- int counter = (Integer)storage.get(KEY).get() + 1;
- storage.put(KEY, counter);
- return "Tick: " + counter + "\n";
- }
- }
-
- @prerestart
- public void preRestart() {
- System.out.println("Prepare for restart by supervisor");
- }
-
- @postrestart
- public void postRestart() {
- System.out.println("Reinitialize after restart by supervisor");
- }
+public interface SimpleService {
+ public String count();
}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java
new file mode 100644
index 0000000000..96400a0404
--- /dev/null
+++ b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2009-2010 Scalable Solutions AB
+ */
+
+package sample.rest.java;
+
+import se.scalablesolutions.akka.actor.TypedActor;
+import se.scalablesolutions.akka.actor.TypedTransactor;
+import se.scalablesolutions.akka.actor.TypedActorContext;
+import se.scalablesolutions.akka.stm.TransactionalMap;
+
+public class SimpleServiceImpl extends TypedTransactor implements SimpleService {
+ private String KEY = "COUNTER";
+
+ private boolean hasStartedTicking = false;
+ private TransactionalMap storage;
+ private Receiver receiver = TypedActor.newInstance(Receiver.class, ReceiverImpl.class);
+
+ public String count() {
+ if (storage == null) storage = new TransactionalMap();
+ if (!hasStartedTicking) {
+ storage.put(KEY, 0);
+ hasStartedTicking = true;
+ return "Tick: 0\n";
+ } else {
+ // Grabs the sender address and returns it
+ //SimpleService sender = receiver.receive();
+ int counter = (Integer)storage.get(KEY).get() + 1;
+ storage.put(KEY, counter);
+ return "Tick: " + counter + "\n";
+ }
+ }
+
+ @Override
+ public void preRestart(Throwable cause) {
+ System.out.println("Prepare for restart by supervisor");
+ }
+
+ @Override
+ public void postRestart(Throwable cause) {
+ System.out.println("Reinitialize after restart by supervisor");
+ }
+}
\ No newline at end of file
diff --git a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml
index 665d03a05e..13c45e6d3b 100644
--- a/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml
+++ b/akka-spring/akka-spring-test-java/src/main/resources/se/scalablesolutions/akka/spring/foo/test-config.xml
@@ -10,7 +10,7 @@ http://www.akkasource.org/schema/akka
http://scalablesolutions.se/akka/akka-0.10.xsd">
diff --git a/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/ActiveObjectConfigurationTest.java b/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/ActiveObjectConfigurationTest.java
index 7cc691f3e3..4117347380 100644
--- a/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/ActiveObjectConfigurationTest.java
+++ b/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/ActiveObjectConfigurationTest.java
@@ -21,10 +21,10 @@ import se.scalablesolutions.akka.remote.RemoteNode;
import se.scalablesolutions.akka.spring.foo.MyPojo;
/**
- * Tests for spring configuration of active objects and supervisor configuration.
+ * Tests for spring configuration of typed actors and supervisor configuration.
* @author michaelkober
*/
-public class ActiveObjectConfigurationTest {
+public class TypedActorConfigurationTest {
private ApplicationContext context = null;
@@ -50,7 +50,7 @@ public class ActiveObjectConfigurationTest {
}
@Test
- public void testSimpleActiveObject() {
+ public void testSimpleTypedActor() {
MyPojo myPojo = (MyPojo) context.getBean("simple-active-object");
String msg = myPojo.getFoo();
msg += myPojo.getBar();
@@ -58,20 +58,20 @@ public class ActiveObjectConfigurationTest {
}
@Test(expected = FutureTimeoutException.class)
- public void testSimpleActiveObject_Timeout() {
+ public void testSimpleTypedActor_Timeout() {
MyPojo myPojo = (MyPojo) context.getBean("simple-active-object");
myPojo.longRunning();
}
@Test
- public void testSimpleActiveObject_NoTimeout() {
+ public void testSimpleTypedActor_NoTimeout() {
MyPojo myPojo = (MyPojo) context.getBean("simple-active-object-long-timeout");
String msg = myPojo.longRunning();
assertEquals("this took long", msg);
}
@Test
- public void testTransactionalActiveObject() {
+ public void testTransactionalTypedActor() {
MyPojo myPojo = (MyPojo) context.getBean("transactional-active-object");
String msg = myPojo.getFoo();
msg += myPojo.getBar();
@@ -79,7 +79,7 @@ public class ActiveObjectConfigurationTest {
}
@Test
- public void testRemoteActiveObject() {
+ public void testRemoteTypedActor() {
new Thread(new Runnable() {
public void run() {
RemoteNode.start();
diff --git a/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/SupervisorConfigurationTest.java b/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/SupervisorConfigurationTest.java
index 659433cb9f..c90fd56b72 100644
--- a/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/SupervisorConfigurationTest.java
+++ b/akka-spring/akka-spring-test-java/src/test/java/se/scalablesolutions/akka/spring/SupervisorConfigurationTest.java
@@ -13,8 +13,8 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import se.scalablesolutions.akka.actor.ActiveObject;
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
+import se.scalablesolutions.akka.actor.TypedActor;
+import se.scalablesolutions.akka.config.TypedActorConfigurator;
import se.scalablesolutions.akka.config.JavaConfig.AllForOne;
import se.scalablesolutions.akka.config.JavaConfig.Component;
import se.scalablesolutions.akka.config.JavaConfig.LifeCycle;
@@ -45,10 +45,10 @@ public class SupervisorConfigurationTest {
@Test
public void testSupervision() {
- // get ActiveObjectConfigurator bean from spring context
- ActiveObjectConfigurator myConfigurator = (ActiveObjectConfigurator) context
+ // get TypedActorConfigurator bean from spring context
+ TypedActorConfigurator myConfigurator = (TypedActorConfigurator) context
.getBean("supervision1");
- // get ActiveObjects
+ // get TypedActors
Foo foo = myConfigurator.getInstance(Foo.class);
assertNotNull(foo);
IBar bar = myConfigurator.getInstance(IBar.class);
@@ -59,7 +59,7 @@ public class SupervisorConfigurationTest {
@Test
public void testTransactionalState() {
- ActiveObjectConfigurator conf = (ActiveObjectConfigurator) context
+ TypedActorConfigurator conf = (TypedActorConfigurator) context
.getBean("supervision2");
StatefulPojo stateful = conf.getInstance(StatefulPojo.class);
stateful.setMapState("testTransactionalState", "some map state");
@@ -73,23 +73,23 @@ public class SupervisorConfigurationTest {
@Test
public void testInitTransactionalState() {
- StatefulPojo stateful = ActiveObject.newInstance(StatefulPojo.class,
+ StatefulPojo stateful = TypedActor.newInstance(StatefulPojo.class,
1000, true);
assertTrue("should be inititalized", stateful.isInitialized());
}
@Test
public void testSupervisionWithDispatcher() {
- ActiveObjectConfigurator myConfigurator = (ActiveObjectConfigurator) context
+ TypedActorConfigurator myConfigurator = (TypedActorConfigurator) context
.getBean("supervision-with-dispatcher");
- // get ActiveObjects
+ // get TypedActors
Foo foo = myConfigurator.getInstance(Foo.class);
assertNotNull(foo);
// TODO how to check dispatcher?
}
@Test
- public void testRemoteActiveObject() {
+ public void testRemoteTypedActor() {
new Thread(new Runnable() {
public void run() {
RemoteNode.start();
@@ -99,13 +99,13 @@ public class SupervisorConfigurationTest {
Thread.currentThread().sleep(1000);
} catch (Exception e) {
}
- Foo instance = ActiveObject.newRemoteInstance(Foo.class, 2000, "localhost", 9999);
+ Foo instance = TypedActor.newRemoteInstance(Foo.class, 2000, "localhost", 9999);
System.out.println(instance.foo());
}
@Test
- public void testSupervisedRemoteActiveObject() {
+ public void testSupervisedRemoteTypedActor() {
new Thread(new Runnable() {
public void run() {
RemoteNode.start();
@@ -116,7 +116,7 @@ public class SupervisorConfigurationTest {
} catch (Exception e) {
}
- ActiveObjectConfigurator conf = new ActiveObjectConfigurator();
+ TypedActorConfigurator conf = new TypedActorConfigurator();
conf.configure(
new RestartStrategy(new AllForOne(), 3, 10000, new Class[] { Exception.class }),
new Component[] {
diff --git a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd
index 6eb0ec48fa..5fd9b94c38 100644
--- a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd
+++ b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd
@@ -134,7 +134,7 @@
-
+
@@ -196,7 +196,7 @@
-
+
@@ -252,7 +252,7 @@
-
+
diff --git a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala
deleted file mode 100644
index 7e33d0176a..0000000000
--- a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package se.scalablesolutions.akka.spring
-
-import java.beans.PropertyDescriptor
-import java.lang.reflect.Method
-import javax.annotation.PreDestroy
-import javax.annotation.PostConstruct
-import reflect.BeanProperty
-
-import org.springframework.beans.BeanWrapperImpl
-import org.springframework.beans.BeanWrapper
-import org.springframework.beans.BeanUtils
-import org.springframework.beans.factory.BeanFactory
-import org.springframework.beans.factory.config.AbstractFactoryBean
-import org.springframework.context.{ApplicationContext,ApplicationContextAware}
-import org.springframework.util.ReflectionUtils
-import org.springframework.util.StringUtils
-
-import se.scalablesolutions.akka.actor.{ActiveObjectConfiguration, ActiveObject}
-import se.scalablesolutions.akka.config.ScalaConfig.{ShutdownCallback, RestartCallbacks}
-import se.scalablesolutions.akka.dispatch.MessageDispatcher
-import se.scalablesolutions.akka.util.{Logging, Duration}
-
-/**
- * Factory bean for active objects.
- *
- * @author michaelkober
- * @author Johan Rask
- * @author Martin Krasser
- */
-class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging with ApplicationContextAware {
- import StringReflect._
- import AkkaSpringConfigurationTags._
-
- @BeanProperty var target: String = ""
- @BeanProperty var timeout: Long = _
- @BeanProperty var interface: String = ""
- @BeanProperty var transactional: Boolean = false
- @BeanProperty var pre: String = ""
- @BeanProperty var post: String = ""
- @BeanProperty var shutdown: String = ""
- @BeanProperty var host: String = ""
- @BeanProperty var port: Int = _
- @BeanProperty var lifecycle: String = ""
- @BeanProperty var dispatcher: DispatcherProperties = _
- @BeanProperty var scope:String = VAL_SCOPE_SINGLETON
- @BeanProperty var property:PropertyEntries = _
- @BeanProperty var applicationContext:ApplicationContext = _
-
- // Holds info about if deps has been set or not. Depends on
- // if interface is specified or not. We must set deps on
- // target instance if interface is specified
- var hasSetDependecies = false
-
-
- override def isSingleton:Boolean = {
- if(scope.equals(VAL_SCOPE_SINGLETON)) {
- true
- } else {
- false
- }
- }
-
- /*
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- def getObjectType: Class[AnyRef] = try {
- target.toClass
- } catch {
- // required by contract to return null
- case e: ClassNotFoundException => null
- }
-
- /*
- * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
- */
- def createInstance: AnyRef = {
- var argumentList = ""
- if (isRemote) argumentList += "r"
- if (hasInterface) argumentList += "i"
- if (hasDispatcher) argumentList += "d"
-
- postConstruct(
- setProperties(
- create(argumentList)))
-
- }
-
- /**
- * Stop the active object if it is a singleton.
- */
- override def destroyInstance(instance:AnyRef) {
- ActiveObject.stop(instance)
- }
-
- /**
- * Invokes any method annotated with @PostConstruct
- * When interfaces are specified, this method is invoked both on the
- * target instance and on the active object, so a developer is free do decide
- * where the annotation should be. If no interface is specified it is only invoked
- * on the active object
- */
- private def postConstruct(ref:AnyRef) : AnyRef = {
- // Invoke postConstruct method if any
- for(method <- ref.getClass.getMethods) {
- if(method.isAnnotationPresent(classOf[PostConstruct])) {
- method.invoke(ref)
- }
- }
- ref
- }
-
-
- private def setProperties(ref:AnyRef) : AnyRef = {
- if(hasSetDependecies) {
- return ref
- }
-
- log.debug("Processing properties and dependencies for target class %s",target)
- val beanWrapper = new BeanWrapperImpl(ref);
- if(ref.isInstanceOf[ApplicationContextAware]) {
- log.debug("Setting application context")
- beanWrapper.setPropertyValue("applicationContext",applicationContext)
- }
- for(entry <- property.entryList) {
- val propertyDescriptor = BeanUtils.getPropertyDescriptor(ref.getClass,entry.name)
- val method = propertyDescriptor.getWriteMethod();
-
- if(StringUtils.hasText(entry.ref)) {
- log.debug("Setting property %s with bean ref %s using method %s",
- entry.name,entry.ref,method.getName)
- method.invoke(ref,getBeanFactory().getBean(entry.ref))
- } else if(StringUtils.hasText(entry.value)) {
- log.debug("Setting property %s with value %s using method %s",
- entry.name,entry.value,method.getName)
- beanWrapper.setPropertyValue(entry.name,entry.value)
- } else {
- throw new AkkaBeansException("Either property@ref or property@value must be set on property element")
- }
- }
- ref
- }
-
- private[akka] def create(argList : String) : AnyRef = {
- if (argList == "r") {
- ActiveObject.newInstance(target.toClass, createConfig.makeRemote(host, port))
- } else if (argList == "ri" ) {
- ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), createConfig.makeRemote(host, port))
- } else if (argList == "rd") {
- ActiveObject.newInstance(target.toClass, createConfig.makeRemote(host, port).dispatcher(dispatcherInstance))
- } else if (argList == "rid") {
- ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), createConfig.makeRemote(host, port).dispatcher(dispatcherInstance))
- } else if (argList == "i") {
- ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), createConfig)
- } else if (argList == "id") {
- ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), createConfig.dispatcher(dispatcherInstance))
- } else if (argList == "d") {
- ActiveObject.newInstance(target.toClass, createConfig.dispatcher(dispatcherInstance))
- } else {
- ActiveObject.newInstance(target.toClass, createConfig)
- }
- }
-
-
-
- private[akka] def createConfig: ActiveObjectConfiguration = {
- val config = new ActiveObjectConfiguration().timeout(Duration(timeout, "millis"))
- if (hasRestartCallbacks) config.restartCallbacks(pre, post)
- if (hasShutdownCallback) config.shutdownCallback(shutdown)
- if (transactional) config.makeTransactionRequired
- config
- }
- def aNewInstance[T <: AnyRef](clazz: Class[T]) : T = {
- var ref = clazz.newInstance().asInstanceOf[T]
- postConstruct(
- setProperties(ref))
- hasSetDependecies = true
- ref
- }
-
- private[akka] def isRemote = (host != null) && (!host.isEmpty)
-
- private[akka] def hasInterface = (interface != null) && (!interface.isEmpty)
-
- private[akka] def hasRestartCallbacks = ((pre != null) && !pre.isEmpty) || ((post != null) && !post.isEmpty)
-
- private[akka] def hasShutdownCallback = ((shutdown != null) && !shutdown.isEmpty)
-
- private[akka] def hasDispatcher = (dispatcher != null) && (dispatcher.dispatcherType != null) && (!dispatcher.dispatcherType.isEmpty)
-
- private[akka] def dispatcherInstance : MessageDispatcher = {
- import DispatcherFactoryBean._
- createNewInstance(dispatcher)
- }
-}
diff --git a/akka-spring/src/main/scala/AkkaNamespaceHandler.scala b/akka-spring/src/main/scala/AkkaNamespaceHandler.scala
index 466dbeca30..34dede40aa 100644
--- a/akka-spring/src/main/scala/AkkaNamespaceHandler.scala
+++ b/akka-spring/src/main/scala/AkkaNamespaceHandler.scala
@@ -12,7 +12,7 @@ import AkkaSpringConfigurationTags._
*/
class AkkaNamespaceHandler extends NamespaceHandlerSupport {
def init = {
- registerBeanDefinitionParser(ACTIVE_OBJECT_TAG, new ActiveObjectBeanDefinitionParser());
+ registerBeanDefinitionParser(ACTIVE_OBJECT_TAG, new TypedActorBeanDefinitionParser());
registerBeanDefinitionParser(SUPERVISION_TAG, new SupervisionBeanDefinitionParser());
registerBeanDefinitionParser(DISPATCHER_TAG, new DispatcherBeanDefinitionParser());
registerBeanDefinitionParser(CAMEL_SERVICE_TAG, new CamelServiceBeanDefinitionParser);
diff --git a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala
index 80a9f2e8d0..1e13865ad3 100644
--- a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala
+++ b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala
@@ -38,7 +38,7 @@ object AkkaSpringConfigurationTags {
// --- ATTRIBUTES
//
- // active object attributes
+ // typed actor attributes
val TIMEOUT = "timeout"
val TARGET = "target"
val INTERFACE = "interface"
diff --git a/akka-spring/src/main/scala/DispatcherBeanDefinitionParser.scala b/akka-spring/src/main/scala/DispatcherBeanDefinitionParser.scala
index 826125fcfc..9d4a16ff9b 100644
--- a/akka-spring/src/main/scala/DispatcherBeanDefinitionParser.scala
+++ b/akka-spring/src/main/scala/DispatcherBeanDefinitionParser.scala
@@ -12,7 +12,7 @@ import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanD
* Parser for custom namespace configuration.
* @author michaelkober
*/
-class DispatcherBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActiveObjectParser with DispatcherParser {
+class DispatcherBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with TypedActorParser with DispatcherParser {
/*
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
*/
diff --git a/akka-spring/src/main/scala/SupervisionBeanDefinitionParser.scala b/akka-spring/src/main/scala/SupervisionBeanDefinitionParser.scala
index dde14f3cb2..4a76f5b008 100644
--- a/akka-spring/src/main/scala/SupervisionBeanDefinitionParser.scala
+++ b/akka-spring/src/main/scala/SupervisionBeanDefinitionParser.scala
@@ -18,7 +18,7 @@ import org.springframework.util.xml.DomUtils
* Parser for custom namespace for Akka declarative supervisor configuration.
* @author michaelkober
*/
-class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActiveObjectParser {
+class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with TypedActorParser {
/* (non-Javadoc)
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
*/
@@ -33,7 +33,7 @@ class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser
val strategyElement = mandatoryElement(element, STRATEGY_TAG);
val activeObjectsElement = mandatoryElement(element, ACTIVE_OBJECTS_TAG);
parseRestartStrategy(strategyElement, builder)
- parseActiveObjectList(activeObjectsElement, builder)
+ parseTypedActorList(activeObjectsElement, builder)
}
private[akka] def parseRestartStrategy(element: Element, builder: BeanDefinitionBuilder) {
@@ -46,9 +46,9 @@ class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser
builder.addPropertyValue("restartStrategy", restartStrategy)
}
- private[akka] def parseActiveObjectList(element: Element, builder: BeanDefinitionBuilder) {
+ private[akka] def parseTypedActorList(element: Element, builder: BeanDefinitionBuilder) {
val activeObjects = DomUtils.getChildElementsByTagName(element, ACTIVE_OBJECT_TAG).toArray.toList.asInstanceOf[List[Element]]
- val activeObjectProperties = activeObjects.map(parseActiveObject(_))
+ val activeObjectProperties = activeObjects.map(parseTypedActor(_))
builder.addPropertyValue("supervised", activeObjectProperties)
}
diff --git a/akka-spring/src/main/scala/SupervisionFactoryBean.scala b/akka-spring/src/main/scala/SupervisionFactoryBean.scala
index d8c44c3502..80a1f8a5fa 100644
--- a/akka-spring/src/main/scala/SupervisionFactoryBean.scala
+++ b/akka-spring/src/main/scala/SupervisionFactoryBean.scala
@@ -4,7 +4,7 @@
package se.scalablesolutions.akka.spring
import org.springframework.beans.factory.config.AbstractFactoryBean
-import se.scalablesolutions.akka.config.ActiveObjectConfigurator
+import se.scalablesolutions.akka.config.TypedActorConfigurator
import se.scalablesolutions.akka.config.JavaConfig._
import AkkaSpringConfigurationTags._
import reflect.BeanProperty
@@ -14,20 +14,20 @@ import reflect.BeanProperty
* Factory bean for supervisor configuration.
* @author michaelkober
*/
-class SupervisionFactoryBean extends AbstractFactoryBean[ActiveObjectConfigurator] {
+class SupervisionFactoryBean extends AbstractFactoryBean[TypedActorConfigurator] {
@BeanProperty var restartStrategy: RestartStrategy = _
- @BeanProperty var supervised: List[ActiveObjectProperties] = _
+ @BeanProperty var supervised: List[TypedActorProperties] = _
/*
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
*/
- def getObjectType: Class[ActiveObjectConfigurator] = classOf[ActiveObjectConfigurator]
+ def getObjectType: Class[TypedActorConfigurator] = classOf[TypedActorConfigurator]
/*
* @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
*/
- def createInstance: ActiveObjectConfigurator = {
- val configurator = new ActiveObjectConfigurator()
+ def createInstance: TypedActorConfigurator = {
+ val configurator = new TypedActorConfigurator()
configurator.configure(
restartStrategy,
@@ -36,9 +36,9 @@ class SupervisionFactoryBean extends AbstractFactoryBean[ActiveObjectConfigurato
}
/**
- * Create configuration for ActiveObject
+ * Create configuration for TypedActor
*/
- private[akka] def createComponent(props: ActiveObjectProperties): Component = {
+ private[akka] def createComponent(props: TypedActorProperties): Component = {
import StringReflect._
val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new LifeCycle(new Temporary()) else new LifeCycle(new Permanent())
val isRemote = (props.host != null) && (!props.host.isEmpty)
diff --git a/akka-spring/src/main/scala/ActiveObjectBeanDefinitionParser.scala b/akka-spring/src/main/scala/TypedActorBeanDefinitionParser.scala
similarity index 84%
rename from akka-spring/src/main/scala/ActiveObjectBeanDefinitionParser.scala
rename to akka-spring/src/main/scala/TypedActorBeanDefinitionParser.scala
index 0189147994..7869a6a33f 100644
--- a/akka-spring/src/main/scala/ActiveObjectBeanDefinitionParser.scala
+++ b/akka-spring/src/main/scala/TypedActorBeanDefinitionParser.scala
@@ -13,17 +13,17 @@ import org.w3c.dom.Element
* Parser for custom namespace configuration.
* @author michaelkober
*/
-class ActiveObjectBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActiveObjectParser {
+class TypedActorBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with TypedActorParser {
/*
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
*/
override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val activeObjectConf = parseActiveObject(element)
+ val activeObjectConf = parseTypedActor(element)
activeObjectConf.setAsProperties(builder)
}
/*
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
*/
- override def getBeanClass(element: Element): Class[_] = classOf[ActiveObjectFactoryBean]
+ override def getBeanClass(element: Element): Class[_] = classOf[TypedActorFactoryBean]
}
diff --git a/akka-spring/src/main/scala/TypedActorFactoryBean.scala b/akka-spring/src/main/scala/TypedActorFactoryBean.scala
new file mode 100644
index 0000000000..0e2848f8d6
--- /dev/null
+++ b/akka-spring/src/main/scala/TypedActorFactoryBean.scala
@@ -0,0 +1,167 @@
+/**
+ * Copyright (C) 2009-2010 Scalable Solutions AB
+ */
+
+package se.scalablesolutions.akka.spring
+
+import java.beans.PropertyDescriptor
+import java.lang.reflect.Method
+import javax.annotation.PreDestroy
+import javax.annotation.PostConstruct
+import reflect.BeanProperty
+
+import org.springframework.beans.BeanWrapperImpl
+import org.springframework.beans.BeanWrapper
+import org.springframework.beans.BeanUtils
+import org.springframework.beans.factory.BeanFactory
+import org.springframework.beans.factory.config.AbstractFactoryBean
+import org.springframework.context.{ApplicationContext,ApplicationContextAware}
+import org.springframework.util.ReflectionUtils
+import org.springframework.util.StringUtils
+
+import se.scalablesolutions.akka.actor.{TypedActorConfiguration, TypedActor}
+import se.scalablesolutions.akka.config.ScalaConfig.{ShutdownCallback, RestartCallbacks}
+import se.scalablesolutions.akka.dispatch.MessageDispatcher
+import se.scalablesolutions.akka.util.{Logging, Duration}
+
+/**
+ * Factory bean for typed actors.
+ *
+ * @author michaelkober
+ * @author Johan Rask
+ * @author Martin Krasser
+ * @author Jonas Bonér
+ */
+class TypedActorFactoryBean extends AbstractFactoryBean[AnyRef] with Logging with ApplicationContextAware {
+ import StringReflect._
+ import AkkaSpringConfigurationTags._
+
+ @BeanProperty var target: String = ""
+ @BeanProperty var timeout: Long = _
+ @BeanProperty var interface: String = ""
+ @BeanProperty var transactional: Boolean = false
+ @BeanProperty var pre: String = ""
+ @BeanProperty var post: String = ""
+ @BeanProperty var shutdown: String = ""
+ @BeanProperty var host: String = ""
+ @BeanProperty var port: Int = _
+ @BeanProperty var lifecycle: String = ""
+ @BeanProperty var dispatcher: DispatcherProperties = _
+ @BeanProperty var scope: String = VAL_SCOPE_SINGLETON
+ @BeanProperty var property: PropertyEntries = _
+ @BeanProperty var applicationContext: ApplicationContext = _
+
+ // Holds info about if deps has been set or not. Depends on
+ // if interface is specified or not. We must set deps on
+ // target instance if interface is specified
+ var hasSetDependecies = false
+
+ override def isSingleton = scope.equals(VAL_SCOPE_SINGLETON)
+
+ /*
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ def getObjectType: Class[AnyRef] = try {
+ target.toClass
+ } catch {
+ // required by contract to return null
+ case e: ClassNotFoundException => null
+ }
+
+ /*
+ * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
+ */
+ def createInstance: AnyRef = {
+ var argumentList = ""
+ if (isRemote) argumentList += "r"
+ if (hasInterface) argumentList += "i"
+ if (hasDispatcher) argumentList += "d"
+ postConstruct(setProperties(create(argumentList)))
+ }
+
+ /**
+ * Stop the typed actor if it is a singleton.
+ */
+ override def destroyInstance(instance: AnyRef) = TypedActor.stop(instance.asInstanceOf[TypedActor])
+
+ /**
+ * Invokes any method annotated with @PostConstruct
+ * When interfaces are specified, this method is invoked both on the
+ * target instance and on the typed actor, so a developer is free do decide
+ * where the annotation should be. If no interface is specified it is only invoked
+ * on the typed actor
+ */
+ private def postConstruct(ref: AnyRef): AnyRef = {
+ // Invoke postConstruct method if any
+ for {
+ method <- ref.getClass.getMethods
+ if method.isAnnotationPresent(classOf[PostConstruct])
+ } method.invoke(ref)
+ ref
+ }
+
+
+ private def setProperties(ref: AnyRef): AnyRef = {
+ if (hasSetDependecies) return ref
+ log.debug("Processing properties and dependencies for target class\n\t[%s]", target)
+ val beanWrapper = new BeanWrapperImpl(ref);
+ if (ref.isInstanceOf[ApplicationContextAware]) {
+ log.debug("Setting application context")
+ beanWrapper.setPropertyValue("applicationContext", applicationContext)
+ }
+ for (entry <- property.entryList) {
+ val propertyDescriptor = BeanUtils.getPropertyDescriptor(ref.getClass, entry.name)
+ val method = propertyDescriptor.getWriteMethod
+ if (StringUtils.hasText(entry.ref)) {
+ log.debug("Setting property %s with bean ref %s using method %s", entry.name, entry.ref, method.getName)
+ method.invoke(ref,getBeanFactory().getBean(entry.ref))
+ } else if(StringUtils.hasText(entry.value)) {
+ log.debug("Setting property %s with value %s using method %s", entry.name, entry.value, method.getName)
+ beanWrapper.setPropertyValue(entry.name,entry.value)
+ } else throw new AkkaBeansException("Either property@ref or property@value must be set on property element")
+ }
+ ref
+ }
+
+ private[akka] def create(argList: String) : AnyRef = argList match {
+ case "ri" => TypedActor.newInstance(interface.toClass, newInstanceFor(target.toClass), createConfig.makeRemote(host, port))
+ case "i" => TypedActor.newInstance(interface.toClass, newInstanceFor(target.toClass), createConfig)
+ case "id" => TypedActor.newInstance(interface.toClass, newInstanceFor(target.toClass), createConfig.dispatcher(dispatcherInstance))
+ case "rid" => TypedActor.newInstance(interface.toClass, newInstanceFor(target.toClass),
+ createConfig.makeRemote(host, port).dispatcher(dispatcherInstance))
+ // case "rd" => TypedActor.newInstance(target.toClass, createConfig.makeRemote(host, port).dispatcher(dispatcherInstance))
+ // case "r" => TypedActor.newInstance(target.toClass, createConfig.makeRemote(host, port))
+ // case "d" => TypedActor.newInstance(target.toClass, createConfig.dispatcher(dispatcherInstance))
+ case _ => throw new AkkaBeansException("Illegal configuration argument list for TypedActor Spring bean [" + argList + "]")
+ }
+
+ private[akka] def createConfig: TypedActorConfiguration = {
+ val config = new TypedActorConfiguration().timeout(Duration(timeout, "millis"))
+ if (hasRestartCallbacks) config.restartCallbacks(pre, post)
+ if (hasShutdownCallback) config.shutdownCallback(shutdown)
+ if (transactional) config.makeTransactionRequired
+ config
+ }
+
+ def newInstanceFor[T <: AnyRef](clazz: Class[T]) : T = {
+ var ref = clazz.newInstance().asInstanceOf[T]
+ postConstruct(setProperties(ref))
+ hasSetDependecies = true
+ ref
+ }
+
+ private[akka] def isRemote = (host != null) && (!host.isEmpty)
+
+ private[akka] def hasInterface = (interface != null) && (!interface.isEmpty)
+
+ private[akka] def hasRestartCallbacks = ((pre != null) && !pre.isEmpty) || ((post != null) && !post.isEmpty)
+
+ private[akka] def hasShutdownCallback = ((shutdown != null) && !shutdown.isEmpty)
+
+ private[akka] def hasDispatcher = (dispatcher != null) && (dispatcher.dispatcherType != null) && (!dispatcher.dispatcherType.isEmpty)
+
+ private[akka] def dispatcherInstance: MessageDispatcher = {
+ import DispatcherFactoryBean._
+ createNewInstance(dispatcher)
+ }
+}
diff --git a/akka-spring/src/main/scala/ActiveObjectParser.scala b/akka-spring/src/main/scala/TypedActorParser.scala
similarity index 90%
rename from akka-spring/src/main/scala/ActiveObjectParser.scala
rename to akka-spring/src/main/scala/TypedActorParser.scala
index 8838360a44..43e713f00e 100644
--- a/akka-spring/src/main/scala/ActiveObjectParser.scala
+++ b/akka-spring/src/main/scala/TypedActorParser.scala
@@ -15,16 +15,16 @@ import se.scalablesolutions.akka.actor.IllegalActorStateException
* @author Johan Rask
* @author Martin Krasser
*/
-trait ActiveObjectParser extends BeanParser with DispatcherParser {
+trait TypedActorParser extends BeanParser with DispatcherParser {
import AkkaSpringConfigurationTags._
/**
- * Parses the given element and returns a ActiveObjectProperties.
+ * Parses the given element and returns a TypedActorProperties.
* @param element dom element to parse
- * @return configuration for the active object
+ * @return configuration for the typed actor
*/
- def parseActiveObject(element: Element): ActiveObjectProperties = {
- val objectProperties = new ActiveObjectProperties()
+ def parseTypedActor(element: Element): TypedActorProperties = {
+ val objectProperties = new TypedActorProperties()
val remoteElement = DomUtils.getChildElementByTagName(element, REMOTE_TAG);
val restartCallbacksElement = DomUtils.getChildElementByTagName(element, RESTART_CALLBACKS_TAG);
val shutdownCallbackElement = DomUtils.getChildElementByTagName(element, SHUTDOWN_CALLBACK_TAG);
diff --git a/akka-spring/src/main/scala/ActiveObjectProperties.scala b/akka-spring/src/main/scala/TypedActorProperties.scala
similarity index 94%
rename from akka-spring/src/main/scala/ActiveObjectProperties.scala
rename to akka-spring/src/main/scala/TypedActorProperties.scala
index 0f4b09d559..53f2fca05a 100644
--- a/akka-spring/src/main/scala/ActiveObjectProperties.scala
+++ b/akka-spring/src/main/scala/TypedActorProperties.scala
@@ -8,11 +8,11 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder
import AkkaSpringConfigurationTags._
/**
- * Data container for active object configuration data.
+ * Data container for typed actor configuration data.
* @author michaelkober
* @author Martin Krasser
*/
-class ActiveObjectProperties {
+class TypedActorProperties {
var target: String = ""
var timeout: Long = _
var interface: String = ""
diff --git a/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala
index dc48ecc4b1..1984e32c47 100644
--- a/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala
+++ b/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala
@@ -12,16 +12,16 @@ import ScalaDom._
import org.w3c.dom.Element
/**
- * Test for ActiveObjectParser
+ * Test for TypedActorParser
* @author michaelkober
*/
@RunWith(classOf[JUnitRunner])
-class ActiveObjectBeanDefinitionParserTest extends Spec with ShouldMatchers {
- private class Parser extends ActiveObjectParser
+class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers {
+ private class Parser extends TypedActorParser
- describe("An ActiveObjectParser") {
+ describe("An TypedActorParser") {
val parser = new Parser()
- it("should parse the active object configuration") {
+ it("should parse the typed actor configuration") {
val xml =
- val props = parser.parseActiveObject(dom(xml).getDocumentElement);
+ val props = parser.parseTypedActor(dom(xml).getDocumentElement);
assert(props != null)
assert(props.timeout === 1000)
assert(props.target === "foo.bar.MyPojo")
@@ -44,25 +44,25 @@ class ActiveObjectBeanDefinitionParserTest extends Spec with ShouldMatchers {
timeout="1000"
transactional="true"/>
- evaluating { parser.parseActiveObject(dom(xml).getDocumentElement) } should produce [IllegalArgumentException]
+ evaluating { parser.parseTypedActor(dom(xml).getDocumentElement) } should produce [IllegalArgumentException]
}
- it("should parse ActiveObjects configuration with dispatcher") {
+ it("should parse TypedActors configuration with dispatcher") {
val xml =
- val props = parser.parseActiveObject(dom(xml).getDocumentElement);
+ val props = parser.parseTypedActor(dom(xml).getDocumentElement);
assert(props != null)
assert(props.dispatcher.dispatcherType === "thread-based")
}
- it("should parse remote ActiveObjects configuration") {
+ it("should parse remote TypedActors configuration") {
val xml =
- val props = parser.parseActiveObject(dom(xml).getDocumentElement);
+ val props = parser.parseTypedActor(dom(xml).getDocumentElement);
assert(props != null)
assert(props.host === "com.some.host")
assert(props.port === 9999)
diff --git a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala
index 68dac8e97c..c65344cd9e 100644
--- a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala
+++ b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala
@@ -11,14 +11,14 @@ import org.springframework.core.io.ResourceEditor
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
- * Test for ActiveObjectFactoryBean
+ * Test for TypedActorFactoryBean
* @author michaelkober
*/
@RunWith(classOf[JUnitRunner])
-class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
+class TypedActorFactoryBeanTest extends Spec with ShouldMatchers {
- describe("A ActiveObjectFactoryBean") {
- val bean = new ActiveObjectFactoryBean
+ describe("A TypedActorFactoryBean") {
+ val bean = new TypedActorFactoryBean
it("should have java getters and setters for all properties") {
bean.setTarget("java.lang.String")
assert(bean.getTarget == "java.lang.String")
@@ -26,7 +26,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
assert(bean.getTimeout == 1000)
}
- it("should create a remote active object when a host is set") {
+ it("should create a remote typed actor when a host is set") {
bean.setHost("some.host.com");
assert(bean.isRemote)
}
@@ -36,7 +36,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
assert(bean.hasInterface)
}
- it("should create an active object with dispatcher if dispatcher is set") {
+ it("should create an typed actor with dispatcher if dispatcher is set") {
val props = new DispatcherProperties()
props.dispatcherType = "executor-based-event-driven"
bean.setDispatcher(props);
@@ -49,7 +49,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
}
it("should create a proxy of type ResourceEditor") {
- val bean = new ActiveObjectFactoryBean()
+ val bean = new TypedActorFactoryBean()
// we must have a java class here
bean.setTarget("org.springframework.core.io.ResourceEditor")
val entries = new PropertyEntries()
@@ -78,7 +78,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
assert(pojoInf.gotApplicationContext)
}
- it("should stop the created active object when scope is singleton and the context is closed") {
+ it("should stop the created typed actor when scope is singleton and the context is closed") {
var ctx = new ClassPathXmlApplicationContext("appContext.xml");
val target = ctx.getBean("bean-singleton").asInstanceOf[SampleBean]
assert(!target.down)
@@ -86,7 +86,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
assert(target.down)
}
- it("should not stop the created active object when scope is prototype and the context is closed") {
+ it("should not stop the created typed actor when scope is prototype and the context is closed") {
var ctx = new ClassPathXmlApplicationContext("appContext.xml");
val target = ctx.getBean("bean-prototype").asInstanceOf[SampleBean]
assert(!target.down)
diff --git a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala b/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala
index d260afa44f..b78f5d552f 100644
--- a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala
+++ b/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala
@@ -6,7 +6,7 @@ import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FeatureSpec}
import org.springframework.context.support.ClassPathXmlApplicationContext
import se.scalablesolutions.akka.camel.CamelContextManager
-import se.scalablesolutions.akka.actor.{ActiveObject, ActorRegistry}
+import se.scalablesolutions.akka.actor.{TypedActor, ActorRegistry}
class CamelServiceSpringFeatureTest extends FeatureSpec with BeforeAndAfterEach with BeforeAndAfterAll {
override protected def beforeAll = {
@@ -20,22 +20,22 @@ class CamelServiceSpringFeatureTest extends FeatureSpec with BeforeAndAfterEach
feature("start CamelService from Spring application context") {
import CamelContextManager._
- scenario("with a custom CamelContext and access a registered active object") {
+ scenario("with a custom CamelContext and access a registered typed actor") {
val appctx = new ClassPathXmlApplicationContext("/appContextCamelServiceCustom.xml")
assert(context.isInstanceOf[SpringCamelContext])
assert("hello sample" === template.requestBody("direct:test", "sample"))
appctx.close
}
- scenario("with a default CamelContext and access a registered active object") {
+ scenario("with a default CamelContext and access a registered typed actor") {
val appctx = new ClassPathXmlApplicationContext("/appContextCamelServiceDefault.xml")
// create a custom registry
val registry = new SimpleRegistry
- registry.put("custom", ActiveObject.newInstance(classOf[SampleBean]))
+ registry.put("custom", TypedActor.newInstance(classOf[SampleBean]))
// set custom registry in DefaultCamelContext
assert(context.isInstanceOf[DefaultCamelContext])
context.asInstanceOf[DefaultCamelContext].setRegistry(registry)
- // access registered active object
+ // access registered typed actor
assert("hello sample" === template.requestBody("active-object:custom?method=foo", "sample"))
appctx.close
}
diff --git a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala
index bd5490a1b0..64e9ea2425 100644
--- a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala
+++ b/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala
@@ -89,7 +89,7 @@ class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers {
}
- it("should throw IllegalArgumentException when configuring a thread based dispatcher without ActiveObject") {
+ it("should throw IllegalArgumentException when configuring a thread based dispatcher without TypedActor") {
val xml =
evaluating { parser.parseDispatcher(dom(xml).getDocumentElement) } should produce [IllegalArgumentException]
}
diff --git a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala
index ffc1f7a95d..317421c207 100644
--- a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala
+++ b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala
@@ -26,8 +26,8 @@ class SupervisionBeanDefinitionParserTest extends Spec with ShouldMatchers {
val parser = new Parser()
val builder = BeanDefinitionBuilder.genericBeanDefinition("foo.bar.Foo")
- it("should be able to parse active object configuration") {
- val props = parser.parseActiveObject(createActiveObjectElement);
+ it("should be able to parse typed actor configuration") {
+ val props = parser.parseTypedActor(createTypedActorElement);
assert(props != null)
assert(props.timeout == 1000)
assert(props.target == "foo.bar.MyPojo")
@@ -45,9 +45,9 @@ class SupervisionBeanDefinitionParserTest extends Spec with ShouldMatchers {
expect(1000) { strategy.withinTimeRange }
}
- it("should parse the supervised active objects") {
+ it("should parse the supervised typed actors") {
parser.parseSupervisor(createSupervisorElement, builder);
- val supervised = builder.getBeanDefinition.getPropertyValues.getPropertyValue("supervised").getValue.asInstanceOf[List[ActiveObjectProperties]]
+ val supervised = builder.getBeanDefinition.getPropertyValues.getPropertyValue("supervised").getValue.asInstanceOf[List[TypedActorProperties]]
assert(supervised != null)
expect(4) { supervised.length }
val iterator = supervised.iterator
@@ -75,7 +75,7 @@ class SupervisionBeanDefinitionParserTest extends Spec with ShouldMatchers {
}
}
- private def createActiveObjectElement : Element = {
+ private def createTypedActorElement : Element = {
val xml =