Examples

Parent POM for Facebook open source java projects that should be distributed through the central Maven repository using oss.sonatype.org

License

License

GroupId

GroupId

com.facebook.nifty
ArtifactId

ArtifactId

nifty-examples
Last Version

Last Version

0.12.0
Release Date

Release Date

Type

Type

jar
Description

Description

Examples
Parent POM for Facebook open source java projects that should be distributed through the central Maven repository using oss.sonatype.org
Project Organization

Project Organization

Facebook, Inc.

Download nifty-examples

How to add to project

<!-- https://jarcasting.com/artifacts/com.facebook.nifty/nifty-examples/ -->
<dependency>
    <groupId>com.facebook.nifty</groupId>
    <artifactId>nifty-examples</artifactId>
    <version>0.12.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.facebook.nifty/nifty-examples/
implementation 'com.facebook.nifty:nifty-examples:0.12.0'
// https://jarcasting.com/artifacts/com.facebook.nifty/nifty-examples/
implementation ("com.facebook.nifty:nifty-examples:0.12.0")
'com.facebook.nifty:nifty-examples:jar:0.12.0'
<dependency org="com.facebook.nifty" name="nifty-examples" rev="0.12.0">
  <artifact name="nifty-examples" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.facebook.nifty', module='nifty-examples', version='0.12.0')
)
libraryDependencies += "com.facebook.nifty" % "nifty-examples" % "0.12.0"
[com.facebook.nifty/nifty-examples "0.12.0"]

Dependencies

compile (6)

Group / Artifact Type Version
com.facebook.nifty : nifty-core jar 0.12.0
io.netty : netty jar 3.7.0.Final
javax.inject : javax.inject jar 1
com.google.inject : guice jar 3.0
org.apache.thrift : libthrift jar 0.9.1
org.slf4j : slf4j-api jar 1.7.5

runtime (2)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.5
log4j : log4j jar 1.2.17

test (4)

Group / Artifact Type Version
com.facebook.nifty : nifty-client jar 0.12.0
com.google.guava : guava jar 16.0.1
io.airlift : units jar 0.83
org.testng : testng jar 6.8.7

Project Modules

There are no modules declared in this project.

Project Status: 🚨 Unmaintained 🚨

This project is archived and no longer maintained. At the time of archiving, open issues and pull requests were closed and tagged with 2018-05-archive. For pre-existing users who need an open source alternative, we recommend taking a look at airlift/drift.

Nifty

Nifty is an implementation of Thrift clients and servers on Netty.

It is also the implementation used by Swift.

Examples

To create a basic Thrift server using Nifty, use the Thrift 0.9.0 code generator to generate Java stub code, write a Handler for your service interface, and pass it to Nifty like this:

public void startServer() {
    // Create the handler
    MyService.Iface serviceInterface = new MyServiceHandler();

    // Create the processor
    TProcessor processor = new MyService.Processor<>(serviceInterface);

    // Build the server definition
    ThriftServerDef serverDef = new ThriftServerDefBuilder().withProcessor(processor)
                                                            .build();

    // Create the server transport
    final NettyServerTransport server = new NettyServerTransport(serverDef,
                                                                 new NettyServerConfigBuilder(),
                                                                 new DefaultChannelGroup(),
                                                                 new HashedWheelTimer());

    // Create netty boss and executor thread pools
    ExecutorService bossExecutor = Executors.newCachedThreadPool();
    ExecutorService workerExecutor = Executors.newCachedThreadPool();

    // Start the server
    server.start(bossExecutor, workerExecutor);

    // Arrange to stop the server at shutdown
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                server.stop();
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    });
}

Or the same thing using guice:

public void startGuiceServer() {
    final NiftyBootstrap bootstrap = Guice.createInjector(
        Stage.PRODUCTION,
        new NiftyModule() {
            @Override
            protected void configureNifty() {
                // Create the handler
                MyService.Iface serviceInterface = new MyServiceHandler();

                // Create the processor
                TProcessor processor = new MyService.Processor<>(serviceInterface);

                // Build the server definition
                ThriftServerDef serverDef = new ThriftServerDefBuilder().withProcessor(processor)
                                                                        .build();

                // Bind the definition
                bind().toInstance(serverDef);
            }
        }).getInstance(NiftyBootstrap.class);

    // Start the server
    bootstrap.start();

    // Arrange to stop the server at shutdown
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            bootstrap.stop();
        }
    });
}
com.facebook.nifty

Facebook

We are working to build community through open source technology. NB: members must have two-factor auth.

Versions

Version
0.12.0
0.11.0
0.10.0
0.9.0
0.8.0
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0