Package com.facebook.nifty.core

Examples of com.facebook.nifty.core.NiftyBootstrap


    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();
            }
        });
    }
View Full Code Here


    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()
                        );
                        withNettyServerConfig(NettyConfigProvider.class);
                    }
                }
        ).getInstance(NiftyBootstrap.class);

        bootstrap.start();

        Runtime.getRuntime().addShutdownHook(new Thread()
        {
            @Override
            public void run()
            {
                bootstrap.stop();
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.facebook.nifty.core.NiftyBootstrap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.