Top Description Fields Methods
org.apache.derby.iapi.store.access

public Interface FileResource

Known Direct Implementers
org.apache.derby.impl.store.raw.data.RFResource
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.io.StorageFile, java.io.InputStream

Management of file resources within a database. Suitable for jar files, images etc.

A file resource is identified by the pair (name,generationId). Name is an arbitrary String supplied by the caller. GenerationId is a non-repeating sequence number constructed by the database. Within a database a (name,generationId) pair uniquely identifies a version of a file resource for all time. Newer generation numbers reflect newer versions of the file.

A database supports the concept of a designated current version of a fileResource. The management of the current version is transactional. The following rules apply

  1. Adding a FileResource makes the added version the current version
  2. Removing a FileResource removes the current version of the resource. After this operation the database holds no current version of the FileResoure.
  3. Replacing a FileResource removes the current version of the resource.

For the benefit of replication, a database optionally retains historic versions of stored files. These old versions are useful when processing old transactions in the stage.

Field Summary

Modifier and TypeField and Description
public static final String
JAR_DIRECTORY_NAME

The name of the jar directory

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the generationId for the file resource. This quantity increases when you replace the file resource.
add
(String
the name of the file resource.
name
,
InputStream
an input stream for reading the content of the file resource.
source
)

Add a file resource, copying from the input stream.

public StorageFile

Returns:

A StorageFile object representing the file.
getAsFile
(String
The name of the fileResource
name
,
long
the generationId of the fileResource
generationId
)

Get the StorageFile for a file resource.

public char

Returns:

the separator character to be used in file names.
getSeparatorChar
()

public void
remove(String
the name of the fileResource to remove.
name
,
long currentGenerationId)

Remove the current generation of a file resource from the database.

public void
removeJarDir(String f)

During hard upgrade to <= 10.9, remove a jar directory (at post-commit time) from the database.

public long

Returns:

the generationId for the new 'current' version of the file resource.
replace
(String
the name of the file resource.
name
,
long currentGenerationId, InputStream
an input stream for reading the content of the file resource.
source
)

Replace a file resource with a new version.

Field Detail

JAR_DIRECTORY_NAMEback to summary
public static final String JAR_DIRECTORY_NAME

The name of the jar directory

Method Detail

addback to summary
public long add(String name, InputStream source) throws StandardException

Add a file resource, copying from the input stream. The InputStream will be closed by this method.

Parameters
name:String

the name of the file resource.

source:InputStream

an input stream for reading the content of the file resource.

Returns:long

the generationId for the file resource. This quantity increases when you replace the file resource.

Exceptions
StandardException:
some error occured.
getAsFileback to summary
public StorageFile getAsFile(String name, long generationId)

Get the StorageFile for a file resource.

Parameters
name:String

The name of the fileResource

generationId:long

the generationId of the fileResource

Returns:StorageFile

A StorageFile object representing the file.

getSeparatorCharback to summary
public char getSeparatorChar()
Returns:char

the separator character to be used in file names.

removeback to summary
public void remove(String name, long currentGenerationId) throws StandardException

Remove the current generation of a file resource from the database.

Parameters
name:String

the name of the fileResource to remove.

Exceptions
StandardException:
some error occured.
removeJarDirback to summary
public void removeJarDir(String f) throws StandardException

During hard upgrade to <= 10.9, remove a jar directory (at post-commit time) from the database.

Exceptions
StandardException:
if an error occurs
replaceback to summary
public long replace(String name, long currentGenerationId, InputStream source) throws StandardException

Replace a file resource with a new version.

The InputStream will be closed by this method.

Parameters
name:String

the name of the file resource.

source:InputStream

an input stream for reading the content of the file resource.

Returns:long

the generationId for the new 'current' version of the file resource.

Exceptions
StandardException:
some error occured.