org.springframework.batch.admin.launch
Class JobLauncherSynchronizer

java.lang.Object
  extended by org.springframework.batch.admin.launch.JobLauncherSynchronizer
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

@ManagedResource
public class JobLauncherSynchronizer
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean

Wrapper for a JobLauncher that synchronizes jobs globally so that only one execution of a given Job can be active at once.

Author:
Dave Syer

Constructor Summary
JobLauncherSynchronizer()
           
 
Method Summary
 void addJobName(java.lang.String jobName)
          A job name that will be synchronized.
 void afterPropertiesSet()
           
 void checkJobBeforeLaunch(org.springframework.batch.core.Job job)
           
 void checkJobDuringLaunch(java.lang.String jobName, org.springframework.batch.core.JobExecution jobExecution)
           
 java.util.Set<java.lang.String> getJobNames()
           
 void removeJobName(java.lang.String jobName)
          Remove a job name from the list to synchronize.
 void setJobExplorer(org.springframework.batch.core.explore.JobExplorer jobExplorer)
          The JobExplorer to use to inspect existing executions.
 void setJobNames(java.util.Set<java.lang.String> jobNames)
          Set of job names that will be synchronized.
 void setJobRepository(org.springframework.batch.core.repository.JobRepository jobRepository)
          The JobRepository needed for updates to execution data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobLauncherSynchronizer

public JobLauncherSynchronizer()
Method Detail

setJobExplorer

public void setJobExplorer(org.springframework.batch.core.explore.JobExplorer jobExplorer)
The JobExplorer to use to inspect existing executions.

Parameters:
jobExplorer - a JobExplorer

setJobRepository

public void setJobRepository(org.springframework.batch.core.repository.JobRepository jobRepository)
The JobRepository needed for updates to execution data.

Parameters:
jobRepository - a JobRepository

setJobNames

public void setJobNames(java.util.Set<java.lang.String> jobNames)
Set of job names that will be synchronized. Others are ignored.

Parameters:
jobNames - the job names

addJobName

@ManagedOperation
public void addJobName(java.lang.String jobName)
A job name that will be synchronized.

Parameters:
jobName - the job name

removeJobName

@ManagedOperation
public void removeJobName(java.lang.String jobName)
Remove a job name from the list to synchronize.

Parameters:
jobName - the job name

getJobNames

@ManagedAttribute
public java.util.Set<java.lang.String> getJobNames()
Returns:
the jobNames

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

checkJobBeforeLaunch

public void checkJobBeforeLaunch(org.springframework.batch.core.Job job)
                          throws org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
Throws:
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException

checkJobDuringLaunch

public void checkJobDuringLaunch(java.lang.String jobName,
                                 org.springframework.batch.core.JobExecution jobExecution)
                          throws org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
Throws:
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException


Copyright © 2011. All Rights Reserved.