IN PROGRESS - issue BATCH-159: JobExecutor should return a JobExecution (which itself contains the ExitStatus)

http://opensource.atlassian.com/projects/spring/browse/BATCH-159

Merged JobLauncher implementations together and separated out thread interruption and JMX notification responsibilities to separate collaborators.
This commit is contained in:
dsyer
2007-10-24 17:34:32 +00:00
parent 63c78f629a
commit 48c5ddc41e
5 changed files with 0 additions and 207 deletions

View File

@@ -1,51 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.executor;
import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.io.exception.BatchCriticalException;
import org.springframework.batch.repeat.ExitStatus;
/**
* Support class with empty implementations of interface methods.
*
* @author Dave Syer
*
*/
public abstract class AbstractJobExecutor implements JobExecutor {
/**
* Wraps a call to {@link #run(JobConfiguration, JobExecution)} with a call
* to the listener's before and after methods. The after listener is also
* executed in a finally block.
*
* @see org.springframework.batch.core.executor.JobExecutor#run(org.springframework.batch.core.configuration.JobConfiguration,
* org.springframework.batch.core.domain.JobExecution,
* org.springframework.batch.core.executor.JobExecutionListener)
*/
public final ExitStatus run(JobConfiguration configuration,
JobExecution execution, JobExecutionListener listener)
throws BatchCriticalException {
listener.before(execution);
try {
return this.run(configuration, execution);
} finally {
listener.after(execution);
}
}
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.executor;
import org.springframework.batch.core.domain.JobExecution;
/**
* Listener interface for the job execution lifecycle.
*
* @author Dave Syer
*
*/
public interface JobExecutionListener {
/**
* Callback for the start of a job, before any steps are processed.
*
* @param execution
* the current {@link JobExecution}
*/
void before(JobExecution execution);
/**
* Callback for the start of a job, after all steps are processed, or on an
* error.
*
* @param execution
*/
void after(JobExecution execution);
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.executor;
import org.springframework.batch.core.domain.JobExecution;
/**
* Simple no-op implementation of {@link JobExecutionListener} which does
* nothing.
*
* @author Dave Syer
*
*/
public class JobExecutionListenerSupport implements JobExecutionListener {
/**
* No-op for subclasses to extend.
*
* @see org.springframework.batch.core.executor.JobExecutionListener#after(org.springframework.batch.core.domain.JobExecution)
*/
public void after(JobExecution execution) {
// no-op
}
/**
* No-op for subclasses to extend.
*
* @see org.springframework.batch.core.executor.JobExecutionListener#before(org.springframework.batch.core.domain.JobExecution)
*/
public void before(JobExecution execution) {
// no-op
}
}

View File

@@ -33,5 +33,4 @@ public interface JobExecutor {
public ExitStatus run(JobConfiguration configuration, JobExecution execution) throws BatchCriticalException;
public ExitStatus run(JobConfiguration configuration, JobExecution execution, JobExecutionListener listener) throws BatchCriticalException;
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.executor;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.domain.JobExecution;
/**
* @author Dave Syer
*
*/
public class JobExecutionListenerSupportTests extends TestCase {
private List list = new ArrayList();
/**
* Test method for
* {@link org.springframework.batch.core.executor.JobExecutionListenerSupport#after(org.springframework.batch.core.domain.JobExecution)}.
*/
public void testAfter() {
JobExecutionListener listener = new JobExecutionListenerSupport() {
public void after(JobExecution execution) {
super.after(execution);
list.add("after");
}
};
listener.after(null);
assertEquals(1, list.size());
}
/**
* Test method for
* {@link org.springframework.batch.core.executor.JobExecutionListenerSupport#before(org.springframework.batch.core.domain.JobExecution)}.
*/
public void testBefore() {
JobExecutionListener listener = new JobExecutionListenerSupport() {
public void before(JobExecution execution) {
super.before(execution);
list.add("after");
}
};
listener.before(null);
assertEquals(1, list.size());
}
}