Class AbstractLazyLoadingListener<R,T>
- java.lang.Object
-
- org.projectbarbel.histo.extension.AbstractLazyLoadingListener<R,T>
-
- Type Parameters:
R
- the data resource to accessT
- the type stored in the resource
- All Implemented Interfaces:
LazyLoadingListenerProtocol<R,T>
- Direct Known Subclasses:
DefaultLazyLoadingListener
public abstract class AbstractLazyLoadingListener<R,T> extends Object implements LazyLoadingListenerProtocol<R,T>
Mongo shadow lazy loading listener implementation to pre-fetch saved data from previous sessions back toBarbelHisto
.
The simple listener implementations provide support for allBarbelQueries
and all custom queries as long they use theBarbelQueries.DOCUMENT_ID
as a filter criterion. If you run an instance ofBarbelHisto
as global singleton in your application set-up, set thesingletonContext
flag to true. This will increase performance as data is the listener refuses to refresh data on each retrieve operation. This is safe, if only ever oneBarbelHisto
instance is using the accessed data resource.- Author:
- Niklas Schlimm
-
-
Field Summary
Fields Modifier and Type Field Description protected String
documentIdFieldName
protected boolean
fullfetchAllowed
protected com.google.gson.Gson
gson
protected Class<?>
managedType
protected BarbelMode
mode
protected Class<?>
persistedType
protected R
shadow
protected boolean
singletonContext
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLazyLoadingListener(Class<?> managedType, com.google.gson.Gson gson, boolean singletonContext, boolean fullfetchAllowed)
-
Method Summary
Modifier and Type Method Description abstract String
fromStoredDocumentToPersistenceObjectJson(T document)
Bitemporal
fromStoreDocumentPersistenceObject(T document)
void
handleInitialization(EventType.BarbelInitializedEvent event)
void
handleInitializeJournal(EventType.InitializeJournalEvent event)
void
handleRetrieveData(EventType.RetrieveDataEvent event)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.projectbarbel.histo.extension.LazyLoadingListenerProtocol
getExternalDataResource, queryAll, queryJournal
-
-
-
-
Field Detail
-
managedType
protected final Class<?> managedType
-
persistedType
protected final Class<?> persistedType
-
mode
protected final BarbelMode mode
-
gson
protected final com.google.gson.Gson gson
-
singletonContext
protected final boolean singletonContext
-
fullfetchAllowed
protected final boolean fullfetchAllowed
-
documentIdFieldName
protected final String documentIdFieldName
-
shadow
protected R shadow
-
-
Constructor Detail
-
AbstractLazyLoadingListener
protected AbstractLazyLoadingListener(Class<?> managedType, com.google.gson.Gson gson, boolean singletonContext, boolean fullfetchAllowed)
-
-
Method Detail
-
handleInitialization
public void handleInitialization(EventType.BarbelInitializedEvent event)
- Specified by:
handleInitialization
in interfaceLazyLoadingListenerProtocol<R,T>
-
handleRetrieveData
public void handleRetrieveData(EventType.RetrieveDataEvent event)
- Specified by:
handleRetrieveData
in interfaceLazyLoadingListenerProtocol<R,T>
-
handleInitializeJournal
public void handleInitializeJournal(EventType.InitializeJournalEvent event)
- Specified by:
handleInitializeJournal
in interfaceLazyLoadingListenerProtocol<R,T>
-
fromStoreDocumentPersistenceObject
public Bitemporal fromStoreDocumentPersistenceObject(T document)
- Specified by:
fromStoreDocumentPersistenceObject
in interfaceLazyLoadingListenerProtocol<R,T>
-
-