OPEN - issue BATCH-890, BATCH-879: Stop transition in XML namespace, decision state support.
Added StepExecution to decider interface and some protection for multithreaded job executions.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.flow;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface FlowExecutionListener {
|
||||
|
||||
/**
|
||||
* @param result
|
||||
*/
|
||||
void close(FlowExecution result);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.flow;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class FlowExecutionListenerSupport implements FlowExecutionListener {
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
* @see FlowExecutionListener#close(FlowExecution)
|
||||
*/
|
||||
public void close(FlowExecution result) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -111,21 +111,37 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
* @see Flow#resume(String, Object)
|
||||
*/
|
||||
public FlowExecution resume(String stateName, T context) throws FlowExecutionException {
|
||||
|
||||
String status = FlowExecution.UNKNOWN;
|
||||
State<T> state = stateMap.get(stateName);
|
||||
|
||||
FlowExecutionListener listener = new FlowExecutionListenerSupport();
|
||||
if (context instanceof FlowExecutionListener) {
|
||||
listener = (FlowExecutionListener)context;
|
||||
}
|
||||
|
||||
// Terminate if there are no more states
|
||||
while (state != null) {
|
||||
|
||||
stateName = state.getName();
|
||||
|
||||
try {
|
||||
status = state.handle(context);
|
||||
}
|
||||
catch (Exception e) {
|
||||
listener.close(new FlowExecution(stateName, status));
|
||||
throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name,
|
||||
stateName), e);
|
||||
}
|
||||
|
||||
state = nextState(stateName, status);
|
||||
|
||||
}
|
||||
return new FlowExecution(stateName, status);
|
||||
|
||||
FlowExecution result = new FlowExecution(stateName, status);
|
||||
listener.close(result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user