Class JiraServiceContainerImpl
- All Implemented Interfaces:
ObjectConfigurable,JiraService,JiraServiceContainer,Runnable
-
Field Summary
Fields inherited from interface com.atlassian.jira.service.JiraService
NAME_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()This method is called when the service is unloaded (usually when the web application or server is being shut down).Get the cron expression.getDefaultProperty(String propertyKey) Returns the default property value for a keylonggetDelay()The length of delay in milliseconds between runs of this service.A textual description of the service.getId()getKey()Return the key of this objectfinal longThe time that this service was last run.getLongProperty(String propertyKey) Returns a property of this object with the specified key as a longgetName()A textual name of the service as entered by the user from the web interface.Retrieves an object configuration object with properties that can be setcom.opensymphony.module.propertyset.PropertySetRetrieve all the specified Properties for this objectgetProperty(String propertyKey) Returns a property of this object with the specified keyClass<? extends JiraService>getTextProperty(String propertyKey) Returns a property of this object with the specified key, the property is of type textbooleanhasProperty(String propertyKey) Checks if this object has a particular propertyvoidinit(com.opensymphony.module.propertyset.PropertySet props) Deprecated.voidinit(com.opensymphony.module.propertyset.PropertySet props, long configurationIdentifier) Initialise the service passing configuration identifier which is unique per configuration of the service.booleanisDueAt(long time) Is this service due to run at the specified time.booleanIndicates whether administrators can delete this service from within the web interface.booleanReturns true if in a clustered environment this service should run locally on every node.booleanWhether a service is currently running.booleanisUnique()Whether this service class should be unique.booleanisUsable()voidrun()Perform the action of this service.voidsetCronExpression(String cronExpression) Set the cron expression.voidsetDelay(long delay) Sets the delay between invocation of each service.final voidSet the last run time to be the current time.voidUsed to set the service's name.toString()
-
Constructor Details
-
JiraServiceContainerImpl
-
-
Method Details
-
init
public void init(com.opensymphony.module.propertyset.PropertySet props, long configurationIdentifier) throws ObjectConfigurationException Description copied from interface:JiraServiceInitialise the service passing configuration identifier which is unique per configuration of the service.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.
this method may be called multiple times during the services lifetime.
- Specified by:
initin interfaceJiraService- Parameters:
props- initialisation parametersconfigurationIdentifier- identifier of the configuration of the service- Throws:
ObjectConfigurationException- in case of an error with initialisation parameters
-
init
@Deprecated public void init(com.opensymphony.module.propertyset.PropertySet props) throws ObjectConfigurationException Deprecated.Description copied from interface:JiraServiceInitialise 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:
initin interfaceJiraService- Parameters:
props- initialisation parameters- Throws:
ObjectConfigurationException- in case of an error with initialisation parameters- See Also:
-
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:
runin interfaceJiraService- Specified by:
runin interfaceRunnable- See Also:
-
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:
destroyin interfaceJiraService
-
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:
isInternalin interfaceJiraService- Returns:
- true if this service is internal to JIRA, false otherwise
-
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.- Specified by:
getLastRunin interfaceJiraServiceContainer- 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.- Specified by:
setLastRunin interfaceJiraServiceContainer- See Also:
-
setDelay
public void setDelay(long delay) Sets the delay between invocation of each service.- Specified by:
setDelayin interfaceJiraServiceContainer- 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.- Specified by:
getDelayin interfaceJiraServiceContainer- Returns:
- the interval delay for scheduling the service
-
getCronExpression
Description copied from interface:JiraServiceContainerGet the cron expression.- Specified by:
getCronExpressionin interfaceJiraServiceContainer- Returns:
- cron Cron Expression
-
setCronExpression
Description copied from interface:JiraServiceContainerSet the cron expression.- Specified by:
setCronExpressionin interfaceJiraServiceContainer- Parameters:
cronExpression- Cron Expression
-
isDueAt
public boolean isDueAt(long time) Description copied from interface:JiraServiceContainerIs this service due to run at the specified time.- Specified by:
isDueAtin interfaceJiraServiceContainer- Parameters:
time- the time to check whether it is due.- Returns:
- true if due.
-
isUnique
public boolean isUnique()Description copied from interface:JiraServiceWhether 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:
isUniquein interfaceJiraService- Returns:
- Whether this service class should be unique.
-
getDescription
Description copied from interface:JiraServiceA 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:
getDescriptionin interfaceJiraService- Returns:
- A HTML description of the service
-
getName
Description copied from interface:JiraServiceA textual name of the service as entered by the user from the web interface.The name should be unique to identify services of the same class.
This is enforced when adding new services via the web interface.The value of name does not effect the service, hence can be set to null
- Specified by:
getNamein interfaceJiraService- Returns:
- The name of the service
-
setName
Description copied from interface:JiraServiceUsed to set the service's name. For details on the services name seeJiraService.getName()- Specified by:
setNamein interfaceJiraService- Parameters:
name- service name to set
-
getObjectConfiguration
Description copied from interface:ObjectConfigurableRetrieves an object configuration object with properties that can be set- Specified by:
getObjectConfigurationin interfaceObjectConfigurable- Returns:
- ObjectConfiguration object
- Throws:
ObjectConfigurationException
-
hasProperty
Description copied from interface:ObjectConfigurableChecks if this object has a particular property- Specified by:
hasPropertyin interfaceObjectConfigurable- Parameters:
propertyKey- to look for- Returns:
- true If there is a value
- Throws:
ObjectConfigurationException
-
getProperty
Description copied from interface:ObjectConfigurableReturns a property of this object with the specified key- Specified by:
getPropertyin interfaceObjectConfigurable- Parameters:
propertyKey- String key used to retrieve the property value- Returns:
- Property value
- Throws:
ObjectConfigurationException
-
getTextProperty
Description copied from interface:ObjectConfigurableReturns a property of this object with the specified key, the property is of type text- Specified by:
getTextPropertyin interfaceObjectConfigurable- Parameters:
propertyKey- String key used to retrieve the property value- Returns:
- Property value
- Throws:
ObjectConfigurationException
-
getLongProperty
Description copied from interface:ObjectConfigurableReturns a property of this object with the specified key as a long- Specified by:
getLongPropertyin interfaceObjectConfigurable- Parameters:
propertyKey- String key used to retrieve the property value- Returns:
- Property value
- Throws:
ObjectConfigurationException
-
getDefaultProperty
Description copied from interface:ObjectConfigurableReturns the default property value for a key- Specified by:
getDefaultPropertyin interfaceObjectConfigurable- Parameters:
propertyKey- String key used to retrieve the properties default value- Returns:
- Default property key
- Throws:
ObjectConfigurationException
-
getProperties
public com.opensymphony.module.propertyset.PropertySet getProperties() throws ObjectConfigurationExceptionDescription copied from interface:ObjectConfigurableRetrieve all the specified Properties for this object- Specified by:
getPropertiesin interfaceObjectConfigurable- Returns:
- Set of properties for this object
- Throws:
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.- Specified by:
isRunningin interfaceJiraServiceContainer
-
getKey
Description copied from interface:ObjectConfigurableReturn the key of this object- Specified by:
getKeyin interfaceObjectConfigurable- Returns:
- Key of object
-
getId
- Specified by:
getIdin interfaceJiraServiceContainer
-
getServiceClass
- Specified by:
getServiceClassin interfaceJiraServiceContainer
-
getServiceClassObject
- Specified by:
getServiceClassObjectin interfaceJiraServiceContainer- Returns:
- the Class object of the underlying service, or null if service could not be loaded
-
isUsable
public boolean isUsable()- Specified by:
isUsablein interfaceJiraServiceContainer
-
isLocalService
public boolean isLocalService()Description copied from interface:JiraServiceContainerReturns true if in a clustered environment this service should run locally on every node.- Specified by:
isLocalServicein interfaceJiraServiceContainer- Returns:
- true if in a clustered environment this service should run locally on every node.
-
toString
-