Package org.hippoecm.frontend.model
Class ModelReference<T>
java.lang.Object
org.hippoecm.frontend.model.ModelReference<T>
- Type Parameters:
T
- the type of the object for the shared model
- All Implemented Interfaces:
Serializable
,org.apache.wicket.model.IDetachable
,org.apache.wicket.util.io.IClusterable
,IObservable
,IModelReference<T>
The default implementation of the
IModelReference
service interface.
After a model service is created, it can be made to register it self under the provided service id
using the init(org.hippoecm.frontend.plugin.IPluginContext)
method.
When model services are no longer needed, e.g. because the cluster that need it is no longer active,
be sure to unregister the service using destroy()
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hippoecm.frontend.model.IModelReference
IModelReference.IModelChangeEvent<T>
-
Constructor Summary
ConstructorDescriptionModelReference
(String serviceId, org.apache.wicket.model.IModel<T> model) Construct a model service with a given service id and initial model. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Unregister the service with the specified service id.void
detach()
org.apache.wicket.model.IModel<T>
getModel()
Retrieve the current model of the model servicevoid
init
(IPluginContext context) Register the service with the specified service id.void
Update the model of the service.void
setObservationContext
(IObservationContext context) Before observation is started on the observable, an observation context is injected by the observer registry.void
When the firstIObserver
of this observable is registered with the observer registry, observation is started.void
When the lastIObserver
unregisters, observation is stopped.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hippoecm.frontend.model.event.IObservable
equals, hashCode
-
Constructor Details
-
ModelReference
Construct a model service with a given service id and initial model.- Parameters:
serviceId
- the service id that the service will be registered undermodel
- the initial model
-
-
Method Details
-
init
Register the service with the specified service id.- Parameters:
context
- the plugin context to use for registration
-
destroy
public void destroy()Unregister the service with the specified service id. -
getModel
Description copied from interface:IModelReference
Retrieve the current model of the model service- Specified by:
getModel
in interfaceIModelReference<T>
- Returns:
- the model
-
setModel
Description copied from interface:IModelReference
Update the model of the service. Observers will be notified with anIModelReference.IModelChangeEvent
.- Specified by:
setModel
in interfaceIModelReference<T>
- Parameters:
newModel
- the new model
-
setObservationContext
Description copied from interface:IObservable
Before observation is started on the observable, an observation context is injected by the observer registry. This context can be used to notify listeners.- Specified by:
setObservationContext
in interfaceIObservable
-
startObservation
public void startObservation()Description copied from interface:IObservable
When the firstIObserver
of this observable is registered with the observer registry, observation is started. Implementations must notify observers until observation is stopped.An implementation should register listeners with external data sources, when appropriate. It is possible for an observable to register as an observer for another observable.
- Specified by:
startObservation
in interfaceIObservable
-
stopObservation
public void stopObservation()Description copied from interface:IObservable
When the lastIObserver
unregisters, observation is stopped. Any listeners or observers registered by the observable must be unregistered by the implementation.- Specified by:
stopObservation
in interfaceIObservable
-
detach
public void detach()- Specified by:
detach
in interfaceorg.apache.wicket.model.IDetachable
-