Interface PersistentService
- All Known Implementing Classes:
StorageFactoryService
public interface PersistentService
A PersistentService modularises the access to persistent services,
abstracting out details such as finding the list of services to
be started at boot time, finding the service.properties file
and creating and deleting the persistent storage for a service.
These modules must only be used by the monitor.
Possible examples of implementations are:
- Store services in a directory in the file system.
- Store services in a zip file
- Service data is provided by a web server
- Service data is stored on the class path.
This class also serves as the registry the defined name for all the implementations of PersistentService. These need to be kept track of as they can be used in JDBC URLS.
An implementation of PersistentService can implement ModuleSupportable but must not implement ModuleControl. This is because the monitor will not execute ModuleControl methods for a PersistentService.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringService stored on the class path (can be in a zip/jar on the class path).static final StringThe readme file cautioning users against touching the files in the database directorystatic final StringService stored in a directory.static final StringService stored in a web server .static final Stringstatic final StringService stored in memory only (not persistent), virtual file memory.static final StringService stored in a jar/zip archive.static final StringThe typical name for the service's properties file.static final StringThe root of any stored data.static final StringThe type of PersistentService used to boot the service. -
Method Summary
Modifier and TypeMethodDescriptionvoidPut a readme file in database directory which will caution users against touching any files in the directory.createServiceRoot(String name, boolean deleteExisting) Returns the canonical name of the service.Return an Enumeration of service names descriptors (Strings) that should be be started at boot time by the monitor.Convert a service name into its canonical form.getServiceProperties(String serviceName, Properties defaultProperties) For a service return its service properties, typically from the service.properties file.getStorageFactoryInstance(boolean useHome, String databaseName, String tempDirName, String uniqueName) Get an initialized StorageFactoryInstancegetType()Return the type of this service.getUserServiceName(String serviceName) Return the user form of a service name.booleanbooleanisSameService(String serviceName1, String serviceName2) booleanremoveServiceRoot(String serviceName) Remove a service's root and its contents.voidsaveServiceProperties(String serviceName, Properties properties) Save to a backup file.voidsaveServiceProperties(String serviceName, StorageFactory storageFactory, Properties properties, boolean replace)
-
Field Details
-
DIRECTORY
-
CLASSPATH
Service stored on the class path (can be in a zip/jar on the class path).- See Also:
-
JAR
-
HTTP
-
HTTPS
- See Also:
-
INMEMORY
Service stored in memory only (not persistent), virtual file memory.- See Also:
-
DB_README_FILE_NAME
The readme file cautioning users against touching the files in the database directory- See Also:
-
PROPERTIES_NAME
-
ROOT
-
TYPE
-
-
Method Details
-
getType
String getType()Return the type of this service. -
getBootTimeServices
Enumeration getBootTimeServices()Return an Enumeration of service names descriptors (Strings) that should be be started at boot time by the monitor. The monitor will boot the service if getServiceProperties() returns a Properties object and the properties does not indicate the service should not be auto-booted.This method may return null if there are no services that need to be booted automatically at boot time.
The service name returned by the Enumeration must be in its canonical form.
-
createDataWarningFile
Put a readme file in database directory which will caution users against touching any files in the directory. This file will be created at database creation time.- Parameters:
sf- StorageFactory will be used to create the file- Throws:
StandardException- File can't be created
-
getServiceProperties
Properties getServiceProperties(String serviceName, Properties defaultProperties) throws StandardException For a service return its service properties, typically from the service.properties file.- Returns:
- A Properties object or null if serviceName does not represent a valid service.
- Throws:
StandardException- Service appears valid but the properties cannot be created.
-
saveServiceProperties
void saveServiceProperties(String serviceName, StorageFactory storageFactory, Properties properties, boolean replace) throws StandardException - Throws:
StandardException- Properties cannot be saved.
-
saveServiceProperties
Save to a backup file.- Throws:
StandardException- Properties cannot be saved.
-
createServiceRoot
Returns the canonical name of the service.- Throws:
StandardException- Service root cannot be created.
-
removeServiceRoot
Remove a service's root and its contents. -
getCanonicalServiceName
Convert a service name into its canonical form. Returns null if the name cannot be converted into a canonical form.- Throws:
StandardException- if an error happens when converting the name (name probably invalid)
-
getUserServiceName
-
isSameService
-
hasStorageFactory
boolean hasStorageFactory()- Returns:
- true if the PersistentService has a StorageFactory, false if not.
-
getStorageFactoryInstance
StorageFactory getStorageFactoryInstance(boolean useHome, String databaseName, String tempDirName, String uniqueName) throws StandardException, IOException Get an initialized StorageFactoryInstance- Parameters:
useHome- If true and the database name is not absolute then the database directory will be relative to the home directory, if one is defined in the properties file.databaseName- The name of the database (directory). The name does not include the subSubProtocol. If null then the storage factory will only be used to deal with the directory containing the databases.tempDirName- 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- A unique name that can be used to create the temporary file directory for this database. If null then temporary files will not be created in this StorageFactory instance.- Returns:
- An initialized StorageFactory.
- Throws:
StandardExceptionIOException
-