1 20 package org.apache.mina.filter.codec; 21 22 import org.apache.mina.common.IoSession; 23 24 35 public class SynchronizedProtocolEncoder implements ProtocolEncoder { 36 private final ProtocolEncoder encoder; 37 38 41 public SynchronizedProtocolEncoder(ProtocolEncoder encoder) { 42 if (encoder == null) { 43 throw new NullPointerException ("encoder"); 44 } 45 this.encoder = encoder; 46 } 47 48 51 public ProtocolEncoder getEncoder() { 52 return encoder; 53 } 54 55 public void encode(IoSession session, Object message, 56 ProtocolEncoderOutput out) throws Exception { 57 synchronized (encoder) { 58 encoder.encode(session, message, out); 59 } 60 } 61 62 public void dispose(IoSession session) throws Exception { 63 synchronized (encoder) { 64 encoder.dispose(session); 65 } 66 } 67 } 68 | Popular Tags |