You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by rm...@apache.org on 2013/11/05 08:39:04 UTC
[27/62] importing batchee from github - a fork from the IBm RI
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/FlowPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/FlowPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/FlowPropertyResolver.java
new file mode 100755
index 0000000..f16cd4a
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/FlowPropertyResolver.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.modelresolver.PropertyResolverFactory;
+import org.apache.batchee.jaxb.Decision;
+import org.apache.batchee.jaxb.Flow;
+import org.apache.batchee.jaxb.Split;
+import org.apache.batchee.jaxb.Step;
+
+import java.util.Properties;
+
+public class FlowPropertyResolver extends AbstractPropertyResolver<Flow> {
+
+
+ public FlowPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public Flow substituteProperties(final Flow flow, final Properties submittedProps, final Properties parentProps) {
+
+ // resolve all the properties used in attributes and update the JAXB model
+ flow.setId(this.replaceAllProperties(flow.getId(), submittedProps, parentProps));
+ flow.setNextFromAttribute(this.replaceAllProperties(flow.getNextFromAttribute(), submittedProps, parentProps));
+
+ Properties currentProps = parentProps;
+
+ for (final ExecutionElement next : flow.getExecutionElements()) {
+ if (next instanceof Step) {
+ PropertyResolverFactory.createStepPropertyResolver(this.isPartitionedStep).substituteProperties((Step) next, submittedProps, currentProps);
+ } else if (next instanceof Decision) {
+ PropertyResolverFactory.createDecisionPropertyResolver(this.isPartitionedStep).substituteProperties((Decision) next, submittedProps, currentProps);
+ } else if (next instanceof Flow) {
+ PropertyResolverFactory.createFlowPropertyResolver(this.isPartitionedStep).substituteProperties((Flow) next, submittedProps, currentProps);
+ } else if (next instanceof Split) {
+ PropertyResolverFactory.createSplitPropertyResolver(this.isPartitionedStep).substituteProperties((Split) next, submittedProps, currentProps);
+ }
+ }
+
+ return flow;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemProcessorPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemProcessorPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemProcessorPropertyResolver.java
new file mode 100755
index 0000000..3773794
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemProcessorPropertyResolver.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2013 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.ItemProcessor;
+
+import java.util.Properties;
+
+
+public class ItemProcessorPropertyResolver extends AbstractPropertyResolver<ItemProcessor> {
+
+
+ public ItemProcessorPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public ItemProcessor substituteProperties(ItemProcessor processor,
+ Properties submittedProps, Properties parentProps) {
+
+ //resolve all the properties used in attributes and update the JAXB model
+ processor.setRef(this.replaceAllProperties(processor.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this artifact
+ if (processor.getProperties() != null) {
+ this.resolveElementProperties(processor.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return processor;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemReaderPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemReaderPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemReaderPropertyResolver.java
new file mode 100755
index 0000000..3cdfa2e
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemReaderPropertyResolver.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2013 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.ItemReader;
+
+import java.util.Properties;
+
+
+public class ItemReaderPropertyResolver extends AbstractPropertyResolver<ItemReader> {
+
+
+ public ItemReaderPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+
+ @Override
+ public ItemReader substituteProperties(ItemReader reader,
+ Properties submittedProps, Properties parentProps) {
+
+ //resolve all the properties used in attributes and update the JAXB model
+ reader.setRef(this.replaceAllProperties(reader.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this artifact
+ if (reader.getProperties() != null) {
+ this.resolveElementProperties(reader.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return reader;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemWriterPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemWriterPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemWriterPropertyResolver.java
new file mode 100755
index 0000000..cb2069b
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ItemWriterPropertyResolver.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2013 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.ItemWriter;
+
+import java.util.Properties;
+
+
+public class ItemWriterPropertyResolver extends AbstractPropertyResolver<ItemWriter> {
+
+ public ItemWriterPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public ItemWriter substituteProperties(ItemWriter writer,
+ Properties submittedProps, Properties parentProps) {
+
+ //resolve all the properties used in attributes and update the JAXB model
+ writer.setRef(this.replaceAllProperties(writer.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this artifact
+ if (writer.getProperties() != null) {
+ this.resolveElementProperties(writer.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return writer;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/JobPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/JobPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/JobPropertyResolver.java
new file mode 100755
index 0000000..3321d0c
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/JobPropertyResolver.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.modelresolver.PropertyResolverFactory;
+import org.apache.batchee.jaxb.Decision;
+import org.apache.batchee.jaxb.Flow;
+import org.apache.batchee.jaxb.JSLJob;
+import org.apache.batchee.jaxb.Listener;
+import org.apache.batchee.jaxb.Split;
+import org.apache.batchee.jaxb.Step;
+
+import java.util.Properties;
+
+
+public class JobPropertyResolver extends AbstractPropertyResolver<JSLJob> {
+
+ public JobPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ /**
+ * @param job This method will modify the given job. If you need to hold on
+ * to the original job you need to create a clone of the job
+ * before passing it to this method.
+ * @param submittedProps The job parameters associated with this job. null is valid if
+ * no parameters are passed.
+ * @param parentProps Properties that are inherited from parent elements. Job is top
+ * level element so it can have no parents, so this paramter is
+ * currently ignored. Null is valid.
+ * @return
+ */
+ public JSLJob substituteProperties(final JSLJob job, final Properties submittedProps, final Properties parentProps) {
+
+ // resolve all the properties used in attributes and update the JAXB
+ // model
+ job.setId(this.replaceAllProperties(job.getId(), submittedProps, parentProps));
+ job.setRestartable(this.replaceAllProperties(job.getRestartable(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for a job
+ Properties currentProps = null;
+ if (job.getProperties() != null) {
+ currentProps = this.resolveElementProperties(job.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ // Resolve Listener properties, this is list of listeners List<Listener>
+ if (job.getListeners() != null) {
+ for (final Listener listener : job.getListeners().getListenerList()) {
+ PropertyResolverFactory.createListenerPropertyResolver(this.isPartitionedStep).substituteProperties(listener, submittedProps, currentProps);
+ }
+ }
+
+ for (final ExecutionElement next : job.getExecutionElements()) {
+ if (next instanceof Step) {
+ PropertyResolverFactory.createStepPropertyResolver(this.isPartitionedStep).substituteProperties((Step) next, submittedProps, currentProps);
+ } else if (next instanceof Decision) {
+ PropertyResolverFactory.createDecisionPropertyResolver(this.isPartitionedStep).substituteProperties((Decision) next, submittedProps, currentProps);
+ } else if (next instanceof Split) {
+ PropertyResolverFactory.createSplitPropertyResolver(this.isPartitionedStep).substituteProperties((Split) next, submittedProps, currentProps);
+ } else if (next instanceof Flow) {
+ PropertyResolverFactory.createFlowPropertyResolver(this.isPartitionedStep).substituteProperties((Flow) next, submittedProps, currentProps);
+ }
+ }
+
+
+ return job;
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ListenerPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ListenerPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ListenerPropertyResolver.java
new file mode 100755
index 0000000..0396e2c
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/ListenerPropertyResolver.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.Listener;
+
+import java.util.Properties;
+
+
+public class ListenerPropertyResolver extends AbstractPropertyResolver<Listener> {
+
+
+ public ListenerPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public Listener substituteProperties(final Listener listener, final Properties submittedProps, final Properties parentProps) {
+ //resolve all the properties used in attributes and update the JAXB model
+ listener.setRef(this.replaceAllProperties(listener.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this listener
+ if (listener.getProperties() != null) {
+ this.resolveElementProperties(listener.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return listener;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionMapperPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionMapperPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionMapperPropertyResolver.java
new file mode 100755
index 0000000..92a3120
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionMapperPropertyResolver.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.PartitionMapper;
+
+import java.util.Properties;
+
+
+public class PartitionMapperPropertyResolver extends
+ AbstractPropertyResolver<PartitionMapper> {
+
+ public PartitionMapperPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public PartitionMapper substituteProperties(PartitionMapper partitionMapper,
+ Properties submittedProps, Properties parentProps) {
+
+ /*
+ <xs:complexType name="PartitionMapper">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties" minOccurs="0" maxOccurs="1" />
+ </xs:sequence>
+ <xs:attribute name="ref" use="required" type="jsl:artifactRef" />
+ </xs:complexType>
+ */
+
+ partitionMapper.setRef(this.replaceAllProperties(partitionMapper.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this step
+ Properties currentProps = parentProps;
+ if (partitionMapper.getProperties() != null) {
+ currentProps = this.resolveElementProperties(partitionMapper.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return partitionMapper;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPlanPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPlanPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPlanPropertyResolver.java
new file mode 100755
index 0000000..a09948b
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPlanPropertyResolver.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.JSLProperties;
+import org.apache.batchee.jaxb.PartitionPlan;
+
+import java.util.List;
+import java.util.Properties;
+
+
+public class PartitionPlanPropertyResolver extends
+ AbstractPropertyResolver<PartitionPlan> {
+
+ public PartitionPlanPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public PartitionPlan substituteProperties(PartitionPlan partitionPlan,
+ Properties submittedProps, Properties parentProps) {
+
+ /*
+ <xs:complexType name="PartitionPlan">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="instances" use="optional" type="xs:string" />
+ <xs:attribute name="threads" use="optional" type="xs:string" />
+ </xs:complexType>
+ */
+
+ partitionPlan.setPartitions(this.replaceAllProperties(partitionPlan.getPartitions(), submittedProps, parentProps));
+ partitionPlan.setThreads(this.replaceAllProperties(partitionPlan.getThreads(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this plan
+ Properties currentProps = parentProps;
+ if (partitionPlan.getProperties() != null) {
+
+ List<JSLProperties> jslProps = partitionPlan.getProperties();
+
+ if (jslProps != null) {
+ for (JSLProperties jslProp : jslProps) {
+ //for partition properties perform substitution on the partition attribute
+ if (jslProp.getPartition() != null) {
+ jslProp.setPartition(this.replaceAllProperties(jslProp.getPartition(), submittedProps, parentProps));
+ }
+ currentProps = this.resolveElementProperties(jslProp.getPropertyList(), submittedProps, parentProps);
+ }
+ }
+
+
+ }
+
+ return partitionPlan;
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPropertyResolver.java
new file mode 100755
index 0000000..a84569f
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionPropertyResolver.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.container.modelresolver.PropertyResolverFactory;
+import org.apache.batchee.jaxb.Partition;
+
+import java.util.Properties;
+
+public class PartitionPropertyResolver extends AbstractPropertyResolver<Partition> {
+
+
+ public PartitionPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public Partition substituteProperties(final Partition partition, final Properties submittedProps, final Properties parentProps) {
+ /**
+ <xs:complexType name="Partition">
+ <xs:sequence>
+ <xs:element name="mapper" type="jsl:PartitionMapper" minOccurs="0" maxOccurs="1" />
+ <xs:element name="plan" type="jsl:PartitionPlan" minOccurs="0" maxOccurs="1" />
+ <xs:element name="collector" type="jsl:Collector" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="analyzer" type="jsl:Analyzer" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="reducer " type="jsl:PartitionReducer" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ */
+
+ // Resolve all the properties defined for a partition
+ if (partition.getMapper() != null) {
+ PropertyResolverFactory.createPartitionMapperPropertyResolver(this.isPartitionedStep).substituteProperties(partition.getMapper(), submittedProps, null);
+ }
+
+ if (partition.getPlan() != null) {
+ PropertyResolverFactory.createPartitionPlanPropertyResolver(this.isPartitionedStep).substituteProperties(partition.getPlan(), submittedProps, null);
+ }
+
+ if (partition.getCollector() != null) {
+ PropertyResolverFactory.createCollectorPropertyResolver(this.isPartitionedStep).substituteProperties(partition.getCollector(), submittedProps, null);
+ }
+
+ if (partition.getAnalyzer() != null) {
+ PropertyResolverFactory.createAnalyzerPropertyResolver(this.isPartitionedStep).substituteProperties(partition.getAnalyzer(), submittedProps, null);
+ }
+
+ if (partition.getReducer() != null) {
+ PropertyResolverFactory.createPartitionReducerPropertyResolver(this.isPartitionedStep).substituteProperties(partition.getReducer(), submittedProps, null);
+ }
+
+ return partition;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionReducerPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionReducerPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionReducerPropertyResolver.java
new file mode 100755
index 0000000..25cdb2e
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/PartitionReducerPropertyResolver.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.jaxb.PartitionReducer;
+
+import java.util.Properties;
+
+
+public class PartitionReducerPropertyResolver extends
+ AbstractPropertyResolver<PartitionReducer> {
+
+ public PartitionReducerPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+
+ @Override
+ public PartitionReducer substituteProperties(PartitionReducer reducer,
+ Properties submittedProps, Properties parentProps) {
+ /*
+ <xs:complexType name="Collector">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties" minOccurs="0" maxOccurs="1" />
+ </xs:sequence>
+ <xs:attribute name="ref" use="required" type="jsl:artifactRef" />
+ </xs:complexType>
+ */
+
+ //resolve all the properties used in attributes and update the JAXB model
+ reducer.setRef(this.replaceAllProperties(reducer.getRef(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this artifact
+ if (reducer.getProperties() != null) {
+ this.resolveElementProperties(reducer.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ return reducer;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/SplitPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/SplitPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/SplitPropertyResolver.java
new file mode 100755
index 0000000..ed25e0a
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/SplitPropertyResolver.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.container.modelresolver.PropertyResolverFactory;
+import org.apache.batchee.jaxb.Flow;
+import org.apache.batchee.jaxb.Split;
+
+import java.util.Properties;
+
+public class SplitPropertyResolver extends AbstractPropertyResolver<Split> {
+
+
+ public SplitPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public Split substituteProperties(final Split split, final Properties submittedProps, final Properties parentProps) {
+ // resolve all the properties used in attributes and update the JAXB model
+ split.setId(this.replaceAllProperties(split.getId(), submittedProps, parentProps));
+ split.setNextFromAttribute(this.replaceAllProperties(split.getNextFromAttribute(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this step
+ Properties currentProps = parentProps;
+ for (final Flow flow : split.getFlows()) {
+ PropertyResolverFactory.createFlowPropertyResolver(this.isPartitionedStep).substituteProperties(flow, submittedProps, currentProps);
+ }
+
+ return split;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/StepPropertyResolver.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/StepPropertyResolver.java b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/StepPropertyResolver.java
new file mode 100755
index 0000000..d3e1e74
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/StepPropertyResolver.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.modelresolver.impl;
+
+import org.apache.batchee.container.jsl.TransitionElement;
+import org.apache.batchee.container.modelresolver.PropertyResolverFactory;
+import org.apache.batchee.jaxb.Listener;
+import org.apache.batchee.jaxb.Step;
+
+import java.util.Properties;
+
+
+public class StepPropertyResolver extends AbstractPropertyResolver<Step> {
+
+ public StepPropertyResolver(boolean isPartitionStep) {
+ super(isPartitionStep);
+ }
+
+ @Override
+ public Step substituteProperties(final Step step, final Properties submittedProps, final Properties parentProps) {
+
+ // resolve all the properties used in attributes and update the JAXB
+ // model
+ step.setId(this.replaceAllProperties(step.getId(), submittedProps, parentProps));
+
+ step.setAllowStartIfComplete(this.replaceAllProperties(step.getAllowStartIfComplete(), submittedProps, parentProps));
+ step.setNextFromAttribute(this.replaceAllProperties(step.getNextFromAttribute(), submittedProps, parentProps));
+ step.setStartLimit(this.replaceAllProperties(step.getStartLimit(), submittedProps, parentProps));
+
+ // Resolve all the properties defined for this step
+ Properties currentProps = parentProps;
+ if (step.getProperties() != null) {
+ currentProps = this.resolveElementProperties(step.getProperties().getPropertyList(), submittedProps, parentProps);
+ }
+
+ // Resolve partition
+ if (step.getPartition() != null) {
+ PropertyResolverFactory.createPartitionPropertyResolver(this.isPartitionedStep).substituteProperties(step.getPartition(), submittedProps, currentProps);
+ }
+
+ // Resolve Listener properties, this is list of listeners List<Listener>
+ if (step.getListeners() != null) {
+ for (final Listener listener : step.getListeners().getListenerList()) {
+ PropertyResolverFactory.createListenerPropertyResolver(this.isPartitionedStep).substituteProperties(listener, submittedProps, currentProps);
+ }
+ }
+
+ if (step.getTransitionElements() != null) {
+ for (final TransitionElement controlElement : step.getTransitionElements()) {
+ PropertyResolverFactory.createTransitionElementPropertyResolver(this.isPartitionedStep).substituteProperties(controlElement, submittedProps, currentProps);
+ }
+ }
+
+
+ // Resolve Batchlet properties
+ if (step.getBatchlet() != null) {
+ PropertyResolverFactory.createBatchletPropertyResolver(this.isPartitionedStep).substituteProperties(step.getBatchlet(), submittedProps, currentProps);
+ }
+
+ // Resolve Chunk properties
+ if (step.getChunk() != null) {
+ PropertyResolverFactory.createChunkPropertyResolver(this.isPartitionedStep).substituteProperties(step.getChunk(), submittedProps, currentProps);
+ }
+
+ return step;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/navigator/AbstractNavigator.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/navigator/AbstractNavigator.java b/jbatch/src/main/java/org/apache/batchee/container/navigator/AbstractNavigator.java
new file mode 100755
index 0000000..2b2fdeb
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/navigator/AbstractNavigator.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.navigator;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.jsl.GlobPatternMatcherImpl;
+import org.apache.batchee.container.jsl.IllegalTransitionException;
+import org.apache.batchee.container.jsl.Transition;
+import org.apache.batchee.container.jsl.TransitionElement;
+import org.apache.batchee.container.status.ExecutionStatus;
+import org.apache.batchee.container.status.ExtendedBatchStatus;
+import org.apache.batchee.jaxb.Decision;
+import org.apache.batchee.jaxb.Flow;
+import org.apache.batchee.jaxb.Next;
+import org.apache.batchee.jaxb.Split;
+import org.apache.batchee.jaxb.Step;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractNavigator<T> implements ModelNavigator<T> {
+ private Map<String, ExecutionElement> alreadyExecutedElements = new HashMap<String, ExecutionElement>();
+
+ public ExecutionElement getFirstExecutionElement(List<ExecutionElement> peerExecutionElements, String restartOn) throws IllegalTransitionException {
+ ExecutionElement startElement;
+
+ if (restartOn != null) {
+ startElement = getExecutionElementFromId(peerExecutionElements, restartOn);
+ if (startElement == null) {
+ throw new IllegalStateException("Didn't find an execution element maching restart-on designated element: " + restartOn);
+ }
+ } else {
+ if (peerExecutionElements.size() > 0) {
+ startElement = peerExecutionElements.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ // We allow repeating a decision
+ if (!(startElement instanceof Decision)) {
+ alreadyExecutedElements.put(startElement.getId(), startElement);
+ }
+
+ validateElementType(startElement);
+
+ return startElement;
+ }
+
+
+ /**
+ * Precedence is: look at elements, then look at attribute, then return quietly
+ *
+ * @param currentElem
+ * @param peerExecutionElements
+ * @param currentStatus
+ * @return
+ * @throws IllegalTransitionException
+ */
+ public Transition getNextTransition(ExecutionElement currentElem, List<ExecutionElement> peerExecutionElements, ExecutionStatus currentStatus)
+ throws IllegalTransitionException {
+ Transition returnTransition = new Transition();
+
+ ExecutionElement nextExecutionElement = null;
+
+ List<TransitionElement> transitionElements = currentElem.getTransitionElements();
+
+ // Check the transition elements first.
+ if (!transitionElements.isEmpty()) {
+ for (final TransitionElement t : transitionElements) {
+ boolean isMatched = matchExitStatusAgainstOnAttribute(currentStatus.getExitStatus(), t);
+ if (isMatched) {
+ if (t instanceof Next) {
+ Next next = (Next) t;
+ nextExecutionElement = getExecutionElementFromId(peerExecutionElements, next.getTo());
+ returnTransition.setNextExecutionElement(nextExecutionElement);
+ break;
+ } else {
+ returnTransition.setTransitionElement(t);
+ }
+ return returnTransition;
+ }
+ }
+ }
+
+ // We've returned already if we matched a Stop, End or Fail
+ if (nextExecutionElement == null) {
+ if (currentStatus.getExtendedBatchStatus().equals(ExtendedBatchStatus.EXCEPTION_THROWN)) {
+ returnTransition.setNoTransitionElementMatchAfterException();
+ return returnTransition;
+ } else {
+ nextExecutionElement = getNextExecutionElemFromAttribute(peerExecutionElements, currentElem);
+ returnTransition.setNextExecutionElement(nextExecutionElement);
+ }
+ }
+
+ if (nextExecutionElement != null) {
+ if (alreadyExecutedElements.containsKey(nextExecutionElement.getId())) {
+ throw new IllegalTransitionException("Execution loop detected !!! Trying to re-execute execution element: " + nextExecutionElement.getId());
+ }
+
+ // We allow repeating a decision
+ if (!(nextExecutionElement instanceof Decision)) {
+ alreadyExecutedElements.put(nextExecutionElement.getId(), nextExecutionElement);
+ }
+ } else {
+ returnTransition.setFinishedTransitioning();
+ }
+ return returnTransition;
+ }
+
+
+ private ExecutionElement getExecutionElementFromId(List<ExecutionElement> executionElements, String id)
+ throws IllegalTransitionException {
+ if (id != null) {
+ for (final ExecutionElement elem : executionElements) {
+ if (elem.getId().equals(id)) {
+ validateElementType(elem);
+ return elem;
+ }
+ }
+ throw new IllegalTransitionException("No execution element found with id = " + id);
+ }
+ return null;
+ }
+
+ private static boolean matchSpecifiedExitStatus(final String currentStepExitStatus, final String exitStatusPattern) {
+ return new GlobPatternMatcherImpl().matchWithoutBackslashEscape(currentStepExitStatus, exitStatusPattern);
+ }
+
+ private boolean matchExitStatusAgainstOnAttribute(final String exitStatus, final TransitionElement elem) {
+ return matchSpecifiedExitStatus(exitStatus, elem.getOn());
+ }
+
+ private ExecutionElement getNextExecutionElemFromAttribute(List<ExecutionElement> peerExecutionElements, ExecutionElement currentElem) throws IllegalTransitionException {
+ ExecutionElement nextExecutionElement = null;
+ String nextAttrId;
+ if (currentElem instanceof Step) {
+ nextAttrId = ((Step) currentElem).getNextFromAttribute();
+ nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
+ } else if (currentElem instanceof Split) {
+ nextAttrId = ((Split) currentElem).getNextFromAttribute();
+ nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
+ } else if (currentElem instanceof Flow) {
+ nextAttrId = ((Flow) currentElem).getNextFromAttribute();
+ nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
+ } else if (currentElem instanceof Decision) {
+ // Nothing special to do in this case.
+ }
+
+ validateElementType(nextExecutionElement);
+
+ return nextExecutionElement;
+ }
+
+ private void validateElementType(ExecutionElement elem) {
+ if (elem != null) {
+ if (!((elem instanceof Decision) || (elem instanceof Flow) || (elem instanceof Split) || (elem instanceof Step))) {
+ throw new IllegalArgumentException("Unknown execution element found, elem = " + elem + ", found with type: " + elem.getClass().getCanonicalName() +
+ " , which is not an instance of Decision, Flow, Split, or Step.");
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/navigator/FlowNavigator.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/navigator/FlowNavigator.java b/jbatch/src/main/java/org/apache/batchee/container/navigator/FlowNavigator.java
new file mode 100755
index 0000000..5f579ce
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/navigator/FlowNavigator.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.navigator;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.jsl.IllegalTransitionException;
+import org.apache.batchee.container.jsl.Transition;
+import org.apache.batchee.container.status.ExecutionStatus;
+import org.apache.batchee.jaxb.Flow;
+
+public class FlowNavigator extends AbstractNavigator<Flow> implements ModelNavigator<Flow> {
+ private Flow flow = null;
+
+ public FlowNavigator(final Flow flow) {
+ this.flow = flow;
+ }
+
+ @Override
+ public ExecutionElement getFirstExecutionElement(String restartOn) throws IllegalTransitionException {
+ return getFirstExecutionElement(flow.getExecutionElements(), restartOn);
+ }
+
+ @Override
+ public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentStatus) throws IllegalTransitionException {
+ return getNextTransition(currentExecutionElem, flow.getExecutionElements(), currentStatus);
+ }
+
+ @Override
+ public Flow getRootModelElement() {
+ return flow;
+ }
+
+ @Override
+ public String toString() {
+ return "FlowNavigator for flow id = " + flow.getId();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/navigator/JobNavigator.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/navigator/JobNavigator.java b/jbatch/src/main/java/org/apache/batchee/container/navigator/JobNavigator.java
new file mode 100755
index 0000000..196db68
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/navigator/JobNavigator.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.navigator;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.jsl.IllegalTransitionException;
+import org.apache.batchee.container.jsl.Transition;
+import org.apache.batchee.container.status.ExecutionStatus;
+import org.apache.batchee.jaxb.JSLJob;
+
+public class JobNavigator extends AbstractNavigator<JSLJob> implements ModelNavigator<JSLJob> {
+ private JSLJob job = null;
+
+ public JobNavigator(final JSLJob job) {
+ this.job = job;
+ }
+
+ @Override
+ public ExecutionElement getFirstExecutionElement(String restartOn) throws IllegalTransitionException {
+ return getFirstExecutionElement(job.getExecutionElements(), restartOn);
+ }
+
+ @Override
+ public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentStatus) throws IllegalTransitionException {
+ return getNextTransition(currentExecutionElem, job.getExecutionElements(), currentStatus);
+ }
+
+ @Override
+ public JSLJob getRootModelElement() {
+ return job;
+ }
+
+ @Override
+ public String toString() {
+ return "JobNavigator for job id = " + job.getId();
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/navigator/ModelNavigator.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/navigator/ModelNavigator.java b/jbatch/src/main/java/org/apache/batchee/container/navigator/ModelNavigator.java
new file mode 100755
index 0000000..6ffc968
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/navigator/ModelNavigator.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.navigator;
+
+import org.apache.batchee.container.jsl.ExecutionElement;
+import org.apache.batchee.container.jsl.IllegalTransitionException;
+import org.apache.batchee.container.jsl.Transition;
+import org.apache.batchee.container.status.ExecutionStatus;
+
+public interface ModelNavigator<T> {
+
+ /**
+ * @param restartOn
+ * @return
+ * @throws IllegalTransitionException
+ */
+ public ExecutionElement getFirstExecutionElement(String restartOn) throws IllegalTransitionException;
+
+ /**
+ * Enforces "can't revisit already visited steps rule".
+ */
+ public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentExecutionStatus)
+ throws IllegalTransitionException;
+
+ /**
+ * E.g. the JSLJob for a job, the Flow for a flow, etc.
+ *
+ * @return
+ */
+ public T getRootModelElement();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/navigator/NavigatorFactory.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/navigator/NavigatorFactory.java b/jbatch/src/main/java/org/apache/batchee/container/navigator/NavigatorFactory.java
new file mode 100755
index 0000000..5137297
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/navigator/NavigatorFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.navigator;
+
+import org.apache.batchee.jaxb.Flow;
+import org.apache.batchee.jaxb.JSLJob;
+
+public class NavigatorFactory {
+ public static JobNavigator createJobNavigator(JSLJob job) {
+ return new JobNavigator(job);
+ }
+
+ public static FlowNavigator createFlowNavigator(Flow flow) {
+ return new FlowNavigator(flow);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/AbstractProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/AbstractProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/AbstractProxy.java
new file mode 100755
index 0000000..740bee0
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/AbstractProxy.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.impl.StepContextImpl;
+
+/**
+ * An abstract class which contains the common behavior for a batch artifact
+ * proxy. This class performs runtime introspection of an artifact instances
+ * annotations and handles property injection.
+ */
+public abstract class AbstractProxy<T> {
+ protected T delegate;
+ protected StepContextImpl stepContext;
+
+ /**
+ * @param delegate An instance of a batch artifact which will back this proxy
+ */
+ AbstractProxy(T delegate) {
+ this.delegate = delegate;
+ }
+
+ public T getDelegate() {
+ return this.delegate;
+ }
+
+ public void setStepContext(final StepContextImpl stepContext) {
+ this.stepContext = stepContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/BatchletProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/BatchletProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/BatchletProxy.java
new file mode 100755
index 0000000..b518da2
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/BatchletProxy.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.Batchlet;
+
+public class BatchletProxy extends AbstractProxy<Batchlet> implements Batchlet {
+ public BatchletProxy(final Batchlet delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public String process() {
+ try {
+ return this.delegate.process();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void stop() {
+ try {
+ this.delegate.stop();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/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
new file mode 100755
index 0000000..39b080e
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/CheckpointAlgorithmProxy.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+import org.apache.batchee.container.impl.controller.chunk.ItemCheckpointAlgorithm;
+
+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
+ * as identical to custom ones.
+ */
+ public CheckpointAlgorithmProxy(final CheckpointAlgorithm delegate) {
+ super(delegate);
+
+ if (delegate instanceof ItemCheckpointAlgorithm) {
+ checkpointType = "item";
+ checkpointName = ItemCheckpointAlgorithm.class.getName();
+ } else {
+ checkpointType = "custom";
+ checkpointName = delegate.getClass().getName();
+ }
+
+ }
+
+
+ public String getCheckpointType() {
+ return checkpointType;
+ }
+
+ public String getCheckpointAlgorithmClassName() {
+ return checkpointName;
+ }
+
+ @Override
+ public void beginCheckpoint() {
+ try {
+ this.delegate.beginCheckpoint();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public int checkpointTimeout() {
+ try {
+ return this.delegate.checkpointTimeout();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void endCheckpoint() {
+ try {
+ this.delegate.endCheckpoint();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean isReadyToCheckpoint() {
+ try {
+ return this.delegate.isReadyToCheckpoint();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ChunkListenerProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ChunkListenerProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ChunkListenerProxy.java
new file mode 100755
index 0000000..747b5bc
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ChunkListenerProxy.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.listener.ChunkListener;
+
+public class ChunkListenerProxy extends AbstractProxy<ChunkListener> implements ChunkListener {
+ ChunkListenerProxy(final ChunkListener delegate) {
+ super(delegate);
+
+ }
+
+ @Override
+ public void afterChunk() throws Exception {
+ try {
+ this.delegate.afterChunk();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeChunk() throws Exception {
+ try {
+ this.delegate.beforeChunk();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onError(Exception ex) throws Exception {
+ try {
+ this.delegate.onError(ex);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/DeciderProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/DeciderProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/DeciderProxy.java
new file mode 100755
index 0000000..800f913
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/DeciderProxy.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.Decider;
+import javax.batch.runtime.StepExecution;
+
+public class DeciderProxy extends AbstractProxy<Decider> implements Decider {
+ DeciderProxy(Decider delegate) {
+ super(delegate);
+
+ }
+
+ @Override
+ public String decide(final StepExecution[] stepExecutions) {
+ try {
+ return delegate.decide(stepExecutions);
+ } catch (final Exception e) {
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/InjectionReferences.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/InjectionReferences.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/InjectionReferences.java
new file mode 100755
index 0000000..c7a8ef2
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/InjectionReferences.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2013 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.jaxb.Property;
+
+import javax.batch.runtime.context.JobContext;
+import javax.batch.runtime.context.StepContext;
+import java.util.List;
+
+
+/**
+ * This is a container class that holds on to the property and context injections
+ * that should be injected into a batch artifact.
+ */
+public class InjectionReferences {
+
+ private final JobContext jobContext;
+ private final StepContext stepContext;
+
+ private List<Property> props;
+
+ public InjectionReferences(final JobContext jobContext, final StepContext stepContext,
+ final List<Property> props) {
+
+ this.jobContext = jobContext;
+ this.stepContext = stepContext;
+ this.props = props;
+ }
+
+ public JobContext getJobContext() {
+ return jobContext;
+ }
+
+ public StepContext getStepContext() {
+ return stepContext;
+ }
+
+ public List<Property> getProps() {
+ return props;
+ }
+
+ public void setProps(final List<Property> props) {
+ this.props = props;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessListenerProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessListenerProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessListenerProxy.java
new file mode 100755
index 0000000..0298e1b
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessListenerProxy.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.listener.ItemProcessListener;
+
+public class ItemProcessListenerProxy extends AbstractProxy<ItemProcessListener> implements ItemProcessListener {
+ ItemProcessListenerProxy(final ItemProcessListener delegate) {
+ super(delegate);
+
+ }
+
+ @Override
+ public void afterProcess(Object item, Object result) {
+ try {
+ this.delegate.afterProcess(item, result);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeProcess(final Object item) {
+ try {
+ this.delegate.beforeProcess(item);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onProcessError(Object item, Exception ex) {
+ try {
+ this.delegate.onProcessError(item, ex);
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessorProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessorProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessorProxy.java
new file mode 100755
index 0000000..0e4e965
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemProcessorProxy.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import javax.batch.api.chunk.ItemProcessor;
+
+public class ItemProcessorProxy extends AbstractProxy<ItemProcessor> implements ItemProcessor {
+ ItemProcessorProxy(final ItemProcessor delegate) {
+ super(delegate);
+ }
+
+ /*
+ * In order to provide skip/retry logic, these exceptions
+ * are thrown as-is rather than beeing wrapped.
+ * @see javax.batch.api.ItemReader#readItem()
+ */
+ @Override
+ public Object processItem(final Object item) throws Exception {
+ return this.delegate.processItem(item);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReadListenerProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReadListenerProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReadListenerProxy.java
new file mode 100755
index 0000000..27fd947
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReadListenerProxy.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.listener.ItemReadListener;
+
+public class ItemReadListenerProxy extends AbstractProxy<ItemReadListener> implements ItemReadListener {
+ ItemReadListenerProxy(final ItemReadListener delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void afterRead(final Object item) {
+ try {
+ this.delegate.afterRead(item);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeRead() {
+ try {
+ this.delegate.beforeRead();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onReadError(final Exception ex) {
+ try {
+ this.delegate.onReadError(ex);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReaderProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReaderProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReaderProxy.java
new file mode 100755
index 0000000..43f2a00
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemReaderProxy.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.ItemReader;
+import java.io.Serializable;
+
+public class ItemReaderProxy extends AbstractProxy<ItemReader> implements ItemReader {
+ ItemReaderProxy(final ItemReader delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public Serializable checkpointInfo() {
+ try {
+ return this.delegate.checkpointInfo();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() {
+ try {
+ this.delegate.close();
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void open(final Serializable checkpoint) {
+ try {
+ this.delegate.open(checkpoint);
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ /*
+ * In order to provide skip/retry logic, these exceptions
+ * are thrown as-is rather than beeing wrapped.
+ * @see javax.batch.api.ItemReader#readItem()
+ */
+ @Override
+ public Object readItem() throws Exception {
+ return this.delegate.readItem();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriteListenerProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriteListenerProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriteListenerProxy.java
new file mode 100755
index 0000000..9691281
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriteListenerProxy.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.listener.ItemWriteListener;
+import java.util.List;
+
+public class ItemWriteListenerProxy extends AbstractProxy<ItemWriteListener> implements ItemWriteListener {
+ ItemWriteListenerProxy(final ItemWriteListener delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void afterWrite(final List<Object> items) {
+ try {
+ this.delegate.afterWrite(items);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeWrite(final List<Object> items) {
+
+ try {
+ this.delegate.beforeWrite(items);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onWriteError(final List<Object> items, final Exception ex) {
+ try {
+ this.delegate.onWriteError(items, ex);
+ } catch (Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriterProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriterProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriterProxy.java
new file mode 100755
index 0000000..2dc6e1a
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/ItemWriterProxy.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.chunk.ItemWriter;
+import java.io.Serializable;
+import java.util.List;
+
+public class ItemWriterProxy extends AbstractProxy<ItemWriter> implements ItemWriter {
+ ItemWriterProxy(final ItemWriter delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public Serializable checkpointInfo() {
+ try {
+ return this.delegate.checkpointInfo();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() {
+ try {
+ this.delegate.close();
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void open(final Serializable checkpoint) {
+ try {
+ this.delegate.open(checkpoint);
+ } catch (final Exception e) {
+ this.stepContext.setException(e);
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+
+ /*
+ * In order to provide skip/retry logic, these exceptions
+ * are thrown as-is rather than beeing wrapped.
+ * @see javax.batch.api.ItemReader#readItem()
+ */
+ @Override
+ public void writeItems(final List<Object> items) throws Exception {
+ this.delegate.writeItems(items);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/main/java/org/apache/batchee/container/proxy/JobListenerProxy.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/proxy/JobListenerProxy.java b/jbatch/src/main/java/org/apache/batchee/container/proxy/JobListenerProxy.java
new file mode 100755
index 0000000..83c95f1
--- /dev/null
+++ b/jbatch/src/main/java/org/apache/batchee/container/proxy/JobListenerProxy.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2012 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 org.apache.batchee.container.proxy;
+
+import org.apache.batchee.container.exception.BatchContainerRuntimeException;
+
+import javax.batch.api.listener.JobListener;
+
+public class JobListenerProxy extends AbstractProxy<JobListener> implements JobListener {
+ JobListenerProxy(final JobListener delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void afterJob() {
+ try {
+ this.delegate.afterJob();
+ } catch (final Exception e) {
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeJob() {
+ try {
+ this.delegate.beforeJob();
+ } catch (final Exception e) {
+ throw new BatchContainerRuntimeException(e);
+ }
+ }
+}