Skip to content

Commit

Permalink
remove duplicated proto in java source tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuo committed Apr 23, 2012
1 parent 5f8012e commit cb79c7b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 35 deletions.
1 change: 1 addition & 0 deletions java/README
@@ -0,0 +1 @@
Set muduo.includedir in pom.xml before building.
30 changes: 29 additions & 1 deletion java/pom.xml
Expand Up @@ -12,6 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<muduo.includedir>../../build/debug-install/include/muduo/net/protorpc</muduo.includedir>
</properties>

<build>
Expand Down Expand Up @@ -39,7 +40,34 @@
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile-protoc</id>
<id>compile-rpc-proto</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-sources"/>
<path id="proto.path">
<fileset dir="${muduo.includedir}">
<include name="*.proto" />
</fileset>
</path>
<path id="proto.path2">
<pathelement location="${muduo.includedir}" />
</path>
<pathconvert pathsep=" " property="proto.files" refid="proto.path" />
<pathconvert pathsep=" " property="proto.include" refid="proto.path2" />
<exec executable="protoc" failonerror="true">
<arg value="--java_out=target/generated-sources"/>
<arg value="-I${proto.include}" />
<arg line="${proto.files}"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>compile-protos</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
Expand Down
34 changes: 0 additions & 34 deletions java/src/main/java/com/chenshuo/muduo/protorpc/rpc.proto

This file was deleted.

48 changes: 48 additions & 0 deletions java/src/test/java/com/chenshuo/muduo/protorpc/RpcList.java
@@ -0,0 +1,48 @@
package com.chenshuo.muduo.protorpc;

import java.net.InetSocketAddress;

import com.chenshuo.muduo.protorpc.RpcServiceProto.ListRpcRequest;
import com.chenshuo.muduo.protorpc.RpcServiceProto.ListRpcResponse;
import com.chenshuo.muduo.protorpc.RpcServiceProto.RpcService;

public class RpcList {

private RpcClient client;
private RpcChannel channel;
RpcService.BlockingInterface rpcService;

public RpcList(InetSocketAddress addr) {
client = new RpcClient();
channel = client.blockingConnect(addr);
rpcService = RpcService.newBlockingStub(channel);
}

public void close() {
channel.disconnect();
client.stop();
}

public void listRpc(boolean listMethod) throws Exception {
ListRpcRequest request = ListRpcRequest.newBuilder().setListMethod(listMethod).build();
ListRpcResponse response = rpcService.listRpc(null, request);
System.out.println(response);
}

public void listOneService(String service, boolean listMethod) throws Exception {
ListRpcRequest request = ListRpcRequest.newBuilder().setServiceName(service).setListMethod(listMethod).build();
ListRpcResponse response = rpcService.listRpc(null, request);
System.out.println(response);
}

public static void main(String[] args) throws Exception {
InetSocketAddress addr = new InetSocketAddress(args[0], Integer.parseInt(args[1]));
RpcList rpcList = new RpcList(addr);
rpcList.listRpc(false);
rpcList.listRpc(true);
rpcList.listOneService("xxx", false);
rpcList.listOneService("zurg.SlaveService", false);
rpcList.listOneService("zurg.SlaveService", true);
rpcList.close();
}
}

0 comments on commit cb79c7b

Please sign in to comment.