org.apache.mina.filter.codec.demux
Class DemuxingProtocolEncoder

java.lang.Object
  extended by org.apache.mina.filter.codec.demux.DemuxingProtocolEncoder
All Implemented Interfaces:
ProtocolEncoder

public class DemuxingProtocolEncoder
extends Object
implements ProtocolEncoder

A composite ProtocolEncoder that demultiplexes incoming message encoding requests into an appropriate MessageEncoder.

Disposing resources acquired by MessageEncoder

Override dispose(IoSession) method. Please don't forget to call super.dispose().

Author:
Apache MINA Project
See Also:
MessageEncoderFactory, MessageEncoder

Constructor Summary
DemuxingProtocolEncoder()
           
 
Method Summary
 void addMessageEncoder(Class<?> messageType, Class<? extends MessageEncoder> encoderClass)
           
<T> void
addMessageEncoder(Class<T> messageType, MessageEncoder<? super T> encoder)
           
<T> void
addMessageEncoder(Class<T> messageType, MessageEncoderFactory<? super T> factory)
           
 void addMessageEncoder(Iterable<Class<?>> messageTypes, Class<? extends MessageEncoder> encoderClass)
           
<T> void
addMessageEncoder(Iterable<Class<? extends T>> messageTypes, MessageEncoder<? super T> encoder)
           
<T> void
addMessageEncoder(Iterable<Class<? extends T>> messageTypes, MessageEncoderFactory<? super T> factory)
           
 void dispose(IoSession session)
          Releases all resources related with this encoder.
 void encode(IoSession session, Object message, ProtocolEncoderOutput out)
          Encodes higher-level message objects into binary or protocol-specific data.
protected  MessageEncoder<Object> findEncoder(org.apache.mina.filter.codec.demux.DemuxingProtocolEncoder.State state, Class<?> type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DemuxingProtocolEncoder

public DemuxingProtocolEncoder()
Method Detail

addMessageEncoder

public void addMessageEncoder(Class<?> messageType,
                              Class<? extends MessageEncoder> encoderClass)

addMessageEncoder

public <T> void addMessageEncoder(Class<T> messageType,
                                  MessageEncoder<? super T> encoder)

addMessageEncoder

public <T> void addMessageEncoder(Class<T> messageType,
                                  MessageEncoderFactory<? super T> factory)

addMessageEncoder

public void addMessageEncoder(Iterable<Class<?>> messageTypes,
                              Class<? extends MessageEncoder> encoderClass)

addMessageEncoder

public <T> void addMessageEncoder(Iterable<Class<? extends T>> messageTypes,
                                  MessageEncoder<? super T> encoder)

addMessageEncoder

public <T> void addMessageEncoder(Iterable<Class<? extends T>> messageTypes,
                                  MessageEncoderFactory<? super T> factory)

encode

public void encode(IoSession session,
                   Object message,
                   ProtocolEncoderOutput out)
            throws Exception
Encodes higher-level message objects into binary or protocol-specific data. MINA invokes ProtocolEncoder.encode(IoSession, Object, ProtocolEncoderOutput) method with message which is popped from the session write queue, and then the encoder implementation puts encoded messages (typically IoBuffers) into ProtocolEncoderOutput.

Specified by:
encode in interface ProtocolEncoder
Throws:
Exception - if the message violated protocol specification

findEncoder

protected MessageEncoder<Object> findEncoder(org.apache.mina.filter.codec.demux.DemuxingProtocolEncoder.State state,
                                             Class<?> type)

dispose

public void dispose(IoSession session)
             throws Exception
Releases all resources related with this encoder.

Specified by:
dispose in interface ProtocolEncoder
Throws:
Exception - if failed to dispose all resources


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.