!rem, clu, mul #3154 Upgrade protobuf to 2.5.0 and add an SBT task

* Added an SBT task to compile protobuf files with protoc
* Upgraded protobuf to 2.5.0 which is the current stable
This commit is contained in:
Björn Antonsson 2013-09-11 12:52:52 +02:00
parent 9456a081b7
commit 2876460dcb
13 changed files with 8484 additions and 4628 deletions

View file

@ -5,14 +5,6 @@
option java_package = "akka.remote.testconductor"; option java_package = "akka.remote.testconductor";
option optimize_for = SPEED; option optimize_for = SPEED;
/******************************************
Compile with:
cd ./akka-multi-node-testkit/src/main/protocol
protoc TestConductorProtocol.proto --java_out ../java
cd ../../../..
./scripts/fix-protobuf.sh
*******************************************/
message Wrapper { message Wrapper {
optional Hello hello = 1; optional Hello hello = 1;
optional EnterBarrier barrier = 2; optional EnterBarrier barrier = 2;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,14 +5,6 @@
option java_package = "akka.remote"; option java_package = "akka.remote";
option optimize_for = SPEED; option optimize_for = SPEED;
/******************************************
Compile with:
cd ./akka-remote/src/main/protocol
protoc ContainerFormats.proto --java_out ../java
cd ../../../..
./scripts/fix-protobuf.sh
*******************************************/
/****************************************** /******************************************
ActorSelection related formats ActorSelection related formats
*******************************************/ *******************************************/

View file

@ -5,14 +5,6 @@
option java_package = "akka.remote"; option java_package = "akka.remote";
option optimize_for = SPEED; option optimize_for = SPEED;
/******************************************
Compile with:
cd ./akka-remote/src/main/protocol
protoc WireFormats.proto --java_out ../java
cd ../../../..
./scripts/fix-protobuf.sh
*******************************************/
/****************************************** /******************************************
* Remoting message formats * Remoting message formats
******************************************/ ******************************************/

View file

@ -3,8 +3,6 @@
package akka.remote; package akka.remote;
import com.google.protobuf.AbstractMessage;
public final class ProtobufProtocol { public final class ProtobufProtocol {
private ProtobufProtocol() {} private ProtobufProtocol() {}
public static void registerAllExtensions( public static void registerAllExtensions(
@ -14,25 +12,52 @@ public final class ProtobufProtocol {
extends com.google.protobuf.MessageOrBuilder { extends com.google.protobuf.MessageOrBuilder {
// required uint64 id = 1; // required uint64 id = 1;
/**
* <code>required uint64 id = 1;</code>
*/
boolean hasId(); boolean hasId();
/**
* <code>required uint64 id = 1;</code>
*/
long getId(); long getId();
// required string name = 2; // required string name = 2;
/**
* <code>required string name = 2;</code>
*/
boolean hasName(); boolean hasName();
String getName(); /**
* <code>required string name = 2;</code>
*/
java.lang.String getName();
/**
* <code>required string name = 2;</code>
*/
com.google.protobuf.ByteString
getNameBytes();
// required bool status = 3; // required bool status = 3;
/**
* <code>required bool status = 3;</code>
*/
boolean hasStatus(); boolean hasStatus();
/**
* <code>required bool status = 3;</code>
*/
boolean getStatus(); boolean getStatus();
} }
/**
* Protobuf type {@code MyMessage}
*/
public static final class MyMessage extends public static final class MyMessage extends
com.google.protobuf.GeneratedMessage com.google.protobuf.GeneratedMessage
implements MyMessageOrBuilder { implements MyMessageOrBuilder {
// Use MyMessage.newBuilder() to construct. // Use MyMessage.newBuilder() to construct.
private MyMessage(Builder builder) { private MyMessage(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
super(builder); super(builder);
this.unknownFields = builder.getUnknownFields();
} }
private MyMessage(boolean noInit) {} private MyMessage(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
private static final MyMessage defaultInstance; private static final MyMessage defaultInstance;
public static MyMessage getDefaultInstance() { public static MyMessage getDefaultInstance() {
@ -43,23 +68,102 @@ public final class ProtobufProtocol {
return defaultInstance; return defaultInstance;
} }
private final com.google.protobuf.UnknownFieldSet unknownFields;
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private MyMessage(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
initFields();
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownField(input, unknownFields,
extensionRegistry, tag)) {
done = true;
}
break;
}
case 8: {
bitField0_ |= 0x00000001;
id_ = input.readUInt64();
break;
}
case 18: {
bitField0_ |= 0x00000002;
name_ = input.readBytes();
break;
}
case 24: {
bitField0_ |= 0x00000004;
status_ = input.readBool();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() { getDescriptor() {
return ProtobufProtocol.internal_static_akka_actor_MyMessage_descriptor; return akka.remote.ProtobufProtocol.internal_static_MyMessage_descriptor;
} }
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() { internalGetFieldAccessorTable() {
return ProtobufProtocol.internal_static_akka_actor_MyMessage_fieldAccessorTable; return akka.remote.ProtobufProtocol.internal_static_MyMessage_fieldAccessorTable
.ensureFieldAccessorsInitialized(
akka.remote.ProtobufProtocol.MyMessage.class, akka.remote.ProtobufProtocol.MyMessage.Builder.class);
}
public static com.google.protobuf.Parser<MyMessage> PARSER =
new com.google.protobuf.AbstractParser<MyMessage>() {
public MyMessage parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new MyMessage(input, extensionRegistry);
}
};
@java.lang.Override
public com.google.protobuf.Parser<MyMessage> getParserForType() {
return PARSER;
} }
private int bitField0_; private int bitField0_;
// required uint64 id = 1; // required uint64 id = 1;
public static final int ID_FIELD_NUMBER = 1; public static final int ID_FIELD_NUMBER = 1;
private long id_; private long id_;
/**
* <code>required uint64 id = 1;</code>
*/
public boolean hasId() { public boolean hasId() {
return ((bitField0_ & 0x00000001) == 0x00000001); return ((bitField0_ & 0x00000001) == 0x00000001);
} }
/**
* <code>required uint64 id = 1;</code>
*/
public long getId() { public long getId() {
return id_; return id_;
} }
@ -67,28 +171,39 @@ public final class ProtobufProtocol {
// required string name = 2; // required string name = 2;
public static final int NAME_FIELD_NUMBER = 2; public static final int NAME_FIELD_NUMBER = 2;
private java.lang.Object name_; private java.lang.Object name_;
/**
* <code>required string name = 2;</code>
*/
public boolean hasName() { public boolean hasName() {
return ((bitField0_ & 0x00000002) == 0x00000002); return ((bitField0_ & 0x00000002) == 0x00000002);
} }
public String getName() { /**
* <code>required string name = 2;</code>
*/
public java.lang.String getName() {
java.lang.Object ref = name_; java.lang.Object ref = name_;
if (ref instanceof String) { if (ref instanceof java.lang.String) {
return (String) ref; return (java.lang.String) ref;
} else { } else {
com.google.protobuf.ByteString bs = com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref; (com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8(); java.lang.String s = bs.toStringUtf8();
if (com.google.protobuf.Internal.isValidUtf8(bs)) { if (bs.isValidUtf8()) {
name_ = s; name_ = s;
} }
return s; return s;
} }
} }
private com.google.protobuf.ByteString getNameBytes() { /**
* <code>required string name = 2;</code>
*/
public com.google.protobuf.ByteString
getNameBytes() {
java.lang.Object ref = name_; java.lang.Object ref = name_;
if (ref instanceof String) { if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b = com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((String) ref); com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
name_ = b; name_ = b;
return b; return b;
} else { } else {
@ -99,9 +214,15 @@ public final class ProtobufProtocol {
// required bool status = 3; // required bool status = 3;
public static final int STATUS_FIELD_NUMBER = 3; public static final int STATUS_FIELD_NUMBER = 3;
private boolean status_; private boolean status_;
/**
* <code>required bool status = 3;</code>
*/
public boolean hasStatus() { public boolean hasStatus() {
return ((bitField0_ & 0x00000004) == 0x00000004); return ((bitField0_ & 0x00000004) == 0x00000004);
} }
/**
* <code>required bool status = 3;</code>
*/
public boolean getStatus() { public boolean getStatus() {
return status_; return status_;
} }
@ -177,76 +298,62 @@ public final class ProtobufProtocol {
return super.writeReplace(); return super.writeReplace();
} }
public static ProtobufProtocol.MyMessage parseFrom( public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
com.google.protobuf.ByteString data) com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data).buildParsed(); return PARSER.parseFrom(data);
} }
public static ProtobufProtocol.MyMessage parseFrom( public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
com.google.protobuf.ByteString data, com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data, extensionRegistry) return PARSER.parseFrom(data, extensionRegistry);
.buildParsed();
} }
public static ProtobufProtocol.MyMessage parseFrom(byte[] data) public static akka.remote.ProtobufProtocol.MyMessage parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data).buildParsed(); return PARSER.parseFrom(data);
} }
public static ProtobufProtocol.MyMessage parseFrom( public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
byte[] data, byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data, extensionRegistry) return PARSER.parseFrom(data, extensionRegistry);
.buildParsed();
} }
public static ProtobufProtocol.MyMessage parseFrom(java.io.InputStream input) public static akka.remote.ProtobufProtocol.MyMessage parseFrom(java.io.InputStream input)
throws java.io.IOException { throws java.io.IOException {
return newBuilder().mergeFrom(input).buildParsed(); return PARSER.parseFrom(input);
} }
public static ProtobufProtocol.MyMessage parseFrom( public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
java.io.InputStream input, java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException { throws java.io.IOException {
return newBuilder().mergeFrom(input, extensionRegistry) return PARSER.parseFrom(input, extensionRegistry);
.buildParsed();
} }
public static ProtobufProtocol.MyMessage parseDelimitedFrom(java.io.InputStream input) public static akka.remote.ProtobufProtocol.MyMessage parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException { throws java.io.IOException {
Builder builder = newBuilder(); return PARSER.parseDelimitedFrom(input);
if (builder.mergeDelimitedFrom(input)) {
return builder.buildParsed();
} else {
return null;
} }
} public static akka.remote.ProtobufProtocol.MyMessage parseDelimitedFrom(
public static ProtobufProtocol.MyMessage parseDelimitedFrom(
java.io.InputStream input, java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException { throws java.io.IOException {
Builder builder = newBuilder(); return PARSER.parseDelimitedFrom(input, extensionRegistry);
if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
return builder.buildParsed();
} else {
return null;
} }
} public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
public static ProtobufProtocol.MyMessage parseFrom(
com.google.protobuf.CodedInputStream input) com.google.protobuf.CodedInputStream input)
throws java.io.IOException { throws java.io.IOException {
return newBuilder().mergeFrom(input).buildParsed(); return PARSER.parseFrom(input);
} }
public static ProtobufProtocol.MyMessage parseFrom( public static akka.remote.ProtobufProtocol.MyMessage parseFrom(
com.google.protobuf.CodedInputStream input, com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException { throws java.io.IOException {
return newBuilder().mergeFrom(input, extensionRegistry) return PARSER.parseFrom(input, extensionRegistry);
.buildParsed();
} }
public static Builder newBuilder() { return Builder.create(); } public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); } public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(ProtobufProtocol.MyMessage prototype) { public static Builder newBuilder(akka.remote.ProtobufProtocol.MyMessage prototype) {
return newBuilder().mergeFrom(prototype); return newBuilder().mergeFrom(prototype);
} }
public Builder toBuilder() { return newBuilder(this); } public Builder toBuilder() { return newBuilder(this); }
@ -257,25 +364,31 @@ public final class ProtobufProtocol {
Builder builder = new Builder(parent); Builder builder = new Builder(parent);
return builder; return builder;
} }
/**
* Protobuf type {@code MyMessage}
*/
public static final class Builder extends public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder> com.google.protobuf.GeneratedMessage.Builder<Builder>
implements ProtobufProtocol.MyMessageOrBuilder { implements akka.remote.ProtobufProtocol.MyMessageOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() { getDescriptor() {
return ProtobufProtocol.internal_static_akka_actor_MyMessage_descriptor; return akka.remote.ProtobufProtocol.internal_static_MyMessage_descriptor;
} }
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() { internalGetFieldAccessorTable() {
return ProtobufProtocol.internal_static_akka_actor_MyMessage_fieldAccessorTable; return akka.remote.ProtobufProtocol.internal_static_MyMessage_fieldAccessorTable
.ensureFieldAccessorsInitialized(
akka.remote.ProtobufProtocol.MyMessage.class, akka.remote.ProtobufProtocol.MyMessage.Builder.class);
} }
// Construct using akka.actor.ProtobufProtocol.MyMessage.newBuilder() // Construct using akka.remote.ProtobufProtocol.MyMessage.newBuilder()
private Builder() { private Builder() {
maybeForceBuilderInitialization(); maybeForceBuilderInitialization();
} }
private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { private Builder(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
super(parent); super(parent);
maybeForceBuilderInitialization(); maybeForceBuilderInitialization();
} }
@ -304,33 +417,23 @@ public final class ProtobufProtocol {
public com.google.protobuf.Descriptors.Descriptor public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() { getDescriptorForType() {
return ProtobufProtocol.MyMessage.getDescriptor(); return akka.remote.ProtobufProtocol.internal_static_MyMessage_descriptor;
} }
public ProtobufProtocol.MyMessage getDefaultInstanceForType() { public akka.remote.ProtobufProtocol.MyMessage getDefaultInstanceForType() {
return ProtobufProtocol.MyMessage.getDefaultInstance(); return akka.remote.ProtobufProtocol.MyMessage.getDefaultInstance();
} }
public ProtobufProtocol.MyMessage build() { public akka.remote.ProtobufProtocol.MyMessage build() {
ProtobufProtocol.MyMessage result = buildPartial(); akka.remote.ProtobufProtocol.MyMessage result = buildPartial();
if (!result.isInitialized()) { if (!result.isInitialized()) {
throw AbstractMessage.Builder.newUninitializedMessageException(result); throw newUninitializedMessageException(result);
} }
return result; return result;
} }
private ProtobufProtocol.MyMessage buildParsed() public akka.remote.ProtobufProtocol.MyMessage buildPartial() {
throws com.google.protobuf.InvalidProtocolBufferException { akka.remote.ProtobufProtocol.MyMessage result = new akka.remote.ProtobufProtocol.MyMessage(this);
ProtobufProtocol.MyMessage result = buildPartial();
if (!result.isInitialized()) {
throw AbstractMessage.Builder.newUninitializedMessageException(
result).asInvalidProtocolBufferException();
}
return result;
}
public ProtobufProtocol.MyMessage buildPartial() {
ProtobufProtocol.MyMessage result = new ProtobufProtocol.MyMessage(this);
int from_bitField0_ = bitField0_; int from_bitField0_ = bitField0_;
int to_bitField0_ = 0; int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) { if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
@ -351,21 +454,23 @@ public final class ProtobufProtocol {
} }
public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof ProtobufProtocol.MyMessage) { if (other instanceof akka.remote.ProtobufProtocol.MyMessage) {
return mergeFrom((ProtobufProtocol.MyMessage)other); return mergeFrom((akka.remote.ProtobufProtocol.MyMessage)other);
} else { } else {
super.mergeFrom(other); super.mergeFrom(other);
return this; return this;
} }
} }
public Builder mergeFrom(ProtobufProtocol.MyMessage other) { public Builder mergeFrom(akka.remote.ProtobufProtocol.MyMessage other) {
if (other == ProtobufProtocol.MyMessage.getDefaultInstance()) return this; if (other == akka.remote.ProtobufProtocol.MyMessage.getDefaultInstance()) return this;
if (other.hasId()) { if (other.hasId()) {
setId(other.getId()); setId(other.getId());
} }
if (other.hasName()) { if (other.hasName()) {
setName(other.getName()); bitField0_ |= 0x00000002;
name_ = other.name_;
onChanged();
} }
if (other.hasStatus()) { if (other.hasStatus()) {
setStatus(other.getStatus()); setStatus(other.getStatus());
@ -394,60 +499,47 @@ public final class ProtobufProtocol {
com.google.protobuf.CodedInputStream input, com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException { throws java.io.IOException {
com.google.protobuf.UnknownFieldSet.Builder unknownFields = akka.remote.ProtobufProtocol.MyMessage parsedMessage = null;
com.google.protobuf.UnknownFieldSet.newBuilder( try {
this.getUnknownFields()); parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
while (true) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
int tag = input.readTag(); parsedMessage = (akka.remote.ProtobufProtocol.MyMessage) e.getUnfinishedMessage();
switch (tag) { throw e;
case 0: } finally {
this.setUnknownFields(unknownFields.build()); if (parsedMessage != null) {
onChanged(); mergeFrom(parsedMessage);
return this; }
default: { }
if (!parseUnknownField(input, unknownFields,
extensionRegistry, tag)) {
this.setUnknownFields(unknownFields.build());
onChanged();
return this; return this;
} }
break;
}
case 8: {
bitField0_ |= 0x00000001;
id_ = input.readUInt64();
break;
}
case 18: {
bitField0_ |= 0x00000002;
name_ = input.readBytes();
break;
}
case 24: {
bitField0_ |= 0x00000004;
status_ = input.readBool();
break;
}
}
}
}
private int bitField0_; private int bitField0_;
// required uint64 id = 1; // required uint64 id = 1;
private long id_ ; private long id_ ;
/**
* <code>required uint64 id = 1;</code>
*/
public boolean hasId() { public boolean hasId() {
return ((bitField0_ & 0x00000001) == 0x00000001); return ((bitField0_ & 0x00000001) == 0x00000001);
} }
/**
* <code>required uint64 id = 1;</code>
*/
public long getId() { public long getId() {
return id_; return id_;
} }
/**
* <code>required uint64 id = 1;</code>
*/
public Builder setId(long value) { public Builder setId(long value) {
bitField0_ |= 0x00000001; bitField0_ |= 0x00000001;
id_ = value; id_ = value;
onChanged(); onChanged();
return this; return this;
} }
/**
* <code>required uint64 id = 1;</code>
*/
public Builder clearId() { public Builder clearId() {
bitField0_ = (bitField0_ & ~0x00000001); bitField0_ = (bitField0_ & ~0x00000001);
id_ = 0L; id_ = 0L;
@ -457,20 +549,47 @@ public final class ProtobufProtocol {
// required string name = 2; // required string name = 2;
private java.lang.Object name_ = ""; private java.lang.Object name_ = "";
/**
* <code>required string name = 2;</code>
*/
public boolean hasName() { public boolean hasName() {
return ((bitField0_ & 0x00000002) == 0x00000002); return ((bitField0_ & 0x00000002) == 0x00000002);
} }
public String getName() { /**
* <code>required string name = 2;</code>
*/
public java.lang.String getName() {
java.lang.Object ref = name_; java.lang.Object ref = name_;
if (!(ref instanceof String)) { if (!(ref instanceof java.lang.String)) {
String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); java.lang.String s = ((com.google.protobuf.ByteString) ref)
.toStringUtf8();
name_ = s; name_ = s;
return s; return s;
} else { } else {
return (String) ref; return (java.lang.String) ref;
} }
} }
public Builder setName(String value) { /**
* <code>required string name = 2;</code>
*/
public com.google.protobuf.ByteString
getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>required string name = 2;</code>
*/
public Builder setName(
java.lang.String value) {
if (value == null) { if (value == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
@ -479,32 +598,55 @@ public final class ProtobufProtocol {
onChanged(); onChanged();
return this; return this;
} }
/**
* <code>required string name = 2;</code>
*/
public Builder clearName() { public Builder clearName() {
bitField0_ = (bitField0_ & ~0x00000002); bitField0_ = (bitField0_ & ~0x00000002);
name_ = getDefaultInstance().getName(); name_ = getDefaultInstance().getName();
onChanged(); onChanged();
return this; return this;
} }
void setName(com.google.protobuf.ByteString value) { /**
* <code>required string name = 2;</code>
*/
public Builder setNameBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002; bitField0_ |= 0x00000002;
name_ = value; name_ = value;
onChanged(); onChanged();
return this;
} }
// required bool status = 3; // required bool status = 3;
private boolean status_ ; private boolean status_ ;
/**
* <code>required bool status = 3;</code>
*/
public boolean hasStatus() { public boolean hasStatus() {
return ((bitField0_ & 0x00000004) == 0x00000004); return ((bitField0_ & 0x00000004) == 0x00000004);
} }
/**
* <code>required bool status = 3;</code>
*/
public boolean getStatus() { public boolean getStatus() {
return status_; return status_;
} }
/**
* <code>required bool status = 3;</code>
*/
public Builder setStatus(boolean value) { public Builder setStatus(boolean value) {
bitField0_ |= 0x00000004; bitField0_ |= 0x00000004;
status_ = value; status_ = value;
onChanged(); onChanged();
return this; return this;
} }
/**
* <code>required bool status = 3;</code>
*/
public Builder clearStatus() { public Builder clearStatus() {
bitField0_ = (bitField0_ & ~0x00000004); bitField0_ = (bitField0_ & ~0x00000004);
status_ = false; status_ = false;
@ -512,7 +654,7 @@ public final class ProtobufProtocol {
return this; return this;
} }
// @@protoc_insertion_point(builder_scope:akka.actor.MyMessage) // @@protoc_insertion_point(builder_scope:MyMessage)
} }
static { static {
@ -520,14 +662,14 @@ public final class ProtobufProtocol {
defaultInstance.initFields(); defaultInstance.initFields();
} }
// @@protoc_insertion_point(class_scope:akka.actor.MyMessage) // @@protoc_insertion_point(class_scope:MyMessage)
} }
private static com.google.protobuf.Descriptors.Descriptor private static com.google.protobuf.Descriptors.Descriptor
internal_static_akka_actor_MyMessage_descriptor; internal_static_MyMessage_descriptor;
private static private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_akka_actor_MyMessage_fieldAccessorTable; internal_static_MyMessage_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() { getDescriptor() {
@ -537,23 +679,21 @@ public final class ProtobufProtocol {
descriptor; descriptor;
static { static {
java.lang.String[] descriptorData = { java.lang.String[] descriptorData = {
"\n\026ProtobufProtocol.proto\022\nakka.actor\"5\n\t" + "\n\026ProtobufProtocol.proto\"5\n\tMyMessage\022\n\n" +
"MyMessage\022\n\n\002id\030\001 \002(\004\022\014\n\004name\030\002 \002(\t\022\016\n\006s" + "\002id\030\001 \002(\004\022\014\n\004name\030\002 \002(\t\022\016\n\006status\030\003 \002(\010B" +
"tatus\030\003 \002(\010" "\r\n\013akka.remote"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors( public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) { com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root; descriptor = root;
internal_static_akka_actor_MyMessage_descriptor = internal_static_MyMessage_descriptor =
getDescriptor().getMessageTypes().get(0); getDescriptor().getMessageTypes().get(0);
internal_static_akka_actor_MyMessage_fieldAccessorTable = new internal_static_MyMessage_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable( com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_akka_actor_MyMessage_descriptor, internal_static_MyMessage_descriptor,
new java.lang.String[] { "Id", "Name", "Status", }, new java.lang.String[] { "Id", "Name", "Status", });
ProtobufProtocol.MyMessage.class,
ProtobufProtocol.MyMessage.Builder.class);
return null; return null;
} }
}; };

View file

@ -0,0 +1,12 @@
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
option java_package = "akka.remote";
message MyMessage {
required uint64 id = 1;
required string name = 2;
required bool status = 3;
}

View file

@ -1,20 +0,0 @@
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor;
/******************************************
Compile with:
cd ./akka-remote/src/test/protocol
protoc ProtobufProtocol.proto --java_out ../java
cd ../../../..
./scripts/fix-protobuf.sh
*******************************************/
message MyMessage {
required uint64 id = 1;
required string name = 2;
required bool status = 3;
}

View file

@ -16,12 +16,12 @@
<osgi.version>4.2.0</osgi.version> <osgi.version>4.2.0</osgi.version>
<paxexam.version>2.6.0</paxexam.version> <paxexam.version>2.6.0</paxexam.version>
<paxswissbox.version>1.6.0</paxswissbox.version> <paxswissbox.version>1.6.0</paxswissbox.version>
<protobuf.version>2.4.1</protobuf.version> <protobuf.version>2.5.0</protobuf.version>
<scala.version>2.10.1</scala.version> <scala.version>2.10.1</scala.version>
<scala.dep.version>2.10</scala.dep.version> <scala.dep.version>2.10</scala.dep.version>
<scalatest.version>1.9.1</scalatest.version> <scalatest.version>1.9.1</scalatest.version>
<typesafe.config.version>1.0.0</typesafe.config.version> <typesafe.config.version>1.0.2</typesafe.config.version>
<scalabuff.version>1.2.0</scalabuff.version> <scalabuff.version>1.3.6</scalabuff.version>
</properties> </properties>
<modules> <modules>

View file

@ -193,7 +193,7 @@ object AkkaBuild extends Build {
id = "akka-remote", id = "akka-remote",
base = file("akka-remote"), base = file("akka-remote"),
dependencies = Seq(actor, actorTests % "test->test", testkit % "test->test"), dependencies = Seq(actor, actorTests % "test->test", testkit % "test->test"),
settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ OSGi.remote ++ Seq( settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ OSGi.remote ++ Protobuf.settings ++ Seq(
libraryDependencies ++= Dependencies.remote, libraryDependencies ++= Dependencies.remote,
// disable parallel tests // disable parallel tests
parallelExecution in Test := false, parallelExecution in Test := false,
@ -205,7 +205,7 @@ object AkkaBuild extends Build {
id = "akka-multi-node-testkit", id = "akka-multi-node-testkit",
base = file("akka-multi-node-testkit"), base = file("akka-multi-node-testkit"),
dependencies = Seq(remote, testkit), dependencies = Seq(remote, testkit),
settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ Seq( settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ Protobuf.settings ++ Seq(
previousArtifact := akkaPreviousArtifact("akka-multi-node-testkit") previousArtifact := akkaPreviousArtifact("akka-multi-node-testkit")
) )
) )
@ -234,7 +234,7 @@ object AkkaBuild extends Build {
settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ multiJvmSettings ++ OSGi.cluster ++ settings = defaultSettings ++ scaladocSettings ++ javadocSettings ++ multiJvmSettings ++ OSGi.cluster ++
scalabuffSettings ++ Seq( scalabuffSettings ++ Seq(
// this version needs to be reflected in the OSGi.scalabuffImport and dining hackers pom.xml // this version needs to be reflected in the OSGi.scalabuffImport and dining hackers pom.xml
scalabuffVersion in ScalaBuff := "1.2.0", scalabuffVersion in ScalaBuff := "1.3.6",
libraryDependencies ++= Dependencies.cluster, libraryDependencies ++= Dependencies.cluster,
// disable parallel tests // disable parallel tests
parallelExecution in Test := false, parallelExecution in Test := false,
@ -1023,8 +1023,8 @@ object AkkaBuild extends Build {
def defaultImports = Seq("!sun.misc", akkaImport(), configImport(), scalaImport(), "*") def defaultImports = Seq("!sun.misc", akkaImport(), configImport(), scalaImport(), "*")
def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.2,2.3)\"".format(packageName) def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.2,2.3)\"".format(packageName)
def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4.1,1.1.0)\"".format(packageName) def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4.1,1.1.0)\"".format(packageName)
def protobufImport(packageName: String = "com.google.protobuf.*") = "%s;version=\"[2.4.0,2.5.0)\"".format(packageName) def protobufImport(packageName: String = "com.google.protobuf.*") = "%s;version=\"[2.5.0,2.6.0)\"".format(packageName)
def scalabuffImport(packageName: String = "net.sandrogrzicic.scalabuff.*") = "%s;version=\"[1.2.0,1.3.0)\"".format(packageName) def scalabuffImport(packageName: String = "net.sandrogrzicic.scalabuff.*") = "%s;version=\"[1.3.6,1.4.0)\"".format(packageName)
def scalaImport(packageName: String = "scala.*") = "%s;version=\"[2.10,2.11)\"".format(packageName) def scalaImport(packageName: String = "scala.*") = "%s;version=\"[2.10,2.11)\"".format(packageName)
def optionalResolution(packageName: String) = "%s;resolution:=optional".format(packageName) def optionalResolution(packageName: String) = "%s;resolution:=optional".format(packageName)
} }
@ -1040,7 +1040,7 @@ object Dependencies {
val config = "com.typesafe" % "config" % "1.0.2" // ApacheV2 val config = "com.typesafe" % "config" % "1.0.2" // ApacheV2
val netty = "io.netty" % "netty" % "3.6.6.Final" // ApacheV2 val netty = "io.netty" % "netty" % "3.6.6.Final" // ApacheV2
val protobuf = "com.google.protobuf" % "protobuf-java" % "2.4.1" // New BSD val protobuf = "com.google.protobuf" % "protobuf-java" % "2.5.0" // New BSD
val scalaStm = "org.scala-stm" %% "scala-stm" % "0.7" // Modified BSD (Scala) val scalaStm = "org.scala-stm" %% "scala-stm" % "0.7" // Modified BSD (Scala)
val scalaBuffRuntime = "net.sandrogrzicic" %% "scalabuff-runtime" % "1.2.0" // ApacheV2 val scalaBuffRuntime = "net.sandrogrzicic" %% "scalabuff-runtime" % "1.2.0" // ApacheV2

77
project/Protobuf.scala Normal file
View file

@ -0,0 +1,77 @@
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka
import sbt._
import Process._
import Keys._
import java.io.File
object Protobuf {
val paths = SettingKey[Seq[File]]("protobuf-paths", "The paths that contain *.proto files.")
val outputPaths = SettingKey[Seq[File]]("protobuf-output-paths", "The paths where to save the generated *.java files.")
val protoc = SettingKey[String]("protobuf-protoc", "The path and name of the protoc executable.")
val protocVersion = SettingKey[String]("protobuf-protoc-version", "The version of the protoc executable.")
val generate = TaskKey[Unit]("protobuf-generate", "Compile the protobuf sources and do all processing.")
lazy val settings: Seq[Setting[_]] = Seq(
paths <<= (sourceDirectory in Compile, sourceDirectory in Test) { (a, b) => Seq(a, b) map (_ / "protobuf") },
outputPaths <<= (sourceDirectory in Compile, sourceDirectory in Test) { (a, b) => Seq(a, b) map (_ / "java") },
protoc := "protoc",
protocVersion := "2.5.0",
generate <<= generateSourceTask
)
private def callProtoc[T](protoc: String, args: Seq[String], log: Logger, thunk: (ProcessBuilder, Logger) => T): T =
try {
val proc = Process(protoc, args)
thunk(proc, log)
} catch { case e: Exception =>
throw new RuntimeException("error while executing '%s' with args: %s" format(protoc, args.mkString(" ")), e)
}
private def checkProtocVersion(protoc: String, protocVersion: String, log: Logger): Unit = {
val res = callProtoc(protoc, Seq("--version"), log, { (p, l) => p !! l })
val version = res.split(" ").last.trim
if (version != protocVersion) {
sys.error("Wrong protoc version! Expected %s but got %s" format (protocVersion, version))
}
}
private def generate(protoc: String, srcDir: File, targetDir: File, log: Logger): Unit = {
val protoFiles = (srcDir ** "*.proto").get
if (srcDir.exists)
if (protoFiles.isEmpty)
log.info("Skipping empty source directory %s" format srcDir)
else {
targetDir.mkdirs()
log.info("Generating %d protobuf files from %s to %s".format(protoFiles.size, srcDir, targetDir))
protoFiles.foreach { proto => log.info("Compiling %s" format proto) }
val exitCode = callProtoc(protoc, Seq("-I" + srcDir.absolutePath, "--java_out=%s" format targetDir.absolutePath) ++
protoFiles.map(_.absolutePath), log, { (p, l) => p ! l })
if (exitCode != 0)
sys.error("protoc returned exit code: %d" format exitCode)
}
}
private def generateSourceTask: Project.Initialize[Task[Unit]] = (streams, paths, outputPaths, protoc, protocVersion) map {
(out, sourceDirs, targetDirs, protoc, protocVersion) =>
if (sourceDirs.size != targetDirs.size)
sys.error("Unbalanced number of paths and destination paths!\nPaths: %s\nDestination Paths: %s" format
(sourceDirs, targetDirs))
if (sourceDirs exists { _.exists }) {
checkProtocVersion(protoc, protocVersion, out.log)
(sourceDirs zip targetDirs) map {
case (sourceDir, targetDir) =>
generate(protoc, sourceDir, targetDir, out.log)
}
}
}
}

View file

@ -1,3 +0,0 @@
#!/bin/bash
find . -name \*.java -print0 | xargs -0 perl -pi -e 's/\Qprivate Builder(BuilderParent parent)/private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent)/'