com.atlassian.jira.service
Class DefaultServiceManager

java.lang.Object
  extended by com.atlassian.jira.service.DefaultServiceManager
All Implemented Interfaces:
JiraManager, ServiceManager

public class DefaultServiceManager
extends Object
implements ServiceManager


Nested Class Summary
protected static class DefaultServiceManager.ServiceScheduleSkipperImpl
          Implementation of ServiceScheduleSkipper that has synchronized access.
 
Nested classes/interfaces inherited from interface com.atlassian.jira.service.ServiceManager
ServiceManager.ServiceScheduleSkipper
 
Constructor Summary
DefaultServiceManager(ServiceConfigStore serviceConfigStore, ComponentClassManager componentClassManager, PermissionManager permissionManager, InBuiltServiceTypes inBuiltServiceTypes)
           
 
Method Summary
 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, 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.
 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 editServiceByName(String name, long delay, 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(com.atlassian.crowd.embedded.api.User 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceManager

public DefaultServiceManager(ServiceConfigStore serviceConfigStore,
                             ComponentClassManager componentClassManager,
                             PermissionManager permissionManager,
                             InBuiltServiceTypes inBuiltServiceTypes)
Method Detail

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

getServices

public Collection<JiraServiceContainer> 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 interface ServiceManager
Returns:
an unmodifiable Collection with JiraServiceContainers as the value

getServicesManageableBy

public Iterable<JiraServiceContainer> getServicesManageableBy(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: ServiceManager
Gets the services that can be managed by an specific user.

Specified by:
getServicesManageableBy in interface ServiceManager
Parameters:
user - The user in play.
Returns:
A collection of services.

getServicesForExecution

public Iterable<JiraServiceContainer> getServicesForExecution(long time)
Description copied from interface: ServiceManager
Gets the services that are ready for execution at a particular time.

Specified by:
getServicesForExecution in interface ServiceManager
Parameters:
time - the time to check for due services.
Returns:
an immutable collection of services.

containsServiceWithId

public boolean containsServiceWithId(Long id)
Description copied from interface: ServiceManager
Quick way of telling whether a service with a specific id is registered or not.

Specified by:
containsServiceWithId in interface ServiceManager
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 interface ServiceManager

getServiceWithId

public JiraServiceContainer getServiceWithId(Long id)
                                      throws Exception
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 interface ServiceManager
Parameters:
id - service id
Returns:
a JiraServiceContainer that is represented by the unique id.
Throws:
Exception - if there is a problem looking up the value in the db.

getServiceWithName

public JiraServiceContainer getServiceWithName(String name)
                                        throws Exception
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 interface ServiceManager
Parameters:
name - the name of the JiraServiceContainer
Returns:
a JiraServiceContainer if it is registered otherwise null
Throws:
Exception - if there is a problem looking up the value in the db.

addService

public JiraServiceContainer addService(String name,
                                       String serviceClassName,
                                       long delay)
                                throws org.ofbiz.core.entity.GenericEntityException,
                                       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 interface ServiceManager
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
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB error.
ServiceException - If there is an error creating the Service.
ClassNotFoundException - If the className could not be resolved.
See Also:
ServiceManager.addService(String, Class, long), ServiceManager.addService(String, String, long, java.util.Map)

addService

public JiraServiceContainer addService(String name,
                                       String serviceClassName,
                                       long delay,
                                       Map<String,String[]> params)
                                throws org.ofbiz.core.entity.GenericEntityException,
                                       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 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 interface ServiceManager
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
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a Db error.
ServiceException - If there is an error creating the Service.
ClassNotFoundException - If the className could not be resolved.
See Also:
ServiceManager.addService(String, Class, long, java.util.Map), ServiceManager.addService(String, String, long)

addService

public JiraServiceContainer addService(String name,
                                       Class<? extends JiraService> serviceClass,
                                       long delay)
                                throws org.ofbiz.core.entity.GenericEntityException,
                                       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 interface ServiceManager
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
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB error.
ServiceException - If there is an error creating the Service.
See Also:
ServiceManager.addService(String, String, long), ServiceManager.addService(String, Class, long, java.util.Map)

addService

public JiraServiceContainer addService(String name,
                                       Class<? extends JiraService> serviceClass,
                                       long delay,
                                       Map<String,String[]> params)
                                throws org.ofbiz.core.entity.GenericEntityException,
                                       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 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 interface ServiceManager
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
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a Db error.
ServiceException - If there is an error creating the Service.
See Also:
ServiceManager.addService(String, String, long, java.util.Map), ServiceManager.addService(String, Class, long)

editServiceByName

public void editServiceByName(String name,
                              long delay,
                              Map<String,String[]> params)
                       throws Exception
Description 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 interface ServiceManager
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:
IllegalArgumentException - if the name can not be resolved
Exception

editService

public void editService(Long id,
                        long delay,
                        Map<String,String[]> params)
                 throws Exception
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 interface ServiceManager
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 - if there is a problem updating the value

removeServiceByName

public void removeServiceByName(String name)
                         throws Exception
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 interface ServiceManager
Parameters:
name - the name of the service to find.
Throws:
IllegalArgumentException - if the name can not be resolved
Exception

removeService

public void removeService(Long id)
                   throws Exception
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 interface ServiceManager
Parameters:
id - the id of the service to find.
Throws:
Exception - if there is a problem removing the service

refreshService

public void refreshService(Long id)
                    throws Exception
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 interface ServiceManager
Parameters:
id - the id of the service to find.
Throws:
Exception - if the value can not be refreshed

refreshServiceByName

public void refreshServiceByName(String name)
                          throws Exception
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 interface ServiceManager
Parameters:
name - the name of the service to find.
Throws:
IllegalArgumentException - if the name can not be resolved
Exception

getScheduleSkipper

public ServiceManager.ServiceScheduleSkipper getScheduleSkipper()
Returns service schedule skipper

Specified by:
getScheduleSkipper in interface ServiceManager
Returns:
service schedule skipper
Since:
v3.10


Copyright © 2002-2012 Atlassian. All Rights Reserved.