forked from WASdev/standards.jsr352.tck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Scott
committed
Aug 11, 2016
1 parent
b60b8ec
commit 008597c
Showing
5 changed files
with
275 additions
and
1 deletion.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...ch.tck/src/main/java/com/ibm/jbatch/tck/artifacts/specialized/ExecutionCountBatchlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2016 International Business Machines Corp. | ||
* | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. 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 com.ibm.jbatch.tck.artifacts.specialized; | ||
|
||
import javax.batch.api.AbstractBatchlet; | ||
import javax.batch.api.BatchProperty; | ||
import javax.batch.runtime.context.JobContext; | ||
import javax.inject.Inject; | ||
|
||
@javax.inject.Named("executionCountBatchlet") | ||
public class ExecutionCountBatchlet extends AbstractBatchlet { | ||
|
||
@Inject | ||
JobContext jobCtx; | ||
|
||
@Inject | ||
@BatchProperty (name="executionCount.number") | ||
String executionNumber; | ||
|
||
@Override | ||
public String process() throws Exception { | ||
|
||
Integer executionCount; | ||
|
||
if(executionNumber!=null){ | ||
executionCount=Integer.parseInt(executionNumber); | ||
} | ||
else{ | ||
executionCount=0; | ||
} | ||
|
||
jobCtx.setTransientUserData(1); | ||
|
||
return "EXECUTION "+executionCount; | ||
} | ||
|
||
@Override | ||
public void stop() throws Exception { | ||
|
||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...tck/src/main/java/com/ibm/jbatch/tck/artifacts/specialized/TransitionDeciderWithFlag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright 2016 International Business Machines Corp. | ||
* | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. 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 com.ibm.jbatch.tck.artifacts.specialized; | ||
|
||
import javax.batch.api.BatchProperty; | ||
import javax.batch.api.Decider; | ||
import javax.batch.runtime.StepExecution; | ||
import javax.batch.runtime.context.JobContext; | ||
import javax.inject.Inject; | ||
|
||
@javax.inject.Named("transitionDeciderWithFlag") | ||
public class TransitionDeciderWithFlag implements Decider { | ||
|
||
@Inject | ||
JobContext jobCtx; | ||
|
||
final public static String firstExecution ="First Execution of Transition Decider with Flag"; | ||
final public static String secondExecution="Second Execution of Transition Decider with Flag"; | ||
|
||
@Override | ||
public String decide(StepExecution[] executions) throws Exception { | ||
|
||
Integer deciderCount = jobCtx.getTransientUserData() == null ? 0 : (Integer)jobCtx.getTransientUserData(); | ||
|
||
String deciderExitStatus = null; | ||
|
||
if (deciderCount==0){ | ||
deciderExitStatus = firstExecution; | ||
jobCtx.setExitStatus(firstExecution); | ||
jobCtx.setTransientUserData(1); | ||
} else{ | ||
jobCtx.setExitStatus(secondExecution); | ||
deciderExitStatus = secondExecution; | ||
} | ||
|
||
return deciderExitStatus; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
com.ibm.jbatch.tck/src/main/resources/META-INF/batch-jobs/job_restart_second_transition.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016 International Business Machines Corp. | ||
See the NOTICE file distributed with this work for additional information | ||
regarding copyright ownership. 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. | ||
--> | ||
<job id="job_restart_second_transition" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
<step id="step1" next="after1"> | ||
<batchlet ref="myBatchletImpl"/> | ||
</step> | ||
<decision id="after1" ref="transitionDeciderWithFlag"> | ||
<next on="First*" to="step2"/> | ||
<fail on="Second*" exit-status="Transitioned to decider twice without failing"></fail> | ||
</decision> | ||
<step id="step2" allow-start-if-complete="true"> | ||
<batchlet ref="executionCountBatchlet"> | ||
<properties> | ||
<property name="executionCount.number" value="#{jobParameters['executionCount.number']}"/> | ||
</properties> | ||
</batchlet> | ||
<!-- The execution number here is in reference to a job parameter --> | ||
<fail on="EXECUTION 1"/> | ||
<next on="EXECUTION 2" to="step1"/> | ||
<fail on="*" exit-status="Invalid amount of executions"/> | ||
</step> | ||
</job> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters