深度集成thrift-netty
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz-plugins-thrift-netty</artifactId>
<version>1.r.62</version>
</dependency>
@At("/echo/?")
@Ok("raw")
@Aop("TCOMPACTPROTOCOL")
public String echo(String info) throws TException {
TProtocol protocol = protocol();
TSegmentService.Client client = new TSegmentService.Client(protocol);
return client.getArabicWords(info);
}
thrift.host=localhost
thrift.port=17424
@IocBy(type = ComboIocProvider.class, args = { "*org.nutz.plugins.thrift.ThriftIocLoader" })
ioc.get(NutThriftNettyFactory.class, "thriftFactory").serverPort(port).tProtocolFactory(new TCompactProtocol.Factory()).load("pkg.service.impl");
<plugin>
<groupId>com.facebook.mojo</groupId>
<artifactId>swift-maven-plugin</artifactId>
<version>${swift-version}</version>
<configuration>
<codeFlavor>java-immutable</codeFlavor>
<skip>false</skip>
<idlFiles>
<directory>${project.basedir}/src/main/thrift/</directory>
<includes>
<include>**/*.thrift</include>
</includes>
<!--<excludes> -->
<!--<exclude>**/other.thrift</exclude> -->
<!--</excludes> -->
</idlFiles>
<addCloseableInterface>true</addCloseableInterface>
<defaultPackage>${project.groupId}.thrift.swift</defaultPackage>
<outputFolder>${project.basedir}/src/main/java/</outputFolder>
<addThriftExceptions>true</addThriftExceptions>
</configuration>
</plugin>
https://github.com/facebook/swift
mvn com.facebook.mojo:swift-maven-plugin:generate