public interface PersistenceHandler
An instance of a PersistenceHandler is created when a new session is created, or an existing session is loaded during start up. PersistenceHandler instance is obtained via the PersistenceContext.getResourceHandler(String)
and PersistenceContext.getBinaryHandler(String)
methods.
getMetadata(String)
persist(com.bea.wli.config.resource.Metadata, Object)
readData(com.bea.wli.config.Ref)
delete(com.bea.wli.config.Ref)
exists(com.bea.wli.config.Ref)
ValueRepresentation
associated with that type which can be obtained by using the following code
ConfigContext cc = ... use the value passed in to the persistence context ... TypeDef typeDef = cc.getConfigService().getTypeDef(typeId); ValueRepresentation vr = null; if (typedef != null) { vr = typedef.getPersistedValueRepresentation(); } if (vr == null) { // if no value representation is provided or this is a simple type then use system default vr = ValueRepresentation.DEFAULT; } vr.fromCanonical(...)See Reference implementation in
FilePersistenceHandler
delete(com.bea.wli.config.Ref)
and persist(com.bea.wli.config.resource.Metadata, Object)
until the end of the transaction for performance reasons. However such delayed execution must be handled carefully in order to avoid 'losing' data. The Config Framework may keep data in memory using soft or weak references. These data may be garbage collected at any time. If a value is garbage collected, the associated persistence hanlder is used to re-read the data from the persisted store. Implementations of this interface therefore must make sure that the readData(com.bea.wli.config.Ref)
and exists(com.bea.wli.config.Ref)
method return the correct result even though the delete and persist operations may have been deleted. For example suppose Object A is being persisted via persist(com.bea.wli.config.resource.Metadata, java.lang.Object)
method, and that the object is subsequently read in the same transaction because it has been garbage collected behind the scenes. The implementations must take into account the previously executed, but delayed, persist(com.bea.wli.config.resource.Metadata, java.lang.Object)
call and return the correct value. If such delayed execution is required one of the following approaches must be used:
LazyPersistenceHandler
instead and decorate the handler, context or service with the corresponding lazy persistence decorators.readData(com.bea.wli.config.Ref)
and exists(com.bea.wli.config.Ref)
methods take into account the previous calls to delete(com.bea.wli.config.Ref)
and persist(com.bea.wli.config.resource.Metadata, java.lang.Object)
methods.Modifier and Type | Method and Description |
---|---|
void |
delete(Ref ref)
Deletes a resource
|
boolean |
exists(Ref ref)
Returns true if the resource exists
|
Metadata[] |
getMetadata(java.lang.String typeId)
Returns metadata associated with all the resources of the given type
|
void |
initialize(java.lang.String typeId)
initializes the handler for the given type.
|
void |
persist(Metadata md, java.lang.Object canonicalData)
Persists the given metadata and the resource data
|
java.lang.Object |
readData(Ref ref)
reads and returns the canonical data associated with a resource
|
void initialize(java.lang.String typeId) throws java.lang.Exception
java.lang.Exception
Metadata[] getMetadata(java.lang.String typeId) throws java.lang.Exception
java.lang.Exception
boolean exists(Ref ref)
java.lang.Object readData(Ref ref) throws java.lang.Exception
java.lang.Exception
void persist(Metadata md, java.lang.Object canonicalData) throws java.lang.Exception
java.lang.Exception
void delete(Ref ref) throws java.lang.Exception
java.lang.Exception