org.abstracthorizon.mercury.maildir.file
Class SharedInputStreamPool

java.lang.Object
  extended by org.abstracthorizon.mercury.maildir.file.SharedInputStreamPool

public class SharedInputStreamPool
extends Object

Pool of shared input stream instance. Since each instance uses RandomAccessFile from java.io package it is important managing these resources.

Author:
Daniel Sendula

Field Summary
protected static SharedInputStreamPool defaultInstance
          Pool default instance
protected  Set<javax.mail.internet.SharedInputStream> files
          Set of opened SharedInputStreamImpls
protected  int maxFiles
          Maximum number of files
protected  int timeout
          Timeout for removing not closed files
 
Constructor Summary
SharedInputStreamPool()
          Default constructor.
 
Method Summary
protected  void closed(SharedInputStreamImpl stream)
          This is callback method used by SharedInputStreamImpl to register that stream is now closed.
 void closeWithProvider(FileProvider provider)
          Method that implicitly releases all RandomAccessFiles from all streams that use given FileProvider
static SharedInputStreamPool getDefaultInstance()
          This method returns default instance
 SharedInputStreamImpl newStream(FileProvider fileProvider, long start, long len)
          This method creates new SharedInputStreamImpl instance.
protected  void opened(SharedInputStreamImpl stream)
          This is callback method used by SharedInputStreamImpl to register that stream is now opened.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultInstance

protected static SharedInputStreamPool defaultInstance
Pool default instance


files

protected Set<javax.mail.internet.SharedInputStream> files
Set of opened SharedInputStreamImpls


maxFiles

protected int maxFiles
Maximum number of files


timeout

protected int timeout
Timeout for removing not closed files

Constructor Detail

SharedInputStreamPool

public SharedInputStreamPool()
Default constructor.

Method Detail

getDefaultInstance

public static SharedInputStreamPool getDefaultInstance()
This method returns default instance

Returns:
default instance

newStream

public SharedInputStreamImpl newStream(FileProvider fileProvider,
                                       long start,
                                       long len)
This method creates new SharedInputStreamImpl instance.

Parameters:
fileProvider - file provider
start - start of the stream
len - end of the stream
Returns:
new SharedInputStreamImpl instance

opened

protected void opened(SharedInputStreamImpl stream)
This is callback method used by SharedInputStreamImpl to register that stream is now opened. This is called each time RandomAccessFile is created over the stream. It is possible for stream to be implicitly "clsoed" and (re)opened several times.

Parameters:
stream - stream that is opened

closed

protected void closed(SharedInputStreamImpl stream)
This is callback method used by SharedInputStreamImpl to register that stream is now closed. This is called each time RandomAccessFile used by the stream is released. It is possible for stream to be implicitly "clsoed" and (re)opened several times.

Parameters:
stream - stream that is closed

closeWithProvider

public void closeWithProvider(FileProvider provider)
Method that implicitly releases all RandomAccessFiles from all streams that use given FileProvider

Parameters:
provider - file provider whos SharedInputStreamImpl belongs to


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.