org.entityfs.impl.impl
Class AbstractFileSystemBuilderImpl<T extends AbstractFileSystemBuilderImpl<T>>

java.lang.Object
  extended by org.entityfs.impl.AbstractFileSystemBuilder<T>
      extended by org.entityfs.impl.impl.AbstractFileSystemBuilderImpl<T>
All Implemented Interfaces:
FileSystemBuilder<T>
Direct Known Subclasses:
AbstractFSFileSystemBuilder, At4jZipFileSystemBuilder, JarFileSystemBuilder, RamFileSystemBuilder, ZipFileSystemBuilder

public abstract class AbstractFileSystemBuilderImpl<T extends AbstractFileSystemBuilderImpl<T>>
extends AbstractFileSystemBuilder<T>

Abstract base class for file system builder classes. This class implements properties shared between all file system implementations.

Implementation note: This class implements the create() method that creates the file system. Subclasses implement a number of callback methods that create calls. See the documentation of the individual methods below.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-core

Field Summary
 
Fields inherited from interface org.entityfs.FileSystemBuilder
DEFAULT_BUFFER_SIZE
 
Constructor Summary
protected AbstractFileSystemBuilderImpl(LogAdapter la, EntityValidityControlStrategy evcs)
           
 
Method Summary
 FileSystem create()
          Create the file system using the builder's settings.
protected abstract  AdapterFactory createAdapterFactory()
          Subclasses implement this to create the right AdapterFactory implementation.
protected  ChildEntityManagerFactory<EntityImplementation> createDefaultChildEntityManagerFactory(FileSystemAdapter fsa, LogAdapterHolder lah)
          Create a default ChildEntityManagerFactory if none is set.
protected abstract  FileSystemImplementation createFileSystem(SupportObjects fso, FileSystemDelegate fsd)
          Subclasses implement this to return a new file system instance.
protected abstract  FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
          This method is implemented by a subclass to create the file system delegate to use.
 T enableEvents()
          Enable events for this file system.
 ChildEntityManagerFactory<EntityImplementation> getChildEntityManagerFactory()
          Get the file system's child entity manager factory.
 EventManager getEventManager()
          Get the file system's event manager.
protected  boolean isFileSystemSupportedByAllCapabilities(boolean readonly)
          Verify that all capability providers are either read only or read/write.
protected abstract  boolean isReadOnly()
          Subclasses implement this method to tell if the file system they are about to create is read only.
 T setChildEntityManagerFactory(ChildEntityManagerFactory<EntityImplementation> cemf)
          Set an alternative child entity manager factory implementation.
 T setEventManager(EventManager em)
          Set the file system's event manager.
 
Methods inherited from class org.entityfs.impl.AbstractFileSystemBuilder
addCapabilityProvider, addCapabilityProviders, disableAccessControls, disableEntityValidityControls, enableLocking, getAccessController, getBufferSize, getCapabilityProviders, getCapabilityProvidersInternal, getEntityValidityControlStrategy, getLockAcquiringStrategy, getLockAdapterFactory, getLockCommandExecutor, getLogAdapter, getName, getThis, setAccessController, setBufferSize, setEntityValidityControlStrategy, setLockAcquiringStrategy, setLockAdapterFactory, setLockCommandExecutor, setLogAdapter, setName, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.entityfs.FileSystemBuilder
isLockingSupported
 

Constructor Detail

AbstractFileSystemBuilderImpl

protected AbstractFileSystemBuilderImpl(LogAdapter la,
                                        EntityValidityControlStrategy evcs)
Method Detail

setEventManager

public T setEventManager(EventManager em)
Set the file system's event manager.

Parameters:
em - The event manager.
Returns:
this
See Also:
enableEvents()

getEventManager

public EventManager getEventManager()
Get the file system's event manager.

Returns:
The event manager.

enableEvents

public T enableEvents()
Enable events for this file system. Calling this method is equivalent to calling setEventManager(EventManager) with the default event manager EventManagerImpl.

Returns:
this
See Also:
setEventManager(EventManager)

setChildEntityManagerFactory

public T setChildEntityManagerFactory(ChildEntityManagerFactory<EntityImplementation> cemf)
Set an alternative child entity manager factory implementation.

Parameters:
cemf - A child entity manager factory implementation.
Returns:
this.

getChildEntityManagerFactory

public ChildEntityManagerFactory<EntityImplementation> getChildEntityManagerFactory()
Get the file system's child entity manager factory.

Returns:
The file system's child entity manager factory.

isFileSystemSupportedByAllCapabilities

protected boolean isFileSystemSupportedByAllCapabilities(boolean readonly)
Verify that all capability providers are either read only or read/write. Subclasses can use this to verify that all their capability providers are of the right type for the file system being built.

Parameters:
readonly - Is the file system to create read only?
Returns:
true if the file system is supported by all capabilities.

createAdapterFactory

protected abstract AdapterFactory createAdapterFactory()
Subclasses implement this to create the right AdapterFactory implementation.

This method is called from create().

Returns:
An AdapterFactory implementation.

createDefaultChildEntityManagerFactory

protected ChildEntityManagerFactory<EntityImplementation> createDefaultChildEntityManagerFactory(FileSystemAdapter fsa,
                                                                                                 LogAdapterHolder lah)
Create a default ChildEntityManagerFactory if none is set.

The default implementation creates a ChildEntityManagerFactoryImpl. That implementation can let entity objects be garbage collected, which is fine for file systems that are backed by another file system, such as the FS file system or the Zip file system. For file systems where the entities themselves contain all file data, such as the RAM file system, another implementation must be used.

This method is called from create().

Parameters:
fsa - The file system adapter
lah - The log adapter holder.
Returns:
An instance of the default ChildEntityManagerFactory.

createFileSystemDelegate

protected abstract FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
This method is implemented by a subclass to create the file system delegate to use.

This method is called from create().

Parameters:
fsa - The file system adapter.
Returns:
A file system delegate.

isReadOnly

protected abstract boolean isReadOnly()
Subclasses implement this method to tell if the file system they are about to create is read only.

This method is called from create().

Returns:
true if the file system that is being created is read only, false if not.

createFileSystem

protected abstract FileSystemImplementation createFileSystem(SupportObjects fso,
                                                             FileSystemDelegate fsd)
Subclasses implement this to return a new file system instance. The returned instance does not have any root directory set (yet).

This method is called from create().

Parameters:
fso - A collection of support objects.
fsd - The file system delegate.
Returns:
A file system implementation.

create

public FileSystem create()
                  throws FileSystemConfigurationException
Create the file system using the builder's settings.

This method uses getter methods to access properties, so if a getter is overridden by a subclass, that method is guaranteed to be called.

Returns:
A new file system object.
Throws:
FileSystemConfigurationException - On configuration errors.