org.apache.derby.impl.services.monitor
Class PersistentServiceImpl

java.lang.Object
  extended byorg.apache.derby.impl.services.monitor.PersistentServiceImpl
All Implemented Interfaces:
PersistentService

public class PersistentServiceImpl
extends java.lang.Object
implements PersistentService

This class implements the PersistentService interface using a StorageFactory class. It handles all subSubProtocols except for cache.


Nested Class Summary
(package private)  class PersistentServiceImpl.DirectoryList
           
 
Field Summary
private  java.lang.String canonicalHome
           
private  java.lang.String home
           
private  StorageFactory rootStorageFactory
           
private  char separatorChar
           
private  java.lang.Class storageFactoryClass
           
private  java.lang.String subSubProtocol
           
 
Fields inherited from interface org.apache.derby.iapi.services.monitor.PersistentService
CLASSPATH, DIRECTORY, HTTP, HTTPS, JAR, PROPERTIES_NAME, ROOT, TYPE
 
Constructor Summary
PersistentServiceImpl(java.lang.String subSubProtocol, java.lang.Class storageFactoryClass)
           
 
Method Summary
 java.lang.String createServiceRoot(java.lang.String name, boolean deleteExisting)
          Properties cannot be saved
 java.util.Enumeration getBootTimeServices()
          Return a list of all the directoies in the system directory.
 java.lang.String getCanonicalServiceName(java.lang.String name)
          Convert a service name into its canonical form.
private  java.lang.String getDirectoryPath(java.lang.String name)
           
 java.util.Properties getServiceProperties(java.lang.String serviceName, java.util.Properties defaultProperties)
          Open the service properties in the directory identified by the service name.
 java.lang.Class getStorageFactoryClass()
          Get the StorageFactory implementation for this PersistentService
 StorageFactory getStorageFactoryInstance(boolean useHome, java.lang.String databaseName, java.lang.String tempDirName, java.lang.String uniqueName)
          Get an initialized StorageFactoryInstance
 java.lang.String getType()
          The type of the service is 'directory'
 java.lang.String getUserServiceName(java.lang.String serviceName)
          Return the user form of a service name.
 boolean hasStorageFactory()
           
 boolean isSameService(java.lang.String serviceName1, java.lang.String serviceName2)
           
private  StorageFactory privGetStorageFactoryInstance(boolean useHome, java.lang.String databaseName, java.lang.String tempDirName, java.lang.String uniqueName)
           
protected  java.lang.String recreateServiceRoot(java.lang.String serviceName, java.util.Properties properties)
           
 boolean removeServiceRoot(java.lang.String serviceName)
          Remove a service's root and its contents.
 void saveServiceProperties(java.lang.String serviceName, java.util.Properties properties, boolean replace)
          Save to a backup file
 void saveServiceProperties(java.lang.String serviceName, StorageFactory sf, java.util.Properties properties, boolean replace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

home

private java.lang.String home

canonicalHome

private java.lang.String canonicalHome

subSubProtocol

private final java.lang.String subSubProtocol

storageFactoryClass

private final java.lang.Class storageFactoryClass

rootStorageFactory

private StorageFactory rootStorageFactory

separatorChar

private char separatorChar
Constructor Detail

PersistentServiceImpl

public PersistentServiceImpl(java.lang.String subSubProtocol,
                             java.lang.Class storageFactoryClass)
                      throws StandardException
Method Detail

hasStorageFactory

public boolean hasStorageFactory()
Specified by:
hasStorageFactory in interface PersistentService
Returns:
true if the PersistentService has a StorageFactory, false if not.

getStorageFactoryInstance

public StorageFactory getStorageFactoryInstance(boolean useHome,
                                                java.lang.String databaseName,
                                                java.lang.String tempDirName,
                                                java.lang.String uniqueName)
                                         throws StandardException,
                                                java.io.IOException
Get an initialized StorageFactoryInstance

Specified by:
getStorageFactoryInstance in interface PersistentService
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:
java.io.IOException - if create, the database directory does not exist, and it cannot be created; if !create and the database does not exist as a directory.
StandardException

privGetStorageFactoryInstance

private StorageFactory privGetStorageFactoryInstance(boolean useHome,
                                                     java.lang.String databaseName,
                                                     java.lang.String tempDirName,
                                                     java.lang.String uniqueName)
                                              throws java.lang.InstantiationException,
                                                     java.lang.IllegalAccessException,
                                                     java.io.IOException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException

getType

public java.lang.String getType()
The type of the service is 'directory'

Specified by:
getType in interface PersistentService
See Also:
PersistentService.getType()

getBootTimeServices

public java.util.Enumeration getBootTimeServices()
Return a list of all the directoies in the system directory.

Specified by:
getBootTimeServices in interface PersistentService
See Also:
PersistentService.getBootTimeServices()

getServiceProperties

public java.util.Properties getServiceProperties(java.lang.String serviceName,
                                                 java.util.Properties defaultProperties)
                                          throws StandardException
Open the service properties in the directory identified by the service name. The property SERVICE_ROOT (db2j.rt.serviceRoot) is added by this method and set to the service directory.

Specified by:
getServiceProperties in interface PersistentService
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

public void saveServiceProperties(java.lang.String serviceName,
                                  StorageFactory sf,
                                  java.util.Properties properties,
                                  boolean replace)
                           throws StandardException
Specified by:
saveServiceProperties in interface PersistentService
Throws:
StandardException - Properties cannot be saved.

saveServiceProperties

public void saveServiceProperties(java.lang.String serviceName,
                                  java.util.Properties properties,
                                  boolean replace)
                           throws StandardException
Save to a backup file

Specified by:
saveServiceProperties in interface PersistentService
Throws:
StandardException - Properties cannot be saved.

recreateServiceRoot

protected java.lang.String recreateServiceRoot(java.lang.String serviceName,
                                               java.util.Properties properties)
                                        throws StandardException
Throws:
StandardException

createServiceRoot

public java.lang.String createServiceRoot(java.lang.String name,
                                          boolean deleteExisting)
                                   throws StandardException
Properties cannot be saved

Specified by:
createServiceRoot in interface PersistentService
Throws:
StandardException - Service root cannot be created.

getDirectoryPath

private java.lang.String getDirectoryPath(java.lang.String name)

removeServiceRoot

public boolean removeServiceRoot(java.lang.String serviceName)
Description copied from interface: PersistentService
Remove a service's root and its contents.

Specified by:
removeServiceRoot in interface PersistentService

getCanonicalServiceName

public java.lang.String getCanonicalServiceName(java.lang.String name)
                                         throws StandardException
Description copied from interface: PersistentService
Convert a service name into its canonical form. Returns null if the name cannot be converted into a canonical form.

Specified by:
getCanonicalServiceName in interface PersistentService
Throws:
StandardException

getUserServiceName

public java.lang.String getUserServiceName(java.lang.String serviceName)
Description copied from interface: PersistentService
Return the user form of a service name. This name is only valid within this system. The separator character used must be '/'

Specified by:
getUserServiceName in interface PersistentService

isSameService

public boolean isSameService(java.lang.String serviceName1,
                             java.lang.String serviceName2)
Specified by:
isSameService in interface PersistentService

getStorageFactoryClass

public java.lang.Class getStorageFactoryClass()
Get the StorageFactory implementation for this PersistentService

Returns:
the StorageFactory class.

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.