public class DefaultServiceManager extends Object implements ServiceManager, Startable
ServiceManager.ServiceScheduleSkipper
SERVICE_ID_KEY
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
JiraServiceContainer |
addService(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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
addService(String name,
String serviceClassName,
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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.
|
JiraServiceContainer |
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 |
containsServiceWithId(Long id)
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 |
editService(Long id,
String cronExpression,
Map<String,String[]> params)
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 |
editServiceByName(String name,
String cronExpression,
Map<String,String[]> params)
This will update the service if a service by this name can be found.
|
ServiceManager.ServiceScheduleSkipper |
getScheduleSkipper()
Returns service schedule skipper
|
Collection<JiraServiceContainer> |
getServices()
This gets all currently registered services with JIRA.
|
Iterable<JiraServiceContainer> |
getServicesForExecution(long time)
Gets the services that are ready for execution at a particular time.
|
Iterable<JiraServiceContainer> |
getServicesManageableBy(ApplicationUser user)
Gets the services that can be managed by an specific user.
|
JiraServiceContainer |
getServiceWithId(Long id)
This will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.
|
JiraServiceContainer |
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 |
refreshAll()
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.
|
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)
public void start()
Startable
@EventListener public void onClearCache(ClearCacheEvent event)
public Collection<JiraServiceContainer> getServices()
ServiceManager
getServices
in interface ServiceManager
public Iterable<JiraServiceContainer> getServicesManageableBy(ApplicationUser user)
ServiceManager
getServicesManageableBy
in interface ServiceManager
user
- The user in play.public void runNow(long serviceId) throws Exception
ServiceManager
runNow
in interface ServiceManager
Exception
public Iterable<JiraServiceContainer> getServicesForExecution(long time)
ServiceManager
getServicesForExecution
in interface ServiceManager
time
- the time to check for due services.public boolean containsServiceWithId(Long id)
ServiceManager
containsServiceWithId
in interface ServiceManager
id
- service idpublic void refreshAll()
ServiceManager
refreshAll
in interface ServiceManager
public JiraServiceContainer getServiceWithId(Long id)
ServiceManager
getServiceWithId
in interface ServiceManager
id
- service id@Nullable public JiraServiceContainer getServiceWithName(String name)
ServiceManager
getServiceWithName
in interface ServiceManager
name
- the name of the JiraServiceContainerpublic JiraServiceContainer addService(String name, String serviceClassName, long delay) throws ServiceException, ClassNotFoundException
ServiceManager
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.
addService
in interface ServiceManager
name
- the key this service is to be known byserviceClassName
- the class defining the servicedelay
- how often the service should run in millisecondsServiceException
- If there is an error creating the Service.ClassNotFoundException
- If the className could not be resolved.ServiceManager.addService(String, Class, long)
,
ServiceManager.addService(String, String, long, java.util.Map)
public JiraServiceContainer addService(String name, String serviceClassName, long delay, Map<String,String[]> params) throws ServiceException, ClassNotFoundException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ClassNotFoundException
- If the className could not be resolved.ServiceManager.addService(String, Class, long, java.util.Map)
,
ServiceManager.addService(String, String, long)
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, long delay) throws ServiceException
ServiceManager
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.
addService
in interface ServiceManager
name
- the key this service is to be known byserviceClass
- the class defining the servicedelay
- how often the service should run in millisecondsServiceException
- If there is an error creating the Service.ServiceManager.addService(String, String, long)
,
ServiceManager.addService(String, Class, long, java.util.Map)
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, long delay, Map<String,String[]> params) throws ServiceException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ServiceManager.addService(String, String, long, java.util.Map)
,
ServiceManager.addService(String, Class, long)
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression) throws ServiceException, ClassNotFoundException
ServiceManager
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.
addService
in interface ServiceManager
name
- the key this service is to be known byserviceClassName
- the class defining the servicecronExpression
- how the service should be scheduledServiceException
- If there is an error creating the Service.ClassNotFoundException
- If the className could not be resolved.ServiceManager.addService(String, Class, String)
,
ServiceManager.addService(String, String, String, java.util.Map)
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression) throws ServiceException
ServiceManager
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.
addService
in interface ServiceManager
name
- the key this service is to be known byserviceClass
- the class defining the servicecronExpression
- how the service should be scheduledServiceException
- If there is an error creating the Service.ServiceManager.addService(String, String, String)
,
ServiceManager.addService(String, Class, String, java.util.Map)
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression, Map<String,String[]> params) throws ServiceException, ClassNotFoundException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ClassNotFoundException
- If the className could not be resolved.ServiceManager.addService(String, Class, String, java.util.Map)
,
ServiceManager.addService(String, String, String)
public JiraServiceContainer addService(String name, String serviceClassName, String cronExpression, long delay, Map<String,String[]> params) throws ServiceException, ClassNotFoundException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ClassNotFoundException
- If the className could not be resolved.ServiceManager.addService(String, Class, String, java.util.Map)
,
ServiceManager.addService(String, String, String)
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, @Nullable Map<String,String[]> params) throws ServiceException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ServiceManager.addService(String, String, String, java.util.Map)
,
ServiceManager.addService(String, Class, String)
public JiraServiceContainer addService(String name, Class<? extends JiraService> serviceClass, String cronExpression, long delay, @Nullable Map<String,String[]> params) throws ServiceException
ServiceManager
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.
addService
in interface ServiceManager
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 serviceServiceException
- If there is an error creating the Service.ServiceManager.addService(String, String, String, java.util.Map)
,
ServiceManager.addService(String, Class, String)
public void editServiceByName(String name, long delay, Map<String,String[]> params) throws Exception
ServiceManager
editServiceByName
in interface ServiceManager
name
- the name of the service to find.delay
- the delay to set on the service in millisecondsparams
- the params to set on the serviceIllegalArgumentException
- if the name can not be resolvedException
public void editService(Long id, long delay, Map<String,String[]> params) throws Exception
ServiceManager
editService
in interface ServiceManager
id
- the id of the service to find.delay
- the delay to set on the service in millisecondsparams
- the params to set on the serviceException
- if there is a problem updating the valuepublic void editServiceByName(String name, String cronExpression, Map<String,String[]> params) throws Exception
ServiceManager
editServiceByName
in interface ServiceManager
name
- the name of the service to find.cronExpression
- how the service should be scheduledparams
- the params to set on the serviceIllegalArgumentException
- if the name can not be resolvedException
public void editService(Long id, String cronExpression, Map<String,String[]> params) throws Exception
ServiceManager
editService
in interface ServiceManager
id
- the id of the service to find.cronExpression
- how the service should be scheduledparams
- the params to set on the serviceException
- if there is a problem updating the valuepublic void removeServiceByName(String name) throws Exception
ServiceManager
removeServiceByName
in interface ServiceManager
name
- the name of the service to find.IllegalArgumentException
- if the name can not be resolvedException
public void removeService(Long id) throws Exception
ServiceManager
removeService
in interface ServiceManager
id
- the id of the service to find.Exception
- if there is a problem removing the servicepublic void refreshService(Long id) throws Exception
ServiceManager
refreshService
in interface ServiceManager
id
- the id of the service to find.Exception
- if the value can not be refreshedpublic void refreshServiceByName(String name) throws Exception
ServiceManager
refreshServiceByName
in interface ServiceManager
name
- the name of the service to find.IllegalArgumentException
- if the name can not be resolvedException
public ServiceManager.ServiceScheduleSkipper getScheduleSkipper()
getScheduleSkipper
in interface ServiceManager
Copyright © 2002-2019 Atlassian. All Rights Reserved.