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:38:55 UTC
[18/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/xsd/jobXML_1_0.xsd
----------------------------------------------------------------------
diff --git a/jbatch/src/main/xsd/jobXML_1_0.xsd b/jbatch/src/main/xsd/jobXML_1_0.xsd
new file mode 100755
index 0000000..f4faf90
--- /dev/null
+++ b/jbatch/src/main/xsd/jobXML_1_0.xsd
@@ -0,0 +1,435 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2012,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. -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified" targetNamespace="http://xmlns.jcp.org/xml/ns/javaee"
+ xmlns:jsl="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
+
+ <xs:annotation>
+ <xs:documentation>
+ Job Specification Language (JSL) specifies a job,
+ its steps, and directs their execution.
+ JSL also can be referred to as "Job XML".
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:simpleType name="artifactRef">
+ <xs:annotation>
+ <xs:documentation>
+ This is a helper type. Though it is not otherwise
+ called out by this name
+ in the specification, it captures the fact
+ that the xs:string value refers
+ to a batch artifact, across numerous
+ other JSL type definitions.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:string"/>
+ </xs:simpleType>
+
+ <xs:complexType name="Job">
+ <xs:annotation>
+ <xs:documentation>
+ The type of a job definition, whether concrete or
+ abstract. This is the type of the root element of any JSL document.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties"
+ minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ The job-level properties, which are accessible
+ via the JobContext.getProperties() API in a batch artifact.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="listeners" type="jsl:Listeners"
+ minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Note that "listeners" sequence order in XML does
+ not imply order of execution by
+ the batch runtime, per the
+ specification.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="decision" type="jsl:Decision"/>
+ <xs:element name="flow" type="jsl:Flow"/>
+ <xs:element name="split" type="jsl:Split"/>
+ <xs:element name="step" type="jsl:Step"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="version" use="required" type="xs:string" fixed="1.0"/>
+ <xs:attribute name="id" use="required" type="xs:ID"/>
+ <xs:attribute name="restartable" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:element name="job" type="jsl:Job">
+ <xs:annotation>
+ <xs:documentation>
+ The definition of an job, whether concrete or
+ abstract. This is the
+ type of the root element of any JSL document.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType name="Listener">
+ <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>
+
+ <xs:complexType name="Split">
+ <xs:sequence>
+ <xs:element name="flow" type="jsl:Flow" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" use="required" type="xs:ID"/>
+ <xs:attribute name="next" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="Flow">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="decision" type="jsl:Decision"/>
+ <xs:element name="flow" type="jsl:Flow"/>
+ <xs:element name="split" type="jsl:Split"/>
+ <xs:element name="step" type="jsl:Step"/>
+ </xs:choice>
+ <xs:group ref="jsl:TransitionElements" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" use="required" type="xs:ID"/>
+ <xs:attribute name="next" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:group name="TransitionElements">
+ <xs:annotation>
+ <xs:documentation>
+ This grouping provides allows for the reuse of the
+ 'end', 'fail', 'next', 'stop' element sequences which
+ may appear at the end of a 'step', 'flow', 'split' or 'decision'.
+ The term 'TransitionElements' does not formally appear in the spec, it is
+ a schema convenience.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:choice>
+ <xs:element name="end" type="jsl:End"/>
+ <xs:element name="fail" type="jsl:Fail"/>
+ <xs:element name="next" type="jsl:Next"/>
+ <xs:element name="stop" type="jsl:Stop"/>
+ </xs:choice>
+ </xs:group>
+
+ <xs:complexType name="Decision">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:group ref="jsl:TransitionElements" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" use="required" type="xs:ID"/>
+ <xs:attribute name="ref" use="required" type="jsl:artifactRef"/>
+ </xs:complexType>
+
+ <xs:attributeGroup name="TerminatingAttributes">
+ <xs:attribute name="on" use="required" type="xs:string"/>
+ <xs:attribute name="exit-status" use="optional" type="xs:string"/>
+ </xs:attributeGroup>
+
+ <xs:complexType name="Fail">
+ <xs:attributeGroup ref="jsl:TerminatingAttributes"/>
+ </xs:complexType>
+
+ <xs:complexType name="End">
+ <xs:attributeGroup ref="jsl:TerminatingAttributes"/>
+ </xs:complexType>
+
+ <xs:complexType name="Stop">
+ <xs:attributeGroup ref="jsl:TerminatingAttributes"/>
+ <xs:attribute name="restart" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="Next">
+ <xs:attribute name="on" use="required" type="xs:string"/>
+ <xs:attribute name="to" use="required" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="CheckpointAlgorithm">
+ <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>
+
+ <xs:complexType name="ExceptionClassFilter">
+ <xs:sequence>
+ <xs:element name="include" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence/>
+ <xs:attribute name="class" use="required" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="exclude" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence/>
+ <xs:attribute name="class" use="required" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Step">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="listeners" type="jsl:Listeners"
+ minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Note that "listeners" sequence order in XML does
+ not imply order of execution by
+ the batch runtime, per the
+ specification.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element name="batchlet" type="jsl:Batchlet"/>
+ <xs:element name="chunk" type="jsl:Chunk"/>
+ </xs:choice>
+ <xs:element name="partition" type="jsl:Partition"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:group ref="jsl:TransitionElements" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" use="required" type="xs:ID"/>
+ <xs:attribute name="start-limit" use="optional" type="xs:string"/>
+ <xs:attribute name="allow-start-if-complete" use="optional"
+ type="xs:string"/>
+ <xs:attribute name="next" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="Batchlet">
+ <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>
+
+ <xs:complexType name="Chunk">
+ <xs:sequence>
+ <xs:element name="reader" type="jsl:ItemReader"/>
+ <xs:element name="processor" type="jsl:ItemProcessor"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="writer" type="jsl:ItemWriter"/>
+ <xs:element name="checkpoint-algorithm" type="jsl:CheckpointAlgorithm"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="skippable-exception-classes" type="jsl:ExceptionClassFilter"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="retryable-exception-classes" type="jsl:ExceptionClassFilter"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="no-rollback-exception-classes" type="jsl:ExceptionClassFilter"
+ minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="checkpoint-policy" use="optional"
+ type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies the checkpoint policy that governs
+ commit behavior for this chunk.
+ Valid values are: "item" or
+ "custom". The "item" policy means the
+ chunk is checkpointed after a
+ specified number of items are
+ processed. The "custom" policy means
+ the chunk is checkpointed
+ according to a checkpoint algorithm
+ implementation. Specifying
+ "custom" requires that the
+ checkpoint-algorithm element is also
+ specified. It is an optional
+ attribute. The default policy is
+ "item". However, we chose not to define
+ a schema-specified default for this attribute.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="item-count" use="optional" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies the number of items to process per chunk
+ when using the item
+ checkpoint policy. It must be valid XML integer.
+ It is an optional
+ attribute. The default is 10. The item-count
+ attribute is ignored
+ for "custom" checkpoint policy. However, to
+ make it easier for implementations to support JSL inheritance
+ we
+ abstain from defining a schema-specified default for this
+ attribute.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="time-limit" use="optional" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies the amount of time in seconds before
+ taking a checkpoint for the
+ item checkpoint policy. It must be valid
+ XML integer. It is an
+ optional attribute. The default is 0, which
+ means no limit. However, to
+ make it easier for implementations to
+ support JSL inheritance
+ we abstain from defining a schema-specified
+ default for this attribute.
+ When a value greater than zero is
+ specified, a checkpoint is taken when
+ time-limit is reached or
+ item-count items have been processed,
+ whichever comes first. The
+ time-limit attribute is ignored for
+ "custom" checkpoint policy.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="skip-limit" use="optional" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies the number of exceptions a step will
+ skip if any configured
+ skippable exceptions are thrown by chunk
+ processing. It must be a
+ valid XML integer value. It is an optional
+ attribute. The default
+ is no limit.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="retry-limit" use="optional" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies the number of times a step will retry if
+ any configured retryable
+ exceptions are thrown by chunk processing.
+ It must be a valid XML
+ integer value. It is an optional attribute.
+ The default is no
+ limit.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="ItemReader">
+ <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>
+
+ <xs:complexType name="ItemProcessor">
+ <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>
+
+ <xs:complexType name="ItemWriter">
+ <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>
+
+ <xs:complexType name="Property">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="value" type="xs:string" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="Properties">
+ <xs:sequence>
+ <xs:element name="property" type="jsl:Property" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="partition" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="Listeners">
+ <xs:sequence>
+ <xs:element name="listener" type="jsl:Listener" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Partition">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element name="mapper" type="jsl:PartitionMapper"/>
+ <xs:element name="plan" type="jsl:PartitionPlan"/>
+ </xs:choice>
+ <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>
+
+ <xs:complexType name="PartitionPlan">
+ <xs:sequence>
+ <xs:element name="properties" type="jsl:Properties"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="partitions" use="optional" type="xs:string"/>
+ <xs:attribute name="threads" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <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>
+
+ <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>
+
+ <xs:complexType name="Analyzer">
+ <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>
+
+ <xs:complexType name="PartitionReducer">
+ <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>
+
+</xs:schema>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/java/org/apache/batchee/test/jmx/JMXTest.java
----------------------------------------------------------------------
diff --git a/jbatch/src/test/java/org/apache/batchee/test/jmx/JMXTest.java b/jbatch/src/test/java/org/apache/batchee/test/jmx/JMXTest.java
new file mode 100644
index 0000000..bafe2b2
--- /dev/null
+++ b/jbatch/src/test/java/org/apache/batchee/test/jmx/JMXTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test.jmx;
+
+import org.apache.batchee.container.services.ServicesManager;
+import org.apache.batchee.jmx.BatchEEMBean;
+import org.apache.batchee.spi.PersistenceManagerService;
+import org.apache.batchee.util.Batches;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.batch.operations.JobOperator;
+import javax.batch.runtime.BatchRuntime;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import java.util.Properties;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+public class JMXTest {
+ private static long id;
+ private static MBeanServer server;
+ private static ObjectName on;
+
+ @BeforeClass
+ public static void createAJob() throws Exception {
+ server = ManagementFactory.getPlatformMBeanServer();
+ on = new ObjectName(BatchEEMBean.DEFAULT_OBJECT_NAME);
+
+ final JobOperator jobOperator = BatchRuntime.getJobOperator();
+ id = jobOperator.start("jmx", new Properties() {{ setProperty("foo", "bar"); }});
+ Batches.waitForEnd(jobOperator, id);
+ }
+
+ @AfterClass
+ public static void deleteJob() throws Exception {
+ ServicesManager.service(PersistenceManagerService.class).cleanUp(id);
+ }
+
+ private static Object attr(final String name) throws Exception {
+ return server.getAttribute(on, name);
+ }
+
+ private static Object result(final String name, final Object... params) throws Exception {
+ final String[] signature = new String[params.length];
+ for (int i = 0; i < params.length; i++) {
+ signature[i] = params[i].getClass().getName().replace(Integer.class.getName(), int.class.getName()).replace(Long.class.getName(), long.class.getName());
+ }
+ return server.invoke(on, name, params, signature);
+ }
+
+ @Test
+ public void jobNames() throws Exception {
+ final String[] names = String[].class.cast(attr("JobNames"));
+ assertNotNull(names);
+ assertEquals(1, names.length);
+ assertEquals("jmx", names[0]);
+ }
+
+ @Test
+ public void jobInstanceCount() throws Exception {
+ final int count = Integer.class.cast(result("getJobInstanceCount", "jmx"));
+ assertEquals(1, count);
+ }
+
+ @Test
+ public void runningExecutions() throws Exception {
+ final Long[] ids = Long[].class.cast(result("getRunningExecutions", "jmx"));
+ assertEquals(0, ids.length);
+ }
+
+ @Test
+ public void jobInstances() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getJobInstances", "jmx", 0, 1));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(new Object[]{"jmx", id});
+ assertEquals(id, cd.get("instanceId"));
+ assertEquals("jmx", cd.get("jobName"));
+ }
+
+ @Test
+ public void parameters() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getParameters", id));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(List.class.cast(instance.keySet().iterator().next()).toArray());
+ assertEquals("foo", cd.get("key"));
+ assertEquals("bar", cd.get("value"));
+ }
+
+ @Test
+ public void jobInstance() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getJobInstance", id));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(new Object[]{"jmx", id});
+ assertEquals(id, cd.get("instanceId"));
+ assertEquals("jmx", cd.get("jobName"));
+ }
+
+ @Test
+ public void jobExecutions() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getJobExecutions", id, "jmx"));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(List.class.cast(instance.keySet().iterator().next()).toArray());
+ assertEquals(id, cd.get("executionId"));
+ assertEquals("jmx", cd.get("jobName"));
+ assertEquals("COMPLETED", cd.get("Exit status"));
+ assertEquals("COMPLETED", cd.get("Batch status"));
+ }
+
+ @Test
+ public void jobExecution() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getJobExecution", id));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(List.class.cast(instance.keySet().iterator().next()).toArray());
+ assertEquals(id, cd.get("executionId"));
+ assertEquals("jmx", cd.get("jobName"));
+ assertEquals("COMPLETED", cd.get("Exit status"));
+ assertEquals("COMPLETED", cd.get("Batch status"));
+ }
+
+ @Test
+ public void stepExecutions() throws Exception {
+ final TabularData instance = TabularData.class.cast(result("getStepExecutions", id));
+ assertEquals(1, instance.size());
+
+ final CompositeData cd = instance.get(List.class.cast(instance.keySet().iterator().next()).toArray());
+ assertEquals(id, cd.get("stepExecutionId"));
+ assertEquals("jmx-step", cd.get("stepName"));
+ assertEquals("mock", cd.get("Exit status"));
+ assertEquals("COMPLETED", cd.get("Batch status"));
+ assertEquals(0L, cd.get("Commit"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/java/org/apache/batchee/test/mock/BatchletMock.java
----------------------------------------------------------------------
diff --git a/jbatch/src/test/java/org/apache/batchee/test/mock/BatchletMock.java b/jbatch/src/test/java/org/apache/batchee/test/mock/BatchletMock.java
new file mode 100644
index 0000000..92e9154
--- /dev/null
+++ b/jbatch/src/test/java/org/apache/batchee/test/mock/BatchletMock.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test.mock;
+
+import javax.batch.api.AbstractBatchlet;
+
+public class BatchletMock extends AbstractBatchlet {
+ @Override
+ public String process() throws Exception {
+ return "mock";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/java/org/apache/batchee/test/tck/jndi/TckContextFactory.java
----------------------------------------------------------------------
diff --git a/jbatch/src/test/java/org/apache/batchee/test/tck/jndi/TckContextFactory.java b/jbatch/src/test/java/org/apache/batchee/test/tck/jndi/TckContextFactory.java
new file mode 100644
index 0000000..60bcd60
--- /dev/null
+++ b/jbatch/src/test/java/org/apache/batchee/test/tck/jndi/TckContextFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test.tck.jndi;
+
+import org.apache.openejb.core.LocalInitialContextFactory;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Hashtable;
+import java.util.Properties;
+
+public class TckContextFactory implements InitialContextFactory {
+ @Override
+ public Context getInitialContext(final Hashtable<?, ?> environment) throws NamingException {
+ final InitialContext delegate = new InitialContext(new Properties() {{
+ setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+ }});
+ return Context.class.cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[]{Context.class}, new InvocationHandler() {
+ @Override
+ // convert jdbc/foo to openejb:Resource/jdbc/foo since jdbc/xxx is not standard - useful for ee tests
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ if ("lookup".equals(method.getName()) && String.class.isInstance(args[0]) && String.class.cast(args[0]).startsWith("jdbc")) {
+ return method.invoke(delegate, "openejb:Resource/" + args[0]);
+ }
+ return method.invoke(delegate, args);
+ }
+ }));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/java/org/apache/batchee/test/tck/lifecycle/ContainerLifecycle.java
----------------------------------------------------------------------
diff --git a/jbatch/src/test/java/org/apache/batchee/test/tck/lifecycle/ContainerLifecycle.java b/jbatch/src/test/java/org/apache/batchee/test/tck/lifecycle/ContainerLifecycle.java
new file mode 100644
index 0000000..d25c0c0
--- /dev/null
+++ b/jbatch/src/test/java/org/apache/batchee/test/tck/lifecycle/ContainerLifecycle.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test.tck.lifecycle;
+
+import org.apache.derby.jdbc.EmbeddedDriver;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+import javax.batch.operations.BatchRuntimeException;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.logging.Logger;
+
+// forces the execution in embedded container
+public class ContainerLifecycle implements ITestListener {
+ private EJBContainer container;
+ private Logger logger = null;
+
+ @Override
+ public void onTestStart(final ITestResult iTestResult) {
+ logger.info("====================================================================================================");
+ logger.info(iTestResult.getMethod().getRealClass().getName() + "#" + iTestResult.getMethod().getMethodName());
+ logger.info("----------------------------------------------------------------------------------------------------");
+ }
+
+ @Override
+ public void onTestSuccess(final ITestResult iTestResult) {
+ logger.info(">>> SUCCESS");
+ }
+
+ @Override
+ public void onTestFailure(final ITestResult iTestResult) {
+ logger.severe(">>> FAILURE");
+ }
+
+ @Override
+ public void onTestSkipped(final ITestResult iTestResult) {
+ logger.warning(">>> SKIPPED");
+ }
+
+ @Override
+ public void onTestFailedButWithinSuccessPercentage(final ITestResult iTestResult) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void onStart(final ITestContext iTestContext) {
+ final String loggerName = "test-lifecycle";
+
+ container = EJBContainer.createEJBContainer(new PropertiesBuilder()
+ .p("openejb.jul.forceReload", Boolean.TRUE.toString())
+ .p("openejb.log.color", Boolean.toString(!System.getProperty("os.name").toLowerCase().contains("win")))
+ .p(loggerName + ".level", "INFO")
+ .p("openejb.jdbc.log", Boolean.FALSE.toString()) // with jdbc set it to TRUE to get sql queries
+
+ .p("jdbc/orderDB", "new://Resource?type=DataSource")
+ .p("jdbc/orderDB.JdbcDriver", EmbeddedDriver.class.getName())
+ .p("jdbc/orderDB.JdbcUrl", "jdbc:derby:memory:orderDB" + ";create=true")
+ .p("jdbc/orderDB.UserName", "app")
+ .p("jdbc/orderDB.Password", "app")
+ .p("jdbc/orderDB.JtaManaged", Boolean.TRUE.toString())
+
+ .p("jdbc/batchee", "new://Resource?type=DataSource")
+ .p("jdbc/batchee.JdbcDriver", EmbeddedDriver.class.getName())
+ .p("jdbc/batchee.JdbcUrl", "jdbc:derby:memory:batchee" + ";create=true")
+ .p("jdbc/batchee.UserName", "app")
+ .p("jdbc/batchee.Password", "app")
+ .p("jdbc/batchee.JtaManaged", Boolean.FALSE.toString())
+ .build());
+
+ logger = Logger.getLogger(loggerName);
+ }
+
+ @Override
+ public void onFinish(final ITestContext iTestContext) {
+ if (container != null) {
+ try {
+ container.close();
+ } catch (final Exception e) {
+ throw new BatchRuntimeException(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/META-INF/batch-jobs/jmx.xml
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/META-INF/batch-jobs/jmx.xml b/jbatch/src/test/resources/META-INF/batch-jobs/jmx.xml
new file mode 100644
index 0000000..e44c036
--- /dev/null
+++ b/jbatch/src/test/resources/META-INF/batch-jobs/jmx.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ See the NOTICE file distributed with this work for additional information
+ regarding copyright ownership. Licensed under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<job id="jmx" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
+ <step id="jmx-step">
+ <batchlet ref="org.apache.batchee.test.mock.BatchletMock"/>
+ </step>
+</job>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/META-INF/persistence.xml b/jbatch/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..599370c
--- /dev/null
+++ b/jbatch/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+
+ <persistence-unit name="batchee" transaction-type="RESOURCE_LOCAL">
+ <class>org.apache.batchee.container.services.persistence.jpa.domain.CheckpointEntity</class>
+ <class>org.apache.batchee.container.services.persistence.jpa.domain.JobExecutionEntity</class>
+ <class>org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity</class>
+ <class>org.apache.batchee.container.services.persistence.jpa.domain.StepExecutionEntity</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
+ <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:jpabatchee;create=true" />
+ <property name="javax.persistence.jdbc.user" value="app" />
+ <property name="javax.persistence.jdbc.password" value="app" />
+
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.Log" value="org.apache.openejb.openjpa.JULOpenJPALogFactory"/>
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/batchee.properties
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/batchee.properties b/jbatch/src/test/resources/batchee.properties
new file mode 100644
index 0000000..8030843
--- /dev/null
+++ b/jbatch/src/test/resources/batchee.properties
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# services
+BatchArtifactFactory = org.apache.batchee.container.services.factory.CDIBatchArtifactFactory
+BatchThreadPoolService = org.apache.batchee.container.services.executor.BoundedThreadPoolService
+
+# It is important to ensure we don't break the "heavy" storage persistance managers using the JDBC one
+# as main sample. To do so just uncomment this line. If we consider it as dangerous we could activate it
+# in *another* execution of TCKs (surefire) by default.
+#
+# PersistenceManagerService = org.apache.batchee.container.services.persistence.JDBCPersistenceManager
+# persistence.database.jndi = jdbc/batchee
+
+# to test jpa implementation - using defaults = resource local on a persistence unit named batchee
+# PersistenceManagerService = org.apache.batchee.container.services.persistence.JPAPersistenceService
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/import-jdbc/orderDB.sql
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/import-jdbc/orderDB.sql b/jbatch/src/test/resources/import-jdbc/orderDB.sql
new file mode 100644
index 0000000..fa8f823
--- /dev/null
+++ b/jbatch/src/test/resources/import-jdbc/orderDB.sql
@@ -0,0 +1,46 @@
+--
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You 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.
+--
+
+---
+--- automatically executed by OpenEJB at started when creating jdbc/orderDB
+---
+CREATE TABLE Numbers (item INT, quantity INT);
+CREATE TABLE Orders (orderID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, itemID INT, quantity INT);
+CREATE TABLE Inventory(itemID INT NOT NULL PRIMARY KEY, quantity INT NOT NULL );
+
+INSERT INTO Inventory VALUES (1, 100);
+INSERT INTO Numbers VALUES (1, 10);
+INSERT INTO Numbers VALUES (2, 10);
+INSERT INTO Numbers VALUES (3, 10);
+INSERT INTO Numbers VALUES (4, 10);
+INSERT INTO Numbers VALUES (5, 10);
+INSERT INTO Numbers VALUES (6, 10);
+INSERT INTO Numbers VALUES (7, 10);
+INSERT INTO Numbers VALUES (8, 10);
+INSERT INTO Numbers VALUES (9, 10);
+INSERT INTO Numbers VALUES (10, 10);
+INSERT INTO Numbers VALUES (11, 10);
+INSERT INTO Numbers VALUES (12, 10);
+INSERT INTO Numbers VALUES (13, 10);
+INSERT INTO Numbers VALUES (14, 10);
+INSERT INTO Numbers VALUES (15, 10);
+INSERT INTO Numbers VALUES (16, 10);
+INSERT INTO Numbers VALUES (17, 10);
+INSERT INTO Numbers VALUES (18, 10);
+INSERT INTO Numbers VALUES (19, 10);
+INSERT INTO Numbers VALUES (20, 10);
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/jndi.properties b/jbatch/src/test/resources/jndi.properties
new file mode 100644
index 0000000..c9a4fc8
--- /dev/null
+++ b/jbatch/src/test/resources/jndi.properties
@@ -0,0 +1,16 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+java.naming.factory.initial = org.apache.batchee.test.tck.jndi.TckContextFactory
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/suites/dev-suite.xml
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/suites/dev-suite.xml b/jbatch/src/test/resources/suites/dev-suite.xml
new file mode 100644
index 0000000..83f5f86
--- /dev/null
+++ b/jbatch/src/test/resources/suites/dev-suite.xml
@@ -0,0 +1,35 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<!--
+ This file is intended to be used by developpers to debug on a single/few TCK(s)
+-->
+<suite name="JSR352-TCK-dev" verbose="2">
+ <listeners>
+ <listener class-name="org.apache.batchee.test.tck.lifecycle.ContainerLifecycle"/>
+ </listeners>
+
+ <test name="dev">
+ <classes>
+ <class name="com.ibm.jbatch.tck.tests.jslxml.JobOperatorTests">
+ <methods>
+ <include name="testJobOperatorAbandonJobDuringARestart" />
+ </methods>
+ </class>
+ </classes>
+ </test>
+</suite>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/jbatch/src/test/resources/suites/tck.xml
----------------------------------------------------------------------
diff --git a/jbatch/src/test/resources/suites/tck.xml b/jbatch/src/test/resources/suites/tck.xml
new file mode 100644
index 0000000..f20ea0d
--- /dev/null
+++ b/jbatch/src/test/resources/suites/tck.xml
@@ -0,0 +1,29 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<suite name="JSR352 TCK" verbose="2">
+ <listeners>
+ <listener class-name="org.apache.batchee.test.tck.lifecycle.ContainerLifecycle"/>
+ </listeners>
+
+ <test name="JSR352 TCK">
+ <packages>
+ <package name="com.ibm.jbatch.tck.tests.ee"/> <!-- EE -->
+ <package name="com.ibm.jbatch.tck.tests.jslxml"/> <!-- JSE -->
+ </packages>
+ </test>
+</suite>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
old mode 100755
new mode 100644
index 26db6cd..bf6b9ab
--- a/pom.xml
+++ b/pom.xml
@@ -1,218 +1,192 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>javax.batch</groupId>
- <artifactId>jbatch</artifactId>
- <version>1.0</version>
- <packaging>pom</packaging>
- <name>JSR-352 RI</name>
- <description>
- Batch processing is a pervasive workload pattern, expressed by a distinct application organization and
- execution model. It is found across virtually every industry, applied to such tasks as statement
- generation, bank postings, risk evaluation, credit score calculation, inventory management, portfolio
- optimization, and on and on. Nearly any bulk processing task from any business sector is a candidate for
- batch processing.
- Batch processing is typified by bulk-oriented, non-interactive, background execution. Frequently long-
- running, it may be data or computationally intensive, execute sequentially or in parallel, and may be
- initiated through various invocation models, including ad hoc, scheduled, and on-demand.
- Batch applications have common requirements, including logging, checkpointing, and parallelization.
- Batch workloads have common requirements, especially operational control, which allow for initiation
- of, and interaction with, batch instances; such interactions include stop and restart.
- </description>
- <url>http://java.net/projects/jbatch</url>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <url>git://java.net/jbatch~jsr-352-git-repository</url>
- <connection>scm:git://java.net/jbatch~jsr-352-git-repository</connection>
- <developerConnection>scm:git://java.net/jbatch~jsr-352-git-repository</developerConnection>
- </scm>
- <parent>
- <groupId>net.java</groupId>
- <artifactId>jvnet-parent</artifactId>
- <version>1</version>
- </parent>
- <developers>
- <developer>
- <id>scottkurz</id>
- <name>Scott Kurz</name>
- <email>skurz@us.ibm.com</email>
- </developer>
- <developer>
- <id></id>
- <name>Kaushik Mukherjee</name>
- <email>kmukherj@us.ibm.com</email>
- </developer>
- <developer>
- <id>htavarez</id>
- <name>Hendrix Tavarez</name>
- <email>htavarez@us.ibm.com</email>
- </developer>
- <developer>
- <id>dmbelina</id>
- <name>Dan Belina</name>
- <email>belina@us.ibm.com</email>
- </developer>
- <developer>
- <id>ajmauer</id>
- <name>Andrew Mauer</name>
- <email>ajmauer@us.ibm.com</email>
- </developer>
- </developers>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
- <!-- Activate PGP signing only when performing a release -->
- <profiles>
- <profile>
- <id>release-sign-artifacts</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <pluginRepositories>
- <pluginRepository>
- <id>mc-release</id>
- <name>Local Maven repository of releases</name>
- <url>http://mc-repo.googlecode.com/svn/maven2/releases</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </pluginRepository>
- </pluginRepositories>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.4</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ http://www.apache.org/licenses/LICENSE-2.0
- </plugins>
- </build>
- </profile>
- </profiles>
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <modules>
- <module>JSR352.JobXML.Model</module>
- <module>JSR352.Runtime</module>
- <module>JSR352.RI.SPI</module>
- </modules>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>13</version>
+ </parent>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <bottom>
- <![CDATA[
- <p align="left">© Copyright IBM Corp. 2013<br>Licensed under the Apache License, Version 2.0
- ]]>
- </bottom>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.mycila.maven-license-plugin</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <configuration>
- <header>header.txt</header>
- <skipExistingHeaders>true</skipExistingHeaders>
- <!-- <strictCheck>true</strictCheck> -->
- <aggregate>true</aggregate>
- <excludes>
- <exclude>**/*.txt</exclude>
- <exclude>**/*.sql</exclude>
- <exclude>LICENSE.txt</exclude>
- <exclude>Documentation</exclude>
- <exclude>JSR352.Aggregation</exclude>
- <exclude>JSR352.BinaryDependencies</exclude>
- <exclude>JSR352.BinaryDependencies.WeDoNotShip</exclude>
- <exclude>JSR352.JEE.CDI.Integration</exclude>
- <exclude>JSR352.TCK.CTS</exclude>
- <exclude>JSR352.WASExtensions</exclude>
- <exclude>Legal.and.Release.Utils</exclude>
- <exclude>**/build.properties</exclude>
- <exclude>**/build.xml</exclude>
- <exclude>**/src/test/resources/**</exclude>
- <exclude>**/src/test/data/**</exclude>
- <exclude>**/bin/**</exclude>
- <exclude>**/jaxbgen/**</exclude>
- <exclude>**/toStringStubs/**</exclude>
- <exclude>**/*.html</exclude>
- <exclude>**/*.css</exclude>
- <exclude>**/.jazzignore</exclude>
- <exclude>**/*.ddl</exclude>
- <exclude>**/testJunitsBin/**</exclude>
- <exclude>**/testArtifactsBin/**</exclude>
- <exclude>**/testResources/**</exclude>
- <exclude>**/jsr352-tck.properties</exclude>
- <exclude>**/jsr352-tck-impl-*.xml</exclude>
- <exclude>**/testng-class.xml</exclude>
- <exclude>**/testng-method.xml</exclude>
- <exclude>**/beans.xml</exclude>
- </excludes>
- <includes>
- <include>JSR352.API/**</include>
- <include>JSR352.JobXML.Model/**</include>
- <include>JSR352.Runtime/**</include>
- <include>JSR352.RI.SPI/**</include>
- <include>JSR352.TCK.SPI/**</include>
- <include>JSR352.Tests.TCK/**</include>
- </includes>
- </configuration>
- <executions>
- <!--
- <execution>
- <id>check-headers</id>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- -->
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+ <groupId>org.apache.batchee</groupId>
+ <artifactId>batchee-parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>BatchEE</name>
+
+ <modules>
+ <module>jbatch</module>
+ <module>extensions</module>
+ <module>gui</module>
+ <module>tools</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- APIs -->
+ <dependency>
+ <groupId>javax.batch</groupId>
+ <artifactId>javax.batch-api</artifactId>
+ <version>${batch-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>3.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${jackson.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Testing libraries -->
+ <dependency> <!-- TCK and default tests -->
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency> <!-- camel/arquillian -->
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.10.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/main/xsd</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.9</version>
+ <configuration>
+ <includes>
+ <include>src/**/*</include>
+ <include>pom.xml</include>
+ </includes>
+ <excludes>
+ <exclude>**/*/MANIFEST.MF</exclude>
+ <exclude>.git</exclude>
+ <exclude>.gitignore</exclude>
+ <exclude>derby.log</exclude>
+ <exclude>**/META-INF/services/*</exclude>
+ <exclude>**/bootstrap-*</exclude>
+ <exclude>**/js/jquery-*</exclude>
+ <exclude>**/*.json</exclude> <!-- json can't get comments -->
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.16</version>
+ <configuration>
+ <systemPropertyVariables>
+ <derby.stream.error.file>target/derby.log</derby.stream.error.file>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <atinject.version>1.0</atinject.version>
+ <batch-api.version>1.0</batch-api.version>
+ <jackson.version>2.2.2</jackson.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-snapshot-repository</id>
+ <url>https://repository.apache.org/snapshots/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>sonatype-public-repository</id>
+ <url>https://oss.sonatype.org/content/groups/public</url>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml
new file mode 100644
index 0000000..a7398c8
--- /dev/null
+++ b/tools/maven-plugin/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>batchee-tools</artifactId>
+ <groupId>org.apache.batchee</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>batchee-maven-plugin</artifactId>
+ <name>BatchEE :: Tools :: Maven Plugin</name>
+ <packaging>maven-plugin</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.batch</groupId>
+ <artifactId>javax.batch-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.batchee</groupId>
+ <artifactId>batchee-jbatch</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.batchee</groupId>
+ <artifactId>batchee-jaxrs-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <goalPrefix>batchee</goalPrefix>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/AbandonMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/AbandonMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/AbandonMojo.java
new file mode 100644
index 0000000..d1bad8e
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/AbandonMojo.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Abandon a job.
+ */
+@Mojo(name = "abandon")
+public class AbandonMojo extends BatchEEMojoBase {
+ /**
+ * the executionId to abandon.
+ */
+ @Parameter(required = true, property = "batchee.executionId")
+ protected long executionId;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getOrCreateOperator().abandon(executionId);
+ getLog().info("Abandonned job #" + executionId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/BatchEEMojoBase.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/BatchEEMojoBase.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/BatchEEMojoBase.java
new file mode 100644
index 0000000..8b01a14
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/BatchEEMojoBase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.batchee.container.services.ServicesManager;
+import org.apache.batchee.jaxrs.client.BatchEEJAXRSClientFactory;
+import org.apache.batchee.jaxrs.client.ClientConfiguration;
+import org.apache.batchee.tools.maven.locator.MavenPluginLocator;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.operations.JobOperator;
+import javax.batch.runtime.BatchRuntime;
+import java.util.Map;
+
+public abstract class BatchEEMojoBase extends AbstractMojo {
+ /**
+ * the BatchEE properties when executed locally
+ */
+ @Parameter
+ protected Map<String, String> properties;
+
+ /**
+ * when executed remotely the client configuration
+ */
+ @Parameter
+ private ClientConfiguration clientConfiguration;
+
+ /**
+ * force to use a custom JobOperator
+ */
+ @Parameter(property = "batchee.job-operator")
+ private String jobOperatorClass;
+
+ /**
+ * The json provider to use to unmarshall responses in remote mode
+ */
+ @Parameter(property = "batchee.json-provider", defaultValue = "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider")
+ private String jsonProvider;
+
+ protected volatile JobOperator operator = null;
+
+ protected JobOperator getOrCreateOperator() {
+ if (operator == null) {
+ synchronized (this) {
+ if (operator == null) {
+ if (jobOperatorClass != null) {
+ try {
+ operator = JobOperator.class.cast(Thread.currentThread().getContextClassLoader().loadClass(jobOperatorClass).newInstance());
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("JobOperator " + jobOperatorClass + " can't be used", e);
+ }
+ } else if (clientConfiguration == null) {
+ configureBatchEE();
+ operator = BatchRuntime.getJobOperator();
+ } else {
+ operator = BatchEEJAXRSClientFactory.newClient(clientConfiguration);
+ }
+ }
+ }
+ }
+ return operator;
+ }
+
+ private void configureBatchEE() {
+ try {
+ final MavenPluginLocator locator = new MavenPluginLocator();
+ locator.init(properties);
+ ServicesManager.setServicesManagerLocator(locator);
+ } catch (final Throwable th) {
+ try {
+ Thread.currentThread().getContextClassLoader().loadClass("org.apache.batchee.container.services.ServicesManager");
+
+ getLog().error(th.getMessage(), th);
+ } catch (final Throwable ignored) {
+ getLog().info("You don't use this plugin with BatchEE so configuration will be ignored");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobActionMojoBase.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobActionMojoBase.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobActionMojoBase.java
new file mode 100644
index 0000000..a2f5330
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobActionMojoBase.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.operations.JobOperator;
+import javax.batch.runtime.BatchStatus;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+public abstract class JobActionMojoBase extends BatchEEMojoBase {
+ private static final Collection<BatchStatus> BATCH_END_STATUSES = Arrays.asList(BatchStatus.COMPLETED, BatchStatus.FAILED, BatchStatus.STOPPED, BatchStatus.ABANDONED);
+
+ /**
+ * the job parameters to use.
+ */
+ @Parameter
+ protected Map<String, String> jobParameters;
+
+ /**
+ * wait or not the end of this task before exiting maven plugin execution.
+ */
+ @Parameter(property = "batchee.wait", defaultValue = "false")
+ protected boolean wait;
+
+ protected static Properties toProperties(final Map<String, String> jobParameters) {
+ final Properties jobParams = new Properties();
+ if (jobParameters != null) {
+ jobParams.putAll(jobParameters);
+ }
+ return jobParams;
+ }
+
+ protected void waitEnd(final JobOperator jobOperator, final long id) {
+ do {
+ try {
+ Thread.sleep(100);
+ } catch (final InterruptedException e) {
+ return;
+ }
+ } while (!BATCH_END_STATUSES.contains(jobOperator.getJobExecution(id).getBatchStatus()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojo.java
new file mode 100644
index 0000000..0011233
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojo.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.runtime.JobExecution;
+
+/**
+ * Print job an execution.
+ */
+@Mojo(name = "execution")
+public class JobExecutionMojo extends JobExecutionMojoBase {
+ /**
+ * the executionId to query.
+ */
+ @Parameter(required = true, property = "batchee.executionId")
+ protected long executionId;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ final JobExecution execution = getOrCreateOperator().getJobExecution(executionId);
+ getLog().info("Job execution for execution #" + executionId + ":");
+ getLog().info(" - " + toStr(execution));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojoBase.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojoBase.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojoBase.java
new file mode 100644
index 0000000..b95acc3
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionMojoBase.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import javax.batch.runtime.JobExecution;
+
+public abstract class JobExecutionMojoBase extends BatchEEMojoBase {
+ protected static String toStr(final JobExecution exec) {
+ return "id = #" + exec.getExecutionId() + ", batch status = " + exec.getBatchStatus()
+ + ", exit status = " + exec.getExitStatus() + ", created = " + exec.getCreateTime()
+ + ", started = " + exec.getStartTime() + ", ended = " + exec.getEndTime();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionsMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionsMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionsMojo.java
new file mode 100644
index 0000000..cdfe9b3
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobExecutionsMojo.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.batchee.jaxrs.client.impl.JobInstanceImpl;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.runtime.JobExecution;
+import java.util.List;
+
+/**
+ * Print job instance executions.
+ */
+@Mojo(name = "executions")
+public class JobExecutionsMojo extends JobExecutionMojoBase {
+ /**
+ * the job name to use to query job executions
+ */
+ @Parameter(required = true, property = "batchee.job")
+ protected String jobName;
+
+ /**
+ * the instanceId to use to query job executions
+ */
+ @Parameter(required = true, property = "batchee.instance")
+ protected long instanceId;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ final List<JobExecution> executions = getOrCreateOperator().getJobExecutions(new JobInstanceImpl(jobName, instanceId));
+ getLog().info("Job executions for job instance #" + instanceId + " (" + jobName + "):");
+ for (final JobExecution exec : executions) {
+ getLog().info(" - " + toStr(exec));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceCountMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceCountMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceCountMojo.java
new file mode 100644
index 0000000..bc11d5e
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceCountMojo.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Count job instance.
+ */
+@Mojo(name = "count-instance")
+public class JobInstanceCountMojo extends BatchEEMojoBase {
+ /**
+ * the job name to use to count job instances
+ */
+ @Parameter(required = true, property = "batchee.job")
+ protected String jobName;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Job instances: " + getOrCreateOperator().getJobInstanceCount(jobName));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceMojo.java
new file mode 100644
index 0000000..44c3a4d
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstanceMojo.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.runtime.JobInstance;
+
+/**
+ * Print JobInstance for a particular execution.
+ */
+@Mojo(name = "instance")
+public class JobInstanceMojo extends BatchEEMojoBase {
+ /**
+ * the executionId to use to find the corresponding job instance
+ */
+ @Parameter(required = true, property = "batchee.executionId")
+ protected long executionId;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ final JobInstance instance = getOrCreateOperator().getJobInstance(executionId);
+ getLog().info("Job name for execution #" + executionId + ": " + instance.getJobName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstancesMojo.java
----------------------------------------------------------------------
diff --git a/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstancesMojo.java b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstancesMojo.java
new file mode 100644
index 0000000..550df5b
--- /dev/null
+++ b/tools/maven-plugin/src/main/java/org/apache/batchee/tools/maven/JobInstancesMojo.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.batch.runtime.JobInstance;
+import java.util.List;
+
+/**
+ * Print job instances.
+ */
+@Mojo(name = "instances")
+public class JobInstancesMojo extends BatchEEMojoBase {
+ /**
+ * the job name to use to find job instances
+ */
+ @Parameter(required = true, property = "batchee.job")
+ protected String jobName;
+
+ /**
+ * the first job instance to take into account
+ */
+ @Parameter(property = "batchee.start", defaultValue = "0")
+ protected int start;
+
+ /**
+ * the maximum number of instance to bring back
+ */
+ @Parameter(property = "batchee.count", defaultValue = "10")
+ protected int count;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ final List<JobInstance> jobInstances = getOrCreateOperator().getJobInstances(jobName, start, count);
+ getLog().info("Job instances (" + jobInstances.size() + "):");
+ for (final JobInstance instance : jobInstances) {
+ getLog().info(" - #" + instance.getInstanceId() + " -> " + instance.getJobName());
+ }
+ }
+}