/** * Registers the given InputStream as currently in use, in order to: * <ul> * <li>count the number of bytes that have been read from it (see {@link #getCurrentFileByteCounter()}) * <li>block read methods calls when the job is paused * <li>limit the throughput if a limit has been specified (see {@link #setThroughputLimit(long)}) * <li>close the InputStream when the job is stopped * </ul> * * <p>This method should be called by subclasses when creating a new InputStream, before the InputStream is used. * * @param in the InputStream to be used * @return the 'augmented' InputStream using the given stream as the underlying InputStream */ protected synchronized InputStream setCurrentInputStream(InputStream in) { if(tlin==null) { tlin = new ThroughputLimitInputStream(new CounterInputStream(in, currentFileByteCounter), throughputLimit); } else { tlin.setUnderlyingInputStream(new CounterInputStream(in, currentFileByteCounter)); } return tlin; }