Skip to content

Applied some standartization #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target/
libs/
tmp/
node_modules/
jaxws/jaxws-client/src/main/

# OS Files #
.DS_Store
Expand Down
27 changes: 27 additions & 0 deletions batch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Java EE 7 Samples: Batch #

The [JSR 352](https://jcp.org/en/jsr/detail?id=352) specifies a programming model for batch applications and a runtime for scheduling and executing jobs.

## Samples ##

- batchlet-simple
- chunk-checkpoint
- chunk-csv-database
- chunk-exception
- chunk-mapper
- chunk-optional-processor
- chunk-partition
- chunk-simple
- decision
- flow
- batch-listeners
- multiple-steps
- split
- chunk-simple-nobeans
- scheduling

## How to run

More information on how to run can be found at: <https://github.com/javaee-samples/javaee7-samples#how-to-run->


16 changes: 8 additions & 8 deletions batch/batch-listeners/pom.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<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">
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.javaee7.batch</groupId>
<artifactId>batch-samples</artifactId>
<groupId>org.javaee7</groupId>
<artifactId>batch</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>batch-listeners</artifactId>
<artifactId>batch-batch-listeners</artifactId>
<packaging>war</packaging>
<name>Batch Listeners</name>
<name>Java EE 7 Sample: batch - batch-listeners</name>
<description>Batch Listeners - Applying Listeners to Job, Chunk, Step, Reader, Processor and Writer</description>

<dependencies>
<dependency>
<groupId>org.javaee7</groupId>
<artifactId>util-samples</artifactId>
<artifactId>util</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
public class MyInputRecord {
private int id;

public MyInputRecord() { }


public MyInputRecord() {
}

public MyInputRecord(int id) {
this.id = id;
}
Expand All @@ -19,7 +20,7 @@ public int getId() {
public void setId(int id) {
this.id = id;
}

@Override
public String toString() {
return "MyInputRecord: " + id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MyItemProcessor implements ItemProcessor {
@Override
public Object processItem(Object t) {
System.out.println("processItem: " + t);
return (((MyInputRecord)t).getId() % 2 == 0) ? null : new MyOutputRecord(((MyInputRecord)t).getId() * 2);

return (((MyInputRecord) t).getId() % 2 == 0) ? null : new MyOutputRecord(((MyInputRecord) t).getId() * 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
@Named
public class MyItemReader extends AbstractItemReader {

private final StringTokenizer tokens;

public MyItemReader() {
tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
}

@Override
public MyInputRecord readItem() {
if (tokens.hasMoreTokens()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
public class MyOutputRecord {
private int id;

public MyOutputRecord() { }


public MyOutputRecord() {
}

public MyOutputRecord(int id) {
this.id = id;
}
Expand All @@ -19,7 +20,7 @@ public int getId() {
public void setId(int id) {
this.id = id;
}

@Override
public String toString() {
return "MyOutputRecord: " + id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ public class BatchListenersTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClass(BatchTestHelper.class)
.addPackage("org.javaee7.batch.batch.listeners")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
.addClass(BatchTestHelper.class)
.addPackage("org.javaee7.batch.batch.listeners")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
System.out.println(war.toString(true));
return war;
}
Expand Down
17 changes: 8 additions & 9 deletions batch/batchlet-simple/pom.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<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">
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.javaee7.batch</groupId>
<artifactId>batch-samples</artifactId>
<groupId>org.javaee7</groupId>
<artifactId>batch</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>batchlet-simple</artifactId>
<artifactId>batch-batchlet-simple</artifactId>
<packaging>war</packaging>
<name>Batchlet Simple</name>
<name>Java EE 7 Sample: batch - batchlet-simple</name>
<description>Batchlet Simple - Execute a task oriented step</description>

<dependencies>
<dependency>
<groupId>org.javaee7</groupId>
<artifactId>util-samples</artifactId>
<artifactId>util</artifactId>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public class MyBatchletTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClass(BatchTestHelper.class)
.addClass(MyBatchlet.class)
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
.addClass(BatchTestHelper.class)
.addClass(MyBatchlet.class)
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
System.out.println(war.toString(true));
return war;
}
Expand Down
16 changes: 8 additions & 8 deletions batch/chunk-checkpoint/pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<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">
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.javaee7.batch</groupId>
<artifactId>batch-samples</artifactId>
<groupId>org.javaee7</groupId>
<artifactId>batch</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>chunk-checkpoint</artifactId>
<artifactId>batch-chunk-checkpoint</artifactId>
<packaging>war</packaging>
<name>Batch Chunk Checkpoint</name>
<name>Java EE 7 Sample: batch - chunk-checkpoint</name>
<description>Chunk Checkpoint - Custom Checkpoint Policy</description>

<dependencies>
<dependency>
<groupId>org.javaee7</groupId>
<artifactId>util-samples</artifactId>
<artifactId>util</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
public class MyInputRecord {
private int id;

public MyInputRecord() { }


public MyInputRecord() {
}

public MyInputRecord(int id) {
this.id = id;
}
Expand All @@ -19,7 +20,7 @@ public int getId() {
public void setId(int id) {
this.id = id;
}

@Override
public String toString() {
return "MyInputRecord: " + id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MyItemProcessor implements ItemProcessor {
@Override
public MyOutputRecord processItem(Object t) {
System.out.println("processItem: " + t);
return (((MyInputRecord)t).getId() % 2 == 0) ? null : new MyOutputRecord(((MyInputRecord)t).getId() * 2);

return (((MyInputRecord) t).getId() % 2 == 0) ? null : new MyOutputRecord(((MyInputRecord) t).getId() * 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
*/
@Named
public class MyItemReader extends AbstractItemReader {

private StringTokenizer tokens;
static int COUNT = 0;

@Override
public void open(Serializable checkpoint) throws Exception {
tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
}

@Override
public MyInputRecord readItem() {
if (tokens.hasMoreTokens()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
public class MyOutputRecord {
private int id;

public MyOutputRecord() { }


public MyOutputRecord() {
}

public MyOutputRecord(int id) {
this.id = id;
}
Expand All @@ -19,7 +20,7 @@ public int getId() {
public void setId(int id) {
this.id = id;
}

@Override
public String toString() {
return "MyOutputRecord: " + id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<processor ref="myItemProcessor"/>
<writer ref="myItemWriter"/>
<checkpoint-algorithm ref="myCheckpointAlgorithm"/>
</chunk>
</chunk>
</step>
</job>

Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public class BatchChunkCheckpointTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClass(BatchTestHelper.class)
.addPackage("org.javaee7.batch.chunk.checkpoint")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
.addClass(BatchTestHelper.class)
.addPackage("org.javaee7.batch.chunk.checkpoint")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/myJob.xml");
System.out.println(war.toString(true));
return war;
}
Expand Down
16 changes: 8 additions & 8 deletions batch/chunk-csv-database/pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<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">
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.javaee7.batch</groupId>
<artifactId>batch-samples</artifactId>
<groupId>org.javaee7</groupId>
<artifactId>batch</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>chunk-csv-database</artifactId>
<artifactId>batch-chunk-csv-database</artifactId>
<packaging>war</packaging>
<name>Batch Chunk CSV Database</name>
<name>Java EE 7 Sample: batch - chunk-csv-database</name>
<description>Chunk Processing - Read, Process, Write to a Database</description>

<dependencies>
<dependency>
<groupId>org.javaee7</groupId>
<artifactId>util-samples</artifactId>
<artifactId>util</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ public class MyItemProcessor implements ItemProcessor {
@Override
public Person processItem(Object t) {
System.out.println("processItem: " + t);
StringTokenizer tokens = new StringTokenizer((String)t, ",");

StringTokenizer tokens = new StringTokenizer((String) t, ",");

String name = tokens.nextToken();
String date;

try {
date = tokens.nextToken();
format.setLenient(false);
format.parse(date);
} catch (ParseException e) {
return null;
}

return new Person(id++, name, date);
}
}
Loading