@Internal public class ComponentManager extends Object implements Shutdown
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.
Modifier and Type | Class and Description |
---|---|
static class |
ComponentManager.PluginSystemState |
static interface |
ComponentManager.State
The state of the
ComponentManager . |
Modifier and Type | Field and Description |
---|---|
static String |
EXTENSION_PROVIDER_PROPERTY |
Modifier and Type | Method and Description |
---|---|
void |
bootstrapInitialise()
Initialization registers components for the bootstrap loading of JIRA.
|
boolean |
componentsAvailable()
Determines whether components have already been instantiated regardless of which container is in play.
|
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.
|
org.picocontainer.PicoContainer |
getContainer()
Returns container
|
static ComponentManager |
getInstance()
Retuns a singleton instance of this class.
|
org.picocontainer.MutablePicoContainer |
getMutablePicoContainer()
Returns container
|
static <T> T |
getOSGiComponentInstanceOfType(Class<T> clazz)
Deprecated.
since 6.0 - please use the jira-api
ComponentAccessor.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()
What
ComponentManager.State is the ComponentManager in. |
void |
initialise()
Initialization registers components and then registers extensions.
|
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.
|
void |
start()
Starts the plugin system and registers plugin components with pico.
|
void |
stop() |
public static final String EXTENSION_PROVIDER_PROPERTY
public void bootstrapInitialise()
public void setupInitialise()
public void extendBootstrapContainerForFailedStartup()
public void initialise()
public void start()
public void lateStart()
public boolean componentsAvailable()
ContainerLevel#FULL_CONTAINER
,
ContainerLevel#EXTENDED_BOOTSTRAP
public void stop()
public void dispose()
public void shutdown()
Shutdown
public ComponentManager.State getState()
ComponentManager.State
is the ComponentManager
in.public ComponentManager.PluginSystemState getPluginSystemState()
ComponentManager.PluginSystemState
is the plugin system in?
This can be used to discover whether delayed plugins were started.public org.picocontainer.PicoContainer getContainer()
public org.picocontainer.MutablePicoContainer getMutablePicoContainer()
public static ComponentManager getInstance()
public static <T> T getComponentInstanceOfType(Class<T> clazz)
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.
clazz
- class to find a component instance bygetOSGiComponentInstanceOfType(Class)
,
PicoContainer#getComponent(Class))
@Nullable public static <T> T getComponent(Class<T> clazz)
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.
clazz
- class to find a component instance bygetOSGiComponentInstanceOfType(Class)
,
PicoContainer.getComponent(Object)
@Nullable public static <T> T getOSGiComponentInstanceOfType(Class<T> clazz)
ComponentAccessor.getOSGiComponentInstanceOfType(Class)
instead
Plugin developers should prefer the API method ComponentAccessor.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 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.
clazz
- class to find an OSGi component instance forgetComponentInstanceOfType(Class)
public static <T> List<T> getComponentsOfType(Class<T> clazz)
clazz
- the class to search for.public static <T> Map<String,T> getComponentsOfTypeMap(Class<T> iface)
iface
- The class to search forCopyright © 2002-2017 Atlassian. All Rights Reserved.