jcai / fepss-rpc Goto Github PK
View Code? Open in Web Editor NEWProtocol Buffers RPC Server Implemention based on Mina(2.0.0-RC1) and Protobuf(2.1.0)
Home Page: http://www.ganshane.com
Protocol Buffers RPC Server Implemention based on Mina(2.0.0-RC1) and Protobuf(2.1.0)
Home Page: http://www.ganshane.com
Protocol Buffers RPC Server Implemention based on Tapestry(5.1.0.5) ,Mina(2.0.0-RC1) and Protobuf(2.1.0) == Usage == ses RpcApplicationTest.java 1) define your service ,eg:test.proto package protobuf.socketrpc; option java_package = "com.fepss.rpc.test"; option java_outer_classname = "TestProto"; message User{ optional string userName=1; } message Result{ optional string result=1; optional bool success=2; } service TestService { rpc TestMethod(User) returns(Result); } 2) generate service code protoc test.proto --java_out . 3) implement your service. public class TestServiceImpl extends TestService{ @Override public void testMethod(RpcController controller, User request, RpcCallback<Result> done) { Builder builder =Result.newBuilder().setResult("get user"+request.getUserName()); builder.setSuccess(true); done.run(builder.build()); } } 4) client call,RpcApplicationTest.java @Test public void testRpc() throws IOException{ RpcApplication application = new RpcApplication(TestModule.class); try{ application.start(); // create client to call rpc RpcChannelImpl channel = new RpcChannelImpl(RpcConstants.DEFAULT_HOST,RpcConstants.DEFAULT_PORT); RpcController controller = channel.newRpcController(); Stub service = TestService.newStub(channel); // request data String reqdata = "Request Data"; User request = User.newBuilder().setUserName(reqdata).build(); // response callback RpcCallback<Result> done = new RpcCallback<Result>() { @Override public void run(Result result) { Assert.assertEquals(result.getResult(), "get userRequest Data"); Assert.assertTrue(result.getSuccess()); } }; // execute remote method service.testMethod(controller, request, done); Assert.assertFalse(controller.failed()); Assert.assertEquals(controller.errorText(), null); }finally{ application.stop(); } } public static class TestModule{ public static void contributeIoHandler(MappedConfiguration<String,Service> configruation){ configruation.add(TestService.getDescriptor().getFullName(),new TestServiceImpl()); } } 5)feedback Jun.Tsai AT gmail.com
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.