Class DefaultServiceManager
- All Implemented Interfaces:
Startable,InitializingComponent,ServiceManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.service.ServiceManager
ServiceManager.ServiceScheduleSkipper -
Field Summary
Fields inherited from interface com.atlassian.jira.service.ServiceManager
SERVICE_ID_KEY -
Constructor Summary
ConstructorsConstructorDescriptionDefaultServiceManager(ServiceConfigStore serviceConfigStore, ComponentClassManager componentClassManager, PermissionManager permissionManager, InBuiltServiceTypes inBuiltServiceTypes, com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.cache.CacheManager cacheManager, com.atlassian.beehive.ClusterLockService clusterLockService, ClusterMessagingService messagingService, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionaddService(String name, Class<? extends JiraService> serviceClass, long delay) This will add a service configuration to the JIRA DB and the service to the list of services which are running.addService(String name, Class<? extends JiraService> serviceClass, long delay, Map<String, String[]> params) This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.addService(String name, Class<? extends JiraService> serviceClass, String cronExpression) This will add a service configuration to the JIRA DB and the service to the list of services which are running.addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, long delay, Map<String, String[]> params) This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, Map<String, String[]> params) This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.addService(String name, String serviceClassName, long delay) This will add a service configuration to the JIRA DB and the service to the list of services which are running.This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.addService(String name, String serviceClassName, String cronExpression) This will add a service configuration to the JIRA DB and the service to the list of services which are running.addService(String name, String serviceClassName, String cronExpression, long delay, Map<String, String[]> params) This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.addService(String name, String serviceClassName, String cronExpression, Map<String, String[]> params) This will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.voidCalled after all the beans are constructed and the ApplicationContext is fully populated.booleanQuick way of telling whether a service with a specific id is registered or not.voideditService(Long id, long delay, Map<String, String[]> params) This will update the service if a service with this id can be found.voidThis will update the service if a service with this id can be found.voideditServiceByName(String name, long delay, Map<String, String[]> params) This will update the service if a service by this name can be found.voidThis will update the service if a service by this name can be found.Returns service schedule skipperThis gets all currently registered services with JIRA.getServicesForExecution(long time) Gets the services that are ready for execution at a particular time.Gets the services that can be managed by an specific user.getServiceWithId(Long id) This will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.getServiceWithName(String name) This will return a JiraServiceContainer for the provided name if one is registered, otherwise this will return null.voidonClearCache(ClearCacheEvent event) voidThis will force a complete re-sync of the service cache with the values stored in the db.voidrefreshService(Long id) This will update the in-memory cache with the values from the db for the service with the id if it can be resolved.voidrefreshServiceByName(String name) This will update the in-memory cache with the values from the db for the named service if it can be resolved.voidremoveService(Long id) This will remove a service from the db and cache and it will try to resolve the service by id.voidremoveServiceByName(String name) This will remove a service from the db and cache and it will try to resolve the service by name.voidrunNow(long serviceId) Runs the service immediately.voidstart()This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.
-
Constructor Details
-
DefaultServiceManager
public DefaultServiceManager(ServiceConfigStore serviceConfigStore, ComponentClassManager componentClassManager, PermissionManager permissionManager, InBuiltServiceTypes inBuiltServiceTypes, com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.cache.CacheManager cacheManager, com.atlassian.beehive.ClusterLockService clusterLockService, ClusterMessagingService messagingService, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponentCalled after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiationin interfaceInitializingComponent- Throws:
Exception
-
start
public void start()Description copied from interface:StartableThis method will be called after the plugin system is fully initialised and all components added to the dependency injection framework. -
onClearCache
-
getServices
Description copied from interface:ServiceManagerThis gets all currently registered services with JIRA. This is an unmodifiable Collections that is returned, modifications to the services map will be made as a side-effect of calling the edit/refresh/add/remove methods of this manager.- Specified by:
getServicesin interfaceServiceManager- Returns:
- an unmodifiable Collection with JiraServiceContainers as the value
-
getServicesManageableBy
Description copied from interface:ServiceManagerGets the services that can be managed by an specific user.- Specified by:
getServicesManageableByin interfaceServiceManager- Parameters:
user- The user in play.- Returns:
- A collection of services.
-
runNow
Description copied from interface:ServiceManagerRuns the service immediately. This call returns once the job is submitted. It does not wait for the service to complete. In a clustered environment the service may run on any node in the cluster.- Specified by:
runNowin interfaceServiceManager- Parameters:
serviceId-- Throws:
Exception
-
getServicesForExecution
Description copied from interface:ServiceManagerGets the services that are ready for execution at a particular time.- Specified by:
getServicesForExecutionin interfaceServiceManager- Parameters:
time- the time to check for due services.- Returns:
- an immutable collection of services.
-
containsServiceWithId
Description copied from interface:ServiceManagerQuick way of telling whether a service with a specific id is registered or not.- Specified by:
containsServiceWithIdin interfaceServiceManager- Parameters:
id- service id- Returns:
- true if the service with the id is registered
-
refreshAll
public void refreshAll()Description copied from interface:ServiceManagerThis will force a complete re-sync of the service cache with the values stored in the db.- Specified by:
refreshAllin interfaceServiceManager
-
getServiceWithId
Description copied from interface:ServiceManagerThis will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.- Specified by:
getServiceWithIdin interfaceServiceManager- Parameters:
id- service id- Returns:
- a JiraServiceContainer that is represented by the unique id.
-
getServiceWithName
Description copied from interface:ServiceManagerThis will return a JiraServiceContainer for the provided name if one is registered, otherwise this will return null.- Specified by:
getServiceWithNamein interfaceServiceManager- Parameters:
name- the name of the JiraServiceContainer- Returns:
- a JiraServiceContainer if it is registered otherwise null
-
addService
public JiraServiceContainer addService(String name, String serviceClassName, long delay) throws ServiceException, ClassNotFoundException Description copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClassName- the class defining the servicedelay- how often the service should run in milliseconds- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.ClassNotFoundException- If the className could not be resolved.- See Also:
-
addService
public JiraServiceContainer addService(String name, String serviceClassName, long delay, Map<String, String[]> params) throws ServiceException, ClassNotFoundExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClassName- the class defining the servicedelay- how often the service should run in millisecondsparams- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.ClassNotFoundException- If the className could not be resolved.- See Also:
-
addService
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, long delay) throws ServiceException Description copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClass- the class defining the servicedelay- how often the service should run in milliseconds- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.- See Also:
-
addService
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, long delay, Map<String, String[]> params) throws ServiceExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClass- the class defining the servicedelay- how often the service should run in millisecondsparams- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.- See Also:
-
addService
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression) throws ServiceException, ClassNotFoundException Description copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClassName- the class defining the servicecronExpression- how the service should be scheduled- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.ClassNotFoundException- If the className could not be resolved.- See Also:
-
addService
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression) throws ServiceException Description copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClass- the class defining the servicecronExpression- how the service should be scheduled- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.- See Also:
-
addService
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression, Map<String, String[]> params) throws ServiceException, ClassNotFoundExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClassName- the class defining the servicecronExpression- how the service should be scheduledparams- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.ClassNotFoundException- If the className could not be resolved.- See Also:
-
addService
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression, long delay, Map<String, String[]> params) throws ServiceException, ClassNotFoundExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClassName- the class defining the servicecronExpression- how the service should be scheduleddelay- How often the service should run in milliseconds. This is not used, but the value will be retained and will be used in place of the cron expression if the instance is downgraded to a JIRA version prior to 6.4.params- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.ClassNotFoundException- If the className could not be resolved.- See Also:
-
addService
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, @Nullable Map<String, String[]> params) throws ServiceExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClass- the class defining the servicecronExpression- how the service should be scheduledparams- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.- See Also:
-
addService
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, long delay, @Nullable Map<String, String[]> params) throws ServiceExceptionDescription copied from interface:ServiceManagerThis will add a service configuration to the JIRA DB and the service to the list of services which are running with an optional list of params.It is preferred to pass the actual Class rather than the class name when adding services to JIRA from plugins, because it avoids possible ClassLoader issues. See http://jira.atlassian.com/browse/JRA-18578.
- Specified by:
addServicein interfaceServiceManager- Parameters:
name- the key this service is to be known byserviceClass- the class defining the servicecronExpression- how the service should be scheduleddelay- How often the service should run in milliseconds. This is not used, but the value will be retained and will be used in place of the cron expression if the instance is downgraded to a JIRA version prior to 6.4.params- Additional params to specify for the service- Returns:
- the JiraServiceContainer that was just created
- Throws:
ServiceException- If there is an error creating the Service.- See Also:
-
editServiceByName
public void editServiceByName(String name, long delay, Map<String, String[]> params) throws ExceptionDescription copied from interface:ServiceManagerThis will update the service if a service by this name can be found. The delay and the params will be updated.- Specified by:
editServiceByNamein interfaceServiceManager- Parameters:
name- the name of the service to find.delay- the delay to set on the service in millisecondsparams- the params to set on the service- Throws:
Exception
-
editService
Description copied from interface:ServiceManagerThis will update the service if a service with this id can be found. The delay and the params will be updated.- Specified by:
editServicein interfaceServiceManager- Parameters:
id- the id of the service to find.delay- the delay to set on the service in millisecondsparams- the params to set on the service- Throws:
Exception- if there is a problem updating the value
-
editServiceByName
public void editServiceByName(String name, String cronExpression, Map<String, String[]> params) throws ExceptionDescription copied from interface:ServiceManagerThis will update the service if a service by this name can be found. The cronExpression and the params will be updated.- Specified by:
editServiceByNamein interfaceServiceManager- Parameters:
name- the name of the service to find.cronExpression- how the service should be scheduledparams- the params to set on the service- Throws:
Exception
-
editService
public void editService(Long id, String cronExpression, Map<String, String[]> params) throws ExceptionDescription copied from interface:ServiceManagerThis will update the service if a service with this id can be found. The cronExpression and the params will be updated.- Specified by:
editServicein interfaceServiceManager- Parameters:
id- the id of the service to find.cronExpression- how the service should be scheduledparams- the params to set on the service- Throws:
Exception- if there is a problem updating the value
-
removeServiceByName
Description copied from interface:ServiceManagerThis will remove a service from the db and cache and it will try to resolve the service by name.- Specified by:
removeServiceByNamein interfaceServiceManager- Parameters:
name- the name of the service to find.- Throws:
Exception
-
removeService
Description copied from interface:ServiceManagerThis will remove a service from the db and cache and it will try to resolve the service by id.- Specified by:
removeServicein interfaceServiceManager- Parameters:
id- the id of the service to find.- Throws:
Exception- if there is a problem removing the service
-
refreshService
Description copied from interface:ServiceManagerThis will update the in-memory cache with the values from the db for the service with the id if it can be resolved.- Specified by:
refreshServicein interfaceServiceManager- Parameters:
id- the id of the service to find.- Throws:
Exception- if the value can not be refreshed
-
refreshServiceByName
Description copied from interface:ServiceManagerThis will update the in-memory cache with the values from the db for the named service if it can be resolved.- Specified by:
refreshServiceByNamein interfaceServiceManager- Parameters:
name- the name of the service to find.- Throws:
Exception
-
getScheduleSkipper
Returns service schedule skipper- Specified by:
getScheduleSkipperin interfaceServiceManager- Returns:
- service schedule skipper
-