You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by st...@apache.org on 2014/04/25 00:11:40 UTC
git commit: BATCHEE-29 remove StepContext where not needed
Repository: incubator-batchee
Updated Branches:
refs/heads/master b5a976081 -> 2f73d8358
BATCHEE-29 remove StepContext where not needed
most time it's simple redundant
Project: http://git-wip-us.apache.org/repos/asf/incubator-batchee/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-batchee/commit/2f73d835
Tree: http://git-wip-us.apache.org/repos/asf/incubator-batchee/tree/2f73d835
Diff: http://git-wip-us.apache.org/repos/asf/incubator-batchee/diff/2f73d835
Branch: refs/heads/master
Commit: 2f73d835878dccff03ec04b0c6b0afc5fa2736e5
Parents: b5a9760
Author: Mark Struberg <st...@apache.org>
Authored: Fri Apr 25 00:05:28 2014 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Fri Apr 25 00:05:28 2014 +0200
----------------------------------------------------------------------
.../controller/PartitionedStepController.java | 6 ++--
.../SingleThreadedStepController.java | 2 +-
.../batchlet/BatchletStepController.java | 2 +-
.../chunk/CheckpointAlgorithmFactory.java | 5 ++-
.../controller/chunk/ChunkStepController.java | 8 ++---
.../proxy/CheckpointAlgorithmProxy.java | 6 ----
.../batchee/container/proxy/ProxyFactory.java | 33 +++++++++++++-------
7 files changed, 33 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/impl/controller/PartitionedStepController.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/PartitionedStepController.java b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/PartitionedStepController.java
index 6eb0194..7ba8db4 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/PartitionedStepController.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/PartitionedStepController.java
@@ -136,7 +136,7 @@ public class PartitionedStepController extends BaseStepController {
// Some of them may be null
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propertyList);
final PartitionMapper partitionMapperProxy =
- ProxyFactory.createPartitionMapperProxy(factory, partitionMapper.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ ProxyFactory.createPartitionMapperProxy(factory, partitionMapper.getRef(), injectionRef, jobExecutionImpl);
PartitionPlan mapperPlan = null;
@@ -431,14 +431,14 @@ public class PartitionedStepController extends BaseStepController {
if (analyzer != null) {
final List<Property> propList = analyzer.getProperties() == null ? null : analyzer.getProperties().getPropertyList();
injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propList);
- analyzerProxy = ProxyFactory.createPartitionAnalyzerProxy(factory, analyzer.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ analyzerProxy = ProxyFactory.createPartitionAnalyzerProxy(factory, analyzer.getRef(), injectionRef, jobExecutionImpl);
}
final org.apache.batchee.jaxb.PartitionReducer partitionReducer = step.getPartition().getReducer();
if (partitionReducer != null) {
final List<Property> propList = partitionReducer.getProperties() == null ? null : partitionReducer.getProperties().getPropertyList();
injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propList);
- partitionReducerProxy = ProxyFactory.createPartitionReducerProxy(factory, partitionReducer.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ partitionReducerProxy = ProxyFactory.createPartitionReducerProxy(factory, partitionReducer.getRef(), injectionRef, jobExecutionImpl);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/impl/controller/SingleThreadedStepController.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/SingleThreadedStepController.java b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/SingleThreadedStepController.java
index 09d41d7..eb92abe 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/SingleThreadedStepController.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/SingleThreadedStepController.java
@@ -77,7 +77,7 @@ public abstract class SingleThreadedStepController extends BaseStepController im
* contexts may be null
*/
injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propList);
- this.collectorProxy = ProxyFactory.createPartitionCollectorProxy(factory, collector.getRef(), injectionRef, this.stepContext, jobExecutionImpl);
+ this.collectorProxy = ProxyFactory.createPartitionCollectorProxy(factory, collector.getRef(), injectionRef, jobExecutionImpl);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/impl/controller/batchlet/BatchletStepController.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/batchlet/BatchletStepController.java b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/batchlet/BatchletStepController.java
index 35587bc..457ccdd 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/batchlet/BatchletStepController.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/batchlet/BatchletStepController.java
@@ -50,7 +50,7 @@ public class BatchletStepController extends SingleThreadedStepController {
final String batchletId = batchlet.getRef();
final List<Property> propList = (batchlet.getProperties() == null) ? null : batchlet.getProperties().getPropertyList();
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propList);
- batchletProxy = ProxyFactory.createBatchletProxy(factory, batchletId, injectionRef, stepContext, jobExecutionImpl);
+ batchletProxy = ProxyFactory.createBatchletProxy(factory, batchletId, injectionRef, jobExecutionImpl);
if (!wasStopIssued()) {
String processRetVal = null;
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/CheckpointAlgorithmFactory.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/CheckpointAlgorithmFactory.java b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/CheckpointAlgorithmFactory.java
index c55d1f4..49df47e 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/CheckpointAlgorithmFactory.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/CheckpointAlgorithmFactory.java
@@ -17,7 +17,6 @@
package org.apache.batchee.container.impl.controller.chunk;
-import org.apache.batchee.container.impl.StepContextImpl;
import org.apache.batchee.container.impl.jobinstance.RuntimeJobExecution;
import org.apache.batchee.container.proxy.CheckpointAlgorithmProxy;
import org.apache.batchee.container.proxy.InjectionReferences;
@@ -28,12 +27,12 @@ import org.apache.batchee.spi.BatchArtifactFactory;
public final class CheckpointAlgorithmFactory {
public static CheckpointAlgorithmProxy getCheckpointAlgorithmProxy(final BatchArtifactFactory factory, final Step step, final InjectionReferences injectionReferences,
- final StepContextImpl stepContext, final RuntimeJobExecution jobExecution) {
+ final RuntimeJobExecution jobExecution) {
final Chunk chunk = step.getChunk();
final String checkpointType = chunk.getCheckpointPolicy();
final CheckpointAlgorithmProxy proxy;
if ("custom".equalsIgnoreCase(checkpointType)) {
- proxy = ProxyFactory.createCheckpointAlgorithmProxy(factory, chunk.getCheckpointAlgorithm().getRef(), injectionReferences, stepContext, jobExecution);
+ proxy = ProxyFactory.createCheckpointAlgorithmProxy(factory, chunk.getCheckpointAlgorithm().getRef(), injectionReferences, jobExecution);
} else /* "item" */ {
proxy = new CheckpointAlgorithmProxy(new ItemCheckpointAlgorithm());
}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/ChunkStepController.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/ChunkStepController.java b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/ChunkStepController.java
index 00c37f6..fae9429 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/ChunkStepController.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/controller/chunk/ChunkStepController.java
@@ -674,7 +674,7 @@ public class ChunkStepController extends SingleThreadedStepController {
final org.apache.batchee.jaxb.ItemReader itemReader = chunk.getReader();
final List<Property> itemReaderProps = itemReader.getProperties() == null ? null : itemReader.getProperties().getPropertyList();
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, itemReaderProps);
- readerProxy = ProxyFactory.createItemReaderProxy(artifactFactory, itemReader.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ readerProxy = ProxyFactory.createItemReaderProxy(artifactFactory, itemReader.getRef(), injectionRef, jobExecutionImpl);
}
{
@@ -682,7 +682,7 @@ public class ChunkStepController extends SingleThreadedStepController {
if (itemProcessor != null) {
final List<Property> itemProcessorProps = itemProcessor.getProperties() == null ? null : itemProcessor.getProperties().getPropertyList();
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, itemProcessorProps);
- processorProxy = ProxyFactory.createItemProcessorProxy(artifactFactory, itemProcessor.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ processorProxy = ProxyFactory.createItemProcessorProxy(artifactFactory, itemProcessor.getRef(), injectionRef, jobExecutionImpl);
}
}
@@ -690,7 +690,7 @@ public class ChunkStepController extends SingleThreadedStepController {
final org.apache.batchee.jaxb.ItemWriter itemWriter = chunk.getWriter();
final List<Property> itemWriterProps = itemWriter.getProperties() == null ? null : itemWriter.getProperties().getPropertyList();
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, itemWriterProps);
- writerProxy = ProxyFactory.createItemWriterProxy(artifactFactory, itemWriter.getRef(), injectionRef, stepContext, jobExecutionImpl);
+ writerProxy = ProxyFactory.createItemWriterProxy(artifactFactory, itemWriter.getRef(), injectionRef, jobExecutionImpl);
}
{
@@ -702,7 +702,7 @@ public class ChunkStepController extends SingleThreadedStepController {
}
final InjectionReferences injectionRef = new InjectionReferences(jobExecutionImpl.getJobContext(), stepContext, propList);
- checkpointProxy = CheckpointAlgorithmFactory.getCheckpointAlgorithmProxy(artifactFactory, step, injectionRef, stepContext, jobExecutionImpl);
+ checkpointProxy = CheckpointAlgorithmFactory.getCheckpointAlgorithmProxy(artifactFactory, step, injectionRef, jobExecutionImpl);
}
{
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java
index 39b080e..e2aac5b 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java
@@ -24,7 +24,6 @@ import javax.batch.api.chunk.CheckpointAlgorithm;
public class CheckpointAlgorithmProxy extends AbstractProxy<CheckpointAlgorithm> implements CheckpointAlgorithm {
private String checkpointType = null;
- private String checkpointName = null;
/*
* Allow this to be public as a special case so we can easily treat the built-in algorithms
@@ -35,10 +34,8 @@ public class CheckpointAlgorithmProxy extends AbstractProxy<CheckpointAlgorithm>
if (delegate instanceof ItemCheckpointAlgorithm) {
checkpointType = "item";
- checkpointName = ItemCheckpointAlgorithm.class.getName();
} else {
checkpointType = "custom";
- checkpointName = delegate.getClass().getName();
}
}
@@ -48,9 +45,6 @@ public class CheckpointAlgorithmProxy extends AbstractProxy<CheckpointAlgorithm>
return checkpointType;
}
- public String getCheckpointAlgorithmClassName() {
- return checkpointName;
- }
@Override
public void beginCheckpoint() {
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/2f73d835/jbatch/src/main/java/org/apache/batchee/container/proxy/ProxyFactory.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ProxyFactory.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ProxyFactory.java
index 1a7b975..bbf15a6 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/proxy/ProxyFactory.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ProxyFactory.java
@@ -20,7 +20,6 @@ import java.lang.reflect.Proxy;
import java.util.HashSet;
import java.util.Set;
-import org.apache.batchee.container.impl.StepContextImpl;
import org.apache.batchee.container.impl.jobinstance.RuntimeJobExecution;
import org.apache.batchee.spi.BatchArtifactFactory;
@@ -68,6 +67,18 @@ public class ProxyFactory {
return INJECTION_CONTEXT.get();
}
+ /**
+ * set the InjectionReferences into the ThreadLocal and return the previously stored value
+ */
+ public static InjectionReferences setInjectionReferences(InjectionReferences injectionReferences) {
+ InjectionReferences oldRef = INJECTION_CONTEXT.get();
+ INJECTION_CONTEXT.set(injectionReferences);
+ if (injectionReferences == null) {
+ INJECTION_CONTEXT.remove();
+ }
+ return oldRef;
+ }
+
public static <T> T createProxy(T delegate, InjectionReferences injectionRefs, String... nonExceptionHandlingMethods) {
return (T) Proxy.newProxyInstance(delegate.getClass().getClassLoader(), getInterfaces(delegate.getClass()),
new BatchProxyInvocationHandler(delegate, injectionRefs, nonExceptionHandlingMethods));
@@ -87,7 +98,7 @@ public class ProxyFactory {
* Batchlet artifact
*/
public static Batchlet createBatchletProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final Batchlet loadedArtifact = (Batchlet) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs);
}
@@ -97,27 +108,27 @@ public class ProxyFactory {
*/
public static CheckpointAlgorithmProxy createCheckpointAlgorithmProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final CheckpointAlgorithm loadedArtifact = (CheckpointAlgorithm) loadArtifact(factory, id, injectionRefs, execution);
final CheckpointAlgorithmProxy proxy = new CheckpointAlgorithmProxy(loadedArtifact);
- proxy.setStepContext(stepContext);
+ proxy.setStepContext(injectionRefs.getStepContext());
return proxy;
}
public static ItemReader createItemReaderProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final ItemReader loadedArtifact = (ItemReader) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs, "readItem");
}
public static ItemProcessor createItemProcessorProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final ItemProcessor loadedArtifact = (ItemProcessor) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs, "processItem");
}
public static ItemWriter createItemWriterProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final ItemWriter loadedArtifact = (ItemWriter) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs, "writeItems");
}
@@ -127,25 +138,25 @@ public class ProxyFactory {
*/
public static PartitionReducer createPartitionReducerProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final PartitionReducer loadedArtifact = (PartitionReducer) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs);
}
public static PartitionMapper createPartitionMapperProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final PartitionMapper loadedArtifact = (PartitionMapper) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs);
}
public static PartitionAnalyzer createPartitionAnalyzerProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final PartitionAnalyzer loadedArtifact = (PartitionAnalyzer) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs);
}
public static PartitionCollector createPartitionCollectorProxy(final BatchArtifactFactory factory, final String id, final InjectionReferences injectionRefs,
- final StepContextImpl stepContext, final RuntimeJobExecution execution) {
+ final RuntimeJobExecution execution) {
final PartitionCollector loadedArtifact = (PartitionCollector) loadArtifact(factory, id, injectionRefs, execution);
return createProxy(loadedArtifact, injectionRefs);
}