public class OsgiPlugin extends AbstractPlugin implements OsgiBackedPlugin, ContainerManagedPlugin
AbstractPlugin.install() method is invoked. Any attempt to access a method that requires a bundle will throw an
IllegalPluginStateException.
This class uses a OsgiPluginHelper to represent different behaviors of key methods in different states.
OsgiPluginUninstalledHelper implements the methods when the plugin hasn't yet been installed into the
OSGi container, while OsgiPluginInstalledHelper implements the methods when the bundle is available. This
leaves this class to manage the PluginState and interactions with the event system.
| Modifier and Type | Field and Description |
|---|---|
static String |
ATLASSIAN_PLUGIN_KEY
Manifest key for the Atlassian plugin key entry
|
static String |
ATLASSIAN_SCAN_FOLDERS
Manifest key for additional scan folders
|
static String |
REMOTE_PLUGIN_KEY
Manifest key denoting Atlassian remote plugins
|
pluginArtifact| Constructor and Description |
|---|
OsgiPlugin(String key,
OsgiContainerManager mgr,
PluginArtifact artifact,
PluginArtifact originalPluginArtifact,
PluginEventManager pluginEventManager) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
disableInternal()
Disables the plugin by changing the bundle state back to resolved
|
protected PluginState |
enableInternal()
Enables the plugin by setting the OSGi bundle state to enabled.
|
org.osgi.framework.Bundle |
getBundle()
Returns
OSGi Bundle that corresponds to the current plugin |
ClassLoader |
getClassLoader()
Get the classloader for the plugin.
|
ContainerAccessor |
getContainerAccessor() |
Date |
getDateInstalled()
The date this plugin was installed into the system, is the same as the loaded date for non artifact backed plugins
|
PluginDependencies |
getDependencies()
Determines which plugin keys are dependencies based on tracing the wires, categorising them as mandatory,
optional or dynamic.
|
InstallationMode |
getInstallationMode()
Gets the installation mode
|
URL |
getResource(String name)
Retrieve the URL of the resource from the plugin.
|
InputStream |
getResourceAsStream(String name)
Load a given resource from the plugin.
|
protected void |
installInternal()
Installs the plugin artifact into OSGi
|
boolean |
isDeleteable()
Should the plugin file be deleted on uninstall?
|
boolean |
isDynamicallyLoaded()
Whether or not this plugin is loaded dynamically at runtime.
|
boolean |
isUninstallable()
Whether or not this plugin can be 'uninstalled'.
|
<T> Class<T> |
loadClass(String clazz,
Class<?> callingClass)
Get the plugin to load a specific class.
|
void |
onPluginContainerFailed(PluginContainerFailedEvent event)
Called when the plugin container for the bundle has failed to be created.
|
void |
onPluginContainerRefresh(PluginContainerRefreshedEvent event)
Called when the plugin container for the bundle has been created or refreshed.
|
void |
onPluginFrameworkShutdownEvent(PluginFrameworkShutdownEvent event) |
void |
onPluginFrameworkShuttingDownEvent(PluginFrameworkShuttingDownEvent event) |
void |
onPluginFrameworkStartedEvent(PluginFrameworkStartedEvent event) |
void |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitEndedEvent event) |
void |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitTimedOutEvent event) |
void |
onServiceDependencyWaitStarting(PluginServiceDependencyWaitStartingEvent event) |
void |
resolve()
Perform any required resolution.
|
void |
setKey(String key)
Sets key to the specified value.
|
String |
toString() |
protected void |
uninstallInternal()
Uninstalls the bundle from the OSGi container
|
addDynamicModuleDescriptor, addModuleDescriptor, cleanVersionString, close, compareAndSetPluginState, compareTo, containsSystemModule, disable, enable, getActivePermissions, getDateEnabled, getDateEnabling, getDateLoaded, getDynamicModuleDescriptors, getI18nNameKey, getKey, getLog, getModuleDescriptor, getModuleDescriptors, getModuleDescriptorsByModuleClass, getName, getPluginArtifact, getPluginInformation, getPluginState, getPluginsVersion, getRequiredPlugins, getResourceDescriptor, getResourceDescriptors, getResourceLocation, getScopeKey, hasAllPermissions, install, isBundledPlugin, isEnabledByDefault, isSystemPlugin, removeDynamicModuleDescriptor, removeModuleDescriptor, setBundledPlugin, setEnabledByDefault, setI18nNameKey, setName, setPluginInformation, setPluginState, setPluginsVersion, setResources, setSystemPlugin, uninstallclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddModuleDescriptor, containsSystemModule, disable, enable, getActivePermissions, getDateEnabled, getDateEnabling, getDateLoaded, getI18nNameKey, getKey, getModuleDescriptor, getModuleDescriptors, getModuleDescriptorsByModuleClass, getName, getPluginArtifact, getPluginInformation, getPluginState, getPluginsVersion, hasAllPermissions, install, isBundledPlugin, isEnabledByDefault, isSystemPlugin, setEnabledByDefault, setI18nNameKey, setName, setPluginInformation, setPluginsVersion, setResources, setSystemPlugin, uninstallgetScopeKeygetResourceDescriptor, getResourceDescriptors, getResourceLocationcompareTopublic static final String ATLASSIAN_PLUGIN_KEY
public static final String ATLASSIAN_SCAN_FOLDERS
public static final String REMOTE_PLUGIN_KEY
public OsgiPlugin(String key, OsgiContainerManager mgr, PluginArtifact artifact, PluginArtifact originalPluginArtifact, PluginEventManager pluginEventManager)
public org.osgi.framework.Bundle getBundle()
throws IllegalPluginStateException
OsgiBackedPluginOSGi Bundle that corresponds to the current plugin
Note that Bundle could be not available on some of Plugin lifecycle
stages. In that case method call results in IllegalPluginStateException
getBundle in interface OsgiBackedPluginOSGi representation of the current pluginIllegalPluginStateException - if plugin has no OSGi representation yetpublic InstallationMode getInstallationMode()
PlugingetInstallationMode in interface PlugingetInstallationMode in class AbstractPluginpublic boolean isUninstallable()
PluginisUninstallable in interface Pluginpublic boolean isDynamicallyLoaded()
PluginisDynamicallyLoaded in interface Pluginpublic boolean isDeleteable()
PluginisDeleteable in interface Pluginpublic Date getDateInstalled()
PlugingetDateInstalled in interface PlugingetDateInstalled in class AbstractPluginpublic void setKey(String key)
setKey in interface PluginsetKey in class AbstractPluginpublic <T> Class<T> loadClass(String clazz, Class<?> callingClass) throws ClassNotFoundException, IllegalPluginStateException
PluginloadClass in interface PluginT - The class typeclazz - The name of the class to be loadedcallingClass - The class calling the loading (used to help find a classloader)ClassNotFoundException - If the class cannot be foundIllegalPluginStateException - if the bundle hasn't been created yetpublic URL getResource(String name) throws IllegalPluginStateException
PlugingetResource in interface Pluginname - The resource nameIllegalPluginStateException - if the bundle hasn't been created yetpublic InputStream getResourceAsStream(String name) throws IllegalPluginStateException
PlugingetResourceAsStream in interface Pluginname - The name of the resource to be loaded.IllegalPluginStateException - if the bundle hasn't been created yetpublic ClassLoader getClassLoader() throws IllegalPluginStateException
PlugingetClassLoader in interface PluginIllegalPluginStateException - if the bundle hasn't been created yetpublic void onPluginContainerFailed(PluginContainerFailedEvent event) throws IllegalPluginStateException
event - The plugin container failed eventIllegalPluginStateException - If the plugin key hasn't been set yetpublic void onPluginFrameworkStartedEvent(PluginFrameworkStartedEvent event)
public void onPluginFrameworkShutdownEvent(PluginFrameworkShutdownEvent event)
public void onPluginFrameworkShuttingDownEvent(PluginFrameworkShuttingDownEvent event)
public void onServiceDependencyWaitStarting(PluginServiceDependencyWaitStartingEvent event)
public void onServiceDependencyWaitEnded(PluginServiceDependencyWaitEndedEvent event)
public void onServiceDependencyWaitEnded(PluginServiceDependencyWaitTimedOutEvent event)
public void onPluginContainerRefresh(PluginContainerRefreshedEvent event) throws IllegalPluginStateException
event - The eventIllegalPluginStateException - If the plugin key hasn't been set yet@Nonnull public PluginDependencies getDependencies()
Namespace.RESOLUTION_OPTIONAL and PackageNamespace.RESOLUTION_DYNAMIC are mapped to
optional and dynamic, respectively. Any others are mapped to mandatory.getDependencies in interface PlugingetDependencies in class AbstractPluginPlugin.getDependencies()public String toString()
toString in class AbstractPluginprotected void installInternal()
throws IllegalPluginStateException
installInternal in class AbstractPluginIllegalPluginStateException - if the bundle hasn't been created yetprotected PluginState enableInternal() throws OsgiContainerException, IllegalPluginStateException
enableInternal in class AbstractPluginPluginState.ENABLEDif the container is being refreshed or PluginState.ENABLING if we are waiting
on a plugin container (first time being activated, as all subsequent times are considered refreshes)OsgiContainerException - If the underlying OSGi system threw an exception or we tried to enable the bundle
when it was in an invalid stateIllegalPluginStateException - if the bundle hasn't been created yetprotected void disableInternal()
throws OsgiContainerException,
IllegalPluginStateException
disableInternal in class AbstractPluginOsgiContainerException - If the OSGi system threw an exceptionIllegalPluginStateException - if the bundle hasn't been created yetprotected void uninstallInternal()
throws OsgiContainerException,
IllegalPluginStateException
uninstallInternal in class AbstractPluginOsgiContainerException - If the underlying OSGi system threw an exceptionIllegalPluginStateException - if the bundle hasn't been created yetpublic ContainerAccessor getContainerAccessor()
getContainerAccessor in interface ContainerManagedPluginpublic void resolve()
Pluginresolve in interface Pluginresolve in class AbstractPluginCopyright © 2019 Atlassian. All rights reserved.