@InstallSubject(value="loadDelegate") public interface InstanceLoader<E extends Entity> extends DataLoader
Modifier and Type | Interface and Description |
---|---|
static class |
InstanceLoader.PostLoadEvent<T extends Entity>
Event sent after successful loading of an entity instance, merging it into
DataContext and setting to
the container. |
static class |
InstanceLoader.PreLoadEvent<T extends Entity>
Event sent before loading an entity instance.
|
Modifier and Type | Method and Description |
---|---|
Subscription |
addPostLoadListener(java.util.function.Consumer<InstanceLoader.PostLoadEvent> listener)
Adds a listener to
InstanceLoader.PostLoadEvent . |
Subscription |
addPreLoadListener(java.util.function.Consumer<InstanceLoader.PreLoadEvent> listener)
Adds a listener to
InstanceLoader.PreLoadEvent . |
InstanceContainer<E> |
getContainer()
Returns the container which accepts the loaded entity.
|
java.lang.Object |
getEntityId()
Returns id of the entity to load.
|
java.util.function.Function<LoadContext<E>,E> |
getLoadDelegate()
Returns a function which will be used to load data instead of standard implementation.
|
View |
getView()
Returns the view which is used when loading.
|
boolean |
isLoadDynamicAttributes()
Returns true if the entity's dynamic attributes are loaded.
|
void |
setContainer(InstanceContainer<E> container)
Sets the container which accepts the loaded entity.
|
void |
setEntityId(java.lang.Object entityId)
Sets the id of the entity to load.
|
void |
setLoadDelegate(java.util.function.Function<LoadContext<E>,E> delegate)
Sets a function which will be used to load data instead of standard implementation.
|
void |
setLoadDynamicAttributes(boolean loadDynamicAttributes)
Set to true to load the entity's dynamic attributes.
|
void |
setView(java.lang.String viewName)
Sets the name of the view which is used when loading.
|
void |
setView(View view)
Sets the view which is used when loading.
|
getCondition, getDataContext, getParameter, getParameters, getQuery, isSoftDeletion, load, removeParameter, setCondition, setDataContext, setParameter, setParameters, setQuery, setSoftDeletion
InstanceContainer<E> getContainer()
getContainer
in interface DataLoader
void setContainer(InstanceContainer<E> container)
java.lang.Object getEntityId()
void setEntityId(java.lang.Object entityId)
View getView()
void setView(View view)
void setView(java.lang.String viewName)
java.lang.IllegalStateException
- if the view has already been set by setView(View)
boolean isLoadDynamicAttributes()
void setLoadDynamicAttributes(boolean loadDynamicAttributes)
java.util.function.Function<LoadContext<E>,E> getLoadDelegate()
void setLoadDelegate(java.util.function.Function<LoadContext<E>,E> delegate)
Subscription addPreLoadListener(java.util.function.Consumer<InstanceLoader.PreLoadEvent> listener)
InstanceLoader.PreLoadEvent
.
You can also add an event listener declaratively using a controller method annotated with Subscribe
:
@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPreLoad(InstanceLoader.PreLoadEvent event) { // handle event here }
listener
- listenerSubscription addPostLoadListener(java.util.function.Consumer<InstanceLoader.PostLoadEvent> listener)
InstanceLoader.PostLoadEvent
.
You can also add an event listener declaratively using a controller method annotated with Subscribe
:
@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPostLoad(InstanceLoader.PostLoadEvent event) { // handle event here }
listener
- listener