Class DefaultServiceManager
- All Implemented Interfaces:
Startable
,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.boolean
Quick way of telling whether a service with a specific id is registered or not.void
editService
(Long id, long delay, Map<String, String[]> params) This will update the service if a service with this id can be found.void
This will update the service if a service with this id can be found.void
editServiceByName
(String name, long delay, Map<String, String[]> params) This will update the service if a service by this name can be found.void
This 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.void
onClearCache
(ClearCacheEvent event) void
This will force a complete re-sync of the service cache with the values stored in the db.void
refreshService
(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.void
refreshServiceByName
(String name) This will update the in-memory cache with the values from the db for the named service if it can be resolved.void
removeService
(Long id) This will remove a service from the db and cache and it will try to resolve the service by id.void
removeServiceByName
(String name) This will remove a service from the db and cache and it will try to resolve the service by name.void
runNow
(long serviceId) Runs the service immediately.void
start()
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
-
start
public void start()Description copied from interface:Startable
This 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:ServiceManager
This 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:
getServices
in interfaceServiceManager
- Returns:
- an unmodifiable Collection with JiraServiceContainers as the value
-
getServicesManageableBy
Description copied from interface:ServiceManager
Gets the services that can be managed by an specific user.- Specified by:
getServicesManageableBy
in interfaceServiceManager
- Parameters:
user
- The user in play.- Returns:
- A collection of services.
-
runNow
Description copied from interface:ServiceManager
Runs 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:
runNow
in interfaceServiceManager
- Throws:
Exception
-
getServicesForExecution
Description copied from interface:ServiceManager
Gets the services that are ready for execution at a particular time.- Specified by:
getServicesForExecution
in interfaceServiceManager
- Parameters:
time
- the time to check for due services.- Returns:
- an immutable collection of services.
-
containsServiceWithId
Description copied from interface:ServiceManager
Quick way of telling whether a service with a specific id is registered or not.- Specified by:
containsServiceWithId
in interfaceServiceManager
- Parameters:
id
- service id- Returns:
- true if the service with the id is registered
-
refreshAll
public void refreshAll()Description copied from interface:ServiceManager
This will force a complete re-sync of the service cache with the values stored in the db.- Specified by:
refreshAll
in interfaceServiceManager
-
getServiceWithId
Description copied from interface:ServiceManager
This will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.- Specified by:
getServiceWithId
in interfaceServiceManager
- Parameters:
id
- service id- Returns:
- a JiraServiceContainer that is represented by the unique id.
-
getServiceWithName
Description copied from interface:ServiceManager
This will return a JiraServiceContainer for the provided name if one is registered, otherwise this will return null.- Specified by:
getServiceWithName
in 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:ServiceManager
This 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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
This 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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
This 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:
addService
in 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:ServiceManager
This 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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
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.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:
addService
in 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:ServiceManager
This will update the service if a service by this name can be found. The delay and the params will be updated.- Specified by:
editServiceByName
in 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:
IllegalArgumentException
- if the name can not be resolvedException
-
editService
Description copied from interface:ServiceManager
This will update the service if a service with this id can be found. The delay and the params will be updated.- Specified by:
editService
in 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:ServiceManager
This will update the service if a service by this name can be found. The cronExpression and the params will be updated.- Specified by:
editServiceByName
in 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:
IllegalArgumentException
- if the name can not be resolvedException
-
editService
public void editService(Long id, String cronExpression, Map<String, String[]> params) throws ExceptionDescription copied from interface:ServiceManager
This will update the service if a service with this id can be found. The cronExpression and the params will be updated.- Specified by:
editService
in 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:ServiceManager
This will remove a service from the db and cache and it will try to resolve the service by name.- Specified by:
removeServiceByName
in interfaceServiceManager
- Parameters:
name
- the name of the service to find.- Throws:
IllegalArgumentException
- if the name can not be resolvedException
-
removeService
Description copied from interface:ServiceManager
This will remove a service from the db and cache and it will try to resolve the service by id.- Specified by:
removeService
in 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:ServiceManager
This 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:
refreshService
in interfaceServiceManager
- Parameters:
id
- the id of the service to find.- Throws:
Exception
- if the value can not be refreshed
-
refreshServiceByName
Description copied from interface:ServiceManager
This will update the in-memory cache with the values from the db for the named service if it can be resolved.- Specified by:
refreshServiceByName
in interfaceServiceManager
- Parameters:
name
- the name of the service to find.- Throws:
IllegalArgumentException
- if the name can not be resolvedException
-
getScheduleSkipper
Returns service schedule skipper- Specified by:
getScheduleSkipper
in interfaceServiceManager
- Returns:
- service schedule skipper
-