com.atlassian.jira.component
Class ComponentAccessor

java.lang.Object
  extended by com.atlassian.jira.component.ComponentAccessor

@PublicApi
public class ComponentAccessor
extends Object

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:

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.

Since:
v4.3

Nested Class Summary
static interface ComponentAccessor.Worker
           
 
Constructor Summary
ComponentAccessor()
           
 
Method Summary
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.
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 ConstantsManager getConstantsManager()
           
static com.atlassian.crowd.embedded.api.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 IssueIndexManager getIssueIndexManager()
          Returns the IssueIndexManager component.
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 com.atlassian.mail.queue.MailQueue getMailQueue()
           
static com.atlassian.mail.server.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 OfBizDelegator getOfBizDelegator()
           
static OptionsManager getOptionsManager()
           
static
<T> T
getOSGiComponentInstanceOfType(Class<T> componentClass)
          Retrieves and returns a public component from OSGi land via its class name.
static PermissionContextFactory getPermissionContextFactory()
           
static PermissionManager getPermissionManager()
           
static PermissionSchemeManager getPermissionSchemeManager()
           
static com.atlassian.plugin.PluginAccessor getPluginAccessor()
           
static com.atlassian.plugin.PluginController getPluginController()
           
static com.atlassian.plugin.event.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 org.quartz.Scheduler getScheduler()
          Deprecated. since v6.2; to be removed in v7.0. Please use the SchedulerService instead of accessing Quartz directly. It should be injected if possible; otherwise, use getComponent(SchedulerService.class) to obtain it.
static ServiceManager getServiceManager()
           
static SubscriptionManager getSubscriptionManager()
           
static SubTaskManager getSubTaskManager()
          Retrieves and returns the subtask manager instance
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 com.atlassian.velocity.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 com.atlassian.plugin.webresource.WebResourceManager getWebResourceManager()
          Retrieves and returns the web resource manager instance
static com.atlassian.plugin.webresource.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
static ComponentAccessor.Worker initialiseWorker(ComponentAccessor.Worker componentAccessorWorker)
          This is called during system bootstrap to initialise this static helper class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentAccessor

public ComponentAccessor()
Method Detail

getComponent

public 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.

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
See Also:
getComponentOfType(Class)

getComponentReference

