@PublicApi public class

ComponentAccessor

extends Object
java.lang.Object
   ↳ com.atlassian.jira.component.ComponentAccessor

@PublicApi

This class is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Provides static methods for accessing JIRA's managed components — that is, the components in the PicoContainer.

Normally, developers should get the dependencies injected into the constructor of the calling class by Pico; however, this utility provides access for when that is impossible or impractical. Examples include:

  • Components with circular dependencies between them, as one of them must be resolved first without the other dependency available for injection yet
  • Classes that are not injectable components but are instead explicitly constructed in a long chain of classes that would not otherwise need the target component
  • Static-only utility classes, which are never constructed at all

Plugin developers that are trying to figure out how to fix an IllegalStateException that they are getting in a unit test should read the documentation for the MockComponentWorker in the jira-tests artifact for instructions.

Summary

Nested Classes
interface ComponentAccessor.Worker  
Public Constructors
ComponentAccessor()
Public Methods
static ApplicationProperties getApplicationProperties()
static AttachmentManager getAttachmentManager()
static AttachmentPathManager getAttachmentPathManager()
Retrieves and returns the attachment path instance
static AvatarManager getAvatarManager()
static AvatarService getAvatarService()
static BulkOperationManager getBulkOperationManager()
Retrieves and return the bulk operation manager instance
static ChangeHistoryManager getChangeHistoryManager()
Retrieves and returns the ChangeHistoryManager manager instance
static ColumnLayoutManager getColumnLayoutManager()
Retrieves and returns the column layout manager instance
static CommentManager getCommentManager()
static <T> T getComponent(Class<T> componentClass)
Returns the core component which is stored in JIRA's Dependency Injection container under the key that is the given class.
static ComponentClassManager getComponentClassManager()
static <T> T getComponentOfType(Class<T> componentClass)
Returns the core component of the given Type (a Class or an Interface) which is stored in JIRA's Dependency Injection container.
@ExperimentalApi static <T> ComponentReference<T> getComponentReference(Class<T> componentClass)
Returns a thread-safe, Serializable lazy reference to the core component which is stored in JIRA's Dependency Injection container under the key that is the given class.
static <T> Optional<T> getComponentSafely(Class<T> componentClass)
Returns the core component which is stored in JIRA's Dependency Injection container under the key that is the given class, if and only if Pico is fully initialized and that component is present.
static ConstantsManager getConstantsManager()
static CrowdService getCrowdService()
static CustomFieldManager getCustomFieldManager()
static EventTypeManager getEventTypeManager()
static FieldConfigSchemeManager getFieldConfigSchemeManager()
static FieldLayoutManager getFieldLayoutManager()
Retrieves and returns the field layout manager
static FieldManager getFieldManager()
static FieldScreenManager getFieldScreenManager()
Retrieves and returns the field screen manager instance
static FieldScreenRendererFactory getFieldScreenRendererFactory()
Retrieves and returns the field screen renderer factory instance
static GlobalPermissionManager getGlobalPermissionManager()
static GroupManager getGroupManager()
static I18nHelper.BeanFactory getI18nHelperFactory()
static IndexPathManager getIndexPathManager()
Retrieves and returns the index path manager instance
static IssueEventManager getIssueEventManager()
static IssueFactory getIssueFactory()
static IssueLinkManager getIssueLinkManager()
Returns the IssueLinkManager component.
static IssueManager getIssueManager()
static IssueSecurityLevelManager getIssueSecurityLevelManager()
static IssueService getIssueService()
Retrieves and returns the issue service instance
static IssueTypeSchemeManager getIssueTypeSchemeManager()
Retrieves and returns the issue type scheme manager instance
static IssueTypeScreenSchemeManager getIssueTypeScreenSchemeManager()
Retrieves and returns the issue type screen scheme manager instance
static JiraAuthenticationContext getJiraAuthenticationContext()
static JiraDurationUtils getJiraDurationUtils()
static ListenerManager getListenerManager()
static LocaleManager getLocaleManager()
static MailQueue getMailQueue()
static MailServerManager getMailServerManager()
Retrieves and returns the mail server manager instance
static MailThreadManager getMailThreadManager()
static MoveSubTaskOperationManager getMoveSubTaskOperationManager()
Retrieves and returns the move subtask operation manager instance
static NotificationSchemeManager getNotificationSchemeManager()
static <T> T getOSGiComponentInstanceOfType(Class<T> componentClass)
Retrieves and returns a public component from OSGi land via its class name.
static OfBizDelegator getOfBizDelegator()
static OptionsManager getOptionsManager()
@Deprecated @Internal static <T> OsgiComponentReference<T> getOsgiComponentReference(Class<T> componentClass)
This method is deprecated. Use getOSGiComponentInstanceOfType(Class) every time it is needed, instead. In the rare instances where this has unacceptable performance consequences, consider using a ServiceTracker or other similar enhanced access methods available through OSGi and through the plugin system in general. Since v7.0.0.
static PermissionContextFactory getPermissionContextFactory()
static PermissionManager getPermissionManager()
static PermissionSchemeManager getPermissionSchemeManager()
static PluginAccessor getPluginAccessor()
static PluginController getPluginController()
static PluginEventManager getPluginEventManager()
static ProjectComponentManager getProjectComponentManager()
Retrieves and returns the project component manager instance
static ProjectFactory getProjectFactory()
Retrieves and returns the project factory instance
static ProjectManager getProjectManager()
static RendererManager getRendererManager()
Retrieves the RendererManager component.
static ServiceManager getServiceManager()
static SubTaskManager getSubTaskManager()
Retrieves and returns the subtask manager instance
static SubscriptionManager getSubscriptionManager()
static TranslationManager getTranslationManager()
Retrieves and returns the translation manager instance
static UserKeyService getUserKeyService()
static UserManager getUserManager()
static UserPreferencesManager getUserPreferencesManager()
Retrieves and returns the user preferences manager instance
static UserPropertyManager getUserPropertyManager()
Retrieves and returns the user preferences manager instance
static UserUtil getUserUtil()
static VelocityManager getVelocityManager()
static VelocityParamFactory getVelocityParamFactory()
static VersionManager getVersionManager()
static VoteManager getVoteManager()
Retrieves and returns the vote manager instance
static WatcherManager getWatcherManager()
Retrieves and returns the watcher manager instance
static WebResourceManager getWebResourceManager()
Retrieves and returns the web resource manager instance
static WebResourceUrlProvider getWebResourceUrlProvider()
Retrieves and returns the web resource URL provider instance
static WorkflowManager getWorkflowManager()
static WorkflowSchemeManager getWorkflowSchemeManager()
Retrieves and returns the workflow scheme manager instance
static WorklogManager getWorklogManager()
Retrieves and returns the worklog manager instance
@Internal static ComponentAccessor.Worker initialiseWorker(ComponentAccessor.Worker componentAccessorWorker)
This is called during system bootstrap to initialise this static helper class.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ComponentAccessor ()

