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


Constructor Summary
DefaultServiceManager(ServiceConfigStore serviceConfigStore)
           
 
Method Summary
 JiraServiceContainer addService(String name, String clazz, 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 clazz, long delay, Map 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 params)
          This will update the service if a service with this id can be found.
 void editServiceByName(String name, long delay, Map params)
          This will update the service if a service by this name can be found.
 Collection getServices()
          This gets all currently registered services with JIRA.
 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 returna JiraServiceContainer for the provided name if one is registered, otherwise this will return null.
 void refreshAll()
          This will force a complete re-synch 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)
Method Detail

getServices

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

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
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-synch 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
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 returna 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 clazz,
                                       long delay)
                                throws Exception
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.

Specified by:
addService in interface ServiceManager
Parameters:
name - the key this service is to be known by
clazz - the class defining the service
delay - how often the service should run in milliseconds
Returns:
the JiraServiceContainer that was just created
Throws:
Exception - if there is a problem creating the service

addService

public JiraServiceContainer addService(String name,
                                       String clazz,
                                       long delay,
                                       Map params)
                                throws Exception
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.

Specified by:
addService in interface ServiceManager
Parameters:
name - the key this service is to be known by
clazz - 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:
Exception - if there is a problem creating the service

editServiceByName

public void editServiceByName(String name,
                              long delay,
                              Map 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 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


Copyright © 2002-2007 Atlassian. All Rights Reserved.