|
||||||||||
| 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
|
static java.lang.String |
SPRING_CONTEXT
|
| Fields inherited from interface com.atlassian.plugin.Plugin |
|---|
NAME_COMPARATOR |
| Constructor Summary | |
|---|---|
OsgiPlugin(java.lang.String key,
OsgiContainerManager mgr,
PluginArtifact artifact,
PluginEventManager pluginEventManager)
|
|
| Method Summary | ||
|---|---|---|
|
autowire(java.lang.Class<T> clazz)
Creates and autowires the class, using Spring's autodetection algorithm |
|
|
autowire(java.lang.Class<T> clazz,
AutowireCapablePlugin.AutowireStrategy autowireStrategy)
Creates and autowires the class |
|
void |
autowire(java.lang.Object instance)
Autowires the instance using Spring's autodetection 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. |
|
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 |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitEndedEvent event)
|
|
void |
onServiceDependencyWaitEnded(PluginServiceDependencyWaitTimedOutEvent event)
|
|
void |
onServiceDependencyWaitStarting(PluginServiceDependencyWaitStartingEvent event)
|
|
void |
onSpringContextFailed(PluginContainerFailedEvent event)
Called when the spring context for the bundle has failed to be created. |
|
void |
onSpringContextRefresh(PluginContainerRefreshedEvent event)
Called when the spring context for the bundle has been created or refreshed. |
|
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 |
| Field Detail |
|---|
public static final java.lang.String SPRING_CONTEXT
public static final java.lang.String ATLASSIAN_PLUGIN_KEY
| Constructor Detail |
|---|
public OsgiPlugin(java.lang.String key,
OsgiContainerManager mgr,
PluginArtifact artifact,
PluginEventManager pluginEventManager)
| Method Detail |
|---|
public org.osgi.framework.Bundle getBundle()
throws IllegalPluginStateException
IllegalPluginStateException - if the bundle hasn't been created yetpublic boolean isUninstallable()
Plugin
isUninstallable in interface Pluginpublic boolean isDynamicallyLoaded()
Plugin
isDynamicallyLoaded in interface Pluginpublic boolean isDeleteable()
Plugin
isDeleteable in interface Plugin
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 onSpringContextFailed(PluginContainerFailedEvent event)
throws IllegalPluginStateException
event - The plugin container failed event
IllegalPluginStateException - If the plugin key hasn't been set yetpublic void onServiceDependencyWaitStarting(PluginServiceDependencyWaitStartingEvent event)
public void onServiceDependencyWaitEnded(PluginServiceDependencyWaitEndedEvent event)
public void onServiceDependencyWaitEnded(PluginServiceDependencyWaitTimedOutEvent event)
public void onSpringContextRefresh(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 spring isn't necessory or PluginState.ENABLING if we are waiting
on a spring context
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 yet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||