com.atlassian.jira.service
Class JiraServiceContainer

java.lang.Object
  |
  +--com.atlassian.jira.service.JiraServiceContainer
All Implemented Interfaces:
JiraService, com.atlassian.configurable.ObjectConfigurable

public class JiraServiceContainer
extends java.lang.Object
implements JiraService

Proxies calls to JiraService & manages delay between calls.


Constructor Summary
JiraServiceContainer(JiraService service)
           
 
Method Summary
 void destroy()
          This method is called when the service is unloaded (usually when the web application or server is being shut down).
 java.lang.String[] getAcceptedParams()
          Deprecated.  
 java.lang.String getDefaultProperty(java.lang.String propertyKey)
           
 long getDelay()
          The length of delay in milliseconds between runs of this service.
 java.lang.String getDescription()
          A textual description of the service.
 long getLastRun()
          The time that this service was last run.
 com.atlassian.configurable.ObjectConfiguration getObjectConfiguration()
           
 com.opensymphony.module.propertyset.PropertySet getProperties()
           
 java.lang.String getProperty(java.lang.String propertyKey)
           
 boolean hasProperty(java.lang.String propertyKey)
           
 void init(com.opensymphony.module.propertyset.PropertySet props)
          Initialise the service.
 boolean isInternal()
          Indicates whether administrators can delete this service from within the web interface.
 boolean isRunning()
          Whether a service is currently running.
 boolean isUnique()
          Whether this service class should be unique.
 void run()
          Perform the action of this service.
 void setDelay(long delay)
          Sets the delay between invocation of each service.
 void setLastRun()
          Set the last run time to be the current time.
 void setRunning(boolean running)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JiraServiceContainer

public JiraServiceContainer(JiraService service)
Method Detail

init

public void init(com.opensymphony.module.propertyset.PropertySet props)
          throws com.atlassian.configurable.ObjectConfigurationException
Description copied from interface: JiraService
Initialise the service. This method is guaranteed to be called before the first call to run().

As the parameters are gained from the user's interaction with the website, it is not guaranteed to be called with the correct, or indeed with any parameters.

init() may be called multiple times during the services lifetime.

Specified by:
init in interface JiraService
com.atlassian.configurable.ObjectConfigurationException

getAcceptedParams

public java.lang.String[] getAcceptedParams()
Deprecated.  


run

public void run()
Perform the action of this service. The caller of this method assumes that no housekeeping has been done, and will call setLastRun() after the run() method.

init() is guaranteed to be called before run(), but the parameters passed to init() are not guaranteed to be correct. Any parameters expected to be set by init() should be checked in this method upon each invocation.

Specified by:
run in interface JiraService
See Also:
JiraService.init(com.opensymphony.module.propertyset.PropertySet)

destroy

public void destroy()
This method is called when the service is unloaded (usually when the web application or server is being shut down).

You may wish to remove any connections that you have established, eg. database connections.

Specified by:
destroy in interface JiraService

isInternal

public boolean isInternal()
Indicates whether administrators can delete this service from within the web interface.

Generally only Atlassian services should return true from this.

Specified by:
isInternal in interface JiraService

getLastRun

public final long getLastRun()
The time that this service was last run. Generally this is called after the service has executed, to ensure that there is X delay between finish of previous run & start of the next one.

Returns:
The time in milliseconds that this service was last run.

setLastRun

public final void setLastRun()
Set the last run time to be the current time. As we do not assume that users will call this in their run method, all code that calls run() should also call this afterwards.

See Also:
run()

setDelay

public void setDelay(long delay)
Sets the delay between invocation of each service.

Parameters:
delay - The time in milliseconds between runs of the service.

getDelay

public long getDelay()
The length of delay in milliseconds between runs of this service.


isUnique

public boolean isUnique()
Description copied from interface: JiraService
Whether this service class should be unique. Some service are fine to have multiples, and some are not.

Having multiple backup services could be fine - perhaps you want to backup once an hour, and also once a day.

With other services, you may wish to enforce their uniqueness

Specified by:
isUnique in interface JiraService
Returns:
Whether this service class should be unique.

getDescription

public java.lang.String getDescription()
Description copied from interface: JiraService
A textual description of the service. You can include HTML if required, but do not use tables, or DHTML, as the description may be displayed inside tables / frames.

A good description will describe what this service does, and then explains the parameters required for configuring the service.

If no description is appropriate, return null.

Specified by:
getDescription in interface JiraService
Returns:
A HTML description of the service

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getObjectConfiguration

public com.atlassian.configurable.ObjectConfiguration getObjectConfiguration()
                                                                      throws com.atlassian.configurable.ObjectConfigurationException
Specified by:
getObjectConfiguration in interface com.atlassian.configurable.ObjectConfigurable
com.atlassian.configurable.ObjectConfigurationException

hasProperty

public boolean hasProperty(java.lang.String propertyKey)
                    throws com.atlassian.configurable.ObjectConfigurationException
Specified by:
hasProperty in interface com.atlassian.configurable.ObjectConfigurable
com.atlassian.configurable.ObjectConfigurationException

getProperty

public java.lang.String getProperty(java.lang.String propertyKey)
                             throws com.atlassian.configurable.ObjectConfigurationException
Specified by:
getProperty in interface com.atlassian.configurable.ObjectConfigurable
com.atlassian.configurable.ObjectConfigurationException

getDefaultProperty

public java.lang.String getDefaultProperty(java.lang.String propertyKey)
                                    throws com.atlassian.configurable.ObjectConfigurationException
Specified by:
getDefaultProperty in interface com.atlassian.configurable.ObjectConfigurable
com.atlassian.configurable.ObjectConfigurationException

getProperties

public com.opensymphony.module.propertyset.PropertySet getProperties()
                                                              throws com.atlassian.configurable.ObjectConfigurationException
Specified by:
getProperties in interface com.atlassian.configurable.ObjectConfigurable
com.atlassian.configurable.ObjectConfigurationException

isRunning

public boolean isRunning()
Whether a service is currently running. This is needed for services that may potentially run for longer than their delay period. Eg a service that is run every minute, but takes 2 mins to run.


setRunning

public void setRunning(boolean running)


Copyright © 2002-2003 Atlassian. All Rights Reserved.