@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); } }
public void dispose( IoSession session ) throws Exception { synchronized( encoder ) { encoder.dispose( session ); } } }
/** * {@inheritDoc} */ @Override public void dispose(IoSession session) throws Exception { synchronized (encoder) { encoder.dispose(session); } } }
/** * {@inheritDoc} */ @Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { synchronized (encoder) { encoder.encode(session, message, out); } }
/** * {@inheritDoc} */ @Override public void dispose(IoSession session) throws Exception { synchronized (encoder) { encoder.dispose(session); } } }
public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception { synchronized( encoder ) { encoder.encode( session, message, out ); } }
public void dispose(IoSession session) throws Exception { synchronized (encoder) { encoder.dispose(session); } } }
/** * {@inheritDoc} */ @Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { synchronized (encoder) { encoder.encode(session, message, out); } }
/** * Dispose the encoder, removing its instance from the * session's attributes, and calling the associated * dispose method. */ private void disposeEncoder(IoSession session) { ProtocolEncoder encoder = (ProtocolEncoder) session.removeAttribute(ENCODER); if (encoder == null) { return; } try { encoder.dispose(session); } catch (Exception e) { LOGGER.warn("Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')'); } }
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { synchronized (encoder) { encoder.encode(session, message, out); } }
/** * Dispose the encoder, removing its instance from the * session's attributes, and calling the associated * dispose method. */ private void disposeEncoder(IoSession session) { ProtocolEncoder encoder = (ProtocolEncoder) session.removeAttribute(ENCODER); if (encoder == null) { return; } try { encoder.dispose(session); } catch (Exception e) { LOGGER.warn("Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')'); } }
@Override public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception { Object message = writeRequest.getMessage(); // Bypass the encoding if the message is contained in a IoBuffer, // as it has already been encoded before if (message instanceof IoBuffer || message instanceof FileRegion) { nextFilter.filterWrite(session, writeRequest); return; } // Get the encoder in the session ProtocolEncoder encoder = getEncoder(session); ProtocolEncoderOutput encoderOut = getEncoderOut(session, nextFilter, writeRequest); try { // Now we can try to encode the response encoder.encode(session, message, encoderOut); // Flush the encoded message (assumes single encoded message) ((ProtocolEncoderOutputImpl) encoderOut).flushWithFuture(nextFilter, session, writeRequest); } catch (Throwable t) { ProtocolEncoderException pee; // Generate the correct exception if (t instanceof ProtocolEncoderException) { pee = (ProtocolEncoderException) t; } else { pee = new ProtocolEncoderException(t); } throw pee; } }
/** * Dispose the encoder, removing its instance from the * session's attributes, and calling the associated * dispose method. */ private void disposeEncoder(IoSession session) { ProtocolEncoder encoder = (ProtocolEncoder) session .removeAttribute(ENCODER); if (encoder == null) { return; } try { encoder.dispose(session); } catch (Throwable t) { LOGGER.warn( "Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')'); } }
encoder.encode(session, message, encoderOut);
/** * Dispose the encoder, removing its instance from the * session's attributes, and calling the associated * dispose method. */ private void disposeEncoder(IoSession session) { ProtocolEncoder encoder = (ProtocolEncoder) session .removeAttribute(ENCODER); if (encoder == null) { return; } try { encoder.dispose(session); } catch (Throwable t) { LOGGER.warn( "Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')'); } }
encoder.encode(session, message, encoderOut);
private void disposeEncoder( IoSession session ) { ProtocolEncoder encoder = ( ProtocolEncoder ) session.removeAttribute( ENCODER ); if( encoder == null ) { return; } try { encoder.dispose( session ); } catch( Throwable t ) { SessionLog.warn( session, "Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')' ); } }
encoder.encode(session, message, encoderOut);
encoder.encode( session, message, encoderOut );