@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.
More information can be found at the PicoContainer website.
Modifier and Type | Class and Description |
---|---|
static class |
ComponentManager.ContainerLevel |
static class |
ComponentManager.PluginSystemState |
static interface |
ComponentManager.State
The state of the
ComponentManager . |
Modifier and Type | Field and Description |
---|---|
static String |
EXTENSION_PROVIDER_PROPERTY
Deprecated.
since 7.11 this extension point is being removed in Jira 8.0
|
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.
|
<T> T |
createRequestScopedComponent(Class<T> componentClass)
Creates a request-scoped component of the given class.
|
void |
dispose() |
void |
extendBootstrapContainerForFailedStartup() |
static <T> T |
getComponent(Class<T> componentClass)
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.
|
<T> List<T> |
getComponents(Class<T> type)
Returns the components of the given type.
|
static <T> List<T> |
getComponentsOfType(Class<T> type)
Returns all the components inside Pico that are instances of the given class.
|
static <T> Map<String,T> |
getComponentsOfTypeMap(Class<T> type)
Returns all the components currently inside Pico which are instances of the given class, mapping them to their
component key.
|
ComponentManager.ContainerLevel |
getContainerLevel()
Returns the current Pico container level.
|
static ComponentManager |
getInstance()
Retuns a singleton instance of this class.
|
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()
Registers components and extensions.
|
void |
lateStart()
Start delayed plugins (if any)
|
<T> T |
loadComponent(Class<T> componentClass,
Collection<Object> dependencies)
Instantiates a component from its class and dependent classes/instances.
|
void |
registerComponent(Class<?> interfaceClass,
Class<?> componentClass)
Deprecated.
only required for Plugins 1; use Plugins 2 instead
|
void |
restart()
Stops and restarts this component manager, which ensures that all the managers are reinitialised after the
license has changed.
|
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()
Publishes a
ComponentManagerShutdownEvent and shuts down the plugin system. |
void |
unregisterComponent(Class<?> interfaceClass,
Class<?> componentClass)
Deprecated.
only required for Plugins 1; use Plugins 2 instead
|
@Deprecated public static final String EXTENSION_PROVIDER_PROPERTY
ContainerProvider
.public void bootstrapInitialise()
public void setupInitialise()
public void extendBootstrapContainerForFailedStartup()
public void initialise()
public void start()
public void lateStart()
public boolean componentsAvailable()
ComponentManager.ContainerLevel.FULL_CONTAINER
,
ComponentManager.ContainerLevel.EXTENDED_BOOTSTRAP
public void stop()
ComponentManagerShutdownEvent
and shuts down the plugin system.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 ComponentManager.ContainerLevel getContainerLevel()
@Nonnull 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> componentClass)
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 Container. 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.
componentClass
- 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 <T> List<T> getComponents(Class<T> type)
T
- the component typetype
- the component typePicoContainer.getComponents(Class)
public static <T> List<T> getComponentsOfType(Class<T> type)
type
- the class for which to searchpublic static <T> Map<String,T> getComponentsOfTypeMap(Class<T> type)
type
- the type for which to search@Deprecated public void registerComponent(@Nullable Class<?> interfaceClass, @Nonnull Class<?> componentClass)
interfaceClass
- the interface to use as the keycomponentClass
- the component class@Deprecated public void unregisterComponent(@Nullable Class<?> interfaceClass, @Nonnull Class<?> componentClass)
interfaceClass
- the interface to use as the keycomponentClass
- the component classpublic <T> T createRequestScopedComponent(Class<T> componentClass)
T
- the type of the componentcomponentClass
- the class of component to instantiate@Nullable public <T> T loadComponent(Class<T> componentClass, Collection<Object> dependencies)
public void restart()
Copyright © 2002-2019 Atlassian. All Rights Reserved.