class NettyChannelFactory extends BasePoolableObjectFactory {
    private String factoryName;
    private NettyClient nettyClient;

    public NettyChannelFactory(NettyClient nettyClient) {
        super();

        this.nettyClient = nettyClient;
        this.factoryName = "NettyChannelFactory_" + nettyClient.getUrl().getHost() + "_"
                + nettyClient.getUrl().getPort();
    }

    public String getFactoryName() {
        return factoryName;
    }

    @Override
    public String toString() {
        return factoryName;
    }

    @Override
    public Object makeObject() {
        NettyChannel nettyChannel = new NettyChannel(nettyClient);
        nettyChannel.open();

        return nettyChannel;
    }

    @Override
    public void destroyObject(final Object obj) {
        if (obj instanceof NettyChannel) {
            NettyChannel client = (NettyChannel) obj;
            URL url = nettyClient.getUrl();

            try {
                client.close();

                LoggerUtil.info(factoryName + " client disconnect Success: " + url.getUri());
            } catch (Exception e) {
                LoggerUtil.error(factoryName + " client disconnect Error: " + url.getUri(), e);
            }
        }
    }

    @Override
    public boolean validateObject(final Object obj) {
        if (obj instanceof NettyChannel) {
            final NettyChannel client = (NettyChannel) obj;
            try {
                return client.isAvailable();
            } catch (final Exception e) {
                return false;
            }
        } else {
            return false;
        }
    }

    @Override
    public void activateObject(Object obj) {<FILL_FUNCTION_BODY>}

}

        if (obj instanceof NettyChannel) {
            final NettyChannel client = (NettyChannel) obj;
            if (!client.isAvailable()) {
                client.open();
            }
        }
    
<methods>public void <init>() ,public void activateObject(java.lang.Object) throws java.lang.Exception,public void destroyObject(java.lang.Object) throws java.lang.Exception,public abstract java.lang.Object makeObject() throws java.lang.Exception,public void passivateObject(java.lang.Object) throws java.lang.Exception,public boolean validateObject(java.lang.Object) <variables>