Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

Commit 2ab3a89

Browse files
author
Arun Gupta
committed
Adding the first cut of Java EE 7 samples
Former-commit-id: 1fcb2d4dd163a01151635cbb16d2b7aa070910dc
0 parents  commit 2ab3a89

451 files changed

Lines changed: 32053 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This workspace will provide different Java EE 7 Samples.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.glassfish</groupId>
6+
<artifactId>batchlet-simple</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>war</packaging>
9+
10+
<name>batchlet-simple</name>
11+
12+
<properties>
13+
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<repositories>
18+
<repository>
19+
<id>java.net-promoted</id>
20+
<url>https://maven.java.net/content/groups/promoted/</url>
21+
</repository>
22+
</repositories>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>javax</groupId>
27+
<artifactId>javaee-api</artifactId>
28+
<version>7.0-b78</version>
29+
<scope>provided</scope>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>javax.batch</groupId>
34+
<artifactId>javax.batch-api-all</artifactId>
35+
<version>1.0-b10</version>
36+
</dependency>
37+
</dependencies>
38+
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-compiler-plugin</artifactId>
44+
<version>2.3.2</version>
45+
<configuration>
46+
<source>1.7</source>
47+
<target>1.7</target>
48+
</configuration>
49+
</plugin>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-war-plugin</artifactId>
53+
<version>2.1.1</version>
54+
<configuration>
55+
<failOnMissingWebXml>false</failOnMissingWebXml>
56+
</configuration>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
61+
</project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
41+
package org.glassfish.batchlet.simple;
42+
43+
import javax.batch.api.AbstractBatchlet;
44+
45+
/**
46+
* @author Arun Gupta
47+
*/
48+
public class MyBatchlet extends AbstractBatchlet {
49+
50+
@Override
51+
public String process() {
52+
System.out.println("Running inside a batchlet");
53+
54+
return "COMPLETED";
55+
}
56+
57+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package org.glassfish.batchlet.simple;
6+
7+
import java.io.IOException;
8+
import java.io.PrintWriter;
9+
import java.util.Properties;
10+
import java.util.logging.Level;
11+
import java.util.logging.Logger;
12+
import javax.batch.operations.JobOperator;
13+
import javax.batch.operations.exception.JobStartException;
14+
import javax.batch.runtime.BatchRuntime;
15+
import javax.servlet.ServletException;
16+
import javax.servlet.annotation.WebServlet;
17+
import javax.servlet.http.HttpServlet;
18+
import javax.servlet.http.HttpServletRequest;
19+
import javax.servlet.http.HttpServletResponse;
20+
21+
/**
22+
*
23+
* @author arungup
24+
*/
25+
@WebServlet(urlPatterns = {"/TestServlet"})
26+
public class TestServlet extends HttpServlet {
27+
28+
/**
29+
* Processes requests for both HTTP
30+
* <code>GET</code> and
31+
* <code>POST</code> methods.
32+
*
33+
* @param request servlet request
34+
* @param response servlet response
35+
* @throws ServletException if a servlet-specific error occurs
36+
* @throws IOException if an I/O error occurs
37+
*/
38+
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
39+
throws ServletException, IOException {
40+
response.setContentType("text/html;charset=UTF-8");
41+
try (PrintWriter out = response.getWriter()) {
42+
out.println("<html>");
43+
out.println("<head>");
44+
out.println("<title>Servlet TestServlet</title>");
45+
out.println("</head>");
46+
out.println("<body>");
47+
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
48+
out.println("About to start the job<br>");
49+
JobOperator jo = BatchRuntime.getJobOperator();
50+
out.println("Got the job operator: " + jo + "<br>");
51+
jo.start("myJob", new Properties());
52+
out.println("Job submitted<br>");
53+
out.println("</body>");
54+
out.println("</html>");
55+
} catch (JobStartException ex) {
56+
Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);
57+
}
58+
}
59+
60+
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
61+
/**
62+
* Handles the HTTP
63+
* <code>GET</code> method.
64+
*
65+
* @param request servlet request
66+
* @param response servlet response
67+
* @throws ServletException if a servlet-specific error occurs
68+
* @throws IOException if an I/O error occurs
69+
*/
70+
@Override
71+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
72+
throws ServletException, IOException {
73+
processRequest(request, response);
74+
}
75+
76+
/**
77+
* Handles the HTTP
78+
* <code>POST</code> method.
79+
*
80+
* @param request servlet request
81+
* @param response servlet response
82+
* @throws ServletException if a servlet-specific error occurs
83+
* @throws IOException if an I/O error occurs
84+
*/
85+
@Override
86+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
87+
throws ServletException, IOException {
88+
processRequest(request, response);
89+
}
90+
91+
/**
92+
* Returns a short description of the servlet.
93+
*
94+
* @return a String containing servlet description
95+
*/
96+
@Override
97+
public String getServletInfo() {
98+
return "Short description";
99+
}// </editor-fold>
100+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
/*
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4+
*
5+
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
6+
*
7+
* The contents of this file are subject to the terms of either the GNU
8+
* General Public License Version 2 only ("GPL") or the Common Development
9+
* and Distribution License("CDDL") (collectively, the "License"). You
10+
* may not use this file except in compliance with the License. You can
11+
* obtain a copy of the License at
12+
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
13+
* or packager/legal/LICENSE.txt. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*
16+
* When distributing the software, include this License Header Notice in each
17+
* file and include the License file at packager/legal/LICENSE.txt.
18+
*
19+
* GPL Classpath Exception:
20+
* Oracle designates this particular file as subject to the "Classpath"
21+
* exception as provided by Oracle in the GPL Version 2 section of the License
22+
* file that accompanied this code.
23+
*
24+
* Modifications:
25+
* If applicable, add the following below the License Header, with the fields
26+
* enclosed by brackets [] replaced by your own identifying information:
27+
* "Portions Copyright [year] [name of copyright owner]"
28+
*
29+
* Contributor(s):
30+
* If you wish your version of this file to be governed by only the CDDL or
31+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
32+
* elects to include this software in this distribution under the [CDDL or GPL
33+
* Version 2] license." If you don't indicate a single choice of license, a
34+
* recipient has the option to distribute your version of this file under
35+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
36+
* its licensees as provided above. However, if you add GPL Version 2 code
37+
* and therefore, elected the GPL Version 2 license, then the option applies
38+
* only if the new code is made subject to such option by the copyright
39+
* holder.
40+
*/
41+
-->
42+
43+
<job id="myJob" xmlns="http://batch.jsr352/jsl">
44+
<step id="myStep" >
45+
<batchlet ref="myBatchlet"/>
46+
</step>
47+
</job>
48+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/*
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5+
*
6+
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
7+
*
8+
* The contents of this file are subject to the terms of either the GNU
9+
* General Public License Version 2 only ("GPL") or the Common Development
10+
* and Distribution License("CDDL") (collectively, the "License"). You
11+
* may not use this file except in compliance with the License. You can
12+
* obtain a copy of the License at
13+
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
14+
* or packager/legal/LICENSE.txt. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
* When distributing the software, include this License Header Notice in each
18+
* file and include the License file at packager/legal/LICENSE.txt.
19+
*
20+
* GPL Classpath Exception:
21+
* Oracle designates this particular file as subject to the "Classpath"
22+
* exception as provided by Oracle in the GPL Version 2 section of the License
23+
* file that accompanied this code.
24+
*
25+
* Modifications:
26+
* If applicable, add the following below the License Header, with the fields
27+
* enclosed by brackets [] replaced by your own identifying information:
28+
* "Portions Copyright [year] [name of copyright owner]"
29+
*
30+
* Contributor(s):
31+
* If you wish your version of this file to be governed by only the CDDL or
32+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
33+
* elects to include this software in this distribution under the [CDDL or GPL
34+
* Version 2] license." If you don't indicate a single choice of license, a
35+
* recipient has the option to distribute your version of this file under
36+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
37+
* its licensees as provided above. However, if you add GPL Version 2 code
38+
* and therefore, elected the GPL Version 2 license, then the option applies
39+
* only if the new code is made subject to such option by the copyright
40+
* holder.
41+
*/
42+
-->
43+
44+
<batch-artifacts xmlns="http://jcp.org.batch/jsl">
45+
<ref id="myBatchlet" class="org.glassfish.batchlet.simple.MyBatchlet"/>
46+
</batch-artifacts>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!--
2+
/*
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4+
*
5+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
6+
*
7+
* The contents of this file are subject to the terms of either the GNU
8+
* General Public License Version 2 only ("GPL") or the Common Development
9+
* and Distribution License("CDDL") (collectively, the "License"). You
10+
* may not use this file except in compliance with the License. You can
11+
* obtain a copy of the License at
12+
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
13+
* or packager/legal/LICENSE.txt. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*
16+
* When distributing the software, include this License Header Notice in each
17+
* file and include the License file at packager/legal/LICENSE.txt.
18+
*
19+
* GPL Classpath Exception:
20+
* Oracle designates this particular file as subject to the "Classpath"
21+
* exception as provided by Oracle in the GPL Version 2 section of the License
22+
* file that accompanied this code.
23+
*
24+
* Modifications:
25+
* If applicable, add the following below the License Header, with the fields
26+
* enclosed by brackets [] replaced by your own identifying information:
27+
* "Portions Copyright [year] [name of copyright owner]"
28+
*
29+
* Contributor(s):
30+
* If you wish your version of this file to be governed by only the CDDL or
31+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
32+
* elects to include this software in this distribution under the [CDDL or GPL
33+
* Version 2] license." If you don't indicate a single choice of license, a
34+
* recipient has the option to distribute your version of this file under
35+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
36+
* its licensees as provided above. However, if you add GPL Version 2 code
37+
* and therefore, elected the GPL Version 2 license, then the option applies
38+
* only if the new code is made subject to such option by the copyright
39+
* holder.
40+
*/
41+
-->
42+
<%@page contentType="text/html" pageEncoding="UTF-8"%>
43+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
44+
"http://www.w3.org/TR/html4/loose.dtd">
45+
46+
<html>
47+
<head>
48+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
49+
<title>Getting Started with Batch API - Simple Batchlet!</title>
50+
</head>
51+
<body>
52+
<h1>Getting Started with Batch API - Simple Batchlet!</h1>
53+
Start the <a href="${pageContext.request.contextPath}/TestServlet"/>job</a>.
54+
</body>
55+
</html>

0 commit comments

Comments
 (0)