Top Description Fields Constructors Methods
org.apache.derby.impl.io

pack-priv abstract Class BaseStorageFactory

extends Object
implements StorageFactory
Class Inheritance
All Implemented Interfaces
org.apache.derby.io.StorageFactory
Known Direct Subclasses
org.apache.derby.impl.io.CPStorageFactory, org.apache.derby.impl.io.DirStorageFactory, org.apache.derby.impl.io.JarStorageFactory, org.apache.derby.impl.io.URLStorageFactory
Imports
org.apache.derby.iapi.store.raw.data.DataFactory, org.apache.derby.io.StorageFactory, .StorageFile, java.io.File, .IOException

This class provides a base for implementations of the StorageFactory interface. It is used by the database engine to access persistent data and transaction logs under the directory (default) subsubprotocol.

Field Summary

Modifier and TypeField and Description
protected String
protected String
pack-priv String
protected String
private static final String
protected StorageFile
protected String
protected String

Constructor Summary

AccessConstructor and Description
pack-priv
BaseStorageFactory()

Most of the initialization is done in the init method.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public StorageFile

Returns:

StorageFile
createTemporaryFile
(String
String to prefix the random name generator.
prefix
,
String
String to suffix the random name generator.
suffix
)

Implements org.apache.derby.io.StorageFactory.createTemporaryFile.

Create and returns a temporary file in temporary file system of database.

pack-priv abstract void
public String

Returns:

the canonical name
getCanonicalName
()

Implements org.apache.derby.io.StorageFactory.getCanonicalName.

Get the canonical name of the database.

public char

Returns:

