A wrapper around another
Storage that also maintains a reference
counter. The inner storage gets deleted only if the reference counter reaches
Reference counting is used to delete the storage when it is no longer needed. So, any users of this class should note:
addReference()should be called when the storage is shared.
addReference()should ensure that
delete()is called once and only once.
Storageinstance passed into
MultiReferenceStorage(Storage)may lead to miscounting and premature deletion
|Constructor and Description|
Creates a new
|Modifier and Type||Method and Description|
Increments the reference counter.
Decrements the reference counter and deletes the inner
Returns the input stream of the inner
public MultiReferenceStorage(Storage storage)
MultiReferenceStorageinstance for the given back-end. The reference counter is initially set to one so the caller does not have to call
addReference()after this constructor.
storage- storage back-end that should be reference counted.
IllegalArgumentException- when storage is null
public void addReference()
IllegalStateException- if the reference counter is zero which implies that the backing storage has already been deleted.
public void delete()
Storageobject if the reference counter reaches zero.
A client that holds a reference to this object must make sure not to invoke this method a second time.
Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.