class BluetoothApiHandler implements Callable<FullHttpResponse> {

    @Override
    public FullHttpResponse call() throws Exception {
    	LoggingService.logDebug(MODULE_NAME, "Handle Bluetooth api http request");
    	
        String host = "localhost";
        int port = 10500;

        EventLoopGroup group = new NioEventLoopGroup(1);

        try {
            Bootstrap b = new Bootstrap();
            b.option(ChannelOption.SO_REUSEADDR, true);
            b.group(group)
                    .channel(NioSocketChannel.class)
                    .handler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) {
                            ch.pipeline().addLast(new HttpClientCodec());
                            ch.pipeline().addLast(new HttpObjectAggregator(1048576));
                            ChannelInboundHandler handler = new SimpleChannelInboundHandler<HttpObject>() {
                                protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
                                    if (msg instanceof HttpResponse) {
                                        FullHttpResponse res = (FullHttpResponse) msg;

                                        outputBuffer.writeBytes(res.content());
                                        response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, res.status(), outputBuffer);
                                        HttpUtil.setContentLength(response, outputBuffer.readableBytes());
                                        response.headers().set(res.headers());
                                        ctx.channel().close().sync();
                                    }
                                }
                            };
                            ch.pipeline().addLast(handler);
                        }
                    });

            ByteBuf requestContent = Unpooled.copiedBuffer(content);
            try {
                Channel channel = b.connect(host, port).sync().channel();
                String endpoint = req.uri().substring(12);
                FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, req.method(), endpoint, requestContent);
                request.headers().set(req.headers());
                channel.writeAndFlush(request).addListener(ChannelFutureListener.CLOSE);
            } catch (Exception e) {
                throw e;
            } finally {
                ReferenceCountUtil.release(requestContent);
            }
        } catch (Exception e) {
            LoggingService.logError(MODULE_NAME, "Error unable to reach RESTblue container!", e);
        } finally {
            group.shutdownGracefully();
        }

        if (response == null) {
            String responseString = "{\"error\":\"unable to reach RESTblue container!\"}";
            outputBuffer.writeBytes(responseString.getBytes(UTF_8));
            response = ApiHandlerHelpers.notFoundResponse(outputBuffer, responseString);
            response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json");
            LoggingService.logInfo(MODULE_NAME, "error unable to reach RESTblue container!");
        }
        
        LoggingService.logDebug(MODULE_NAME, "Finished processing commandline api request");
        return response;
    }

    public  BluetoothApiHandler(FullHttpRequest req, ByteBuf outputBuffer, byte[] content);

}