Mina框架中的filter (一)编码器

 
package com.tianze.jmsn.gps;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
import org.apache.mina.filter.codec.demux.MessageEncoder;

/**
 *
 * @author wjp    //编码器
 */
public class AppliedServerEncoder implements MessageEncoder {

    private static final Set<Class<?>> TYPES;
    static
    {
        Set<Class<?>> types = new HashSet<Class<?>>();
        types.add( ByteBuffer.class );
        TYPES = Collections.unmodifiableSet( types );
    }
 public Set<Class<?>> getMessageTypes() {
  return AppliedServerEncoder.TYPES;
 }

    public AppliedServerEncoder()
    {
       
    }

    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception
    {
        ByteBuffer m = (ByteBuffer) message ;
        if (m==null) {
         return;
        }
        out.write(m);
       
    }

}

你可能感兴趣的:(框架,exception,session,filter,Mina,Types)