private static final Logger log = LoggerFactory.getLogger(Plain.class);
public static void main(String[] args)
throws Exception
{
final NiftyBootstrap bootstrap = Guice.createInjector(
Stage.PRODUCTION,
new NiftyModule()
{
@Override
protected void configureNifty()
{
bind().toInstance(new ThriftServerDefBuilder()
.listen(8080)
.withProcessor(new scribe.Processor<scribe.Iface>(new scribe.Iface()
{
@Override
public ResultCode Log(List<LogEntry> messages)
throws TException
{
for (LogEntry message : messages) {
log.info("{}: {}", message.getCategory(), message.getMessage());
}
return ResultCode.OK;
}
}))
.build()
);
withNettyConfig(NettyConfigProvider.class);
}
}
).getInstance(NiftyBootstrap.class);
bootstrap.start();
Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
bootstrap.stop();
}
});
}