Interface AmPlugin
-
- All Known Implementing Classes:
AbstractNodeAmPlugin
,IotPlugin
@SupportedAll public interface AmPlugin
Define an AM plugin. Implementing classes can use@Inject
setters to get access to APIs available via Guice dependency injection. For example, if you want to add an SMS service on install, you can add the following setter:
So that you can use the@Inject
public void setPluginTools(PluginTools tools) { this.tools = tools; }PluginTools.addSmsService(java.io.InputStream)
method to load your schema XML.It can be assumed that when running, implementations of this class will be singleton instances.
It should not be expected that the runtime singleton instances will be the instances on which
onAmUpgrade(String, String)
will be called. Guice-injected properties will also not be populated during that method call.Plugins should not use the
ShutdownManager
/ShutdownListener
API for handling shutdown, as the order of calling those listeners is not deterministic. TheonShutdown()
method for all plugins will be called in the reverse order from the order thatonStartup()
was called, with dependent plugins being notified after their dependencies for startup, and before them for shutdown.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default Map<Class<? extends AmPlugin>,String>
getDependencies()
Get the collection of plugins that this plugin expects to be installed.String
getPluginVersion()
The plugin version.default Map<String,String>
getServiceSchemaXML()
Defines the SMS Service name and an SMS Service Schema XML for each service that thisAmPlugin
implementation registers as part of startup.default void
onAmUpgrade(String fromVersion, String toVersion)
Handle AM system upgrade.void
onInstall()
Handle plugin installation.default void
onShutdown()
Handle plugin shutdown.default void
onStartup()
Deprecated.UseonStartup(StartupType)
instead.default void
onStartup(org.forgerock.openam.plugins.StartupType startupType)
Handle plugin startup.default void
onUnsatisfiedDependency(Set<String> missingDependencies)
This method will be called if the plugin has previously been installed, but the dependencies cannot currently be satisfied.default void
upgrade(String fromVersion)
This method will be called when the version returned bygetPluginVersion()
is higher than the version already installed.
-
-
-
Method Detail
-
getPluginVersion
String getPluginVersion()
The plugin version. This must be in semver (semantic version) format.- Returns:
- The version of the plugin.
- See Also:
- Semantic Versioning
-
getDependencies
default Map<Class<? extends AmPlugin>,String> getDependencies()
Get the collection of plugins that this plugin expects to be installed. TheonInstall()
,upgrade(String)
andonStartup()
methods will only be called if all these dependencies are satisfied. If any plugin cannot be satisfied from the classpath, if the plugin is not yet installed, it will not be installed and system installation will result in an error, otherwise theonUnsatisfiedDependency(Set)
method will be called.- Returns:
- A non-null map of plugin class to plugin version for the dependencies of this plugin. The version can use
OSGi version range syntax, e.g.
[1.3,1.8.3)
for greater than or equal to 1.3 and less than 1.8.3. - See Also:
- OSGi SemVer
-
onUnsatisfiedDependency
default void onUnsatisfiedDependency(Set<String> missingDependencies) throws PluginException
This method will be called if the plugin has previously been installed, but the dependencies cannot currently be satisfied.- Parameters:
missingDependencies
- The plugin class names for all the plugin dependencies that cannot be satisfied.- Throws:
PluginException
-
onInstall
void onInstall() throws PluginException
Handle plugin installation. This method will only be called once, on first AM startup once the plugin is included in the classpath. TheonStartup()
method will be called after this one.- Throws:
PluginException
-
onAmUpgrade
default void onAmUpgrade(String fromVersion, String toVersion) throws PluginException
Handle AM system upgrade. This method will be called once for each system upgrade that takes place after the plugin has already been installed. After this method is called,upgrade(String)
may be called, andonStartup()
will be called.- Parameters:
fromVersion
- The old AM version.toVersion
- The new AM version.- Throws:
PluginException
-
upgrade
default void upgrade(String fromVersion) throws PluginException
This method will be called when the version returned bygetPluginVersion()
is higher than the version already installed. This method will be called before theonStartup()
method.- Parameters:
fromVersion
- The old version of the plugin that has been installed.- Throws:
PluginException
-
onStartup
default void onStartup(org.forgerock.openam.plugins.StartupType startupType) throws PluginException
Handle plugin startup. This method will be called every time AM starts, afteronInstall()
,onAmUpgrade(String, String)
andupgrade(String)
have been called (if relevant).- Parameters:
startupType
- The type of startup that is taking place.- Throws:
PluginException
-
onStartup
@Deprecated default void onStartup() throws PluginException
Deprecated.UseonStartup(StartupType)
instead.Handle plugin startup. This method will be called every time AM starts, afteronInstall()
,onAmUpgrade(String, String)
andupgrade(String)
have been called (if relevant).- Throws:
PluginException
-
onShutdown
default void onShutdown()
Handle plugin shutdown. This method will be called when AM is shutting down, and should be used to close any resources that the plugin is using. This method will only be called ifonStartup()
was called to indicate that the plugin can startup.
-
getServiceSchemaXML
default Map<String,String> getServiceSchemaXML() throws PluginException
Defines the SMS Service name and an SMS Service Schema XML for each service that thisAmPlugin
implementation registers as part of startup.On Startup: this method will be called to automatically request the XML schema and then load it into the SMS both during configuration and after a restart.
- Returns:
- If this
AmPlugin
implementation does not define any SMS services then this method can returnnull
or an emptyMap
. Otherwise it should return a mapping of the SMS Service name and its corresponding SMS Service Schema. - Throws:
PluginException
- if there is a problem getting the serviceSchemaXML
-
-