@Test public void test1 () throws Exception { final DataGenerator dg = new DataGenerator ( new HashSet<String> ( Arrays.asList ( "AVG", "MIN", "MAX" ) ), 1200 ); final UpdateQueryData message = dg.createData (); final ProtocolEncoder encoder = new ObjectSerializationEncoder (); testEncoder ( encoder, message ); }
@Override public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception { if(mProtocolEncoder == null) { mProtocolEncoder = new IcecastEncoder(); } return mProtocolEncoder; }
@Override public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception { if(mEncoder == null) { mEncoder = new UltravoxEncoder(); } return mEncoder; }
@Override public ProtocolEncoder getEncoder(IoSession session) throws Exception { MinaEncoder minaEncoder = null; Object value = session.getAttribute(ENCODER_ATTRIBUTE); if (value != null && value instanceof MinaEncoder) minaEncoder = (MinaEncoder) value; if (minaEncoder == null) { minaEncoder = new MinaEncoder(codecFactory.getEncoder()); session.setAttribute(ENCODER_ATTRIBUTE, minaEncoder); } return minaEncoder; }
@Override public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception { Object message = writeRequest.getMessage(); ProtocolEncoder encoder = getEncoder(session); ProtocolEncoderOutput encoderOut = new DirectOutput(session, nextFilter, writeRequest); try { encoder.encode(session, message, encoderOut); nextFilter.filterWrite(session, new EndOfMessage(writeRequest)); } catch (ProtocolEncoderException e) { throw e; } catch (Throwable t) { throw new ProtocolEncoderException(t); } }
@Override public ProtocolEncoder getEncoder(IoSession arg0) throws Exception { return encoder; }
@Override public ProtocolEncoder getEncoder(IoSession session) throws Exception { return msgEncoder; }
public ProtocolEncoder getEncoder() { return encoder; }
public ModbusRtuProtocolCodecFilter ( final ProtocolEncoder encoder, final ModbusRtuDecoder decoder ) { super ( encoder, decoder ); this.decoder = decoder; }
public ProtocolEncoder getEncoder(IoSession session) { return encoder; }
/** * {@inheritDoc} */ public ProtocolEncoder getEncoder(IoSession session) throws Exception { return encoder; }
public ProtocolEncoder getEncoder(IoSession session) throws Exception { return encoder; }
private void testEncoder ( final ProtocolEncoder encoder, final Object message ) throws Exception { final TestingOutput output = new TestingOutput (); encoder.encode ( null, message, output ); System.out.println ( String.format ( "Encoder %s: %s bytes", encoder, output.getSize () ) ); }
public ProtocolEncoder getEncoder() throws Exception { return encoder; }
@Override public ProtocolEncoder getEncoder(IoSession session) throws Exception { return encoder; }
@Override public ProtocolEncoder getEncoder() throws Exception { return encoder; }
/** * 返回一个新的(或可重复使用的)ProtocolEncoder实例 */ public ProtocolEncoder getEncoder(IoSession session) throws Exception { return encoder; }
public ProtocolEncoder getEncoder(IoSession session) throws Exception { return new HL7MLLPEncoder(config); }