Public Methods

public static ApplicationProperties getApplicationProperties ()

public static AttachmentManager getAttachmentManager ()

public static AttachmentPathManager getAttachmentPathManager ()

Retrieves and returns the attachment path instance

Returns
  • attachment path manager

public static AvatarManager getAvatarManager ()

public static AvatarService getAvatarService ()

public static BulkOperationManager getBulkOperationManager ()

Retrieves and return the bulk operation manager instance

Returns
  • bulk operation manager

public static ChangeHistoryManager getChangeHistoryManager ()

Retrieves and returns the ChangeHistoryManager manager instance

Returns
  • ChangeHistoryManager

public static ColumnLayoutManager getColumnLayoutManager ()

Retrieves and returns the column layout manager instance

Returns
  • column layout manager

public static CommentManager getCommentManager ()

public static T getComponent (Class<T> componentClass)

Returns the core component which is stored in JIRA's Dependency Injection container under the key that is the given class.

In practise, this is the same as getComponentOfType(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.

Parameters
componentClass class to find a component instance by
Returns
  • the dependency injection component

public static ComponentClassManager getComponentClassManager ()

public static T getComponentOfType (Class<T> componentClass)

Returns the core component of the given Type (a Class or an Interface) which is stored in JIRA's Dependency Injection container.

First it tries to find the component using the given Class as a key (like getComponent(Class)), however, if this fails then it will try to find a unique component that implements/extends the given Class. This seems unlikely to be useful, but is included for now, for completeness and backward compatibility.

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.

Parameters
componentClass class to find a component instance by
Returns
  • the dependency injection component

@ExperimentalApi public static ComponentReference<T> getComponentReference (Class<T> componentClass)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Returns a thread-safe, Serializable lazy reference to the core component which is stored in JIRA's Dependency Injection container under the key that is the given class.

WARNING: Component references obtained in this way must not be held past the lifetime of the Pico container, which is thrown away during a full system restore (import). Doing so causes the previous incarnation of the system to bleed across, leading to leaked memory, poor performance, and even inconsistent behaviour as components from the two separate Pico containers accidentally interact. This warning is generally not important to plugin developers, but should be respected by anyone working within jira-core, particularly when messing with filters, seraph authenticators, and other globally static objects.

Parameters
componentClass class to find a component instance by
Returns
  • the dependency injection component reference

public static Optional<T> getComponentSafely (Class<T> componentClass)

Returns the core component which is stored in JIRA's Dependency Injection container under the key that is the given class, if and only if Pico is fully initialized and that component is present.

This is equivalent to checking ComponentManager.getInstance().getState().isContainerInitialised() before retrieving the component and using Optional.empty() for all cases of being unable to resolve it.

This paranoid usage is mainly of interest to very low-level code, such as custom Seraph authenticators or web filters, that might get accessed during system initialization or catastrophic error reporting (404.jsp, error500.jsp, or startup.jsp for example). Plugins generally should not have to worry about this because the Pico container is initialized before the plugin system is started.

Parameters
componentClass class to find a component instance by
Returns
  • an Optional containing the requested component, or Optional.empty() if the component is not currently available

public static ConstantsManager getConstantsManager ()

public static CrowdService getCrowdService ()

public static CustomFieldManager getCustomFieldManager ()

public static EventTypeManager getEventTypeManager ()

public static FieldConfigSchemeManager getFieldConfigSchemeManager ()

public static FieldLayoutManager getFieldLayoutManager ()

Retrieves and returns the field layout manager

Returns
  • field layout manager

public static FieldManager getFieldManager ()

public static FieldScreenManager getFieldScreenManager ()

Retrieves and returns the field screen manager instance

Returns
  • field screen manager

public static FieldScreenRendererFactory getFieldScreenRendererFactory ()

Retrieves and returns the field screen renderer factory instance

Returns
  • field screen renderer factory

public static GlobalPermissionManager getGlobalPermissionManager ()

public static GroupManager getGroupManager ()

public static I18nHelper.BeanFactory getI18nHelperFactory ()

public static IndexPathManager getIndexPathManager ()

Retrieves and returns the index path manager instance

Returns
  • index path manager

public static IssueEventManager getIssueEventManager ()

public static IssueFactory getIssueFactory ()

public static IssueLinkManager getIssueLinkManager ()

Returns the IssueLinkManager component.

Returns
  • the IssueLinkManager component.

public static IssueManager getIssueManager ()

public static IssueSecurityLevelManager getIssueSecurityLevelManager ()

public static IssueService getIssueService ()

Retrieves and returns the issue service instance

Returns
  • issue service

public static IssueTypeSchemeManager getIssueTypeSchemeManager ()

Retrieves and returns the issue type scheme manager instance

Returns
  • issue type scheme manager

public static IssueTypeScreenSchemeManager getIssueTypeScreenSchemeManager ()

Retrieves and returns the issue type screen scheme manager instance

Returns
  • issue type screen scheme manager

public static JiraAuthenticationContext getJiraAuthenticationContext ()

public static JiraDurationUtils getJiraDurationUtils ()

public static ListenerManager getListenerManager ()

public static LocaleManager getLocaleManager ()

public static MailQueue getMailQueue ()

public static MailServerManager getMailServerManager ()

Retrieves and returns the mail server manager instance

Returns
  • mail server manager

public static MailThreadManager getMailThreadManager ()

public static MoveSubTaskOperationManager getMoveSubTaskOperationManager ()

Retrieves and returns the move subtask operation manager instance

Returns
  • move subtask operation manager

public static NotificationSchemeManager getNotificationSchemeManager ()

public static T getOSGiComponentInstanceOfType (Class<T> componentClass)

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 (for example, by saving it 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).

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 example use case for this method is 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
componentClass the class for which to find an OSGi component instance
Returns
  • the found component or null if it does not exist

public static OfBizDelegator getOfBizDelegator ()

public static OptionsManager getOptionsManager ()

@Deprecated @Internal public static OsgiComponentReference<T> getOsgiComponentReference (Class<T> componentClass)

@Internal

This method 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).

