1 20 package org.apache.mina.filter.codec; 21 22 import org.apache.mina.common.ByteBuffer; 23 import org.apache.mina.common.IoSession; 24 25 37 public class SynchronizedProtocolDecoder implements ProtocolDecoder { 38 private final ProtocolDecoder decoder; 39 40 43 public SynchronizedProtocolDecoder(ProtocolDecoder decoder) { 44 if (decoder == null) { 45 throw new NullPointerException ("decoder"); 46 } 47 this.decoder = decoder; 48 } 49 50 53 public ProtocolDecoder getDecoder() { 54 return decoder; 55 } 56 57 public void decode(IoSession session, ByteBuffer in, 58 ProtocolDecoderOutput out) throws Exception { 59 synchronized (decoder) { 60 decoder.decode(session, in, out); 61 } 62 } 63 64 public void finishDecode(IoSession session, ProtocolDecoderOutput out) 65 throws Exception { 66 synchronized (decoder) { 67 decoder.finishDecode(session, out); 68 } 69 } 70 71 public void dispose(IoSession session) throws Exception { 72 synchronized (decoder) { 73 decoder.dispose(session); 74 } 75 } 76 } 77 | Popular Tags |