public
Created

Example of using a Java wrapper with Netty 4 to work around Clojure bug http://dev.clojure.org/jira/browse/CLJ-1183.

  • Download Gist
name.mattp.Netty.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
package name.mattp;
 
import io.netty.bootstrap.ServerBootstrap;
import io.netty.bootstrap.Bootstrap;
 
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ServerChannel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelHandlerContext;
 
public class Netty
{
public static ChannelFuture close (Channel channel)
{
return channel.close ();
}
public static ChannelFuture flush (Channel channel)
{
return channel.flush ();
}
public static ChannelFuture write (Channel channel, Object message)
{
return channel.write (message);
}
public static ChannelPipeline pipeline (Channel channel)
{
return channel.pipeline ();
}
public static ServerBootstrap channel (ServerBootstrap bootstrap,
Class<? extends ServerChannel> channelClass)
{
return bootstrap.channel (channelClass);
}
 
public static Bootstrap clientChannel (Bootstrap bootstrap,
Class<? extends Channel> channelClass)
{
return bootstrap.channel (channelClass);
}
public static Bootstrap group (Bootstrap bootstrap, EventLoopGroup group)
{
return bootstrap.group (group);
}
public static Bootstrap handler (Bootstrap bootstrap,
ChannelHandler handler)
{
return bootstrap.handler (handler);
}
public static Bootstrap option (Bootstrap bootstrap,
ChannelOption option,
Object value)
{
return bootstrap.option (option, value);
}
public static ChannelPipeline pipeline (ChannelHandlerContext ctx)
{
return ctx.pipeline ();
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.