public class DefaultDiskResourceService extends java.lang.Object implements DiskResourceService
DiskResourceService
which can be used explicitly when
persistent user managed caches
are desired.PersistableResourceService.PersistenceSpaceIdentifier<T extends PersistableResourceService>
MaintainableService.MaintenanceScope
Constructor and Description |
---|
DefaultDiskResourceService() |
Modifier and Type | Method and Description |
---|---|
FileBasedPersistenceContext |
createPersistenceContextWithin(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier,
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.
|
PersistableResourceService.PersistenceSpaceIdentifier<DiskResourceService> |
getPersistenceSpaceIdentifier(java.lang.String name,
CacheConfiguration<?,?> config)
Returns a
PersistableResourceService.PersistenceSpaceIdentifier for the space associated to the provided arguments. |
StateRepository |
getStateRepositoryWithin(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier,
java.lang.String name)
Returns a named
state repository in the context of the given
identifier . |
boolean |
handlesResourceType(ResourceType<?> resourceType)
Returns
true if this service handles the given resource type. |
void |
releasePersistenceSpaceIdentifier(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier)
Releases a previously obtained
PersistableResourceService.PersistenceSpaceIdentifier . |
void |
start(ServiceProvider<Service> serviceProvider)
Start this service using the provided configuration and
ServiceProvider . |
void |
startForMaintenance(ServiceProvider<? super MaintainableService> serviceProvider,
MaintainableService.MaintenanceScope maintenanceScope)
Start this service for maintenance, based on its default configuration.
|
void |
stop()
Stops this service.
|
public void start(ServiceProvider<Service> serviceProvider)
ServiceProvider
.
The service provider allows a service to retrieve and use other services.
A Service
retrieved at this stage may not yet be started. The recommended usage pattern therefore, is to keep a
reference to the dependent Service
but use it only when specific methods are invoked on subtypes.
public void startForMaintenance(ServiceProvider<? super MaintainableService> serviceProvider, MaintainableService.MaintenanceScope maintenanceScope)
startForMaintenance
in interface MaintainableService
serviceProvider
- enables to depend on other maintainable servicesmaintenanceScope
- the scope of the maintenancepublic boolean handlesResourceType(ResourceType<?> resourceType)
true
if this service handles the given resource type.handlesResourceType
in interface PersistableResourceService
resourceType
- the resource type to checktrue
if this service handles the resource typepublic PersistableResourceService.PersistenceSpaceIdentifier<DiskResourceService> getPersistenceSpaceIdentifier(java.lang.String name, CacheConfiguration<?,?> config) throws CachePersistenceException
PersistableResourceService.PersistenceSpaceIdentifier
for the space associated to the provided arguments.
This method may create a new persistence space or load one. The returned identifier is the only way to interact with the persistence space.
getPersistenceSpaceIdentifier
in interface PersistableResourceService
name
- the name of the persistence contextconfig
- the configuration for the associated cacheCachePersistenceException
- if the persistence space cannot be createdPersistableResourceService.getStateRepositoryWithin(PersistenceSpaceIdentifier, String)
public void releasePersistenceSpaceIdentifier(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier) throws CachePersistenceException
PersistableResourceService
PersistableResourceService.PersistenceSpaceIdentifier
.
This indicates to the persistence space that resource linked to the given identifier are no longer needed and thus enables cleaning up any transient state left.
releasePersistenceSpaceIdentifier
in interface PersistableResourceService
identifier
- the PersistenceSpaceIdentifier
to releaseCachePersistenceException
- If the identifier is not knownpublic void destroy(java.lang.String name)
This method can be called without having created the persistence space from this JVM.
destroy
in interface PersistableResourceService
name
- persistence context namepublic void destroyAll()
Note that this method can be called without having created the persistence spaces from this JVM.
destroyAll
in interface PersistableResourceService
public StateRepository getStateRepositoryWithin(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier, java.lang.String name) throws CachePersistenceException
state repository
in the context of the given
identifier
.
If the StateRepository
already existed, this method returns it in a fully available state.
getStateRepositoryWithin
in interface PersistableResourceService
identifier
- the space identifiername
- the state repository nameStateRepository
CachePersistenceException
- if the StateRepository
cannot be created or recovered.public FileBasedPersistenceContext createPersistenceContextWithin(PersistableResourceService.PersistenceSpaceIdentifier<?> identifier, java.lang.String name) throws CachePersistenceException
createPersistenceContextWithin
in interface DiskResourceService
identifier
- space to create withinname
- name of the context to createFileBasedPersistenceContext
CachePersistenceException