com.atlassian.plugin.osgi.factory
Class OsgiBundlePlugin

java.lang.Object
  extended by com.atlassian.plugin.impl.AbstractPlugin
      extended by com.atlassian.plugin.osgi.factory.OsgiBundlePlugin
All Implemented Interfaces:
Plugin, PluginArtifactBackedPlugin, Resourced, Comparable<Plugin>

public class OsgiBundlePlugin
extends AbstractPlugin
implements PluginArtifactBackedPlugin

Plugin that wraps an OSGi bundle that has no plugin descriptor.


Field Summary
 
Fields inherited from interface com.atlassian.plugin.Plugin
NAME_COMPARATOR
 
Constructor Summary
OsgiBundlePlugin(org.osgi.framework.Bundle bundle, String key, PluginArtifact pluginArtifact, PluginEventManager pluginEventManager)
           
 
Method Summary
protected  void disableInternal()
          Perform any internal disabling logic.
protected  PluginState enableInternal()
          Perform any internal enabling logic.
 ClassLoader getClassLoader()
          Get the classloader for the plugin.
 Date getDateLoaded()
          The date this plugin was loaded into the system.
 PluginArtifact getPluginArtifact()
           
 URL getResource(String name)
          Retrieve the URL of the resource from the plugin.
 InputStream getResourceAsStream(String name)
          Load a given resource from the plugin.
 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'.
<T> Class<T>
loadClass(String clazz, Class<?> callingClass)
          Get the plugin to load a specific class.
protected  void uninstallInternal()
          Perform any internal uninstallation logic.
 
Methods inherited from class com.atlassian.plugin.impl.AbstractPlugin
addModuleDescriptor, close, compareAndSetPluginState, compareTo, containsSystemModule, disable, enable, getI18nNameKey, getKey, getLog, getModuleDescriptor, getModuleDescriptors, getModuleDescriptorsByModuleClass, getName, getPluginInformation, getPluginState, getPluginsVersion, getRequiredPlugins, getResourceDescriptor, getResourceDescriptors, getResourceDescriptors, getResourceLocation, install, installInternal, isBundledPlugin, isEnabled, isEnabledByDefault, isSystemPlugin, removeModuleDescriptor, setEnabled, setEnabledByDefault, setI18nNameKey, setKey, setName, setPluginInformation, setPluginState, setPluginsVersion, setResources, setSystemPlugin, toString, uninstall
 
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, getI18nNameKey, getKey, getModuleDescriptor, getModuleDescriptors, getModuleDescriptorsByModuleClass, getName, getPluginInformation, getPluginState, getPluginsVersion, getRequiredPlugins, 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
 

Constructor Detail

OsgiBundlePlugin

public OsgiBundlePlugin(org.osgi.framework.Bundle bundle,
                        String key,
                        PluginArtifact pluginArtifact,
                        PluginEventManager pluginEventManager)
Method Detail

getDateLoaded

public Date getDateLoaded()
Description copied from interface: Plugin
The date this plugin was loaded into the system.

Specified by:
getDateLoaded in interface Plugin
Overrides:
getDateLoaded in class AbstractPlugin
Returns:
The date this plugin was loaded into the system.

isUninstallable

public boolean isUninstallable()
Description copied from interface: Plugin
Whether or not this plugin can be 'uninstalled'.

Specified by:
isUninstallable in interface Plugin
Returns:
true if this plugin can be 'uninstalled'.

isDeleteable

public boolean isDeleteable()
Description copied from interface: Plugin
Should the plugin file be deleted on unistall?

Specified by:
isDeleteable in interface Plugin
Returns:
true if this plugin file should be deleted on unistall.

isDynamicallyLoaded

public boolean isDynamicallyLoaded()
Description copied from interface: Plugin
Whether or not this plugin is loaded dynamically at runtime.

Specified by:
isDynamicallyLoaded in interface Plugin
Returns:
true if this plugin is loaded dynamically at runtime.

loadClass

public <T> Class<T> loadClass(String clazz,
                              Class<?> callingClass)
                   throws ClassNotFoundException
Description copied from interface: Plugin
Get the plugin to load a specific class.

Specified by:
loadClass in interface Plugin
Parameters:
clazz - The name of the class to be loaded
callingClass - The class calling the loading (used to help find a classloader)
Returns:
The loaded class.
Throws:
ClassNotFoundException - if the class cannot be located.

getResource

public URL getResource(String name)
Description copied from interface: Plugin
Retrieve the URL of the resource from the plugin.

Specified by:
getResource in interface Plugin
Parameters:
name - the name of the resource to be loaded
Returns:
The URL to the resource, or null if the resource is not found

getResourceAsStream

public InputStream getResourceAsStream(String name)
Description copied from interface: Plugin
Load a given resource from the plugin. Plugins that are loaded dynamically will need to implement this in a way that loads the resource from the same context as the plugin. Static plugins can just pull them from their own classloader.

Specified by:
getResourceAsStream in interface Plugin
Parameters:
name - The name of the resource to be loaded.
Returns:
An InputStream for the resource, or null if the resource is not found.

uninstallInternal

protected void uninstallInternal()
Description copied from class: AbstractPlugin
Perform any internal uninstallation logic. Subclasses should only throw PluginException.

Overrides:
uninstallInternal in class AbstractPlugin

enableInternal

protected PluginState enableInternal()
Description copied from class: AbstractPlugin
Perform any internal enabling logic. Subclasses should only throw PluginException.

Overrides:
enableInternal in class AbstractPlugin
Returns:
Either PluginState.ENABLED or PluginState.ENABLING

disableInternal

protected void disableInternal()
Description copied from class: AbstractPlugin
Perform any internal disabling logic. Subclasses should only throw PluginException.

Overrides:
disableInternal in class AbstractPlugin

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: Plugin
Get the classloader for the plugin.

Specified by:
getClassLoader in interface Plugin
Returns:
The classloader used to load classes for this plugin

getPluginArtifact

public PluginArtifact getPluginArtifact()
Specified by:
getPluginArtifact in interface PluginArtifactBackedPlugin
Returns:
the original, unprocessed or transformed PluginArtifact used to create this plugin instance. Cannot be null.


Copyright © 2013 Atlassian. All Rights Reserved.