1 6 7 package org.sapia.ubik.mcast; 8 9 import org.sapia.ubik.net.Pool; 10 11 15 public class ByteArrayPool extends Pool{ 16 17 private int _bufSize; 18 19 20 public ByteArrayPool(int bufSize) { 21 _bufSize = bufSize; 22 } 23 24 public void setBufSize(int bufSize){ 25 _bufSize = bufSize; 26 } 27 28 public int getBufSize(){ 29 return _bufSize; 30 } 31 32 protected Object onAcquire(Object o) throws Exception { 33 byte[] bytes = (byte[])o; 34 if(bytes.length != _bufSize){ 35 return new byte[_bufSize]; 36 } 37 else{ 38 return o; 39 } 40 } 41 42 protected Object doNewObject() throws Exception { 43 return new byte[_bufSize]; 44 } 45 46 } 47 | Popular Tags |