the pathname separator character. (Normally '/' or '\').
getSeparator
()

Implements org.apache.derby.io.StorageFactory.getSeparator.

Get the pathname separator character used by the StorageFile implementation.

public int
public StorageFile

Returns:

a directory name
getTempDir
()

Implements org.apache.derby.io.StorageFactory.getTempDir.

Get the abstract name of the directory that holds temporary files.

public void
init(String
The name of the directory containing the database. It comes from the system.home system property. It may be null. A storage factory may decide to ignore this parameter. (For instance the classpath storage factory ignores it.
home
,
String
The name of the database (directory). All relative pathnames are relative to this directory. If null then the storage factory will only be used to deal with the directory containing the databases.
databaseName
,
String
The name of the temporary file directory set in properties. If null then a default directory should be used. Each database should get a separate temporary file directory within this one to avoid collisions.
tempDirName
,
String
A unique name that can be used to create the temporary file directory for this database.
uniqueName
)

Implements org.apache.derby.io.StorageFactory.init.

Classes implementing the StorageFactory interface must have a null constructor.

public boolean

Returns:

true if the storage is fast, false if it is slow.
isFast
()

Implements org.apache.derby.io.StorageFactory.isFast.

This method is used to determine whether the storage is fast (RAM based) or slow (disk based).

public boolean
isReadOnlyDatabase()

Implements org.apache.derby.io.StorageFactory.isReadOnlyDatabase.

Determine whether the database is read only.

pack-priv abstract StorageFile

Returns:

A corresponding StorageFile object
newPersistentFile
(String
The path name of the file. Guaranteed not to be in the temporary file directory. If null then the database directory should be returned.
path
)

Construct a persistent StorageFile from a path name.

pack-priv abstract StorageFile

Returns:

A corresponding StorageFile object
newPersistentFile
(String
The path name of the directory. Guaranteed not to be in the temporary file directory. Guaranteed not to be null
directoryName
,
String
The name of the file within the directory. Guaranteed not to be null.
fileName
)

Construct a persistent StorageFile from a directory and path name.

pack-priv abstract StorageFile

Returns:

A corresponding StorageFile object
newPersistentFile
(StorageFile
The path name of the directory. Guaranteed not to be to be null. Guaranteed to be created by a call to one of the newPersistentFile methods.
directoryName
,
String
The name of the file within the directory. Guaranteed not to be null.
fileName
)

Construct a persistent StorageFile from a directory and path name.

public StorageFile

Returns:

A corresponding StorageFile object
newStorageFile
(String
The path name of the file
path
)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a path name.

public StorageFile

Returns:

A corresponding StorageFile object
newStorageFile
(String
The directory part of the path name.
directoryName
,
String
The name of the file within the directory.
fileName
)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a directory and file name.

public StorageFile

Returns:

A corresponding StorageFile object
newStorageFile
(StorageFile
The directory part of the path name.
directoryName
,
String
The name of the file within the directory.
fileName
)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a directory and file name.

private String
public void
setCanonicalName(String
uniquely identifiable name for this database
name
)

Implements org.apache.derby.io.StorageFactory.setCanonicalName.

Set the canonicalName.

public void
shutdown()

Implements org.apache.derby.io.StorageFactory.shutdown.

The shutdown method is called during the normal shutdown of the database.

public boolean

Returns:

true if the storage supports random access, false if it is writable.
supportsRandomAccess
()

Implements org.apache.derby.io.StorageFactory.supportsRandomAccess.

Determine whether the storage supports random access.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canonicalNameback to summary
protected String canonicalName
dataDirectoryback to summary
protected String dataDirectory
homeback to summary
pack-priv String home
separatedDataDirectoryback to summary
protected String separatedDataDirectory
TEMP_DIR_PREFIXback to summary
private static final String TEMP_DIR_PREFIX
tempDirback to summary
protected StorageFile tempDir
tempDirPathback to summary
protected String tempDirPath
uniqueNameback to summary
protected String uniqueName

Constructor Detail

BaseStorageFactoryback to summary
pack-priv BaseStorageFactory()

Most of the initialization is done in the init method.

Method Detail

createTempDirback to summary
pack-priv void createTempDir() throws IOException
createTemporaryFileback to summary
public StorageFile createTemporaryFile(String prefix, String suffix) throws IOException

Implements org.apache.derby.io.StorageFactory.createTemporaryFile.

Create and returns a temporary file in temporary file system of database.

Parameters
prefix:String

String to prefix the random name generator.

suffix:String

String to suffix the random name generator.

Returns:StorageFile

StorageFile

doInitback to summary
pack-priv abstract void doInit() throws IOException
getCanonicalNameback to summary
public String getCanonicalName() throws IOException

Implements org.apache.derby.io.StorageFactory.getCanonicalName.

Get the canonical name of the database. This is a name that uniquely identifies it. It is system dependent. The normal, disk based implementation uses method java.io.File.getCanonicalPath on the directory holding the database to construct the canonical name.

Returns:String

the canonical name

Exceptions
IOException:
if an IO error occurred during the construction of the name.
getSeparatorback to summary
public char getSeparator()

Implements org.apache.derby.io.StorageFactory.getSeparator.

Get the pathname separator character used by the StorageFile implementation.

Returns:char

the pathname separator character. (Normally '/' or '\').

getStorageFactoryVersionback to summary
public int getStorageFactoryVersion()

Implements org.apache.derby.io.StorageFactory.getStorageFactoryVersion.

Returns:int

Doc from org.apache.derby.io.StorageFactory.getStorageFactoryVersion.

the StorageFactory version supported by this implementation

getTempDirback to summary
public StorageFile getTempDir()

Implements org.apache.derby.io.StorageFactory.getTempDir.

Get the abstract name of the directory that holds temporary files.

Returns:StorageFile

a directory name

initback to summary
public void init(String home, String databaseName, String tempDirName, String uniqueName) throws IOException

Implements org.apache.derby.io.StorageFactory.init.

Classes implementing the StorageFactory interface must have a null constructor. This method is called when the database is booted up to initialize the class. It should perform all actions necessary to start the basic storage, such as creating a temporary file directory. The init method will be called once, before any other method is called, and will not be called again.

Parameters
home:String

The name of the directory containing the database. It comes from the system.home system property. It may be null. A storage factory may decide to ignore this parameter. (For instance the classpath storage factory ignores it.

databaseName:String

The name of the database (directory). All relative pathnames are relative to this directory. If null then the storage factory will only be used to deal with the directory containing the databases.

tempDirName:String

The name of the temporary file directory set in properties. If null then a default directory should be used. Each database should get a separate temporary file directory within this one to avoid collisions.

uniqueName:String

A unique name that can be used to create the temporary file directory for this database.

Exceptions
IOException:
on an error (unexpected).
isFastback to summary
public boolean isFast()

Implements org.apache.derby.io.StorageFactory.isFast.

This method is used to determine whether the storage is fast (RAM based) or slow (disk based). It may be used by the database engine to determine the default size of the page cache.

Returns:boolean

true if the storage is fast, false if it is slow.

isReadOnlyDatabaseback to summary
public boolean isReadOnlyDatabase()

Implements org.apache.derby.io.StorageFactory.isReadOnlyDatabase.

Doc from org.apache.derby.io.StorageFactory.isReadOnlyDatabase.

Determine whether the database is read only. The database engine supports read-only databases, even in file systems that are writable.

Returns:boolean

true if the storage is read only, false if it is writable.

newPersistentFileback to summary
pack-priv abstract StorageFile newPersistentFile(String path)

Construct a persistent StorageFile from a path name.

Parameters
path:String

The path name of the file. Guaranteed not to be in the temporary file directory. If null then the database directory should be returned.

Returns:StorageFile

A corresponding StorageFile object

newPersistentFileback to summary
pack-priv abstract StorageFile newPersistentFile(String directoryName, String fileName)

Construct a persistent StorageFile from a directory and path name.

Parameters
directoryName:String

The path name of the directory. Guaranteed not to be in the temporary file directory. Guaranteed not to be null

fileName:String

The name of the file within the directory. Guaranteed not to be null.

Returns:StorageFile

A corresponding StorageFile object

newPersistentFileback to summary
pack-priv abstract StorageFile newPersistentFile(StorageFile directoryName, String fileName)

Construct a persistent StorageFile from a directory and path name.

Parameters
directoryName:StorageFile

The path name of the directory. Guaranteed not to be to be null. Guaranteed to be created by a call to one of the newPersistentFile methods.

fileName:String

The name of the file within the directory. Guaranteed not to be null.

Returns:StorageFile

A corresponding StorageFile object

newStorageFileback to summary
public StorageFile newStorageFile(String path)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a path name.

Parameters
path:String

The path name of the file

Returns:StorageFile

A corresponding StorageFile object

newStorageFileback to summary
public StorageFile newStorageFile(String directoryName, String fileName)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a directory and file name.

Parameters
directoryName:String

The directory part of the path name.

fileName:String

The name of the file within the directory.

Returns:StorageFile

A corresponding StorageFile object

newStorageFileback to summary
public StorageFile newStorageFile(StorageFile directoryName, String fileName)

Implements org.apache.derby.io.StorageFactory.newStorageFile.

Construct a StorageFile from a directory and file name.

Parameters
directoryName:StorageFile

The directory part of the path name.

fileName:String

The name of the file within the directory.

Returns:StorageFile

A corresponding StorageFile object

readOnlyTempRootback to summary
private String readOnlyTempRoot() throws IOException
setCanonicalNameback to summary
public void setCanonicalName(String name)

Implements org.apache.derby.io.StorageFactory.setCanonicalName.

Set the canonicalName. May need adjustment due to DERBY-5096

Parameters
name:String

uniquely identifiable name for this database

shutdownback to summary
public void shutdown()

Implements org.apache.derby.io.StorageFactory.shutdown.

Doc from org.apache.derby.io.StorageFactory.shutdown.

The shutdown method is called during the normal shutdown of the database. However, the database engine cannot guarantee that shutdown will be called. If the JVM terminates abnormally then it will not be called.

supportsRandomAccessback to summary
public boolean supportsRandomAccess()

Implements org.apache.derby.io.StorageFactory.supportsRandomAccess.

Determine whether the storage supports random access. If random access is not supported then it will only be accessed using InputStreams and OutputStreams (if the database is writable).

Returns:boolean

true if the storage supports random access, false if it is writable.