org.ehcache.impl.persistence
Class DefaultLocalPersistenceService

java.lang.Object
  extended by org.ehcache.impl.persistence.DefaultLocalPersistenceService
All Implemented Interfaces:
LocalPersistenceService, MaintainableService, PersistableResourceService, Service

public class DefaultLocalPersistenceService
extends java.lang.Object
implements LocalPersistenceService


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ehcache.core.spi.service.LocalPersistenceService
LocalPersistenceService.PersistenceSpaceIdentifier
 
Constructor Summary
DefaultLocalPersistenceService(PersistenceConfiguration persistenceConfiguration)
           
 
Method Summary
 java.util.Collection<ServiceConfiguration<?>> additionalConfigurationsForPool(java.lang.String alias, ResourcePool pool)
          Enables this service to create additional configurations to enable support of the passed in resource pool in the context of the given alias.
 void create()
          Creates the persistent storage.
 FileBasedPersistenceContext createPersistenceContextWithin(LocalPersistenceService.PersistenceSpaceIdentifier space, java.lang.String name)
          Creates a new persistence context within the given space.
 void destroy(java.lang.String name)
          Destroys the persistence space with the given name.
 void destroyAll()
          Destroys all persistence spaces Note that this method can be called without creating the persistence space beforehand in the same JVM.
 java.io.File getDirectoryFor(java.lang.String identifier)
           
 LocalPersistenceService.PersistenceSpaceIdentifier getOrCreatePersistenceSpace(java.lang.String name)
          Retrieves an existing or creates a new persistence space
 boolean handlesResourceType(ResourceType resourceType)
          Indicates whether this service handles the type of resource passed in.
 void start(ServiceProvider<Service> serviceProvider)
          Start this service using the provided configuration and ServiceProvider.
 void startForMaintenance(ServiceProvider<MaintainableService> serviceProvider)
          Start this service for maintenance, based on its default configuration.
 void stop()
          Stops this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLocalPersistenceService

public DefaultLocalPersistenceService(PersistenceConfiguration persistenceConfiguration)
Method Detail

start

public void start(ServiceProvider<Service> serviceProvider)
Description copied from interface: Service
Start this service using the provided configuration and ServiceProvider.

The goal of the service provider is to allow a service to use other services.

Specified by:
start in interface Service
Parameters:
serviceProvider - the service provider.

startForMaintenance

public void startForMaintenance(ServiceProvider<MaintainableService> serviceProvider)
Description copied from interface: MaintainableService
Start this service for maintenance, based on its default configuration.

Specified by:
startForMaintenance in interface MaintainableService
Parameters:
serviceProvider - enables to depend on other maintainable services

stop

public void stop()
Description copied from interface: Service
Stops this service.

Specified by:
stop in interface Service

handlesResourceType

public boolean handlesResourceType(ResourceType resourceType)
Description copied from interface: PersistableResourceService
Indicates whether this service handles the type of resource passed in.

Specified by:
handlesResourceType in interface PersistableResourceService
Parameters:
resourceType - the resource type to handle
Returns:
true if this service handles this resource type, false otherwise

additionalConfigurationsForPool

public java.util.Collection<ServiceConfiguration<?>> additionalConfigurationsForPool(java.lang.String alias,
                                                                                     ResourcePool pool)
                                                                              throws CachePersistenceException
Description copied from interface: PersistableResourceService
Enables this service to create additional configurations to enable support of the passed in resource pool in the context of the given alias.

Specified by:
additionalConfigurationsForPool in interface PersistableResourceService
Parameters:
alias - the alias context
pool - the resource pool
Returns:
a Collection of ServiceConfiguration, can be empty
Throws:
CachePersistenceException - in case of a persistence related problem

getOrCreatePersistenceSpace

public LocalPersistenceService.PersistenceSpaceIdentifier getOrCreatePersistenceSpace(java.lang.String name)
                                                                               throws CachePersistenceException
Description copied from interface: LocalPersistenceService
Retrieves an existing or creates a new persistence space

Specified by:
getOrCreatePersistenceSpace in interface LocalPersistenceService
Parameters:
name - the name to be used for the persistence space
Returns:
a LocalPersistenceService.PersistenceSpaceIdentifier
Throws:
CachePersistenceException - if the persistence space cannot be created

destroy

public void destroy(java.lang.String name)
             throws CachePersistenceException
Description copied from interface: PersistableResourceService
Destroys the persistence space with the given name. Note that this method can be called without creating the persistence space beforehand in the same JVM. It will nonetheless try to delete any persistent data that could have been associated with the name.

Specified by:
destroy in interface PersistableResourceService
Parameters:
name - the name of the persistence context
Throws:
CachePersistenceException - if the persistence space cannot be destroyed

destroyAll

public void destroyAll()
Description copied from interface: LocalPersistenceService
Destroys all persistence spaces Note that this method can be called without creating the persistence space beforehand in the same JVM. It will nonetheless try to delete any persistent data associated with the root directory provided in the service.

Specified by:
destroyAll in interface LocalPersistenceService
Specified by:
destroyAll in interface PersistableResourceService

createPersistenceContextWithin

public FileBasedPersistenceContext createPersistenceContextWithin(LocalPersistenceService.PersistenceSpaceIdentifier space,
                                                                  java.lang.String name)
                                                           throws CachePersistenceException
Description copied from interface: LocalPersistenceService
Creates a new persistence context within the given space.

Specified by:
createPersistenceContextWithin in interface LocalPersistenceService
Parameters:
space - space to create within
name - name of the context to create
Returns:
a FileBasedPersistenceContext
Throws:
CachePersistenceException

getDirectoryFor

public java.io.File getDirectoryFor(java.lang.String identifier)

create

public void create()
Description copied from interface: PersistableResourceService
Creates the persistent storage.

Specified by:
create in interface PersistableResourceService