|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.plugin.impl.AbstractPlugin
com.atlassian.plugin.osgi.factory.OsgiPlugin
public class OsgiPlugin
Plugin that wraps an OSGi bundle that does contain a plugin descriptor. The actual bundle is not created until the
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.atlassian.plugin.AutowireCapablePlugin |
|---|
AutowireCapablePlugin.AutowireStrategy |
| Field Summary | |
|---|---|
static java.lang.String |
ATLASSIAN_PLUGIN_KEY
Manifest key for the Atlassian plugin key entry |
static java.lang.String |
REMOTE_PLUGIN_KEY
Manifest key denoting Atlassian remote plugins |
| Fields inherited from interface com.atlassian.plugin.Plugin |
|---|
NAME_COMPARATOR, VERSION_1, VERSION_2, VERSION_3 |
| Constructor Summary | |
|---|---|
OsgiPlugin(java.lang.String key,
OsgiContainerManager mgr,
PluginArtifact artifact,
PluginArtifact originalPluginArtifact,
PluginEventManager pluginEventManager)
|
|
| Method Summary | ||
|---|---|---|
|
autowire(java.lang.Class<T> clazz)
Creates and autowires the class, preferring constructor inject, then falling back to private field and setter |
|
|
autowire(java.lang.Class<T> clazz,
AutowireCapablePlugin.AutowireStrategy autowireStrategy)
Creates and autowires the class |
|
void |
autowire(java.lang.Object instance)
Autowires the instance using plugin container's default injection algorithm |
|
void |
autowire(java.lang.Object instance,
AutowireCapablePlugin.AutowireStrategy autowireStrategy)
Autowires the instance |
|
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()
|
|
java.lang.ClassLoader |
getClassLoader()
Get the classloader for the plugin. |
|
ContainerAccessor |
getContainerAccessor()
|
|
java.util.Date |
getDateInstalled()
The date this plugin was installed into the system, is the same as the loaded date for non artifact backed plugins |
|
InstallationMode |
getInstallationMode()
Gets the installation mode |
|
PluginArtifact |
getPluginArtifact()
|
|
java.util.Set<java.lang.String> |
getRequiredPlugins()
Determines which plugins are required for this one to operate based on tracing the "wires" or packages that are imported by this plugin. |
|
java.net.URL |
getResource(java.lang.String name)
Retrieve the URL of the resource from the plugin. |
|
java.io.InputStream |
getResourceAsStream(java.lang.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 unistall? |
|
boolean |
isDynamicallyLoaded()
Whether or not this plugin is loaded dynamically at runtime. |
|
boolean |
isUninstallable()
Whether or not this plugin can be 'uninstalled'. |
|
|
loadClass(java.lang.String clazz,
java.lang.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 |
onPluginFrameworkStartedEvent(PluginFrameworkStartedEvent event)
|
|
void |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitEndedEvent event)
|
|
void |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitTimedOutEvent event)
|
|
void |
onServiceDependencyWaitStarting(PluginServiceDependencyWaitStartingEvent event)
|
|
java.lang.String |
toString()
|
|
protected void |
uninstallInternal()
Uninstalls the bundle from the OSGi container |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.atlassian.plugin.Plugin |
|---|
addModuleDescriptor, close, containsSystemModule, disable, enable, getActivePermissions, getDateLoaded, getI18nNameKey, getKey, getModuleDescriptor, getModuleDescriptors, getModuleDescriptorsByModuleClass, getName, getPluginInformation, getPluginState, getPluginsVersion, hasAllPermissions, install, isBundledPlugin, isEnabled, isEnabledByDefault, isSystemPlugin, setEnabled, setEnabledByDefault, setI18nNameKey, setKey, setName, setPluginInformation, setPluginsVersion, setResources, setSystemPlugin, uninstall |
| Methods inherited from interface com.atlassian.plugin.Resourced |
|---|
getResourceDescriptor, getResourceDescriptors, getResourceDescriptors, getResourceLocation |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
public static final java.lang.String ATLASSIAN_PLUGIN_KEY
public static final java.lang.String REMOTE_PLUGIN_KEY
| Constructor Detail |
|---|
public OsgiPlugin(java.lang.String key,
OsgiContainerManager mgr,
PluginArtifact artifact,
PluginArtifact originalPluginArtifact,
PluginEventManager pluginEventManager)
| Method Detail |
|---|
public org.osgi.framework.Bundle getBundle()
throws IllegalPluginStateException
IllegalPluginStateException - if the bundle hasn't been created yetpublic InstallationMode getInstallationMode()
Plugin
getInstallationMode in interface PlugingetInstallationMode in class AbstractPluginpublic boolean isUninstallable()
Plugin
isUninstallable in interface Pluginpublic boolean isDynamicallyLoaded()
Plugin
isDynamicallyLoaded in interface Pluginpublic boolean isDeleteable()
Plugin
isDeleteable in interface Pluginpublic java.util.Date getDateInstalled()
Plugin
getDateInstalled in interface PlugingetDateInstalled in class AbstractPluginpublic PluginArtifact getPluginArtifact()
getPluginArtifact in interface PluginArtifactBackedPluginPluginArtifact used to create this plugin instance. Cannot be null.
public <T> java.lang.Class<T> loadClass(java.lang.String clazz,
java.lang.Class<?> callingClass)
throws java.lang.ClassNotFoundException,
IllegalPluginStateException
Plugin
loadClass 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)
java.lang.ClassNotFoundException - If the class cannot be found
IllegalPluginStateException - if the bundle hasn't been created yet
public java.net.URL getResource(java.lang.String name)
throws IllegalPluginStateException
Plugin
getResource in interface Pluginname - The resource name
IllegalPluginStateException - if the bundle hasn't been created yet
public java.io.InputStream getResourceAsStream(java.lang.String name)
throws IllegalPluginStateException
Plugin
getResourceAsStream in interface Pluginname - The name of the resource to be loaded.
IllegalPluginStateException - if the bundle hasn't been created yet
public java.lang.ClassLoader getClassLoader()
throws IllegalPluginStateException
Plugin
getClassLoader in interface PluginIllegalPluginStateException - if the bundle hasn't been created yet
public void onPluginContainerFailed(PluginContainerFailedEvent event)
throws IllegalPluginStateException
event - The plugin container failed event
IllegalPluginStateException - If the plugin key hasn't been set yetpublic void onPluginFrameworkStartedEvent(PluginFrameworkStartedEvent event)
public void onPluginFrameworkShutdownEvent(PluginFrameworkShutdownEvent 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 event
IllegalPluginStateException - If the plugin key hasn't been set yet
public <T> T autowire(java.lang.Class<T> clazz)
throws IllegalPluginStateException
autowire in interface AutowireCapablePluginclazz - The class to create
IllegalPluginStateException - if the bundle hasn't been created yet
public <T> T autowire(java.lang.Class<T> clazz,
AutowireCapablePlugin.AutowireStrategy autowireStrategy)
throws IllegalPluginStateException
autowire in interface AutowireCapablePluginclazz - The class to createautowireStrategy - The autowire strategy
IllegalPluginStateException - if the bundle hasn't been created yet
public void autowire(java.lang.Object instance)
throws java.lang.IllegalStateException
autowire in interface AutowireCapablePlugininstance - The object to inject
IllegalPluginStateException - if the bundle hasn't been created yet
java.lang.IllegalStateException
public void autowire(java.lang.Object instance,
AutowireCapablePlugin.AutowireStrategy autowireStrategy)
throws IllegalPluginStateException
autowire in interface AutowireCapablePlugininstance - The object to autowireautowireStrategy - The autowire strategy, must not be constructor
IllegalPluginStateException - if the bundle hasn't been created yet
public java.util.Set<java.lang.String> getRequiredPlugins()
throws IllegalPluginStateException
getRequiredPlugins in interface PlugingetRequiredPlugins in class AbstractPluginIllegalPluginStateExceptionpublic java.lang.String toString()
toString in class AbstractPlugin
protected void installInternal()
throws IllegalPluginStateException
installInternal in class AbstractPluginIllegalPluginStateException - if the bundle hasn't been created yet
protected 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 state
IllegalPluginStateException - if the bundle hasn't been created yet
protected void disableInternal()
throws OsgiContainerException,
IllegalPluginStateException
disableInternal in class AbstractPluginOsgiContainerException - If the OSGi system threw an exception
IllegalPluginStateException - if the bundle hasn't been created yet
protected void uninstallInternal()
throws OsgiContainerException,
IllegalPluginStateException
uninstallInternal in class AbstractPluginOsgiContainerException - If the underlying OSGi system threw an exception
IllegalPluginStateException - if the bundle hasn't been created yetpublic ContainerAccessor getContainerAccessor()
getContainerAccessor in interface ContainerManagedPlugin
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||