This method is deprecated.
Use getOSGiComponentInstanceOfType(Class) every time it is needed, instead. In the rare instances where this has unacceptable performance consequences, consider using a ServiceTracker or other similar enhanced access methods available through OSGi and through the plugin system in general. Since v7.0.0.

Returns a thread-safe, Serializable lazy reference to the OSGi component under the key that is the given class.

WARNING: This probably should not be used by any plugin developer. It effectively caches the result of calling getOSGiComponentInstanceOfType(Class), and as its documentation states, this is dangerous.

Parameters
componentClass class to find an OSGi component instance by
Returns
  • the dependency injection component reference

public static PermissionContextFactory getPermissionContextFactory ()

public static PermissionManager getPermissionManager ()

public static PermissionSchemeManager getPermissionSchemeManager ()

public static PluginAccessor getPluginAccessor ()

public static PluginController getPluginController ()

public static PluginEventManager getPluginEventManager ()

public static ProjectComponentManager getProjectComponentManager ()

Retrieves and returns the project component manager instance

Returns
  • project component manager

public static ProjectFactory getProjectFactory ()

Retrieves and returns the project factory instance

Returns
  • project factory

public static ProjectManager getProjectManager ()

public static RendererManager getRendererManager ()

Retrieves the RendererManager component.

Returns
  • the RendererManager component.

