public class

DefaultServiceManager

extends Object
implements Startable ServiceManager
java.lang.Object
   ↳ com.atlassian.jira.service.DefaultServiceManager

Summary

[Expand]
Inherited Fields
From interface com.atlassian.jira.service.ServiceManager
Public Constructors
DefaultServiceManager(ServiceConfigStore serviceConfigStore, ComponentClassManager componentClassManager, PermissionManager permissionManager, InBuiltServiceTypes inBuiltServiceTypes, SchedulerService schedulerService, CacheManager cacheManager, ClusterLockService clusterLockService, ClusterMessagingService messagingService)
Public Methods
JiraServiceContainer addService(String name, String serviceClassName, long delay, Map<StringString[]> 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, 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<StringString[]> 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<StringString[]> params)
This will update the service if a service with this id can be found.
void editServiceByName(String name, long delay, Map<StringString[]> params)
This will update the service if a service by this name can be found.
ServiceManager.ServiceScheduleSkipper getScheduleSkipper()
Returns service schedule skipper
JiraServiceContainer getServiceWithId(Long id)
This will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.
@Nullable JiraServiceContainer getServiceWithName(String name)
This will return a JiraServiceContainer for the provided name if one is registered, otherwise this will return null.
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(User user)
Gets the services that can be managed by an specific user.
@EventListener 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 wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.extension.Startable
From interface com.atlassian.jira.service.ServiceManager

Public Constructors

public DefaultServiceManager (ServiceConfigStore serviceConfigStore, ComponentClassManager componentClassManager, PermissionManager permissionManager, InBuiltServiceTypes inBuiltServiceTypes, SchedulerService schedulerService, CacheManager cacheManager, ClusterLockService clusterLockService, ClusterMessagingService messagingService)

Public Methods

public JiraServiceContainer addService (String name, String serviceClassName, long delay, Map<StringString[]> 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.

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.

Parameters
name the key this service is to be known by
serviceClassName the class defining the service
delay how often the service should run in milliseconds
params Additional params to specify for the service
Returns
  • the JiraServiceContainer that was just created

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

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.

Parameters
name the key this service is to be known by
serviceClassName the class defining the service
delay how often the service should run in milliseconds
Returns
  • the JiraServiceContainer that was just created

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

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.

Parameters
name the key this service is to be known by
serviceClass the class defining the service
delay how often the service should run in milliseconds
Returns
  • the JiraServiceContainer that was just created

public JiraServiceContainer addService (String name, Class<? extends JiraService> serviceClass, long delay, Map<StringString[]> 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.

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.

Parameters
name the key this service is to be known by
serviceClass the class defining the service
delay how often the service should run in milliseconds
params Additional params to specify for the service
Returns
  • the JiraServiceContainer that was just created

public boolean containsServiceWithId (Long id)

Quick way of telling whether a service with a specific id is registered or not.

Parameters
id service id
Returns
  • true if the service with the id is registered

public void editService (Long id, long delay, Map<StringString[]> params)

This will update the service if a service with this id can be found. The delay and the params will be updated.

Parameters
id the id of the service to find.
delay the delay to set on the service in milliseconds
params the params to set on the service
Throws
Exception

public void editServiceByName (String name, long delay, Map<StringString[]> params)

This will update the service if a service by this name can be found. The delay and the params will be updated.

Parameters
name the name of the service to find.
delay the delay to set on the service in milliseconds
params the params to set on the service
Throws
Exception

public ServiceManager.ServiceScheduleSkipper getScheduleSkipper ()

Returns service schedule skipper

Returns
  • service schedule skipper

public JiraServiceContainer getServiceWithId (Long id)

This will return a JiraServiceContainer for the provided id if one is registered otherwise it will return null.

Parameters
id service id
Returns
  • a JiraServiceContainer that is represented by the unique id.
Throws
Exception

@Nullable public JiraServiceContainer getServiceWithName (String name)

This will return a JiraServiceContainer for the provided name if one is registered, otherwise this will return null.

Parameters
name the name of the JiraServiceContainer
Returns
  • a JiraServiceContainer if it is registered otherwise null
Throws
Exception

public Collection<JiraServiceContainer> getServices ()

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.

Returns
  • an unmodifiable Collection with JiraServiceContainers as the value

public Iterable<JiraServiceContainer> getServicesForExecution (long time)

Gets the services that are ready for execution at a particular time.

Parameters
time the time to check for due services.
Returns
  • an immutable collection of services.

public Iterable<JiraServiceContainer> getServicesManageableBy (User user)

Gets the services that can be managed by an specific user.

Parameters
user The user in play.
Returns
  • A collection of services.

@EventListener public void onClearCache (ClearCacheEvent event)

public void refreshAll ()

This will force a complete re-sync of the service cache with the values stored in the db.

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

Parameters
id the id of the service to find.
Throws
Exception

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

Parameters
name the name of the service to find.
Throws
Exception

public void removeService (Long id)

This will remove a service from the db and cache and it will try to resolve the service by id.

Parameters
id the id of the service to find.
Throws
Exception

public void removeServiceByName (String name)

This will remove a service from the db and cache and it will try to resolve the service by name.

Parameters
name the name of the service to find.
Throws
Exception

public void runNow (long serviceId)

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.

Throws
Exception

public void start ()

This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.