@Internal public class

ComponentManager

extends Object
implements Shutdown
java.lang.Object
   ↳ com.atlassian.jira.ComponentManager

@Internal

This class is an internal implementation detail and will change without notice.

Clients that depend on @Internal classes and interfaces can not expect to be compatible with any version other than the version they were compiled against (even minor version and milestone releases may break binary compatibility with respect to @Internal elements).

Class Overview

This component manager uses PicoContainer to resolve all the dependencies between components.

It is responsible for initialising a large number of components in JIRA. Any components defined here may be injected via a constructor.

The ComponentManager also has static accessor methods for accessing components, such as getComponent(Class). Plugins developers should use ComponentAccessor for this, instead.

The ComponentManager also has various static accessor methods for non-Pico-managed objects, eg. ComponentManager.getInstance().getProjectManager(). Plugins developers should no longer use these - please use ComponentAccessor instead.

More information can be found at the picocontainer website.

Summary

Nested Classes
enum ComponentManager.PluginSystemState  
interface ComponentManager.State The state of the ComponentManager
Constants
String EXTENSION_PROVIDER_PROPERTY
Public Methods
void bootstrapInitialise()
Initialization registers components for the bootstrap loading of JIRA.
void dispose()
void extendBootstrapContainerForFailedStartup()
static <T> T getComponent(Class<T> clazz)
Retrieves and returns a component which is an instance of given class.
static <T> T getComponentInstanceOfType(Class<T> clazz)
Retrieves and returns a component which is an instance of given class.
static <T> List<T> getComponentsOfType(Class<T> clazz)
Returns all the components currently inside of Pico which are instances of the given class.
static <T> Map<String, T> getComponentsOfTypeMap(Class<T> iface)
Returns all the components currently inside Pico which are instances of the given class, mapping them to their component key.
PicoContainer getContainer()
Returns container
static ComponentManager getInstance()
Retuns a singleton instance of this class.
MutablePicoContainer getMutablePicoContainer()
Returns container
@Nullable static <T> T getOSGiComponentInstanceOfType(Class<T> clazz)
This method is deprecated. since 6.0 - please use the jira-api getOSGiComponentInstanceOfType(Class) instead
ComponentManager.PluginSystemState getPluginSystemState()
What ComponentManager.PluginSystemState is the plugin system in? This can be used to discover whether delayed plugins were started.
ComponentManager.State getState()
void initialise()
Initialization registers components and then registers extensions.
synchronized void lateStart()
Start delayed plugins (if any)
void setupInitialise()
If JIRA needs to be setup, then add the extra components needed to the bootstrap container.
void shutdown()
Shutdown.
synchronized void start()
Starts the plugin system and registers plugin components with pico.
synchronized void stop()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.util.Shutdown

Constants

public static final String EXTENSION_PROVIDER_PROPERTY

Constant Value: "jira.extension.container.provider"

Public Methods

public void bootstrapInitialise ()

Initialization registers components for the bootstrap loading of JIRA. This gets enough of PICO registered to allow JIRA to bootstrap without a database.

public void dispose ()

public void extendBootstrapContainerForFailedStartup ()

public static T getComponent (Class<T> clazz)

Retrieves and returns a component which is an instance of given class.

In practise, this is the same as getComponentInstanceOfType(Class) except it will fail faster if the given Class is not a known component key (it also has a shorter and more meaningful name).

Please note that this method only gets components from JIRA's core Pico Containter. That is, it retrieves core components and components declared in Plugins1 plugins, but not components declared in Plugins2 plugins. Plugins2 components can be retrieved via the getOSGiComponentInstanceOfType(Class) method, but only if they are public.

Parameters
clazz class to find a component instance by
Returns
  • found component, or null if not found

public static T getComponentInstanceOfType (Class<T> clazz)

Retrieves and returns a component which is an instance of given class.

In practise, this is the same as getComponent(Class) except it will try to find a unique component that implements/extends the given Class even if the Class is not an actual component key.

Please note that this method only gets components from JIRA's core Pico Containter. That is, it retrieves core components and components declared in Plugins1 plugins, but not components declared in Plugins2 plugins. Plugins2 components can be retrieved via the getOSGiComponentInstanceOfType(Class) method, but only if they are public.

Parameters
clazz class to find a component instance by
Returns
  • found component

public static List<T> getComponentsOfType (Class<T> clazz)

Returns all the components currently inside of Pico which are instances of the given class.

Parameters
clazz the class to search for.
Returns
  • a list containing all the instances of the passed class registered in JIRA's pico container.

public static Map<String, T> getComponentsOfTypeMap (Class<T> iface)

Returns all the components currently inside Pico which are instances of the given class, mapping them to their component key.

Parameters
iface The class to search for
Returns
  • a map, mapping the component key, to the instances of the clas registered in JIRA's pico container.

public PicoContainer getContainer ()

Returns container

Returns
  • container

public static ComponentManager getInstance ()

Retuns a singleton instance of this class.

Returns
  • a singleton instance of this class

public MutablePicoContainer getMutablePicoContainer ()

Returns container

Returns
  • container

@Nullable public static T getOSGiComponentInstanceOfType (Class<T> clazz)

This method is deprecated.
since 6.0 - please use the jira-api getOSGiComponentInstanceOfType(Class) instead

Retrieves and returns a public component from OSGi land via its class name. This method can be used to retrieve a component provided via a plugins2 OSGi bundle. Please note that components returned via this method should *NEVER* be cached (e.g. in a static field) as they may be refreshed at any time as a plugin is enabled/disabled or the componentManager is reinitialised (after an XML import).

Plugin developers should prefer the API method getOSGiComponentInstanceOfType(Class).

It is important to note that this only works for public components. That is components with public="true" declared in their XML configuration. This means that they are available for other plugins to import.

A use case for this is when for example for the dashboards plugin. In several areas in JIRA we may want to render gadgets via the com.atlassian.gadgets.view.GadgetViewFactory. Whilst the interface for this component is available in JIRA core, the implementation is provided by the dashboards OSGi bundle. This method will allow us to access it.

Parameters
clazz class to find an OSGi component instance for
Returns
  • found component

public ComponentManager.PluginSystemState getPluginSystemState ()

What ComponentManager.PluginSystemState is the plugin system in? This can be used to discover whether delayed plugins were started.

Returns
  • the current plugins system state

public ComponentManager.State getState ()

Returns
  • the current state.

public void initialise ()

Initialization registers components and then registers extensions.

public synchronized void lateStart ()

Start delayed plugins (if any)

public void setupInitialise ()

If JIRA needs to be setup, then add the extra components needed to the bootstrap container.

public void shutdown ()

Shutdown. Should not throw any exceptions.

public synchronized void start ()

Starts the plugin system and registers plugin components with pico. If there is no tenant, delayed (phase 2) plugins will not be started.

public synchronized void stop ()