@ExperimentalApi
public static <T> ComponentReference<T> getComponentReference(@Nonnull
                                                                              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.

Parameters:
componentClass - class to find a component instance by
Returns:
the dependency injection component reference
See Also:
ComponentReference

getComponentOfType

public 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.

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
See Also:
getComponent(Class)

getOSGiComponentInstanceOfType

public static <T> 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 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 - class to find an OSGi component instance for
Returns:
found component
See Also:
getComponentOfType(Class)

getProjectManager

public static ProjectManager getProjectManager()

getApplicationProperties

public static ApplicationProperties getApplicationProperties()

getJiraAuthenticationContext

public static JiraAuthenticationContext getJiraAuthenticationContext()

getJiraDurationUtils

public static JiraDurationUtils getJiraDurationUtils()

getConstantsManager

public static ConstantsManager getConstantsManager()

getVelocityManager

public static com.atlassian.velocity.VelocityManager getVelocityManager()

getVelocityParamFactory

public static VelocityParamFactory getVelocityParamFactory()

getI18nHelperFactory

public static I18nHelper.BeanFactory getI18nHelperFactory()

getFieldManager

public static FieldManager getFieldManager()

getIssueManager

public static IssueManager getIssueManager()

getAttachmentManager

public static AttachmentManager getAttachmentManager()

getUserManager

public static UserManager getUserManager()

getUserKeyService

public static UserKeyService getUserKeyService()

getPermissionManager

public static PermissionManager getPermissionManager()

getPermissionContextFactory

public static PermissionContextFactory getPermissionContextFactory()

getCustomFieldManager

public static CustomFieldManager getCustomFieldManager()

getFieldConfigSchemeManager

public static FieldConfigSchemeManager getFieldConfigSchemeManager()

getUserUtil

public static UserUtil getUserUtil()

getGroupManager

public static GroupManager getGroupManager()

getEventTypeManager

public static EventTypeManager getEventTypeManager()

getIssueEventManager

public static IssueEventManager getIssueEventManager()

getWorkflowManager

public static WorkflowManager getWorkflowManager()

getIssueFactory

public static IssueFactory getIssueFactory()

getVersionManager

public static VersionManager getVersionManager()

getCommentManager

public static CommentManager getCommentManager()

getMailThreadManager

public static MailThreadManager getMailThreadManager()

getWebResourceManager

public static com.atlassian.plugin.webresource.WebResourceManager getWebResourceManager()
Retrieves and returns the web resource manager instance

Returns:
web resource manager

getWebResourceUrlProvider

public static com.atlassian.plugin.webresource.WebResourceUrlProvider getWebResourceUrlProvider()
Retrieves and returns the web resource URL provider instance

Returns:
web resource URL provider

getBulkOperationManager

public static BulkOperationManager getBulkOperationManager()
Retrieves and return the bulk operation manager instance

Returns:
bulk operation manager

getMoveSubTaskOperationManager

public static MoveSubTaskOperationManager getMoveSubTaskOperationManager()
Retrieves and returns the move subtask operation manager instance

Returns:
move subtask operation manager

getWorklogManager

public static WorklogManager getWorklogManager()
Retrieves and returns the worklog manager instance

Returns:
worklog manager

getProjectFactory

public static ProjectFactory getProjectFactory()
Retrieves and returns the project factory instance

Returns:
project factory

getIssueTypeSchemeManager

public static IssueTypeSchemeManager getIssueTypeSchemeManager()
Retrieves and returns the issue type scheme manager instance

Returns:
issue type scheme manager

getIssueTypeScreenSchemeManager

public static IssueTypeScreenSchemeManager getIssueTypeScreenSchemeManager()
Retrieves and returns the issue type screen scheme manager instance

Returns:
issue type screen scheme manager

getSubTaskManager

public static SubTaskManager getSubTaskManager()
Retrieves and returns the subtask manager instance

Returns:
subtask manager

getIssueLinkManager

public static IssueLinkManager getIssueLinkManager()
Returns the IssueLinkManager component.

Returns:
the IssueLinkManager component.

getCrowdService

public static com.atlassian.crowd.embedded.api.CrowdService getCrowdService()

getFieldLayoutManager

public static FieldLayoutManager getFieldLayoutManager()
Retrieves and returns the field layout manager

Returns:
field layout manager

getColumnLayoutManager

public static ColumnLayoutManager getColumnLayoutManager()
Retrieves and returns the column layout manager instance

Returns:
column layout manager

getVoteManager

public static VoteManager getVoteManager()
Retrieves and returns the vote manager instance

Returns:
vote manager

getPluginAccessor

public static com.atlassian.plugin.PluginAccessor getPluginAccessor()

getPluginEventManager

public static com.atlassian.plugin.event.PluginEventManager getPluginEventManager()

getComponentClassManager

public static ComponentClassManager getComponentClassManager()

getPluginController

public static com.atlassian.plugin.PluginController getPluginController()

getRendererManager

public static RendererManager getRendererManager()
Retrieves the RendererManager component.

Returns:
the RendererManager component.

getFieldScreenRendererFactory

public static FieldScreenRendererFactory getFieldScreenRendererFactory()
Retrieves and returns the field screen renderer factory instance

Returns:
field screen renderer factory

getWorkflowSchemeManager

public static WorkflowSchemeManager getWorkflowSchemeManager()
Retrieves and returns the workflow scheme manager instance

Returns:
workflow scheme manager

getIssueIndexManager

public static IssueIndexManager getIssueIndexManager()
Returns the IssueIndexManager component.

Returns:
the IssueIndexManager component.

getIssueService

public static IssueService getIssueService()
Retrieves and returns the issue service instance

Returns:
issue service

getIndexPathManager

public static IndexPathManager getIndexPathManager()
Retrieves and returns the index path manager instance

Returns:
index path manager

getAttachmentPathManager

public static AttachmentPathManager getAttachmentPathManager()
Retrieves and returns the attachment path instance

Returns:
attachment path manager

getTranslationManager

public static TranslationManager getTranslationManager()
Retrieves and returns the translation manager instance

Returns:
translation manager

getWatcherManager

public static WatcherManager getWatcherManager()
Retrieves and returns the watcher manager instance

Returns:
watcher manager

getFieldScreenManager

public static FieldScreenManager getFieldScreenManager()
Retrieves and returns the field screen manager instance

Returns:
field screen manager

getMailServerManager

public static com.atlassian.mail.server.MailServerManager getMailServerManager()
Retrieves and returns the mail server manager instance

Returns:
mail server manager

getProjectComponentManager

public static ProjectComponentManager getProjectComponentManager()
Retrieves and returns the project component manager instance

Returns:
project component manager

getChangeHistoryManager

public static ChangeHistoryManager getChangeHistoryManager()
Retrieves and returns the ChangeHistoryManager manager instance

Returns:
ChangeHistoryManager

getUserPreferencesManager

public static UserPreferencesManager getUserPreferencesManager()
Retrieves and returns the user preferences manager instance

Returns:
user preferences manager

getUserPropertyManager

public static UserPropertyManager getUserPropertyManager()
Retrieves and returns the user preferences manager instance

Returns:
user preferences manager

getAvatarService

public static AvatarService getAvatarService()

getAvatarManager

public static AvatarManager getAvatarManager()

getListenerManager

public static ListenerManager getListenerManager()

getMailQueue

public static com.atlassian.mail.queue.MailQueue getMailQueue()

getNotificationSchemeManager

public static NotificationSchemeManager getNotificationSchemeManager()

getPermissionSchemeManager

public static PermissionSchemeManager getPermissionSchemeManager()

getScheduler

@Deprecated
public static org.quartz.Scheduler getScheduler()
Deprecated. since v6.2; to be removed in v7.0. Please use the SchedulerService instead of accessing Quartz directly. It should be injected if possible; otherwise, use getComponent(SchedulerService.class) to obtain it.

Returns the Quartz scheduler.

Returns:
the Quartz scheduler

getIssueSecurityLevelManager

public static IssueSecurityLevelManager getIssueSecurityLevelManager()

getServiceManager

public static ServiceManager getServiceManager()

getSubscriptionManager

public static SubscriptionManager getSubscriptionManager()

getGlobalPermissionManager

public static GlobalPermissionManager getGlobalPermissionManager()

getLocaleManager

public static LocaleManager getLocaleManager()

getOptionsManager

public static OptionsManager getOptionsManager()

getOfBizDelegator

public static OfBizDelegator getOfBizDelegator()

initialiseWorker

@Internal
public static ComponentAccessor.Worker initialiseWorker(ComponentAccessor.Worker componentAccessorWorker)
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)


Copyright © 2002-2014 Atlassian. All Rights Reserved.