protected void configureDataGramCodecFactory(String type, IoServiceConfig config, String encoding, String codec) {
ProtocolCodecFactory codecFactory = getCodecFactory(type, codec);
if (codecFactory == null) {
codecFactory = new ProtocolCodecFactory() {
public ProtocolEncoder getEncoder() throws Exception {
return new ProtocolEncoder() {
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
ByteBuffer buf = toByteBuffer(message);
buf.flip();
out.write(buf);
}