public interface SourceLifecycle extends Serializable
Source, i.e. when the plugin needs to start, stop,
refine, or resume its management of the corresponding data source.
Plugins are expected to associate sources with implementations of this
interface, before the SourceBinder returns the bound sources to the
service. When they need to implement only a subset of the callbacks, they can
conveniently subclass the LifecycleAdapter.
Source.lifecycle(),
SourceBinder,
LifecycleAdapter| Modifier and Type | Method and Description |
|---|---|
void |
init()
Tells the plugin to start managing the data source.
|
void |
reconfigure(Element request)
Gives the plugin a client request with which it can refine its management
of the data source.
|
void |
resume()
Tells the plugin to resume its management of the data source.
|
void |
stop()
Tells the plugin to stop its management of the data source until further
notice.
|
void |
terminate()
Tells the plugin to stop its management of the data source for good.
|
void init()
throws Exception
This occurs during the binding the data source, immediately after the
SourceBinder has returned the corresponding Source to the
service.
Plugins may implement this method to initialise the state of the
Source and schedule any operation that relates to the management
of the data source.
If this method fails, the binding between the plugin and the data source also fails.
Exception - if the operation cannot be completedSourceBinder.bind(Element)void reconfigure(Element request) throws InvalidRequestException, Exception
This occurs during the binding of a data source, when the
SourceBinder returns to the service a Source with the
same identifier as the Source associated with this instance. This
indicates that the plugin is already managing the corresponding data
source and that the client request should be used to re-configure the
existing Source rather than initialise the new one.
Plugins may implement this method to refine the state of a Source
or to change otherwise its management of the corresponding data source.
If this method fails, the client request fails and the plugin retains its current management regime for the data source.
InvalidRequestException - if the client request is incompatible with the current
management regime of the data source.Exception - if the operation cannot be completed for any other reasonSourceBinder.bind(Element)void resume()
throws Exception
This occurs when the service is restoring its state from persistent storage after a restart of the container.
Plugins may implement this method to restart scheduled operations which relate to the management of the data source.
If this method fails, all subsequent client requests about the data source fail.
Exception - if the operation cannot be completedvoid stop()
This may occur when the container is shutting down, or when the service is serialising its state to persistence storage so as to conserve memory resources.
Plugins may implement this method to gracefully stop any operation that relates to the management of the data source.
void terminate()
This occurs when clients indicate that access to the data source is no longer needed.
Plugins may implement this method to terminate any scheduled operation that relates to the management of the data source, or to perform any other relevant form of state cleanup.
Copyright © 2018. All Rights Reserved.