Class VolatileResourceCacheService
- java.lang.Object
- 
- org.silverpeas.core.cache.service.VolatileResourceCacheService
 
- 
 public class VolatileResourceCacheService extends Object This cache allows to reference some volatile resources (an entity that is being registered into persistence, but not yet validated by the user). 
 Elements registered with volatile resource are cleared just after the ending of a user session.How it is working: - first set the identifier of a Contributionwith a volatile identifier. A volatile identifier is generated by this service (newVolatileStringIdentifier()for example). The aim of the volatile identifier is to be unique into the context of the application running and not persisted into repositories or at most persisted temporarily
- then register the Contributioninto the service withregister(String, String). By this way and for deletion mainly, the elements (attachments for example) will be managed according the user session.
- 
 At user session end:
 - If the Contributionhas been validated, and so registered into repository, theContributionhas no more a volatile identifier but the one given by its manager. So the volatile identifier registered into the cache is pointing no resources and clean process will do nothing in the end.
- If the Contributionhas not been validated, nothing has been persisted into repository. Resources (attachment for example) linked to the volatile identifier will be deleted just after the ending of the user session.
 
- If the 
 This above explanations are for understanding. In reality, there just need to use VolatileIdentifierProviderto get a volatile identifier.The system does not know services which have to clean resources linked to volatile contributions (so contribution with volatile identifier indeed). 
 But the system is able to call all implementations ofVolatileResourceCleanerin order to call the only methodVolatileResourceCleaner.cleanVolatileResources(String, String).- Author:
- Yohann Chastagnier
 
- first set the identifier of a 
- 
- 
Constructor SummaryConstructors Constructor Description VolatileResourceCacheService()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all the resources referenced into this instance of volatile cache.static voidclearFrom(SessionInfo sessionInfo)Clears the volatile cache attached to a user session.booleancontains(String volatileId, String componentInstanceId)Indicates if a contribution exists into the volatile cache with the given identifiers.booleancontains(Contribution contribution)Indicates if a contribution exists into the volatile cache.booleancouldBeVolatileId(String id)Indicates if the given identifier could be a volatile one.
 It works only with identifiers generated bynewVolatileStringIdentifier()method.
 
- 
- 
- 
Method Detail- 
clearFrompublic static void clearFrom(SessionInfo sessionInfo) Clears the volatile cache attached to a user session.- Parameters:
- sessionInfo- the session of a user.
 
 - 
containspublic boolean contains(Contribution contribution) Indicates if a contribution exists into the volatile cache.- Parameters:
- contribution- a contribution instance which contains the volatile identifier.
- Returns:
- true if the contribution exists into the volatile cache, false otherwise.
 
 - 
couldBeVolatileIdpublic boolean couldBeVolatileId(String id) Indicates if the given identifier could be a volatile one.
 It works only with identifiers generated bynewVolatileStringIdentifier()method.- Parameters:
- id- an identifier as string.
- Returns:
- true if the identifier is a volatile one, false otherwise.
 
 - 
containspublic boolean contains(String volatileId, String componentInstanceId) Indicates if a contribution exists into the volatile cache with the given identifiers.- Parameters:
- volatileId- the volatile identifier.
- componentInstanceId- the identifier of a component instance.
- Returns:
- true if the contribution exists into the volatile cache, false otherwise.
 
 - 
clearpublic void clear() Clears all the resources referenced into this instance of volatile cache.
 
- 
 
-