use of org.opennms.netmgt.provision.detector.simple.request.LineOrientedRequest in project opennms by OpenNMS.
the class LineOrientedEncoder method encode.
/**
* {@inheritDoc}
*/
@Override
public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception {
final LineOrientedRequest request = (LineOrientedRequest) message;
if (request.getRequest().contains("null")) {
return;
}
CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER);
if (encoder == null) {
encoder = m_charset.newEncoder();
session.setAttribute(ENCODER, encoder);
}
final String value = request.getRequest();
IoBuffer buffer = null;
try {
buffer = IoBuffer.allocate(value.length()).setAutoExpand(true);
buffer.putString(request.getRequest(), encoder);
buffer.flip();
LOG.debug("Client sending: {}", value.trim());
out.write(buffer);
} finally {
if (buffer != null) {
buffer.free();
}
}
}
Aggregations