public static ServiceManager getServiceManager ()

public static SubTaskManager getSubTaskManager ()

Retrieves and returns the subtask manager instance

Returns
  • subtask manager

public static SubscriptionManager getSubscriptionManager ()

public static TranslationManager getTranslationManager ()

Retrieves and returns the translation manager instance

Returns
  • translation manager

public static UserKeyService getUserKeyService ()

public static UserManager getUserManager ()

public static UserPreferencesManager getUserPreferencesManager ()

Retrieves and returns the user preferences manager instance

Returns
  • user preferences manager

public static UserPropertyManager getUserPropertyManager ()

Retrieves and returns the user preferences manager instance

Returns
  • user preferences manager

public static UserUtil getUserUtil ()

public static VelocityManager getVelocityManager ()

public static VelocityParamFactory getVelocityParamFactory ()

public static VersionManager getVersionManager ()

public static VoteManager getVoteManager ()

Retrieves and returns the vote manager instance

Returns
  • vote manager

public static WatcherManager getWatcherManager ()

Retrieves and returns the watcher manager instance

Returns
  • watcher manager

public static WebResourceManager getWebResourceManager ()

Retrieves and returns the web resource manager instance

Returns
  • web resource manager

public static WebResourceUrlProvider getWebResourceUrlProvider ()

Retrieves and returns the web resource URL provider instance

Returns
  • web resource URL provider

public static WorkflowManager getWorkflowManager ()

public static WorkflowSchemeManager getWorkflowSchemeManager ()

Retrieves and returns the workflow scheme manager instance

Returns
  • workflow scheme manager

public static WorklogManager getWorklogManager ()

Retrieves and returns the worklog manager instance

Returns
  • worklog manager

@Internal public static ComponentAccessor.Worker initialiseWorker (ComponentAccessor.Worker componentAccessorWorker)

@Internal

This method 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).

This is called during system bootstrap to initialise this static helper class.

Plugin developers should never call this in production code, although it is useful to put a mock Worker in here inside unit tests.

Parameters
componentAccessorWorker The worker that this static class delegates to in order to do actual work.
Returns
  • the passed worker (a convenience for unit test method chaining)