public abstract class CachingDirectoryFactory extends DirectoryFactory
DirectoryFactory
impl base class for caching Directory instances
per path. Most DirectoryFactory implementations will want to extend this
class and simply implement DirectoryFactory.create(String, DirContext)
.Modifier and Type | Class and Description |
---|---|
protected class |
CachingDirectoryFactory.CacheValue |
static interface |
CachingDirectoryFactory.CloseListener |
DirectoryFactory.DirContext
Modifier and Type | Field and Description |
---|---|
protected Map<Directory,CachingDirectoryFactory.CacheValue> |
byDirectoryCache |
protected Map<String,CachingDirectoryFactory.CacheValue> |
byPathCache |
protected Map<Directory,List<CachingDirectoryFactory.CloseListener>> |
closeListeners |
IOCONTEXT_NO_CACHE
Constructor and Description |
---|
CachingDirectoryFactory() |
Modifier and Type | Method and Description |
---|---|
void |
addCloseListener(Directory dir,
CachingDirectoryFactory.CloseListener closeListener)
Adds a close listener for a Directory.
|
void |
close()
Close the this and all of the Directories it contains.
|
protected abstract Directory |
create(String path,
DirectoryFactory.DirContext dirContext)
Creates a new Directory for a given path.
|
void |
doneWithDirectory(Directory directory)
Indicates a Directory will no longer be used, and when it's ref count
hits 0, it can be closed.
|
boolean |
exists(String path)
Returns true if a Directory exists for a given path.
|
Directory |
get(String path,
DirectoryFactory.DirContext dirContext,
String rawLockType)
Returns the Directory for a given path, using the specified rawLockType.
|
Directory |
get(String path,
DirectoryFactory.DirContext dirContext,
String rawLockType,
boolean forceNew)
Returns the Directory for a given path, using the specified rawLockType.
|
void |
incRef(Directory directory)
Increment the number of references to the given Directory.
|
void |
init(NamedList args) |
void |
release(Directory directory)
Releases the Directory so that it may be closed when it is no longer
referenced.
|
empty, isPersistent, move, normalize, remove, remove, sizeOf, sizeOfDirectory
protected Map<String,CachingDirectoryFactory.CacheValue> byPathCache
protected Map<Directory,CachingDirectoryFactory.CacheValue> byDirectoryCache
protected Map<Directory,List<CachingDirectoryFactory.CloseListener>> closeListeners
public void addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener)
DirectoryFactory
addCloseListener
in class DirectoryFactory
public void doneWithDirectory(Directory directory) throws IOException
DirectoryFactory
doneWithDirectory
in class DirectoryFactory
IOException
- If there is a low-level I/O error.public void close() throws IOException
DirectoryFactory
close
in interface Closeable
close
in class DirectoryFactory
IOException
- If there is a low-level I/O error.protected abstract Directory create(String path, DirectoryFactory.DirContext dirContext) throws IOException
DirectoryFactory
create
in class DirectoryFactory
IOException
- If there is a low-level I/O error.public boolean exists(String path)
DirectoryFactory
exists
in class DirectoryFactory
public final Directory get(String path, DirectoryFactory.DirContext dirContext, String rawLockType) throws IOException
DirectoryFactory
get
in class DirectoryFactory
IOException
- If there is a low-level I/O error.public final Directory get(String path, DirectoryFactory.DirContext dirContext, String rawLockType, boolean forceNew) throws IOException
DirectoryFactory
DirectoryFactory.doneWithDirectory(Directory)
in this case - the old Directory
will be closed when it's ref count hits 0.get
in class DirectoryFactory
IOException
- If there is a low-level I/O error.public void incRef(Directory directory)
DirectoryFactory
incRef
in class DirectoryFactory
public void init(NamedList args)
public void release(Directory directory) throws IOException
DirectoryFactory
release
in class DirectoryFactory
IOException
- If there is a low-level I/O error.Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.