我想创建多个服务,并且我想用不同的标识符来使用它们。 所以我的意思是:我想在一个传输中使用多个服务(Thrift)
我有一个用户和项目服务。 我想同时使用这些。
我的意思是我可以添加更多'服务'到xmlrpc上的“处理程序映射”。
http://ws.apache.org/xmlrpc/server.html
phm.addHandler("Users",
Users.class);
phm.addHandler("Projects",
Projects.class);
我愿做同样的节俭。
下面是一个简单的例子: test.thrift
typedef i64 UserId
struct Bonk
{
1: string message,
2: i32 type
}
struct Insanity
{
1: map<Bonk, UserId> userMap,
2: list<Bonk> xtructs
}
service ThriftTest
{
void testVoid(),
string testString(1: string test),
byte testByte(1: byte test),
i32 testI32(1: i32 test),
i64 testI64(1: i64 test),
double testDouble(1: double test),
list<map<i32,i32>> testMap(1: map<i32,i32> test),
map<string,string> testStringMap(1: map<string,string> test),
set<i32> testSet(1: set<i32> test),
map<i32,map<i32,i32>> testMapMap(1: i32 test),
map<UserId, map<i32,Insanity>> testInsanity(1: Insanity argument)
}
然后,我创建一个implementatino,然后将其添加到TSERVER的实例。
Users.Processor users_proccesor = new Users.Processor(New UsersImpl());
Projects.Processor project_processor = new Projects.Processors(new ProjectsImp());
// I would like to add Users and Projects
ThriftTest.Processor prc = new ThriftTest.Processor(new ThiftTestImp());
TServerTransport serverTransport = new TServerSocket(9090);
TServer server = new TSimpleServer(new Args(serverTransport).processor(prc));
而这里是我的大问题,我无法添加多个服务器实例。
非常感谢您的帮助。