Class ManagedObject<C extends Configuration>
- All Implemented Interfaces:
Closeable,AutoCloseable,ThreadSafe
A new instance of the plugin's ManagedObject class will be created every time the plugin's configuration
is modified; including server startup. The new Configuration object is passed to the new instance of ManagedObject via its
constructor.
If there was at least one previous configuration change, the older instance of ManagedObject
is closed via the close() method before the new instance is created.
The close() method and the constructor of the new instance may be called from different Threads.
The plugin will not be available until the constructor of this object finishes running. If it never completes or throws an Exception, then the plugin will not become active and all requests to the server that require this plugin will respond with an error.
A plugin type may receive an instance of the ManagedObject by injection into its constructor in the same
manner as it receives an instance of its Configuration type.
All implementations extending this abstract class must be Thread-safe.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ManagedObject
Create and initialize thisManagedObject.A new instance of this type will be created by the server every time the plugin configuration is modified.
The provided Configuration instance will contain only primitive values and nested configuration objects. Calling a method that returns a service will result in an
UnsupportedOperationExceptionat runtime.If this constructor throws an Exception, then the plugin will not become active until the next configuration change (when this instance will be closed, and the new instance initialized).
- Parameters:
configuration- of the plugin.
-
-
Method Details
-
close
Close thisManagedObject.This method is called every time the plugin configuration is modified (just before the new instance is created) and on server shutdown.
If any
Exceptionis thrown, the error will be logged but the next instance of this object will be initialized anyway, unless it is a server shutdown.The default implementation of this method does not do anything.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-