From 88cc1559026258c3acc56ff0285a9ea8ca79cb56 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 13:25:13 -0700 Subject: [PATCH 0001/1080] New client to invoke REST endpoint using HttpURLConnection - simple GET and POST requests --- .../org/javaee7/jaxrs/client/MyResource.java | 2 + .../java/org/javaee7/jaxrs/client/People.java | 61 ++++++ ...TestServlet.java => TestJAXRS2Client.java} | 4 +- .../jaxrs/client/TestURLConnectionClient.java | 184 ++++++++++++++++++ jaxrs/jaxrs-client/src/main/webapp/index.jsp | 3 +- 5 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/People.java rename jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/{TestServlet.java => TestJAXRS2Client.java} (98%) create mode 100644 jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestURLConnectionClient.java diff --git a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/MyResource.java b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/MyResource.java index eb005556b..20a752834 100644 --- a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/MyResource.java +++ b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/MyResource.java @@ -39,6 +39,8 @@ */ package org.javaee7.jaxrs.client; +import java.util.ArrayList; +import java.util.List; import javax.ejb.EJB; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; diff --git a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/People.java b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/People.java new file mode 100644 index 000000000..7d2f5fbd9 --- /dev/null +++ b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/People.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author Arun Gupta + */ +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class People { + private Person[] person; + + public Person[] getPerson() { + return person; + } + + public void setPerson(Person[] person) { + this.person = person; + } +} diff --git a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestServlet.java b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestJAXRS2Client.java similarity index 98% rename from jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestServlet.java rename to jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestJAXRS2Client.java index 7f78a1227..6dcb09a72 100644 --- a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestServlet.java +++ b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestJAXRS2Client.java @@ -56,8 +56,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/TestJAXRS2Client"}) +public class TestJAXRS2Client extends HttpServlet { /** * Processes requests for both HTTP diff --git a/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestURLConnectionClient.java b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestURLConnectionClient.java new file mode 100644 index 000000000..02261b45e --- /dev/null +++ b/jaxrs/jaxrs-client/src/main/java/org/javaee7/jaxrs/client/TestURLConnectionClient.java @@ -0,0 +1,184 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestURLConnectionClient"}) +public class TestURLConnectionClient extends HttpServlet { + + private static final String CHARSET = "UTF-8"; + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println("REST Endpoint using HttpURLConnection"); + out.println(""); + out.println(""); + out.println("

REST Endpoint using HttpURLConnection

"); + URL url = new URL("http://" + + request.getServerName() + + ":" + + request.getServerPort() + + request.getContextPath() + + "/webresources/persons"); + + out.print("
POSTing...
"); + // POST + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("POST"); + connection.setDoInput(true); + connection.setDoOutput(true); // required to be able to POST + connection.setRequestProperty("Accept-Charset", CHARSET); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + CHARSET); + String postRequest = String.format("name=%s&age=%s", + URLEncoder.encode("Name", CHARSET), + URLEncoder.encode("17", CHARSET)); + try (OutputStream os = connection.getOutputStream()) { + os.write(postRequest.getBytes(CHARSET)); + } + try (InputStream is = connection.getInputStream()) { + byte[] bytes = new byte[1024]; + is.read(bytes); + out.println(new String(bytes)); + } + connection.disconnect(); + out.print("POSTed a new item ...
"); + + // GET + out.print("
GETTing...
"); + connection = (HttpURLConnection) url.openConnection(); + connection.setDoOutput(false); + connection.setRequestMethod("GET"); +// try (InputStream is = connection.getInputStream()) { +// byte[] bytes = new byte[1024]; +// is.read(bytes); +// out.println(new String(bytes)); +// } + + try { + JAXBContext jc = JAXBContext.newInstance(Person.class, People.class); + Unmarshaller um = jc.createUnmarshaller(); + People people = (People) um.unmarshal(connection.getInputStream()); + out.format("GOT %1$s items
", people.getPerson().length); + for (Person p : people.getPerson()) { + out.print(p + "
"); + } + } catch (JAXBException ex) { + Logger.getLogger(TestURLConnectionClient.class.getName()).log(Level.SEVERE, null, ex); + } + out.println("... done.
"); + + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/jaxrs/jaxrs-client/src/main/webapp/index.jsp b/jaxrs/jaxrs-client/src/main/webapp/index.jsp index dce71e8a2..60d5a41d0 100644 --- a/jaxrs/jaxrs-client/src/main/webapp/index.jsp +++ b/jaxrs/jaxrs-client/src/main/webapp/index.jsp @@ -50,6 +50,7 @@

JAX-RS 2 Client API

- Invoke the Client API. + Invoke using JAX-RS 2 Client API.

+ Invoke using HttpUrlConnection. From 23bfd943c1d946f0d41a0cc992f446e057504d9c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 13:54:14 -0700 Subject: [PATCH 0002/1080] New sample to show PU injection in JAX-RS 2 Entity Provider - throwing NPE at this time --- jaxrs/readerwriter-pu/nb-configuration.xml | 19 +++ jaxrs/readerwriter-pu/pom.xml | 15 ++ .../jaxrs/readerwriter/pu/Employee.java | 87 +++++++++++ .../jaxrs/readerwriter/pu/MyApplication.java | 59 +++++++ .../jaxrs/readerwriter/pu/MyObject.java | 66 ++++++++ .../jaxrs/readerwriter/pu/MyReader.java | 88 +++++++++++ .../jaxrs/readerwriter/pu/MyResource.java | 66 ++++++++ .../jaxrs/readerwriter/pu/MyWriter.java | 87 +++++++++++ .../jaxrs/readerwriter/pu/TestServlet.java | 147 ++++++++++++++++++ .../src/main/resources/META-INF/create.sql | 1 + .../src/main/resources/META-INF/drop.sql | 1 + .../src/main/resources/META-INF/load.sql | 8 + .../main/resources/META-INF/persistence.xml | 18 +++ .../readerwriter-pu/src/main/webapp/index.jsp | 55 +++++++ 14 files changed, 717 insertions(+) create mode 100644 jaxrs/readerwriter-pu/nb-configuration.xml create mode 100644 jaxrs/readerwriter-pu/pom.xml create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java create mode 100644 jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java create mode 100644 jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql create mode 100644 jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql create mode 100644 jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql create mode 100644 jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml create mode 100644 jaxrs/readerwriter-pu/src/main/webapp/index.jsp diff --git a/jaxrs/readerwriter-pu/nb-configuration.xml b/jaxrs/readerwriter-pu/nb-configuration.xml new file mode 100644 index 000000000..38c192ec6 --- /dev/null +++ b/jaxrs/readerwriter-pu/nb-configuration.xml @@ -0,0 +1,19 @@ + + + + + + ide + gfv3ee6 + + diff --git a/jaxrs/readerwriter-pu/pom.xml b/jaxrs/readerwriter-pu/pom.xml new file mode 100644 index 000000000..1486a876c --- /dev/null +++ b/jaxrs/readerwriter-pu/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + org.javaee7.jaxrs + jaxrs-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.jaxrs + readerwriter-pu + 1.0-SNAPSHOT + war + diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java new file mode 100644 index 000000000..d3b5bdb4b --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java @@ -0,0 +1,87 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * http://glassfish.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + +/** + * @author Arun Gupta + */ +@Entity +@Table(name="EMPLOYEE_SCHEMA_GEN_SCRIPTS") +@NamedQueries({ + @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e") +}) +public class Employee implements Serializable { + private static final long serialVersionUID = 1L; + @Id + private int id; + + @Column(length=50) + private String name; + + public Employee() { } + + public Employee(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java new file mode 100644 index 000000000..fa13db8f4 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.util.Set; +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +/** + * @author Arun Gupta + */ +@ApplicationPath("webresources") +public class MyApplication extends Application { + @Override + public Set> getClasses() { + Set> resources = new java.util.HashSet<>(); + resources.add(MyResource.class); + resources.add(MyReader.class); + resources.add(MyWriter.class); + return resources; + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java new file mode 100644 index 000000000..7e6d97026 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java @@ -0,0 +1,66 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.io.Serializable; + +/** + * @author Arun Gupta + */ +public class MyObject implements Serializable { + public static final String MIME_TYPE = "application/myType"; + + private int index; + + public MyObject() { + } + + public MyObject(int index) { + this.index = index; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java new file mode 100644 index 000000000..43394e548 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java @@ -0,0 +1,88 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.ws.rs.Consumes; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyReader; +import javax.ws.rs.ext.Provider; + +/** + * @author Arun Gupta + */ +@Provider +@Consumes(MyObject.MIME_TYPE) +public class MyReader implements MessageBodyReader { + + @PersistenceContext + EntityManager em; + + @Override + public boolean isReadable(Class type, Type type1, Annotation[] antns, MediaType mt) { + return MyObject.class.isAssignableFrom(type); + } + + @Override + public MyObject readFrom(Class type, + Type type1, + Annotation[] antns, + MediaType mt, MultivaluedMap mm, + InputStream in) throws IOException, WebApplicationException { + try { + ObjectInputStream ois = new ObjectInputStream(in); + System.out.println("List of employees: " + em.createNamedQuery("Employee.findAll", Employee.class).getResultList()); + return (MyObject) ois.readObject(); + } catch (ClassNotFoundException ex) { + Logger.getLogger(MyReader.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java new file mode 100644 index 000000000..655c4a35e --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java @@ -0,0 +1,66 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * @author Arun Gupta + */ +@Path("fruits") +public class MyResource { + private final String[] RESPONSE = { "apple", "banana", "mango" }; + + @POST + @Consumes(value=MyObject.MIME_TYPE) + public String getFruit(MyObject mo) { + System.out.println("endpoint invoked (getFruit(" + mo.getIndex() + "))"); + + return RESPONSE[Integer.valueOf(mo.getIndex()) % 3]; + } + + @POST + @Path("fruitInt") + public String getFruit2(int index) { + return RESPONSE[index % 3]; + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java new file mode 100644 index 000000000..0e85c2b91 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java @@ -0,0 +1,87 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyWriter; +import javax.ws.rs.ext.Provider; + +/** + * @author Arun Gupta + */ +@Provider +@Produces(MyObject.MIME_TYPE) +public class MyWriter implements MessageBodyWriter { + + @Override + public boolean isWriteable(Class type, Type type1, Annotation[] antns, MediaType mt) { + return MyObject.class.isAssignableFrom(type); + } + + @Override + public long getSize(MyObject t, Class type, Type type1, Annotation[] antns, MediaType mt) { + // As of JAX-RS 2.0, the method has been deprecated and the + // value returned by the method is ignored by a JAX-RS runtime. + // All MessageBodyWriter implementations are advised to return -1 from + // the method. + + return -1; + } + + @Override + public void writeTo(MyObject t, + Class type, + Type type1, + Annotation[] antns, + MediaType mt, + MultivaluedMap mm, + OutputStream out) throws IOException, WebApplicationException { + ObjectOutputStream oos = new ObjectOutputStream(out); + oos.writeObject(t); + } +} diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java new file mode 100644 index 000000000..554500623 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java @@ -0,0 +1,147 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jaxrs.readerwriter.pu; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println("Servlet TestServlet"); + out.println(""); + out.println(""); + out.println("

Servlet TestServlet at " + request.getContextPath() + "

"); + Client client = ClientBuilder.newClient(); + client + .register(MyReader.class) + .register(MyWriter.class); + + WebTarget target = client.target("http://" + + request.getServerName() + + ":" + + request.getServerPort() + + request.getContextPath() + + "/webresources/fruits"); + System.out.println("POST request"); + String fruit = target + .request() + .post(Entity.entity(new MyObject(1), MyObject.MIME_TYPE), String.class); + out.println("Received response: " + fruit + "

"); + fruit = target + .path("fruitInt") + .request() + .post(Entity.text("1"), String.class); + out.println("Received response: " + fruit + "

"); + + out.println("Check server.log for client/server interceptor output."); + out.println(""); + out.println(""); + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql b/jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql new file mode 100644 index 000000000..ed3b9f5b9 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql @@ -0,0 +1 @@ +CREATE TABLE EMPLOYEE_SCHEMA_READER_WRITER_PU ("ID" INTEGER not null primary key, "NAME" VARCHAR(50) not null) \ No newline at end of file diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql b/jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql new file mode 100644 index 000000000..9a513a51d --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql @@ -0,0 +1 @@ +DROP TABLE EMPLOYEE_SCHEMA_READER_WRITER_PU \ No newline at end of file diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql b/jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql new file mode 100644 index 000000000..90497f062 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql @@ -0,0 +1,8 @@ +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (1, 'Penny') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (2, 'Sheldon') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (3, 'Amy') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (4, 'Leonard') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (5, 'Bernadette') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (6, 'Raj') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (7, 'Howard') +INSERT INTO EMPLOYEE_SCHEMA_READER_WRITER_PU("ID", "NAME") VALUES (8, 'Priya') \ No newline at end of file diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml b/jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml new file mode 100644 index 000000000..010072bfd --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/jaxrs/readerwriter-pu/src/main/webapp/index.jsp b/jaxrs/readerwriter-pu/src/main/webapp/index.jsp new file mode 100644 index 000000000..be74c5d28 --- /dev/null +++ b/jaxrs/readerwriter-pu/src/main/webapp/index.jsp @@ -0,0 +1,55 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Injecting PU in JAX-RS 2 Entity Provider + + +

Injecting PU in JAX-RS 2 Entity Provider

+ Invoke the Client and check server.log for output from PU. + + From 944e5865c6c03e0c33788b9cf4b4bb9475b9eb9b Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 14:02:23 -0700 Subject: [PATCH 0003/1080] Fixed the table name --- .../main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java index d3b5bdb4b..47db55c65 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java +++ b/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java @@ -51,7 +51,7 @@ * @author Arun Gupta */ @Entity -@Table(name="EMPLOYEE_SCHEMA_GEN_SCRIPTS") +@Table(name="EMPLOYEE_SCHEMA_READER_WRITER_PU") @NamedQueries({ @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e") }) From 06a88bfc86b1592ea1c105d8e574cb5b9dc0ee5f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 14:05:05 -0700 Subject: [PATCH 0004/1080] Moving readerwriter-pu to readerwriter-injection --- .../nb-configuration.xml | 0 jaxrs/{readerwriter-pu => readerwriter-injection}/pom.xml | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/Employee.java | 2 +- .../javaee7/jaxrs/readerwriter/injection}/MyApplication.java | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/MyObject.java | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/MyReader.java | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/MyResource.java | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/MyWriter.java | 2 +- .../org/javaee7/jaxrs/readerwriter/injection}/TestServlet.java | 2 +- .../src/main/resources/META-INF/create.sql | 0 .../src/main/resources/META-INF/drop.sql | 0 .../src/main/resources/META-INF/load.sql | 0 .../src/main/resources/META-INF/persistence.xml | 0 .../src/main/webapp/index.jsp | 0 14 files changed, 8 insertions(+), 8 deletions(-) rename jaxrs/{readerwriter-pu => readerwriter-injection}/nb-configuration.xml (100%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/pom.xml (91%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/Employee.java (98%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/MyApplication.java (98%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/MyObject.java (97%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/MyReader.java (98%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/MyResource.java (98%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/MyWriter.java (98%) rename jaxrs/{readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu => readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection}/TestServlet.java (99%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/src/main/resources/META-INF/create.sql (100%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/src/main/resources/META-INF/drop.sql (100%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/src/main/resources/META-INF/load.sql (100%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/src/main/resources/META-INF/persistence.xml (100%) rename jaxrs/{readerwriter-pu => readerwriter-injection}/src/main/webapp/index.jsp (100%) diff --git a/jaxrs/readerwriter-pu/nb-configuration.xml b/jaxrs/readerwriter-injection/nb-configuration.xml similarity index 100% rename from jaxrs/readerwriter-pu/nb-configuration.xml rename to jaxrs/readerwriter-injection/nb-configuration.xml diff --git a/jaxrs/readerwriter-pu/pom.xml b/jaxrs/readerwriter-injection/pom.xml similarity index 91% rename from jaxrs/readerwriter-pu/pom.xml rename to jaxrs/readerwriter-injection/pom.xml index 1486a876c..b10ca56fc 100644 --- a/jaxrs/readerwriter-pu/pom.xml +++ b/jaxrs/readerwriter-injection/pom.xml @@ -9,7 +9,7 @@ org.javaee7.jaxrs - readerwriter-pu + readerwriter-injection 1.0-SNAPSHOT war diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/Employee.java similarity index 98% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/Employee.java index 47db55c65..9e6f088df 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/Employee.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/Employee.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.io.Serializable; import javax.persistence.Column; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyApplication.java similarity index 98% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyApplication.java index fa13db8f4..9d5600a5a 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyApplication.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyApplication.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.util.Set; import javax.ws.rs.ApplicationPath; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyObject.java similarity index 97% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyObject.java index 7e6d97026..374cf621c 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyObject.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyObject.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.io.Serializable; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyReader.java similarity index 98% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyReader.java index 43394e548..1fab532a2 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyReader.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyReader.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.io.IOException; import java.io.InputStream; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyResource.java similarity index 98% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyResource.java index 655c4a35e..504fdc328 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyResource.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyResource.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyWriter.java similarity index 98% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyWriter.java index 0e85c2b91..e40bbc9cf 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/MyWriter.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/MyWriter.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.io.IOException; import java.io.ObjectOutputStream; diff --git a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/TestServlet.java similarity index 99% rename from jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java rename to jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/TestServlet.java index 554500623..286749655 100644 --- a/jaxrs/readerwriter-pu/src/main/java/org/javaee7/jaxrs/readerwriter/pu/TestServlet.java +++ b/jaxrs/readerwriter-injection/src/main/java/org/javaee7/jaxrs/readerwriter/injection/TestServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jaxrs.readerwriter.pu; +package org.javaee7.jaxrs.readerwriter.injection; import java.io.IOException; import java.io.PrintWriter; diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql b/jaxrs/readerwriter-injection/src/main/resources/META-INF/create.sql similarity index 100% rename from jaxrs/readerwriter-pu/src/main/resources/META-INF/create.sql rename to jaxrs/readerwriter-injection/src/main/resources/META-INF/create.sql diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql b/jaxrs/readerwriter-injection/src/main/resources/META-INF/drop.sql similarity index 100% rename from jaxrs/readerwriter-pu/src/main/resources/META-INF/drop.sql rename to jaxrs/readerwriter-injection/src/main/resources/META-INF/drop.sql diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql b/jaxrs/readerwriter-injection/src/main/resources/META-INF/load.sql similarity index 100% rename from jaxrs/readerwriter-pu/src/main/resources/META-INF/load.sql rename to jaxrs/readerwriter-injection/src/main/resources/META-INF/load.sql diff --git a/jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml b/jaxrs/readerwriter-injection/src/main/resources/META-INF/persistence.xml similarity index 100% rename from jaxrs/readerwriter-pu/src/main/resources/META-INF/persistence.xml rename to jaxrs/readerwriter-injection/src/main/resources/META-INF/persistence.xml diff --git a/jaxrs/readerwriter-pu/src/main/webapp/index.jsp b/jaxrs/readerwriter-injection/src/main/webapp/index.jsp similarity index 100% rename from jaxrs/readerwriter-pu/src/main/webapp/index.jsp rename to jaxrs/readerwriter-injection/src/main/webapp/index.jsp From b2acbbb6c9e28788aafd3024428fd4113f330f90 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 14:06:31 -0700 Subject: [PATCH 0005/1080] Adding the new module (readerwriter-injection) --- jaxrs/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxrs/pom.xml b/jaxrs/pom.xml index 21ef1b4d9..647eeb7cd 100644 --- a/jaxrs/pom.xml +++ b/jaxrs/pom.xml @@ -48,6 +48,7 @@ server-sent-event singleton-application singleton-annotation + readerwriter-injection \ No newline at end of file From cff68daf6e7098589e1103f52dea31877bdb50ee Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 15:05:45 -0700 Subject: [PATCH 0006/1080] Removing redundant dependencies --- jaxrs/readerwriter/pom.xml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/jaxrs/readerwriter/pom.xml b/jaxrs/readerwriter/pom.xml index b14296c67..2f39b38fc 100644 --- a/jaxrs/readerwriter/pom.xml +++ b/jaxrs/readerwriter/pom.xml @@ -12,21 +12,4 @@ readerwriter 1.0-SNAPSHOT war - - - org.glassfish.jersey.containers - jersey-container-servlet - 2.0 - - - org.glassfish.jersey.core - jersey-client - 2.0 - - - org.glassfish.jersey.media - jersey-media-multipart - 2.0 - - From da4b97a3411ca1a57d918c78f66cddcb05ab5813 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 15:16:52 -0700 Subject: [PATCH 0007/1080] New sample to show singleton instance of WebSocket endpoint --- .../endpoint-singleton/nb-configuration.xml | 18 +++++ websocket/endpoint-singleton/pom.xml | 15 ++++ .../endpoint/singleton/MyConfigurator.java | 62 ++++++++++++++++ .../endpoint/singleton/MyEndpoint.java | 61 ++++++++++++++++ .../src/main/webapp/index.jsp | 66 +++++++++++++++++ .../src/main/webapp/websocket.js | 73 +++++++++++++++++++ 6 files changed, 295 insertions(+) create mode 100644 websocket/endpoint-singleton/nb-configuration.xml create mode 100644 websocket/endpoint-singleton/pom.xml create mode 100644 websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyConfigurator.java create mode 100644 websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyEndpoint.java create mode 100644 websocket/endpoint-singleton/src/main/webapp/index.jsp create mode 100644 websocket/endpoint-singleton/src/main/webapp/websocket.js diff --git a/websocket/endpoint-singleton/nb-configuration.xml b/websocket/endpoint-singleton/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/endpoint-singleton/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/websocket/endpoint-singleton/pom.xml b/websocket/endpoint-singleton/pom.xml new file mode 100644 index 000000000..5a2ecc6db --- /dev/null +++ b/websocket/endpoint-singleton/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + org.javaee7.websocket + websocket-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.websocket + endpoint-singleton + 1.0-SNAPSHOT + war + diff --git a/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyConfigurator.java b/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyConfigurator.java new file mode 100644 index 000000000..a2502ec69 --- /dev/null +++ b/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyConfigurator.java @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.websocket.endpoint.singleton; + +import javax.websocket.server.ServerEndpointConfig; + +/** + * @author Arun Gupta + */ +public class MyConfigurator extends ServerEndpointConfig.Configurator { + + private static final MyEndpoint ENDPOINT = new MyEndpoint(); + + @Override + public T getEndpointInstance(Class endpointClass) throws InstantiationException { + if (MyEndpoint.class.equals(endpointClass)) { + return (T)ENDPOINT; + } else { + throw new InstantiationException(); + } + } + + + +} diff --git a/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyEndpoint.java b/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyEndpoint.java new file mode 100644 index 000000000..90fa83981 --- /dev/null +++ b/websocket/endpoint-singleton/src/main/java/org/javaee7/websocket/endpoint/singleton/MyEndpoint.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.websocket.endpoint.singleton; + +import javax.websocket.OnMessage; +import javax.websocket.server.ServerEndpoint; + +/** + * @author Arun Gupta + */ +@ServerEndpoint(value="/websocket", configurator = MyConfigurator.class) +public class MyEndpoint { + String newValue = ""; + + /** + * singleton instance of endpoint ensures that string concatenation would work + */ + @OnMessage + public String concat(String value) { + this.newValue += value; + + return newValue; + } +} diff --git a/websocket/endpoint-singleton/src/main/webapp/index.jsp b/websocket/endpoint-singleton/src/main/webapp/index.jsp new file mode 100644 index 000000000..815143703 --- /dev/null +++ b/websocket/endpoint-singleton/src/main/webapp/index.jsp @@ -0,0 +1,66 @@ + + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + WebSocket : Simple Annotated Endpoint - Singleton + + + +

WebSocket : Simple Annotated Endpoint - Singleton

+ +

Click on "Concat" button multiple times to see the concatenated output coming from endpoint.

+
+
+ +
+
+
+ +
+ + + diff --git a/websocket/endpoint-singleton/src/main/webapp/websocket.js b/websocket/endpoint-singleton/src/main/webapp/websocket.js new file mode 100644 index 000000000..c3ad2388e --- /dev/null +++ b/websocket/endpoint-singleton/src/main/webapp/websocket.js @@ -0,0 +1,73 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +var wsUri = "ws://" + document.location.host + document.location.pathname + "websocket"; +console.log("Connecting to " + wsUri); +var websocket = new WebSocket(wsUri); +websocket.onopen = function(evt) { onOpen(evt) }; +websocket.onmessage = function(evt) { onMessage(evt) }; +websocket.onerror = function(evt) { onError(evt) }; + +var output = document.getElementById("output"); + +function concat() { + console.log("concat: " + myField.value); + websocket.send(myField.value); + writeToScreen("SENT: " + myField.value); +} +function onOpen() { + console.log("onOpen"); + writeToScreen("CONNECTED"); +} + +function onMessage(evt) { + writeToScreen("RECEIVED: " + evt.data); +} + +function onError(evt) { + writeToScreen('ERROR: ' + evt.data); +} + +function writeToScreen(message) { + var pre = document.createElement("p"); + pre.style.wordWrap = "break-word"; + pre.innerHTML = message; + output.appendChild(pre); +} From d5b6f38e8908293da3e44592d4802922224bc94a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 15:17:20 -0700 Subject: [PATCH 0008/1080] Adding the singleton module --- websocket/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket/pom.xml b/websocket/pom.xml index 82420d9df..293ea1e8d 100644 --- a/websocket/pom.xml +++ b/websocket/pom.xml @@ -44,6 +44,7 @@ websocket-client-programmatic-config websocket-client-programmatic-encoders whiteboard + endpoint-singleton \ No newline at end of file From 4f7b55d1d3bd915a1a5f89692a35a9547ab748fc Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 10 Sep 2013 15:48:57 -0700 Subject: [PATCH 0009/1080] Updating the list of recepients and title --- .../java/org/javaee7/javamail/definition/TestServlet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java index a95a5f1dd..f3cd13e2a 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java @@ -78,7 +78,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Sending email using JavaMail API"); out.println(""); out.println(""); out.println("

Sending email using JavaMail API

"); @@ -122,7 +122,7 @@ protected PasswordAuthentication getPasswordAuthentication() { // Transport t = session.getTransport(); // t.connect(creds.getProperty("username"), creds.getProperty("password")); // t.send(message); - Transport.send(message); + Transport.send(message, message.getAllRecipients()); out.println("message sent!"); From 5df3d3b40ddeb6b4707f2ee30ef65af5ebffb294 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 09:58:59 -0700 Subject: [PATCH 0010/1080] New sample to show @Transactional and @TransactionScope together --- jta/pom.xml | 1 + jta/transactional-scope/nb-configuration.xml | 18 +++ jta/transactional-scope/pom.xml | 16 +++ .../transactional/scope/MyDataBean.java | 54 +++++++ .../scope/MyTransactionalBean.java | 79 +++++++++++ .../transactional/scope/TestServlet.java | 132 ++++++++++++++++++ .../src/main/webapp/WEB-INF/beans.xml | 5 + .../src/main/webapp/index.jsp | 56 ++++++++ 8 files changed, 361 insertions(+) create mode 100644 jta/transactional-scope/nb-configuration.xml create mode 100644 jta/transactional-scope/pom.xml create mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java create mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java create mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java create mode 100644 jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml create mode 100644 jta/transactional-scope/src/main/webapp/index.jsp diff --git a/jta/pom.xml b/jta/pom.xml index 5171ebb55..10c3bf230 100644 --- a/jta/pom.xml +++ b/jta/pom.xml @@ -18,5 +18,6 @@ transaction-scope tx-exception user-transaction + transactional-scope diff --git a/jta/transactional-scope/nb-configuration.xml b/jta/transactional-scope/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/jta/transactional-scope/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/jta/transactional-scope/pom.xml b/jta/transactional-scope/pom.xml new file mode 100644 index 000000000..1efe4e602 --- /dev/null +++ b/jta/transactional-scope/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + org.javaee7.jta + jta-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.samples.jta + transactional-scope + 1.0-SNAPSHOT + war + + diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java new file mode 100644 index 000000000..37c6344f1 --- /dev/null +++ b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.samples.transactional.scope; + +import java.io.Serializable; +import javax.transaction.TransactionScoped; + +/** + * @author Arun Gupta + */ +@TransactionScoped +public class MyDataBean implements Serializable { + + public String getId() { + return this + ""; + } +} diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java new file mode 100644 index 000000000..48c83c09a --- /dev/null +++ b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java @@ -0,0 +1,79 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.samples.transactional.scope; + +import javax.enterprise.context.ContextNotActiveException; +import javax.inject.Inject; +import javax.transaction.Transactional; + +/** + * @author Arun Gupta + */ +public class MyTransactionalBean { + + @Inject + MyDataBean bean1; + + @Inject + MyDataBean bean2; + + @Transactional + public void scenario1() { + System.out.println("Scenario 1: Bean injected twice, same id"); + System.out.println(bean1.getId()); + System.out.println(bean2.getId()); + } + + @Transactional + public void scenario2() { + System.out.println("Scenario 2: Repeat of Scenario 1, different transaction, different ids"); + System.out.println(bean1.getId()); + System.out.println(bean2.getId()); + } + + public void scenario3() { + System.out.println("Scenario 3: Bean outside a transaction"); + try { + bean1.getId(); + } catch (ContextNotActiveException ex) { + System.out.println("Got expected ContextNotActiveException"); + } + } +} diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java new file mode 100644 index 000000000..27035942a --- /dev/null +++ b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java @@ -0,0 +1,132 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.samples.transactional.scope; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + @Inject MyTransactionalBean bean; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("JTA 1.2 @Transactional and @TransactionScoped"); + out.println(""); + out.println(""); + out.println("

JTA 1.2 @Transactional and @TransactionScoped

"); + out.println("

Scenario 1: Bean injected twice, same id

"); + bean.scenario1(); + out.println("

Scenario 2: Repeat of Scenario 1, different transaction, different ids

"); + bean.scenario2(); + out.println("

Scenario 3: Bean outside a transaction

"); + bean.scenario3(); + out.println("Check server.log for output"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml b/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..4ca8195be --- /dev/null +++ b/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,5 @@ + + + diff --git a/jta/transactional-scope/src/main/webapp/index.jsp b/jta/transactional-scope/src/main/webapp/index.jsp new file mode 100644 index 000000000..072082938 --- /dev/null +++ b/jta/transactional-scope/src/main/webapp/index.jsp @@ -0,0 +1,56 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + + JTA : @Transactional and @TransactionScope + + +

JTA : @Transactional and @TransactionScope

+ Inject @TransactionScoped beans
+ + \ No newline at end of file From a7a6a69fb18faa114cf70e439223702cddc04890 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:50:59 -0700 Subject: [PATCH 0011/1080] CDI extension impl project --- cdi/extension-impl/nb-configuration.xml | 18 ++++++ cdi/extension-impl/pom.xml | 15 +++++ .../cdi/extension/impl/MyExtension.java | 61 +++++++++++++++++++ .../javax.enterprise.inject.spi.Extension | 1 + .../src/main/webapp/WEB-INF/beans.xml | 49 +++++++++++++++ cdi/extension-impl/src/main/webapp/index.jsp | 55 +++++++++++++++++ 6 files changed, 199 insertions(+) create mode 100644 cdi/extension-impl/nb-configuration.xml create mode 100644 cdi/extension-impl/pom.xml create mode 100644 cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java create mode 100644 cdi/extension-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension create mode 100644 cdi/extension-impl/src/main/webapp/WEB-INF/beans.xml create mode 100644 cdi/extension-impl/src/main/webapp/index.jsp diff --git a/cdi/extension-impl/nb-configuration.xml b/cdi/extension-impl/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/cdi/extension-impl/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/cdi/extension-impl/pom.xml b/cdi/extension-impl/pom.xml new file mode 100644 index 000000000..3d3dfb87a --- /dev/null +++ b/cdi/extension-impl/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.javaee7.cdi + cdi-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.cdi + extension-impl + 1.0-SNAPSHOT + jar + diff --git a/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java b/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java new file mode 100644 index 000000000..0945ca4ea --- /dev/null +++ b/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.extension.impl; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.enterprise.event.Observes; +import javax.enterprise.inject.spi.Extension; +import javax.enterprise.inject.spi.ProcessAnnotatedType; + +/** + * @author Arun Gupta + */ +public class MyExtension implements Extension { + + void processAnnotatedType(@Observes ProcessAnnotatedType pat) { + Logger.getAnonymousLogger().log(Level.INFO, + "processing annotation: {0}", + pat. + getAnnotatedType(). + getJavaClass(). + getName()); + } +} diff --git a/cdi/extension-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/cdi/extension-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension new file mode 100644 index 000000000..f58fccd1a --- /dev/null +++ b/cdi/extension-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension @@ -0,0 +1 @@ +org.javaee7.cdi.extension.impl.MyExtension \ No newline at end of file diff --git a/cdi/extension-impl/src/main/webapp/WEB-INF/beans.xml b/cdi/extension-impl/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/cdi/extension-impl/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/cdi/extension-impl/src/main/webapp/index.jsp b/cdi/extension-impl/src/main/webapp/index.jsp new file mode 100644 index 000000000..74ee4a88c --- /dev/null +++ b/cdi/extension-impl/src/main/webapp/index.jsp @@ -0,0 +1,55 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + CDI Extension Implementation + + +

CDI Extension Implementation

+ This project generates a JAR file that is integrated in a WAR file built using "extension" project. Nothing to invoke here. + + From 5e0d1fa3a74d36d03954e393bec52f0fd8727351 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:51:20 -0700 Subject: [PATCH 0012/1080] Starting work on CDI extension sample --- cdi/extension/nb-configuration.xml | 18 +++ cdi/extension/pom.xml | 15 ++ .../javaee7/cdi/bean/discovery/Greeting.java | 47 +++++++ .../cdi/bean/discovery/SimpleGreeting.java | 52 +++++++ .../cdi/bean/discovery/TestServlet.java | 128 ++++++++++++++++++ .../src/main/webapp/WEB-INF/beans.xml | 49 +++++++ .../lib/extension-impl-1.0-SNAPSHOT.jar | Bin 0 -> 3278 bytes cdi/extension/src/main/webapp/index.jsp | 56 ++++++++ 8 files changed, 365 insertions(+) create mode 100644 cdi/extension/nb-configuration.xml create mode 100644 cdi/extension/pom.xml create mode 100644 cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/Greeting.java create mode 100644 cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/SimpleGreeting.java create mode 100644 cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/TestServlet.java create mode 100644 cdi/extension/src/main/webapp/WEB-INF/beans.xml create mode 100644 cdi/extension/src/main/webapp/WEB-INF/lib/extension-impl-1.0-SNAPSHOT.jar create mode 100644 cdi/extension/src/main/webapp/index.jsp diff --git a/cdi/extension/nb-configuration.xml b/cdi/extension/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/cdi/extension/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/cdi/extension/pom.xml b/cdi/extension/pom.xml new file mode 100644 index 000000000..78caa04b1 --- /dev/null +++ b/cdi/extension/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.javaee7.cdi + cdi-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.cdi + extension + 1.0-SNAPSHOT + war + diff --git a/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/Greeting.java b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/Greeting.java new file mode 100644 index 000000000..f47cb70fd --- /dev/null +++ b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/Greeting.java @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.discovery; + +/** + * @author Arun Gupta + */ +public interface Greeting { + public String greet(String name); +} diff --git a/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/SimpleGreeting.java b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/SimpleGreeting.java new file mode 100644 index 000000000..12971c03c --- /dev/null +++ b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/SimpleGreeting.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.discovery; + +/** + * @author Arun Gupta + */ +public class SimpleGreeting implements Greeting { + + @Override + public String greet(String name) { + return "Hello " + name; + } + +} diff --git a/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/TestServlet.java b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/TestServlet.java new file mode 100644 index 000000000..f841eafc8 --- /dev/null +++ b/cdi/extension/src/main/java/org/javaee7/cdi/bean/discovery/TestServlet.java @@ -0,0 +1,128 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.discovery; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author arungup + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + @Inject + Greeting greeting; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("bean-discovery-mode=all"); + out.println(""); + out.println(""); + out.println("

bean-discovery-mode=all

"); + out.println(greeting.greet("Duke")); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/cdi/extension/src/main/webapp/WEB-INF/beans.xml b/cdi/extension/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/cdi/extension/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/cdi/extension/src/main/webapp/WEB-INF/lib/extension-impl-1.0-SNAPSHOT.jar b/cdi/extension/src/main/webapp/WEB-INF/lib/extension-impl-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..af0e783b55ab9115b6231d66499d253af31ccfd0 GIT binary patch literal 3278 zcmWIWW@h1H0D(KD+Rk7Gl;8x?zOEsTx}JV+`T~t1dKY=Ub+yi&Ilno`;EM5sr$stm=T7K&>pF3;KUoqsMNIpE zO2y7O-9f_MLBS<+wbqKra0^W~4ic>qJ{|NKDC1>Z>~-K#r|Z(nmrGd%7K+5KpOQ1- z=d&udk8aEM#O#S-fVqr;;TD<)gpgfUoLW?tnVeb-_Xz{oCqN}|zyf6D7p3D-!2?y1 zl~|UTnre`~POT_O%`48#&%>in9Vd@!B+ayTwslWrVqn~vxTk!Y(+`sp`LwcgcZ#3gvrhkh{(k&^#xu#Pts-*E4Vo_c^*r=spI4SB zbAHzcnVBM+W^AaQ%(qO&$9hI$#(C|vK8=bKPfnAZlpUd;#o6BI?_OD7J zBt>LxmaIf#%GQzq^^L7Q7rovTuk7V{y|7Cqyed45r~g$~eyroEn^S~K6D6KSsT=dm z(eFBtmgud!`l^+xU82#qP@;0+o zYNxe=ro5cS;p#id$9RsE&v(PBpA0+QxlbufdN{8~i4hHg>48uaDVtY*X``Zku~MG#=<4 zK5|yp>1E6t$-_VXN0qf%Nd!x~{k+3((=YVYbylhe-?t@^R~zkCu=c)SkvW&reLZl6 z_xJTT7Ki;x`TJe^^=uyJ@Qt}F6Vs#jrmeC$_ff{=?wJo(3%lo?yJs=u;L^u-0Y7Hx zD}D04?`iz#+HnQWviJrGnMJu1-oFU8JAT7V@v8q6maR>Rs>Qj*dXx3))o&WPUG)5K z+@|+y=iNm!eLNq_MitJIJewc^A0sSzW0su!$T=%Fu`Cri52F{epgauEh7iTTLP!r<#OR?G z9O#<$2y2FyBf4niffKN}EaqwcY|hBQFaek`O-VMZAU{{HA~&aZQlR%?1A*i7MgQN*HRZVr#{pCzCXU`e~h2c?o~ZfTl^$# zJKc49m9JcS;w3)0Vso9J+~dr$V%@ClGL2f79c7a%Uf0?_+tb8m+AQ@%Z01JRc)e$T z<}Ll5T~&0)vUJhyZK-c#&);44vZMY?y0%q>KMPUh@b4=g!w}R9^Z0sZ;6oeu@1VRwaRTj*h`o-yV3^E9*Q{T3K#IrobuSl`0b`&Nh;7J40Dt1ALkvH zx<7ey+XUx)?!NSOlhA3Q;NY`gCj}er6zcXex-2x=yCG<$sOri}g}J+C?qszDRm6-; zBFwnk5M-UB9@(69%+ZG_jAh4uS9Z15pA+ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + CDI : Bean Discovery Mode = All + + +

CDI : Bean Discovery Mode = All

+ Invoke the Greeting. +

Check "server.log" for output from the extension. + + From e5d5031a11069f2e544c807e9f44527cc295877a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:53:29 -0700 Subject: [PATCH 0013/1080] Improving the message --- .../main/java/org/javaee7/cdi/extension/impl/MyExtension.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java b/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java index 0945ca4ea..8b62e0c3e 100644 --- a/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java +++ b/cdi/extension-impl/src/main/java/org/javaee7/cdi/extension/impl/MyExtension.java @@ -52,7 +52,7 @@ public class MyExtension implements Extension { void processAnnotatedType(@Observes ProcessAnnotatedType pat) { Logger.getAnonymousLogger().log(Level.INFO, - "processing annotation: {0}", + "CDI Extension Processing Annotation -> {0}", pat. getAnnotatedType(). getJavaClass(). From 3aef228eef1fabe51179074a14402adda8ded4fd Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:56:34 -0700 Subject: [PATCH 0014/1080] Improving the message --- cdi/extension/src/main/webapp/index.jsp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cdi/extension/src/main/webapp/index.jsp b/cdi/extension/src/main/webapp/index.jsp index 64927d4e3..30e1c30a7 100644 --- a/cdi/extension/src/main/webapp/index.jsp +++ b/cdi/extension/src/main/webapp/index.jsp @@ -46,11 +46,13 @@ - CDI : Bean Discovery Mode = All + CDI Extension -

CDI : Bean Discovery Mode = All

- Invoke the Greeting. -

Check "server.log" for output from the extension. +

CDI Extension

+ Check "server.log" for output from the CDI extension (implemented in "extension-impl"). + +

Optionally invoke the Greeting. + From 0121268cb8f43d8fc9b529c8dc7f100bcf2cc072 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:56:47 -0700 Subject: [PATCH 0015/1080] Updating the extension implementation to show better message --- .../lib/extension-impl-1.0-SNAPSHOT.jar | Bin 3278 -> 3286 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/cdi/extension/src/main/webapp/WEB-INF/lib/extension-impl-1.0-SNAPSHOT.jar b/cdi/extension/src/main/webapp/WEB-INF/lib/extension-impl-1.0-SNAPSHOT.jar index af0e783b55ab9115b6231d66499d253af31ccfd0..24af45c6cda21b458ea39dac484b75ccb01d32ab 100644 GIT binary patch delta 1033 zcmX>nc}7_9A;%;FkqOh$fY=W29spHGdFjtD2t23m8M0xKP6Zg zmu__m5b|MF^1Z+PZHnxsxw&P_S(5$){%UyCY=1yLbSu21BQZ3c%gOq}fX%Enn| zs-EGI>wi`yywLPeHLI82x{0I9@22vS^$)^j)<0pnv}SffO#LLq!yyOxWA?p%W9g*x z(JQoQiLsyFYI{T`TZWaJ9FBRN(suB(r{E2roRz6tV>Zq>J2~ZgUwz5c#nOx` zbDnpdo+$8L=IN)kn*vWfi$4E3;*N^-zl{sGtm&M@qiT7#jA^-=$1+Jj)@7e1cJFDt zv6$78!*zqY)2Ep?K1w^fuJN9n_kJexEW;RSv%JU$W@#Vq9Gc_1_iK~l=5J-nl~OZv zqNbkm{de2ma;|^fyuV3_2ahRD)7i7-V?Ebtu}x-06}ig&=1WRG_bFD3XP+?mxL;`A zLO$0kZPVnw*IZX!y~klQ$BM7wqbM+etD==WYw*`+WP`CZFg}=&wd@v zb2xmXFU!RAXxp+=HlHf^X60G!@q3ZfzdT>&Ov2@|_nI|li=AFA{x>epuK&&3@_yaideO(%>v3*W z;Vj9sZ)d(wh+ll()}+kkflXEBmVV{}_F4mfdp3dY6QM^mianyK-5JJI}jzvX#k>}IW0g`EvF5L+Rf<(q5`<3Cd+aef|*>&yeL^^@&T?u zd5~S;3m|NosP8*s~kEDqq7VajKne1KJPaz8f@NMtThWDQ8fX!2Wb4W=I; mrom))9$^KT^UHunRRXaM+(-t7C5=t&V1=uAatu3P5tQJfjAP@?_KjQRR$g zAZk6MHBjB;H;k1+w@bC1TRYpjCo(ZGY-VL(FkqPckW*&zcP_E|sUflc!j2-g$=uwj zqAV^eRx~Wqjc-<1uqBLRqDye2$K~$}=dN+yw)yP4DGojMUh)AoAJ~5^?kS(<^uwe? zKCSHBo#JQrtkb`rzaPJ!@l3L6tBBlkgQkmqJr6zE=anVOoZt09W~Rud85^o6^DUF{ zv7V8babA0^Pov_*lhY(8W!F1~8kLAoohIFTtB=P!>A3om?Ghm^@nQ=%y;hrHGC%Z) zK`4(?|NAam#iv5+Lqw*-RJWB_vSKKw*9M;2uTrHngE*T(nN`8QR>D#bM(6oq$PUmu6|nYy)>p# z#d`bH<*k`5OEyi_*FElZNBq{~+16o-;Te0+B^O4&xv{*>Y?az+t)M9{r*XLYPVzCH zBjxkmu<9qnPIvB83X>kr>(MxWrR)NSc2VrjqUv)o7kZxVDk!|oSZ>%Y&i5?l(>3q5 zlF!ekd~-YUvh%cZeA<4ih=PqBs_g4y_S7HS)I6u#=H3pC2fBxkoRxKY8S_T+@Q?pd zWo=dx!P0I&@9^973q5t6mFmIwZAs+SM!OZPy)Rf~&ZTr;4_x8>ef^EaVZT!TewThd zo5wkPV=l|Y^ys~5t8C7Flrgz`=7ZJ3?s@0#S0#~;{KWt8+Y7l`lO;4lAcV#mo)6-_yh|3}uo_xPfw-hbg( zK}%Vivqk%h4PBiPhNA9zNgZc$LfQLfE?<>-N4aNCQPmL>fLYBSv_om|ao4Wu^jV7U-NYUQ*6QHMF*KomEZH%Mg! zS28b3rkQ+#D-dL$G`9?+)np59IS_}NON#mb|MbanJWARD-i%Bl%&?rQ?F`DXFrWux sFbFXG|GxyN-f;3~ZY{ Date: Wed, 11 Sep 2013 14:57:05 -0700 Subject: [PATCH 0016/1080] Adding extension sample --- cdi/pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cdi/pom.xml b/cdi/pom.xml index a8b88cc5b..5272a0feb 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -25,6 +25,7 @@ interceptors nobeans-xml beansxml-noversion - beanmanager - + beanmanager + extension + \ No newline at end of file From daa9f74480397407df0eb6443ae4b15e4a5a2696 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 11 Sep 2013 14:57:43 -0700 Subject: [PATCH 0017/1080] Adding NetBeans configuration file --- cdi/built-in/nb-configuration.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cdi/built-in/nb-configuration.xml diff --git a/cdi/built-in/nb-configuration.xml b/cdi/built-in/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/cdi/built-in/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + From 1c6de5d77deb7e07177b058b63bbf289694b7253 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:03:44 -0700 Subject: [PATCH 0018/1080] Fixing the namespace from java.sun.com -> xmlns.jcp.org --- concurrency/executor/src/main/webapp/WEB-INF/web.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/concurrency/executor/src/main/webapp/WEB-INF/web.xml b/concurrency/executor/src/main/webapp/WEB-INF/web.xml index 5af95712c..58a527849 100644 --- a/concurrency/executor/src/main/webapp/WEB-INF/web.xml +++ b/concurrency/executor/src/main/webapp/WEB-INF/web.xml @@ -1,9 +1,9 @@ - + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" + version="3.1"> + + \ No newline at end of file From 69929a69f73aff2e05f4a9650a32bf8719182d49 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:07:57 -0700 Subject: [PATCH 0020/1080] Better headings --- batch/chunk-optional-processor/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/chunk-optional-processor/src/main/webapp/index.jsp b/batch/chunk-optional-processor/src/main/webapp/index.jsp index 66400a913..960870d1c 100644 --- a/batch/chunk-optional-processor/src/main/webapp/index.jsp +++ b/batch/chunk-optional-processor/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - GOptional Processor in Chunk! + Batch : Optional Processor in Chunk -

Optional Processor in Chunk!

+

Batch : Optional Processor in Chunk

Start the job. From 5a8434b69f572ff7ba15e82a58576797a3b4d853 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:08:11 -0700 Subject: [PATCH 0021/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/batch/chunk-optional-processor/src/main/webapp/WEB-INF/beans.xml b/batch/chunk-optional-processor/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/batch/chunk-optional-processor/src/main/webapp/WEB-INF/beans.xml +++ b/batch/chunk-optional-processor/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 56e2f76aff1793b51da96a6598b87374345251ef Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:08:19 -0700 Subject: [PATCH 0022/1080] Adding NetBeans configuration file --- .../nb-configuration.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 batch/chunk-optional-processor/nb-configuration.xml diff --git a/batch/chunk-optional-processor/nb-configuration.xml b/batch/chunk-optional-processor/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/batch/chunk-optional-processor/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + From 5efdd6da433844cd0c0f47393b6cf31d26256b05 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:10:02 -0700 Subject: [PATCH 0023/1080] Better headings --- batch/chunk-partition/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/chunk-partition/src/main/webapp/index.jsp b/batch/chunk-partition/src/main/webapp/index.jsp index fff8e2f65..a5fe3f945 100644 --- a/batch/chunk-partition/src/main/webapp/index.jsp +++ b/batch/chunk-partition/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - Batch Partition + Batch : Partition -

Batch Partition

+

Batch : Partition

Start the job. From 39ca3a5cbb2e53e21a12de9dc221a21f87b47414 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:10:11 -0700 Subject: [PATCH 0024/1080] Better output message --- .../org/javaee7/batch/sample/chunk/partition/TestServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java b/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java index f13974928..989fa34ac 100644 --- a/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java +++ b/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java @@ -95,6 +95,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (String j : jo.getJobNames()) { out.println("--> " + j + "
"); } + out.println("

Check \"server.log\" for out"); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { From 1e59bfcf57ff304b882ed363447b73be929bbe38 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:10:19 -0700 Subject: [PATCH 0025/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/batch/chunk-partition/src/main/webapp/WEB-INF/beans.xml b/batch/chunk-partition/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/batch/chunk-partition/src/main/webapp/WEB-INF/beans.xml +++ b/batch/chunk-partition/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From b00c92656f7b6a8cdb5f21acb9fc695bd20237ff Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:10:26 -0700 Subject: [PATCH 0026/1080] Adding NetBeans configuration file --- batch/chunk-partition/nb-configuration.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 batch/chunk-partition/nb-configuration.xml diff --git a/batch/chunk-partition/nb-configuration.xml b/batch/chunk-partition/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/batch/chunk-partition/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + From e297903ef59efab82452cffd3f7c4140621ba994 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:11:55 -0700 Subject: [PATCH 0027/1080] Better headings --- cdi/decorators/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdi/decorators/src/main/webapp/index.jsp b/cdi/decorators/src/main/webapp/index.jsp index 2d3f5eb53..0feb8a7a6 100644 --- a/cdi/decorators/src/main/webapp/index.jsp +++ b/cdi/decorators/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - CDI Decorators + CDI : Decorators -

CDI Decorators

+

CDI : Decorators

Invoke the bean. From fe4cdb0e51c9d743046d56a5cba6de073fed2b26 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:12:01 -0700 Subject: [PATCH 0028/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/cdi/decorators/src/main/webapp/WEB-INF/beans.xml b/cdi/decorators/src/main/webapp/WEB-INF/beans.xml index 6a5a5448b..704400770 100644 --- a/cdi/decorators/src/main/webapp/WEB-INF/beans.xml +++ b/cdi/decorators/src/main/webapp/WEB-INF/beans.xml @@ -1,7 +1,51 @@ - + + org.javaee7.cdi.decorators.MyDecorator From c868dd21d44c4bf81e9bc08e765aa4ea313d27b5 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:12:47 -0700 Subject: [PATCH 0029/1080] Better headings --- cdi/pkg-level/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdi/pkg-level/src/main/webapp/index.jsp b/cdi/pkg-level/src/main/webapp/index.jsp index c95f02755..d43134eb2 100644 --- a/cdi/pkg-level/src/main/webapp/index.jsp +++ b/cdi/pkg-level/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - CDI Package Level Annotations + CDI : Package Level Annotations -

CDI Package Level Annotations

+

CDI : Package Level Annotations

Invoke the Greeting Service. From 4ed23d8271f1cfebab9ff10887bd02df2c113913 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:13:01 -0700 Subject: [PATCH 0030/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/cdi/pkg-level/src/main/webapp/WEB-INF/beans.xml b/cdi/pkg-level/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/cdi/pkg-level/src/main/webapp/WEB-INF/beans.xml +++ b/cdi/pkg-level/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From ac172441435fa4852916d35612db76cfa498e574 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:13:34 -0700 Subject: [PATCH 0031/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jms/temp-destination/src/main/webapp/WEB-INF/beans.xml b/jms/temp-destination/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jms/temp-destination/src/main/webapp/WEB-INF/beans.xml +++ b/jms/temp-destination/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 9901101aec8662d6aedb515fa87cbdc665b782f2 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:14:10 -0700 Subject: [PATCH 0032/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jpa/listeners/src/main/webapp/WEB-INF/beans.xml b/jpa/listeners/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jpa/listeners/src/main/webapp/WEB-INF/beans.xml +++ b/jpa/listeners/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From dcea8f21f751206ac9b67b38effd0d36b7ed75a1 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:15:42 -0700 Subject: [PATCH 0033/1080] Better output message --- .../java/org/javaee7/jpa/listeners/TestServlet.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/jpa/listeners/src/main/java/org/javaee7/jpa/listeners/TestServlet.java b/jpa/listeners/src/main/java/org/javaee7/jpa/listeners/TestServlet.java index 015b3cf10..e8459447c 100644 --- a/jpa/listeners/src/main/java/org/javaee7/jpa/listeners/TestServlet.java +++ b/jpa/listeners/src/main/java/org/javaee7/jpa/listeners/TestServlet.java @@ -80,15 +80,14 @@ public class TestServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); - PrintWriter out = response.getWriter(); - try { + try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("JPA Listeners"); out.println(""); out.println(""); - out.println("

Servlet TestServlet at " + request.getContextPath() + "

"); + out.println("

JPA Listeners

"); System.out.println("--> Listing movies"); for (Movie m : bean.listMovies()) { @@ -112,12 +111,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (Movie m : bean.listMovies()) { System.out.println(m.getName()); } - out.println("Check server.log for log messages"); + out.println("Check \"server.log\" for output messages from listeners."); out.println(""); out.println(""); - } finally { - out.close(); } } From 9531ff6871cfbe6d120ac3db19b042113f68e5e1 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:16:46 -0700 Subject: [PATCH 0034/1080] Better output message --- jpa/multiple-pu/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jpa/multiple-pu/src/main/webapp/index.jsp b/jpa/multiple-pu/src/main/webapp/index.jsp index 66a5d4187..cd7e8ba2e 100644 --- a/jpa/multiple-pu/src/main/webapp/index.jsp +++ b/jpa/multiple-pu/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - Multiple Persistence Units in a persistence.xml + JPA : Multiple Persistence Units in a persistence.xml -

Multiple Persistence Units in a persistence.xml

+

JPA : Multiple Persistence Units in a persistence.xml

List entities from two different PUs. From 62959daccd828f067b38b93cfac1b058839ddaef Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:16:52 -0700 Subject: [PATCH 0035/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jpa/multiple-pu/src/main/webapp/WEB-INF/beans.xml b/jpa/multiple-pu/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jpa/multiple-pu/src/main/webapp/WEB-INF/beans.xml +++ b/jpa/multiple-pu/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 3bf71fb36fa4b28600a7d25428862fbdfb010131 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:17:56 -0700 Subject: [PATCH 0036/1080] Removing a redundant copy of the sample --- .../nb-configuration.xml | 18 --- batch/chunk-csv-database.clean/pom.xml | 16 --- .../chunk/csv/database/MyItemProcessor.java | 74 ---------- .../chunk/csv/database/MyItemReader.java | 80 ----------- .../chunk/csv/database/MyItemWriter.java | 65 --------- .../batch/chunk/csv/database/Person.java | 132 ----------------- .../batch/chunk/csv/database/TestServlet.java | 136 ------------------ .../resources/META-INF/batch-jobs/myJob.xml | 52 ------- .../src/main/resources/META-INF/create.sql | 1 - .../src/main/resources/META-INF/drop.sql | 1 - .../src/main/resources/META-INF/mydata.csv | 7 - .../main/resources/META-INF/persistence.xml | 17 --- .../src/main/webapp/WEB-INF/beans.xml | 5 - .../src/main/webapp/index.jsp | 55 ------- 14 files changed, 659 deletions(-) delete mode 100644 batch/chunk-csv-database.clean/nb-configuration.xml delete mode 100644 batch/chunk-csv-database.clean/pom.xml delete mode 100644 batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemProcessor.java delete mode 100644 batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemReader.java delete mode 100644 batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java delete mode 100644 batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/Person.java delete mode 100644 batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java delete mode 100644 batch/chunk-csv-database.clean/src/main/resources/META-INF/batch-jobs/myJob.xml delete mode 100644 batch/chunk-csv-database.clean/src/main/resources/META-INF/create.sql delete mode 100644 batch/chunk-csv-database.clean/src/main/resources/META-INF/drop.sql delete mode 100644 batch/chunk-csv-database.clean/src/main/resources/META-INF/mydata.csv delete mode 100644 batch/chunk-csv-database.clean/src/main/resources/META-INF/persistence.xml delete mode 100644 batch/chunk-csv-database.clean/src/main/webapp/WEB-INF/beans.xml delete mode 100644 batch/chunk-csv-database.clean/src/main/webapp/index.jsp diff --git a/batch/chunk-csv-database.clean/nb-configuration.xml b/batch/chunk-csv-database.clean/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-csv-database.clean/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-csv-database.clean/pom.xml b/batch/chunk-csv-database.clean/pom.xml deleted file mode 100644 index 38ea0b9d7..000000000 --- a/batch/chunk-csv-database.clean/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - org.javaee7.batch - batch-samples - 1.0-SNAPSHOT - ../pom.xml - - - org.javaee7.batch - chunk-csv-database - 1.0-SNAPSHOT - war - diff --git a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemProcessor.java b/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemProcessor.java deleted file mode 100644 index 9dfea24e5..000000000 --- a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemProcessor.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.batch.chunk.csv.database; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.StringTokenizer; -import javax.batch.api.chunk.ItemProcessor; -import javax.inject.Named; - -/** - * @author Arun Gupta - */ -@Named -public class MyItemProcessor implements ItemProcessor { - SimpleDateFormat format = new SimpleDateFormat("M/dd/yy"); - - @Override - public Person processItem(Object t) { - System.out.println("processItem: " + 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(name, date); - } -} diff --git a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemReader.java b/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemReader.java deleted file mode 100644 index f3ad72c11..000000000 --- a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemReader.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.batch.chunk.csv.database; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Serializable; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.batch.api.chunk.AbstractItemReader; -import javax.inject.Named; - -/** - * @author Arun Gupta - */ -@Named -public class MyItemReader extends AbstractItemReader { - - private BufferedReader reader; - - @Override - public void open(Serializable checkpoint) throws Exception { - reader = new BufferedReader( - new InputStreamReader( - this - .getClass() - .getClassLoader() - .getResourceAsStream("/META-INF/mydata.csv") - ) - ); - } - - @Override - public String readItem() { - try { - return reader.readLine(); - } catch (IOException ex) { - Logger.getLogger(MyItemReader.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } -} diff --git a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java b/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java deleted file mode 100644 index 7c8a810bb..000000000 --- a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.batch.chunk.csv.database; - -import java.util.List; -import javax.batch.api.chunk.AbstractItemWriter; -import javax.inject.Named; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.transaction.Transactional; - -/** - * @author Arun Gupta - */ -@Named -public class MyItemWriter extends AbstractItemWriter { - - @PersistenceContext - EntityManager em; - - @Override - public void writeItems(List list) { - System.out.println("writeItems: " + list); - for (Object person : list) { - em.persist(person); - } - } -} diff --git a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/Person.java b/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/Person.java deleted file mode 100644 index 5aa9e6e1c..000000000 --- a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/Person.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.batch.chunk.csv.database; - -import java.io.Serializable; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author Arun Gupta - */ -@Entity -@Table(name = "CHUNK_CSV_DATABASE") -@XmlRootElement -@NamedQueries({ - @NamedQuery(name = "Person.findAll", query = "SELECT c FROM Person c"), - @NamedQuery(name = "Person.findByName", query = "SELECT c FROM Person c WHERE c.name = :name"), - @NamedQuery(name = "Person.findByHiredate", query = "SELECT c FROM Person c WHERE c.hiredate = :hiredate")}) -public class Person implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Basic(optional = false) - @NotNull - @Size(min = 1, max = 50) - @Column(name = "NAME") - private String name; - - @Basic(optional = false) - @NotNull - @Size(min = 1, max = 50) - @Column(name = "hiredate") - private String hiredate; - - public Person() { - } - - public Person(String name) { - this.name = name; - } - - public Person(String name, String hiredate) { - this.name = name; - this.hiredate = hiredate; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getHiredate() { - return hiredate; - } - - public void setHiredate(String hiredate) { - this.hiredate = hiredate; - } - - @Override - public int hashCode() { - int hash = 0; - hash += (name != null ? name.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object object) { - // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof Person)) { - return false; - } - Person other = (Person) object; - if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) { - return false; - } - return true; - } - - @Override - public String toString() { - return name; - } - -} diff --git a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java b/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java deleted file mode 100644 index 328d2218c..000000000 --- a/batch/chunk-csv-database.clean/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.batch.chunk.csv.database; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.batch.operations.JobOperator; -import javax.batch.operations.JobSecurityException; -import javax.batch.operations.JobStartException; -import javax.batch.runtime.BatchRuntime; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceUnit; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { - - @PersistenceUnit - EntityManagerFactory em; - - /** - * Processes requests for both HTTP GET and POST - * methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println("Servlet TestServlet"); - out.println(""); - out.println(""); - out.println("

Submitting the Job

"); - JobOperator jo = BatchRuntime.getJobOperator(); - long jid = jo.start("myJob", new Properties()); - out.println("Job submitted: " + jid + "
"); - out.println("Check server.log for output"); - out.println(""); - out.println(""); - } catch (JobStartException | JobSecurityException ex) { - Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); - } - } - - // - /** - * Handles the HTTP GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/batch/chunk-csv-database.clean/src/main/resources/META-INF/batch-jobs/myJob.xml b/batch/chunk-csv-database.clean/src/main/resources/META-INF/batch-jobs/myJob.xml deleted file mode 100644 index 9153134e4..000000000 --- a/batch/chunk-csv-database.clean/src/main/resources/META-INF/batch-jobs/myJob.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - diff --git a/batch/chunk-csv-database.clean/src/main/resources/META-INF/create.sql b/batch/chunk-csv-database.clean/src/main/resources/META-INF/create.sql deleted file mode 100644 index 7a4b78d58..000000000 --- a/batch/chunk-csv-database.clean/src/main/resources/META-INF/create.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE TABLE CHUNK_CSV_DATABASE ("NAME" VARCHAR(50) not null primary key, "HIREDATE" VARCHAR(50) not null) \ No newline at end of file diff --git a/batch/chunk-csv-database.clean/src/main/resources/META-INF/drop.sql b/batch/chunk-csv-database.clean/src/main/resources/META-INF/drop.sql deleted file mode 100644 index 185ba4e7f..000000000 --- a/batch/chunk-csv-database.clean/src/main/resources/META-INF/drop.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE CHUNK_CSV_DATABASE \ No newline at end of file diff --git a/batch/chunk-csv-database.clean/src/main/resources/META-INF/mydata.csv b/batch/chunk-csv-database.clean/src/main/resources/META-INF/mydata.csv deleted file mode 100644 index 6226b623e..000000000 --- a/batch/chunk-csv-database.clean/src/main/resources/META-INF/mydata.csv +++ /dev/null @@ -1,7 +0,0 @@ -Penny, 12/1/12 -Leonard Hofstadter, 14/6/08 -Howard Wolowitz, 8/27/7 -Bernadette Rostenkowski-Wolowitz, 8/14/13 -Sheldon Cooper, 3/18/9 -Amy Farah Fowler, 11/22/10 -Raj Koothrappali, 3/2/11 \ No newline at end of file diff --git a/batch/chunk-csv-database.clean/src/main/resources/META-INF/persistence.xml b/batch/chunk-csv-database.clean/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 4051fe9ca..000000000 --- a/batch/chunk-csv-database.clean/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/batch/chunk-csv-database.clean/src/main/webapp/WEB-INF/beans.xml b/batch/chunk-csv-database.clean/src/main/webapp/WEB-INF/beans.xml deleted file mode 100644 index 4ca8195be..000000000 --- a/batch/chunk-csv-database.clean/src/main/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/batch/chunk-csv-database.clean/src/main/webapp/index.jsp b/batch/chunk-csv-database.clean/src/main/webapp/index.jsp deleted file mode 100644 index eaaabb198..000000000 --- a/batch/chunk-csv-database.clean/src/main/webapp/index.jsp +++ /dev/null @@ -1,55 +0,0 @@ - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - Simple Chunk - - -

Simple Chunk

- Start the job. - - From 943dad622e48eed6430a3eed6c70e367f3480b46 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:31:25 -0700 Subject: [PATCH 0037/1080] Merging with transaction-scope sample --- jta/transactional-scope/nb-configuration.xml | 18 --- jta/transactional-scope/pom.xml | 16 --- .../transactional/scope/MyDataBean.java | 54 ------- .../scope/MyTransactionalBean.java | 79 ----------- .../transactional/scope/TestServlet.java | 132 ------------------ .../src/main/webapp/WEB-INF/beans.xml | 5 - .../src/main/webapp/index.jsp | 56 -------- 7 files changed, 360 deletions(-) delete mode 100644 jta/transactional-scope/nb-configuration.xml delete mode 100644 jta/transactional-scope/pom.xml delete mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java delete mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java delete mode 100644 jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java delete mode 100644 jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml delete mode 100644 jta/transactional-scope/src/main/webapp/index.jsp diff --git a/jta/transactional-scope/nb-configuration.xml b/jta/transactional-scope/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jta/transactional-scope/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jta/transactional-scope/pom.xml b/jta/transactional-scope/pom.xml deleted file mode 100644 index 1efe4e602..000000000 --- a/jta/transactional-scope/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - org.javaee7.jta - jta-samples - 1.0-SNAPSHOT - ../pom.xml - - - org.javaee7.samples.jta - transactional-scope - 1.0-SNAPSHOT - war - - diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java deleted file mode 100644 index 37c6344f1..000000000 --- a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyDataBean.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.samples.transactional.scope; - -import java.io.Serializable; -import javax.transaction.TransactionScoped; - -/** - * @author Arun Gupta - */ -@TransactionScoped -public class MyDataBean implements Serializable { - - public String getId() { - return this + ""; - } -} diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java deleted file mode 100644 index 48c83c09a..000000000 --- a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/MyTransactionalBean.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.samples.transactional.scope; - -import javax.enterprise.context.ContextNotActiveException; -import javax.inject.Inject; -import javax.transaction.Transactional; - -/** - * @author Arun Gupta - */ -public class MyTransactionalBean { - - @Inject - MyDataBean bean1; - - @Inject - MyDataBean bean2; - - @Transactional - public void scenario1() { - System.out.println("Scenario 1: Bean injected twice, same id"); - System.out.println(bean1.getId()); - System.out.println(bean2.getId()); - } - - @Transactional - public void scenario2() { - System.out.println("Scenario 2: Repeat of Scenario 1, different transaction, different ids"); - System.out.println(bean1.getId()); - System.out.println(bean2.getId()); - } - - public void scenario3() { - System.out.println("Scenario 3: Bean outside a transaction"); - try { - bean1.getId(); - } catch (ContextNotActiveException ex) { - System.out.println("Got expected ContextNotActiveException"); - } - } -} diff --git a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java b/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java deleted file mode 100644 index 27035942a..000000000 --- a/jta/transactional-scope/src/main/java/org/javaee7/samples/transactional/scope/TestServlet.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.samples.transactional.scope; - -import java.io.IOException; -import java.io.PrintWriter; -import javax.inject.Inject; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { - - @Inject MyTransactionalBean bean; - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("JTA 1.2 @Transactional and @TransactionScoped"); - out.println(""); - out.println(""); - out.println("

JTA 1.2 @Transactional and @TransactionScoped

"); - out.println("

Scenario 1: Bean injected twice, same id

"); - bean.scenario1(); - out.println("

Scenario 2: Repeat of Scenario 1, different transaction, different ids

"); - bean.scenario2(); - out.println("

Scenario 3: Bean outside a transaction

"); - bean.scenario3(); - out.println("Check server.log for output"); - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml b/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml deleted file mode 100644 index 4ca8195be..000000000 --- a/jta/transactional-scope/src/main/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/jta/transactional-scope/src/main/webapp/index.jsp b/jta/transactional-scope/src/main/webapp/index.jsp deleted file mode 100644 index 072082938..000000000 --- a/jta/transactional-scope/src/main/webapp/index.jsp +++ /dev/null @@ -1,56 +0,0 @@ - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - - JTA : @Transactional and @TransactionScope - - -

JTA : @Transactional and @TransactionScope

- Inject @TransactionScoped beans
- - \ No newline at end of file From 09ec936e873cb3fdcd4d9f962eef0e8ec9448b13 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:32:19 -0700 Subject: [PATCH 0038/1080] Using CDI 1.1 "all" style beans.xml Splitting into user-managed and container-managed transactions use case Better titles/output message --- .../scope/MyTransactionalBean.java | 79 +++++++++++ .../scope/TransactionalBeanClient.java | 132 ++++++++++++++++++ ...ervlet.java => UserTransactionClient.java} | 10 +- .../src/main/webapp/WEB-INF/beans.xml | 52 ++++++- .../src/main/webapp/index.jsp | 13 +- 5 files changed, 274 insertions(+), 12 deletions(-) create mode 100644 jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/MyTransactionalBean.java create mode 100644 jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TransactionalBeanClient.java rename jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/{TestServlet.java => UserTransactionClient.java} (94%) diff --git a/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/MyTransactionalBean.java b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/MyTransactionalBean.java new file mode 100644 index 000000000..1975db6d1 --- /dev/null +++ b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/MyTransactionalBean.java @@ -0,0 +1,79 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jta.transaction.scope; + +import javax.enterprise.context.ContextNotActiveException; +import javax.inject.Inject; +import javax.transaction.Transactional; + +/** + * @author Arun Gupta + */ +public class MyTransactionalBean { + + @Inject + MyBean bean1; + + @Inject + MyBean bean2; + + @Transactional + public void scenario1() { + System.out.println("Scenario 1: Bean injected twice, same id"); + System.out.println(bean1.getId()); + System.out.println(bean2.getId()); + } + + @Transactional + public void scenario2() { + System.out.println("Scenario 2: Repeat of Scenario 1, different transaction, different ids"); + System.out.println(bean1.getId()); + System.out.println(bean2.getId()); + } + + public void scenario3() { + System.out.println("Scenario 3: Bean outside a transaction"); + try { + bean1.getId(); + } catch (ContextNotActiveException ex) { + System.out.println("Got expected ContextNotActiveException"); + } + } +} diff --git a/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TransactionalBeanClient.java b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TransactionalBeanClient.java new file mode 100644 index 000000000..a92d4e633 --- /dev/null +++ b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TransactionalBeanClient.java @@ -0,0 +1,132 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jta.transaction.scope; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TransactionalBeanClient"}) +public class TransactionalBeanClient extends HttpServlet { + + @Inject MyTransactionalBean bean; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("JTA 1.2 @Transactional and @TransactionScoped"); + out.println(""); + out.println(""); + out.println("

JTA 1.2 @Transactional and @TransactionScoped

"); + out.println("

Scenario 1: Bean injected twice, same id

"); + bean.scenario1(); + out.println("

Scenario 2: Repeat of Scenario 1, different transaction, different ids

"); + bean.scenario2(); + out.println("

Scenario 3: Bean outside a transaction

"); + bean.scenario3(); + out.println("Check server.log for output"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TestServlet.java b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/UserTransactionClient.java similarity index 94% rename from jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TestServlet.java rename to jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/UserTransactionClient.java index e625ae36b..5978c1cc2 100644 --- a/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/TestServlet.java +++ b/jta/transaction-scope/src/main/java/org/javaee7/jta/transaction/scope/UserTransactionClient.java @@ -60,8 +60,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/UserTransactionClient"}) +public class UserTransactionClient extends HttpServlet { @Inject MyBean bean; @@ -86,10 +86,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println(""); - out.println("@TransactionScope"); + out.println("JTA 1.2 UserTransaction and @TransactionScoped"); out.println(""); out.println(""); - out.println("

@TransactionScope

"); + out.println("

JTA 1.2 UserTransaction and @TransactionScoped

"); try { out.println("

Scenario 1: Bean1 injected twice, same id

"); ut.begin(); @@ -118,7 +118,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re | HeuristicRollbackException | SecurityException | IllegalStateException ex) { - Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(UserTransactionClient.class.getName()).log(Level.SEVERE, null, ex); } out.println(""); out.println(""); diff --git a/jta/transaction-scope/src/main/webapp/WEB-INF/beans.xml b/jta/transaction-scope/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jta/transaction-scope/src/main/webapp/WEB-INF/beans.xml +++ b/jta/transaction-scope/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file diff --git a/jta/transaction-scope/src/main/webapp/index.jsp b/jta/transaction-scope/src/main/webapp/index.jsp index a622a2a16..c2fc1ed2d 100644 --- a/jta/transaction-scope/src/main/webapp/index.jsp +++ b/jta/transaction-scope/src/main/webapp/index.jsp @@ -47,10 +47,17 @@ - JTA : @TransactionScope beans in 3 different scenarios + JTA : @TransactionScoped beans in 3 different scenarios -

JTA : @TransactionScope beans in 3 different scenarios

- Execute 3 scenarios
+

JTA : @TransactionScoped beans in 3 different scenarios

+ Execute 3 scenarios with: +
    +
  1. container-managed transaction
  2. +
  3. user-managed transaction
  4. +
+ + + \ No newline at end of file From 65c8b7d7a6ba70b9f4fef16f00e17e7e1f931ef9 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:32:38 -0700 Subject: [PATCH 0039/1080] Removing transactional-scope --- jta/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/jta/pom.xml b/jta/pom.xml index 10c3bf230..5171ebb55 100644 --- a/jta/pom.xml +++ b/jta/pom.xml @@ -18,6 +18,5 @@ transaction-scope tx-exception user-transaction - transactional-scope From 304fb952e3428ba94ced3d4e5a996b3ae39bfa58 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:33:02 -0700 Subject: [PATCH 0040/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jta/transactional/src/main/webapp/WEB-INF/beans.xml b/jta/transactional/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jta/transactional/src/main/webapp/WEB-INF/beans.xml +++ b/jta/transactional/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From ebbe4d5db073673e89db9cc1cf0e66d28ef1f04c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:34:21 -0700 Subject: [PATCH 0041/1080] Using CDI 1.1 "all" style beans.xml --- .../methods/src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/validation/methods/src/main/webapp/WEB-INF/beans.xml b/validation/methods/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/validation/methods/src/main/webapp/WEB-INF/beans.xml +++ b/validation/methods/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 22d011cee415977257cbfce9598328e08268e7e1 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:35:00 -0700 Subject: [PATCH 0042/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/websocket/endpoint-programmatic-injection/src/main/webapp/WEB-INF/beans.xml b/websocket/endpoint-programmatic-injection/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/websocket/endpoint-programmatic-injection/src/main/webapp/WEB-INF/beans.xml +++ b/websocket/endpoint-programmatic-injection/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From dafc93e369dd5c2a707097440014dd8620ef9446 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:35:48 -0700 Subject: [PATCH 0043/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/json/twitter-search/src/main/webapp/WEB-INF/beans.xml b/json/twitter-search/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/json/twitter-search/src/main/webapp/WEB-INF/beans.xml +++ b/json/twitter-search/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From ad7bc61cd441f29fe8a86d12e777ff62ec2ad440 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:37:35 -0700 Subject: [PATCH 0044/1080] Fixing the package name --- .../sample => javaee7/json}/twitter/search/TestServlet.java | 2 +- .../sample => javaee7/json}/twitter/search/TwitterSearch.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename json/twitter-search/src/main/java/org/{glassfish/sample => javaee7/json}/twitter/search/TestServlet.java (99%) rename json/twitter-search/src/main/java/org/{glassfish/sample => javaee7/json}/twitter/search/TwitterSearch.java (98%) diff --git a/json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TestServlet.java b/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java similarity index 99% rename from json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TestServlet.java rename to json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java index 2a4c9c336..2b367100f 100644 --- a/json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TestServlet.java +++ b/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.glassfish.sample.twitter.search; +package org.javaee7.json.twitter.search; import java.io.IOException; import java.io.PrintWriter; diff --git a/json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TwitterSearch.java b/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java similarity index 98% rename from json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TwitterSearch.java rename to json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java index 5c99824f1..3eb2713a2 100644 --- a/json/twitter-search/src/main/java/org/glassfish/sample/twitter/search/TwitterSearch.java +++ b/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.glassfish.sample.twitter.search; +package org.javaee7.json.twitter.search; import javax.inject.Inject; import org.glassfish.samples.twitter.api.SearchResults; From 6e943cc16aec0c77fa4e17635a67746558eb0c9e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:38:10 -0700 Subject: [PATCH 0045/1080] Fixing the parent --- json/twitter-search/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/twitter-search/pom.xml b/json/twitter-search/pom.xml index f87b61768..edc6f6d02 100644 --- a/json/twitter-search/pom.xml +++ b/json/twitter-search/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.javaee7.json - json + json-samples 1.0-SNAPSHOT ../pom.xml From fc637f43c52ad524adcd1d2191108f1dfe43c58e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:38:19 -0700 Subject: [PATCH 0046/1080] Adding twitter-search --- json/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/json/pom.xml b/json/pom.xml index ddea023be..7b07e4325 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -18,6 +18,7 @@ object-reader streaming-generate streaming-parser + twitter-search From d9407164066fec7d4f34b19483ebedcd13129e97 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:40:12 -0700 Subject: [PATCH 0047/1080] Fixed the package name --- .../org/javaee7/jsf/{select/items => radio/buttons}/Movie.java | 2 +- .../javaee7/jsf/{select/items => radio/buttons}/MovieBean.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename jsf/radio-buttons/src/main/java/org/javaee7/jsf/{select/items => radio/buttons}/Movie.java (98%) rename jsf/radio-buttons/src/main/java/org/javaee7/jsf/{select/items => radio/buttons}/MovieBean.java (98%) diff --git a/jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/Movie.java b/jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/Movie.java similarity index 98% rename from jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/Movie.java rename to jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/Movie.java index 300f4fa27..6501d1d60 100644 --- a/jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/Movie.java +++ b/jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/Movie.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jsf.select.items; +package org.javaee7.jsf.radio.buttons; import javax.persistence.Id; import javax.validation.constraints.NotNull; diff --git a/jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/MovieBean.java b/jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/MovieBean.java similarity index 98% rename from jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/MovieBean.java rename to jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/MovieBean.java index f95c03140..2bad74edc 100644 --- a/jsf/radio-buttons/src/main/java/org/javaee7/jsf/select/items/MovieBean.java +++ b/jsf/radio-buttons/src/main/java/org/javaee7/jsf/radio/buttons/MovieBean.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.jsf.select.items; +package org.javaee7.jsf.radio.buttons; import java.io.Serializable; import java.util.Arrays; From ca24658859a08ecfb9871099336da671a8b6cc97 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:40:32 -0700 Subject: [PATCH 0048/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jsf/radio-buttons/src/main/webapp/WEB-INF/beans.xml b/jsf/radio-buttons/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jsf/radio-buttons/src/main/webapp/WEB-INF/beans.xml +++ b/jsf/radio-buttons/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 97dae6c5031c7f59737e20a6c3e1b3a4d9446b8b Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:42:35 -0700 Subject: [PATCH 0049/1080] Using CDI 1.1 "all" style beans.xml and fixing namespace from java.sun.com -> xmlns.jcp.org --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- jsf/viewscoped/src/main/webapp/index2.xhtml | 6 +-- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/jsf/viewscoped/src/main/webapp/WEB-INF/beans.xml b/jsf/viewscoped/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jsf/viewscoped/src/main/webapp/WEB-INF/beans.xml +++ b/jsf/viewscoped/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file diff --git a/jsf/viewscoped/src/main/webapp/index2.xhtml b/jsf/viewscoped/src/main/webapp/index2.xhtml index 4b2df4e80..0b25dce3c 100644 --- a/jsf/viewscoped/src/main/webapp/index2.xhtml +++ b/jsf/viewscoped/src/main/webapp/index2.xhtml @@ -1,9 +1,9 @@ + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:ez="http://xmlns.jcp.org/jsf/composite/ezcomp"> From 39496e71546bb7b29ade651e29156732f5a2af56 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:44:15 -0700 Subject: [PATCH 0050/1080] Using CDI 1.1 "all" style beans.xml and fixing namespace from java.sun.com -> xmlns.jcp.org --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- .../src/main/webapp/flow1/flow1.xhtml | 2 +- .../src/main/webapp/flow1/flow1a.xhtml | 2 +- .../src/main/webapp/flow1/flow1b.xhtml | 2 +- .../src/main/webapp/flow2/flow2.xhtml | 4 +- .../src/main/webapp/flow2/flow2a.xhtml | 2 +- .../src/main/webapp/flow2/flow2b.xhtml | 2 +- 7 files changed, 55 insertions(+), 11 deletions(-) diff --git a/jsf/flows-mixed/src/main/webapp/WEB-INF/beans.xml b/jsf/flows-mixed/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jsf/flows-mixed/src/main/webapp/WEB-INF/beans.xml +++ b/jsf/flows-mixed/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file diff --git a/jsf/flows-mixed/src/main/webapp/flow1/flow1.xhtml b/jsf/flows-mixed/src/main/webapp/flow1/flow1.xhtml index d15a6a1dc..4fa9527ea 100644 --- a/jsf/flows-mixed/src/main/webapp/flow1/flow1.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow1/flow1.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> First Page in Flow 1 diff --git a/jsf/flows-mixed/src/main/webapp/flow1/flow1a.xhtml b/jsf/flows-mixed/src/main/webapp/flow1/flow1a.xhtml index 0f2d8956a..e890e0f3c 100644 --- a/jsf/flows-mixed/src/main/webapp/flow1/flow1a.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow1/flow1a.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> Second Page in Flow 1 diff --git a/jsf/flows-mixed/src/main/webapp/flow1/flow1b.xhtml b/jsf/flows-mixed/src/main/webapp/flow1/flow1b.xhtml index d636911b7..0bbc88088 100644 --- a/jsf/flows-mixed/src/main/webapp/flow1/flow1b.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow1/flow1b.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> Last Page in Flow 1 diff --git a/jsf/flows-mixed/src/main/webapp/flow2/flow2.xhtml b/jsf/flows-mixed/src/main/webapp/flow2/flow2.xhtml index ded3f26b2..3d7874b56 100644 --- a/jsf/flows-mixed/src/main/webapp/flow2/flow2.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow2/flow2.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> First Page in Flow 2 @@ -56,7 +56,7 @@

Parameter 1 value from Flow 1: #{flowScope.param1Value}

Parameter 2 value from Flow 1: #{flowScope.param2Value}

-

+

diff --git a/jsf/flows-mixed/src/main/webapp/flow2/flow2a.xhtml b/jsf/flows-mixed/src/main/webapp/flow2/flow2a.xhtml index fcd8788ff..35b58dde4 100644 --- a/jsf/flows-mixed/src/main/webapp/flow2/flow2a.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow2/flow2a.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> Second Page in Flow 2 diff --git a/jsf/flows-mixed/src/main/webapp/flow2/flow2b.xhtml b/jsf/flows-mixed/src/main/webapp/flow2/flow2b.xhtml index c4ceeeb76..2e054cbc4 100644 --- a/jsf/flows-mixed/src/main/webapp/flow2/flow2b.xhtml +++ b/jsf/flows-mixed/src/main/webapp/flow2/flow2b.xhtml @@ -43,7 +43,7 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html"> Last page in Flow 2 From af5c7d1a706f84387ff7c7fecb0763ff0f6ef965 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:45:01 -0700 Subject: [PATCH 0051/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jsf/contracts/src/main/webapp/WEB-INF/beans.xml b/jsf/contracts/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jsf/contracts/src/main/webapp/WEB-INF/beans.xml +++ b/jsf/contracts/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 07ef05cc9ea834e0ba43ba99feeae181e12457fa Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 11:45:16 -0700 Subject: [PATCH 0052/1080] Using CDI 1.1 "all" style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/jsf/file-upload/src/main/webapp/WEB-INF/beans.xml b/jsf/file-upload/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jsf/file-upload/src/main/webapp/WEB-INF/beans.xml +++ b/jsf/file-upload/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 9f68468cf2df7b007b92227aaf8f72b9b49d899c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:12:32 -0700 Subject: [PATCH 0053/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org --- jpa/listeners/src/main/resources/META-INF/orm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jpa/listeners/src/main/resources/META-INF/orm.xml b/jpa/listeners/src/main/resources/META-INF/orm.xml index a9712eb4d..bedc749b2 100644 --- a/jpa/listeners/src/main/resources/META-INF/orm.xml +++ b/jpa/listeners/src/main/resources/META-INF/orm.xml @@ -1,8 +1,8 @@ From 130f5e355967b16086ef6e288a3d338bb986c9a6 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:16:49 -0700 Subject: [PATCH 0054/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org, also adding property drop-source --- jpa/schema-gen/src/main/resources/META-INF/persistence.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jpa/schema-gen/src/main/resources/META-INF/persistence.xml b/jpa/schema-gen/src/main/resources/META-INF/persistence.xml index 2b429d2f9..370e41792 100644 --- a/jpa/schema-gen/src/main/resources/META-INF/persistence.xml +++ b/jpa/schema-gen/src/main/resources/META-INF/persistence.xml @@ -1,9 +1,14 @@ - + + From 6c9f605d8af10bd36e10eb1673863c3548034276 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:17:04 -0700 Subject: [PATCH 0055/1080] Using the names from Big Bang Theory --- .../main/java/org/javaee7/jpa/schemagen/TestServlet.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/TestServlet.java b/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/TestServlet.java index 0973ef488..cf0a7e81e 100644 --- a/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/TestServlet.java +++ b/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/TestServlet.java @@ -55,6 +55,8 @@ public class TestServlet extends HttpServlet { @EJB EmployeeBean bean; + + private static final String[] NAMES = { "Penny", "Leonard", "Howard", "Sheldon", "Raj" }; /** * Processes requests for both HTTP @@ -72,12 +74,12 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("List of Employees"); out.println(""); out.println(""); - out.println("

Servlet TestServlet at " + request.getContextPath() + "

"); + out.println("

List of Employees

"); for (int i=0; i<5; i++) { - bean.persist(new Employee("Name" + i)); + bean.persist(new Employee(NAMES[i])); } for (Employee e : bean.get()) { out.println(e.getName() + "
"); From e699e2c81e4ab7aff01549dc18777b0a34f81f9f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:18:22 -0700 Subject: [PATCH 0056/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org --- jpa/listeners/src/main/resources/META-INF/orm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpa/listeners/src/main/resources/META-INF/orm.xml b/jpa/listeners/src/main/resources/META-INF/orm.xml index bedc749b2..f06db45ab 100644 --- a/jpa/listeners/src/main/resources/META-INF/orm.xml +++ b/jpa/listeners/src/main/resources/META-INF/orm.xml @@ -1,5 +1,5 @@ - Date: Thu, 12 Sep 2013 12:20:28 -0700 Subject: [PATCH 0057/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org --- .../src/main/resources/META-INF/persistence.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jpa/storedprocedure/src/main/resources/META-INF/persistence.xml b/jpa/storedprocedure/src/main/resources/META-INF/persistence.xml index 317bdfc52..1e0118ce5 100644 --- a/jpa/storedprocedure/src/main/resources/META-INF/persistence.xml +++ b/jpa/storedprocedure/src/main/resources/META-INF/persistence.xml @@ -1,5 +1,8 @@ - + From e4c2177ed727e96f381a9429c91e7ef41bd14d53 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:20:47 -0700 Subject: [PATCH 0058/1080] Adding a boilerplate TestServlet, TBD: how to invoke StoredProcedure --- .../jpa/storedprocedure/TestServlet.java | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 jpa/storedprocedure/src/main/java/org/javaee7/jpa/storedprocedure/TestServlet.java diff --git a/jpa/storedprocedure/src/main/java/org/javaee7/jpa/storedprocedure/TestServlet.java b/jpa/storedprocedure/src/main/java/org/javaee7/jpa/storedprocedure/TestServlet.java new file mode 100644 index 000000000..19ef5c1f2 --- /dev/null +++ b/jpa/storedprocedure/src/main/java/org/javaee7/jpa/storedprocedure/TestServlet.java @@ -0,0 +1,122 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * http://glassfish.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.jpa.storedprocedure; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.ejb.EJB; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println("Which stored procedure to invoke ?"); + out.println(""); + out.println(""); + out.println("

Which stored procedure to invoke ?

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} From 068c9306e3068d314f506d4836f1ee47dae4a8a3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:22:39 -0700 Subject: [PATCH 0059/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema --- jsf/contracts/src/main/webapp/WEB-INF/web.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsf/contracts/src/main/webapp/WEB-INF/web.xml b/jsf/contracts/src/main/webapp/WEB-INF/web.xml index b92d292f3..68454ffde 100644 --- a/jsf/contracts/src/main/webapp/WEB-INF/web.xml +++ b/jsf/contracts/src/main/webapp/WEB-INF/web.xml @@ -42,7 +42,11 @@ */ --> - + javax.faces.PROJECT_STAGE Development From d6fba8147d3bd9f76d97af1067394405b213da79 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:22:48 -0700 Subject: [PATCH 0060/1080] Fixing a typo --- jsf/contracts/src/main/webapp/WEB-INF/web.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsf/contracts/src/main/webapp/WEB-INF/web.xml b/jsf/contracts/src/main/webapp/WEB-INF/web.xml index 68454ffde..a67477386 100644 --- a/jsf/contracts/src/main/webapp/WEB-INF/web.xml +++ b/jsf/contracts/src/main/webapp/WEB-INF/web.xml @@ -43,7 +43,7 @@ --> From d556e28bd20abd70d4e1f0c9e05aa0e871b006c7 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:23:37 -0700 Subject: [PATCH 0061/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema --- jsf/contracts-library/src/main/webapp/WEB-INF/web.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsf/contracts-library/src/main/webapp/WEB-INF/web.xml b/jsf/contracts-library/src/main/webapp/WEB-INF/web.xml index 2f9b9372c..08d7f5ef8 100644 --- a/jsf/contracts-library/src/main/webapp/WEB-INF/web.xml +++ b/jsf/contracts-library/src/main/webapp/WEB-INF/web.xml @@ -42,7 +42,11 @@ */ --> - + javax.faces.PROJECT_STAGE Development From 91ef42872cdfd8d3a9e9276135caecc941677c58 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:25:18 -0700 Subject: [PATCH 0062/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/jsf/file-upload/src/main/webapp/WEB-INF/web.xml b/jsf/file-upload/src/main/webapp/WEB-INF/web.xml index a6c450c7d..b49a56269 100644 --- a/jsf/file-upload/src/main/webapp/WEB-INF/web.xml +++ b/jsf/file-upload/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,52 @@ - + + + + javax.faces.PROJECT_STAGE Development From f78445edf61b6a75aad3debe7fd1b9e37af4956e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:25:54 -0700 Subject: [PATCH 0063/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema --- jsf/flows-declarative/src/main/webapp/WEB-INF/web.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsf/flows-declarative/src/main/webapp/WEB-INF/web.xml b/jsf/flows-declarative/src/main/webapp/WEB-INF/web.xml index 23a00da3c..52c031669 100644 --- a/jsf/flows-declarative/src/main/webapp/WEB-INF/web.xml +++ b/jsf/flows-declarative/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,11 @@ */ --> - + javax.faces.PROJECT_STAGE ${webapp.projectStage} From ce6bf8f5d6abad94c9410e9f58205fd052485176 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:27:00 -0700 Subject: [PATCH 0064/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema --- jsf/flows-mixed/src/main/webapp/WEB-INF/web.xml | 6 +++++- jsf/flows-programmatic/src/main/webapp/WEB-INF/web.xml | 6 +++++- jsf/flows-simple/src/main/webapp/WEB-INF/web.xml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/jsf/flows-mixed/src/main/webapp/WEB-INF/web.xml b/jsf/flows-mixed/src/main/webapp/WEB-INF/web.xml index 23a00da3c..52c031669 100644 --- a/jsf/flows-mixed/src/main/webapp/WEB-INF/web.xml +++ b/jsf/flows-mixed/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,11 @@ */ --> - + javax.faces.PROJECT_STAGE ${webapp.projectStage} diff --git a/jsf/flows-programmatic/src/main/webapp/WEB-INF/web.xml b/jsf/flows-programmatic/src/main/webapp/WEB-INF/web.xml index 3b094e236..db5e2ed67 100644 --- a/jsf/flows-programmatic/src/main/webapp/WEB-INF/web.xml +++ b/jsf/flows-programmatic/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,11 @@ */ --> - + javax.faces.CLIENT_WINDOW_MODE url diff --git a/jsf/flows-simple/src/main/webapp/WEB-INF/web.xml b/jsf/flows-simple/src/main/webapp/WEB-INF/web.xml index 23a00da3c..52c031669 100644 --- a/jsf/flows-simple/src/main/webapp/WEB-INF/web.xml +++ b/jsf/flows-simple/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,11 @@ */ --> - + javax.faces.PROJECT_STAGE ${webapp.projectStage} From b234851c5c7f2650aa24d841b0b860f8804bd9b7 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:28:28 -0700 Subject: [PATCH 0065/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/jsf/passthrough/src/main/webapp/WEB-INF/web.xml b/jsf/passthrough/src/main/webapp/WEB-INF/web.xml index a6c450c7d..da103b498 100644 --- a/jsf/passthrough/src/main/webapp/WEB-INF/web.xml +++ b/jsf/passthrough/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,51 @@ - + + + javax.faces.PROJECT_STAGE Development From 7cad696a948752d6c3bf9b74eecd43e62b0671d3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:30:05 -0700 Subject: [PATCH 0066/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml b/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml index a6c450c7d..6e2bd8ac3 100644 --- a/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml +++ b/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,51 @@ - + + javax.faces.PROJECT_STAGE Development From 82f35906d3419b3eba11422bc39cecff7d799999 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:30:31 -0700 Subject: [PATCH 0067/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml b/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml index a6c450c7d..30cfcb222 100644 --- a/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml +++ b/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,51 @@ - - + + javax.faces.PROJECT_STAGE Development From 091c943890ba065b4a534fe814a40618a2ac071a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:36:04 -0700 Subject: [PATCH 0068/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml b/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml index a6c450c7d..30cfcb222 100644 --- a/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml +++ b/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,51 @@ - - + + javax.faces.PROJECT_STAGE Development From 80cec53f56b60477d92df2a529db9edac42fc714 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:36:38 -0700 Subject: [PATCH 0069/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml b/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml index a0e2249d3..d41a408e9 100644 --- a/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml +++ b/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,51 @@ - - + + javax.faces.PROJECT_STAGE Development From 2808646fed3d51c7a1928bb7d280b95888fc5ee2 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:37:08 -0700 Subject: [PATCH 0070/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../src/main/webapp/WEB-INF/web.xml | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml index b6ff84144..efcd379b1 100644 --- a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml +++ b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,51 @@ - - + + TestServlet org.javaee7.servlet.error.mapping.TestServlet From 799a99d76dd8254301268944ade7597ae7af1f82 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:41:04 -0700 Subject: [PATCH 0071/1080] slight formatting --- servlet/error-mapping/src/main/webapp/WEB-INF/web.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml index efcd379b1..6c2f210b5 100644 --- a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml +++ b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml @@ -45,7 +45,8 @@ version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> + TestServlet org.javaee7.servlet.error.mapping.TestServlet From 24710073b4950d53217a708f676f88b20d2467ad Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:42:14 -0700 Subject: [PATCH 0072/1080] Removing metadata-complete --- servlet/error-mapping/src/main/webapp/WEB-INF/web.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml index 6c2f210b5..e9929cfb6 100644 --- a/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml +++ b/servlet/error-mapping/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,6 @@ */ --> Date: Thu, 12 Sep 2013 12:43:14 -0700 Subject: [PATCH 0073/1080] Removing metadata-complete and slight formatting --- jsf/resource-handling/src/main/webapp/WEB-INF/web.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml b/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml index 30cfcb222..c51834343 100644 --- a/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml +++ b/jsf/resource-handling/src/main/webapp/WEB-INF/web.xml @@ -41,11 +41,11 @@ */ --> + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> + javax.faces.PROJECT_STAGE Development From 044188b1421ce0748e017e4c00ed986f1c45e6d1 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:43:30 -0700 Subject: [PATCH 0074/1080] Removing metadata-complete and slight formatting --- jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml b/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml index 30cfcb222..d640117ef 100644 --- a/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml +++ b/jsf/simple-facelet/src/main/webapp/WEB-INF/web.xml @@ -41,11 +41,11 @@ */ --> + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> + javax.faces.PROJECT_STAGE Development From 3c6bd00d3bdb52b66c8c776ac5eaad87cb827525 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:43:53 -0700 Subject: [PATCH 0075/1080] Removing metadata-complete and slight formatting --- jsf/viewscoped/src/main/webapp/WEB-INF/web.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml b/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml index d41a408e9..ece06a97a 100644 --- a/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml +++ b/jsf/viewscoped/src/main/webapp/WEB-INF/web.xml @@ -41,11 +41,11 @@ */ --> + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> + javax.faces.PROJECT_STAGE Development From 8130c95b3a0381e83bf5359bd17dd4a155704d5c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 12:44:10 -0700 Subject: [PATCH 0076/1080] Removing metadata-complete --- jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml b/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml index 6e2bd8ac3..c51834343 100644 --- a/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml +++ b/jsf/radio-buttons/src/main/webapp/WEB-INF/web.xml @@ -41,7 +41,6 @@ */ --> Date: Thu, 12 Sep 2013 12:45:02 -0700 Subject: [PATCH 0077/1080] Fixing namespace from java.sun.com -> xmlns.jcp.org and using Servlet 3.1 schema. Also added copyright --- .../endpoint-security/src/main/webapp/WEB-INF/web.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket/endpoint-security/src/main/webapp/WEB-INF/web.xml b/websocket/endpoint-security/src/main/webapp/WEB-INF/web.xml index 4ca8d9ea8..d87bbfaac 100644 --- a/websocket/endpoint-security/src/main/webapp/WEB-INF/web.xml +++ b/websocket/endpoint-security/src/main/webapp/WEB-INF/web.xml @@ -40,11 +40,11 @@ * holder. */ --> - - + WebSocket Endpoint From 4f4d98567d15da645a79ec9be9ac850c031fa16f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 13:43:15 -0700 Subject: [PATCH 0078/1080] Naming the servlets appropriately --- ...rvlet2.java => AnnotatedEmailServlet.java} | 59 +++++++++++++++---- ...let.java => ProgrammaticEmailServlet.java} | 4 +- javamail/definition/src/main/webapp/index.jsp | 6 +- 3 files changed, 54 insertions(+), 15 deletions(-) rename javamail/definition/src/main/java/org/javaee7/javamail/definition/{TestServlet2.java => AnnotatedEmailServlet.java} (62%) rename javamail/definition/src/main/java/org/javaee7/javamail/definition/{TestServlet.java => ProgrammaticEmailServlet.java} (98%) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet2.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java similarity index 62% rename from javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet2.java rename to javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java index 0c442f9b5..3314e5fad 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet2.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java @@ -1,7 +1,41 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. */ package org.javaee7.javamail.definition; @@ -24,11 +58,12 @@ import javax.servlet.http.HttpServletResponse; /** - * - * @author arungup + * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestServlet2"}) +@WebServlet(urlPatterns = {"/AnnotatedEmailServlet"}) @MailSessionDefinition(name = "java:comp/myMailSession", +// host = "smtp.gmail.com", +// transportProtocol = "smtps", properties = { "mail.smtp.host=smtp.gmail.com", "mail.smtp.ssl.enable=true", @@ -36,7 +71,7 @@ "mail.transport.protocol=smtp", "mail.debug=true" }) -public class TestServlet2 extends HttpServlet { +public class AnnotatedEmailServlet extends HttpServlet { @Resource(lookup = "java:comp/myMailSession") Session session; @@ -57,7 +92,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println(""); - out.println("Servlet TestServlet2"); + out.println("Sending email using @MailSessionDefinition"); out.println(""); out.println(""); out.println("

Sending email using @MailSessionDefinition

"); @@ -76,11 +111,11 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re message.setSubject("Sending message using JavaMail"); message.setText("Java EE 7 is cool!"); -// Transport t = session.getTransport("smtp"); -// t.connect(creds.getProperty("username"), creds.getProperty("password")); -// t.send(message); + Transport t = session.getTransport(); + t.connect(creds.getProperty("username"), creds.getProperty("password")); + t.send(message, message.getAllRecipients()); - Transport.send(message); +// Transport.send(message, message.getAllRecipients()); out.println("message sent!"); diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java similarity index 98% rename from javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java rename to javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java index f3cd13e2a..4ddae4505 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/TestServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java @@ -59,8 +59,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ProgrammaticEmailServlet"}) +public class ProgrammaticEmailServlet extends HttpServlet { /** * Processes requests for both HTTP GET and POST diff --git a/javamail/definition/src/main/webapp/index.jsp b/javamail/definition/src/main/webapp/index.jsp index 380127d7d..0b70c13b9 100644 --- a/javamail/definition/src/main/webapp/index.jsp +++ b/javamail/definition/src/main/webapp/index.jsp @@ -56,6 +56,10 @@
  • password
  • to
  • - Send an email from "username" to "to" using programmatic session or declarative session. + Send an email from "username" to "to" using: +
      +
    1. Programmatic Session
    2. +
    3. Declarative Session
    4. +
    From b113bbc0d71db1397ebfcabf4627baf18e92bd9b Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 14:06:11 -0700 Subject: [PATCH 0079/1080] Using a Credentials class to read the username, password, and To field. Also adding timestamp in email subject. --- .../definition/AnnotatedEmailServlet.java | 17 ++- .../javamail/definition/Credentials.java | 103 ++++++++++++++++++ .../definition/ProgrammaticEmailServlet.java | 21 ++-- 3 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java index 3314e5fad..d3ece6401 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java @@ -42,8 +42,10 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; +import java.util.Calendar; import java.util.Properties; import javax.annotation.Resource; +import javax.inject.Inject; import javax.mail.MailSessionDefinition; import javax.mail.Message; import javax.mail.MessagingException; @@ -75,6 +77,8 @@ public class AnnotatedEmailServlet extends HttpServlet { @Resource(lookup = "java:comp/myMailSession") Session session; + + @Inject Credentials creds; /** * Processes requests for both HTTP GET and POST @@ -96,23 +100,18 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println("

    Sending email using @MailSessionDefinition

    "); - - final Properties creds = new Properties(); - creds.load(new FileInputStream(System.getProperty("user.home") - + System.getProperty("file.separator") - + ".javamail")); try { out.println("Sending message using gmail...
    "); Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(creds.getProperty("username"))); + message.setFrom(new InternetAddress(creds.getUsername())); message.setRecipients(Message.RecipientType.TO, - InternetAddress.parse(creds.getProperty("to"))); - message.setSubject("Sending message using JavaMail"); + InternetAddress.parse(creds.getTo())); + message.setSubject("Sending message using Annotated JavaMail " + Calendar.getInstance().getTime()); message.setText("Java EE 7 is cool!"); Transport t = session.getTransport(); - t.connect(creds.getProperty("username"), creds.getProperty("password")); + t.connect(creds.getUsername(), creds.getPassword()); t.send(message, message.getAllRecipients()); // Transport.send(message, message.getAllRecipients()); diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java new file mode 100644 index 000000000..8f957fcb7 --- /dev/null +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java @@ -0,0 +1,103 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.javamail.definition; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.enterprise.context.ApplicationScoped; + +/** + * @author Arun Gupta + */ +@ApplicationScoped +public class Credentials { + + private String username; + private String password; + private String to; + + public Credentials() { + try { + final Properties creds = new Properties(); + creds.load(new FileInputStream(System.getProperty("user.home") + + System.getProperty("file.separator") + + ".javamail")); + username = creds.getProperty("username"); + password = creds.getProperty("password"); + to = creds.getProperty("to"); + } catch (IOException ex) { + Logger.getLogger(Credentials.class.getName()).log(Level.SEVERE, null, ex); + } + + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + @Override + public String toString() { + return "username: " + username + ", password: " + password + ", to: " + to; + } + +} diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java index 4ddae4505..11a63b854 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java @@ -39,10 +39,11 @@ */ package org.javaee7.javamail.definition; -import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; +import java.util.Calendar; import java.util.Properties; +import javax.inject.Inject; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; @@ -61,6 +62,8 @@ */ @WebServlet(urlPatterns = {"/ProgrammaticEmailServlet"}) public class ProgrammaticEmailServlet extends HttpServlet { + + @Inject Credentials creds; /** * Processes requests for both HTTP GET and POST @@ -90,16 +93,12 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re props.put("mail.transport.protocol", "smtp"); props.put("mail.debug", "true"); - final Properties creds = new Properties(); - creds.load(new FileInputStream(System.getProperty("user.home") - + System.getProperty("file.separator") - + ".javamail")); Session session = Session.getInstance(props, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(creds.getProperty("username"), creds.getProperty("password")); + return new PasswordAuthentication(creds.getUsername(), creds.getPassword()); } }); // Session session = Session.getInstance(props); @@ -107,16 +106,16 @@ protected PasswordAuthentication getPasswordAuthentication() { try { out.println("Sending message from \"" - + creds.getProperty("username") + + creds.getUsername() + "\" to \"" - + creds.getProperty("to") + + creds.getTo() + "\"...
    "); Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(creds.getProperty("username"))); + message.setFrom(new InternetAddress(creds.getUsername())); message.setRecipients(Message.RecipientType.TO, - InternetAddress.parse(creds.getProperty("to"))); - message.setSubject("Sending message using JavaMail"); + InternetAddress.parse(creds.getTo())); + message.setSubject("Sending message using Programmatic JavaMail " + Calendar.getInstance().getTime()); message.setText("Java EE 7 is cool!"); // Transport t = session.getTransport(); From 7db42188516aea5e0c5e808e22f16d1c6a483d1d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 14:25:35 -0700 Subject: [PATCH 0080/1080] Intermittent commit for debugging purpose --- .../definition/AnnotatedEmailServlet.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java index d3ece6401..e4f85072e 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java @@ -64,13 +64,13 @@ */ @WebServlet(urlPatterns = {"/AnnotatedEmailServlet"}) @MailSessionDefinition(name = "java:comp/myMailSession", -// host = "smtp.gmail.com", -// transportProtocol = "smtps", + host = "smtp.gmail.com", + transportProtocol = "smtps", properties = { - "mail.smtp.host=smtp.gmail.com", - "mail.smtp.ssl.enable=true", - "mail.smtp.auth=true", - "mail.transport.protocol=smtp", +// "mail.smtp.host=smtp.gmail.com", +// "mail.smtp.ssl.enable=true", +// "mail.smtp.auth=true", +// "mail.transport.protocol=smtp", "mail.debug=true" }) public class AnnotatedEmailServlet extends HttpServlet { @@ -105,9 +105,9 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println("Sending message using gmail...
    "); Message message = new MimeMessage(session); message.setFrom(new InternetAddress(creds.getUsername())); - message.setRecipients(Message.RecipientType.TO, - InternetAddress.parse(creds.getTo())); - message.setSubject("Sending message using Annotated JavaMail " + Calendar.getInstance().getTime()); + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(creds.getTo())); + message.setSubject("Sending message using Annotated JavaMail " + + Calendar.getInstance().getTime()); message.setText("Java EE 7 is cool!"); Transport t = session.getTransport(); From 8a1238f00971dd2d66c88e711abd13f91e725841 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 15:47:13 -0700 Subject: [PATCH 0081/1080] Changing the format of .javamail --- javamail/definition/src/main/webapp/index.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javamail/definition/src/main/webapp/index.jsp b/javamail/definition/src/main/webapp/index.jsp index 0b70c13b9..487581aa8 100644 --- a/javamail/definition/src/main/webapp/index.jsp +++ b/javamail/definition/src/main/webapp/index.jsp @@ -52,7 +52,7 @@

    JavaMail Definition

    Make sure "<%= System.getProperty("user.home") %><%= System.getProperty("file.separator") %>.javamail" contains the following name/value pairs:

      -
    • username
    • +
    • from
    • password
    • to
    From a76a192855868e0ca03243fc035d69675e389b43 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 16:01:58 -0700 Subject: [PATCH 0082/1080] Cleaning up the code and reading correct attributes from .javamail --- .../javaee7/javamail/definition/Credentials.java | 16 ++++++++-------- .../definition/ProgrammaticEmailServlet.java | 7 ++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java index 8f957fcb7..0ae0d147c 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/Credentials.java @@ -52,7 +52,7 @@ @ApplicationScoped public class Credentials { - private String username; + private String from; private String password; private String to; @@ -62,7 +62,7 @@ public Credentials() { creds.load(new FileInputStream(System.getProperty("user.home") + System.getProperty("file.separator") + ".javamail")); - username = creds.getProperty("username"); + from = creds.getProperty("from"); password = creds.getProperty("password"); to = creds.getProperty("to"); } catch (IOException ex) { @@ -71,12 +71,12 @@ public Credentials() { } - public String getUsername() { - return username; + public String getFrom() { + return from; } - public void setUsername(String username) { - this.username = username; + public void setFrom(String from) { + this.from = from; } public String getPassword() { @@ -94,10 +94,10 @@ public String getTo() { public void setTo(String to) { this.to = to; } - + @Override public String toString() { - return "username: " + username + ", password: " + password + ", to: " + to; + return "from: " + from + ", password: , to: " + to; } } diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java index 11a63b854..691b9136d 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java @@ -88,6 +88,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); +// props.put("mail.smtp.host", "stbeehive.oracle.com"); props.put("mail.smtp.ssl.enable", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.transport.protocol", "smtp"); @@ -98,7 +99,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(creds.getUsername(), creds.getPassword()); + return new PasswordAuthentication(creds.getFrom(), creds.getPassword()); } }); // Session session = Session.getInstance(props); @@ -106,13 +107,13 @@ protected PasswordAuthentication getPasswordAuthentication() { try { out.println("Sending message from \"" - + creds.getUsername() + + creds.getFrom() + "\" to \"" + creds.getTo() + "\"...
    "); Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(creds.getUsername())); + message.setFrom(new InternetAddress(creds.getFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(creds.getTo())); message.setSubject("Sending message using Programmatic JavaMail " + Calendar.getInstance().getTime()); From 1d1d08c91413fd9d1651a4766b66a3d3b29f8501 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 16:02:30 -0700 Subject: [PATCH 0083/1080] Cleaning up the code and putting on backburner until the issues are fixed --- .../definition/AnnotatedEmailServlet.java | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java index e4f85072e..29c9c53ce 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java @@ -39,18 +39,18 @@ */ package org.javaee7.javamail.definition; -import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Calendar; -import java.util.Properties; import javax.annotation.Resource; import javax.inject.Inject; import javax.mail.MailSessionDefinition; import javax.mail.Message; import javax.mail.MessagingException; +import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; +import javax.mail.URLName; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.ServletException; @@ -64,21 +64,25 @@ */ @WebServlet(urlPatterns = {"/AnnotatedEmailServlet"}) @MailSessionDefinition(name = "java:comp/myMailSession", - host = "smtp.gmail.com", - transportProtocol = "smtps", + host = "smtp.gmail.com", + transportProtocol = "smtps", +// host = "stbeehive.oracle.com", + // transportProtocol = "smtps", properties = { -// "mail.smtp.host=smtp.gmail.com", -// "mail.smtp.ssl.enable=true", -// "mail.smtp.auth=true", -// "mail.transport.protocol=smtp", + // "mail.smtp.host=smtp.gmail.com", + // "mail.smtp.host=stbeehive.oracle.com", + // "mail.smtp.ssl.enable=true", + // "mail.smtp.auth=true", +// "mail.transport.protocol=smtps", "mail.debug=true" }) public class AnnotatedEmailServlet extends HttpServlet { @Resource(lookup = "java:comp/myMailSession") Session session; - - @Inject Credentials creds; + + @Inject + Credentials creds; /** * Processes requests for both HTTP GET and POST @@ -100,22 +104,27 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println("

    Sending email using @MailSessionDefinition

    "); - + try { - out.println("Sending message using gmail...
    "); + out.println("Sending message from \"" + + creds.getFrom() + + "\" to \"" + + creds.getTo() + + "\"...
    "); + Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(creds.getUsername())); + message.setFrom(new InternetAddress(creds.getFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(creds.getTo())); - message.setSubject("Sending message using Annotated JavaMail " + message.setSubject("Sending message using Annotated JavaMail " + Calendar.getInstance().getTime()); message.setText("Java EE 7 is cool!"); +// session.setPasswordAuthentication(new URLName("smtp", "stbeehive.oracle.com", -1, "/", creds.getFrom(), creds.getTo()), +// new PasswordAuthentication(creds.getFrom(), creds.getPassword())); Transport t = session.getTransport(); - t.connect(creds.getUsername(), creds.getPassword()); + t.connect(creds.getFrom(), creds.getPassword()); t.send(message, message.getAllRecipients()); -// Transport.send(message, message.getAllRecipients()); - out.println("message sent!"); } catch (MessagingException e) { From a7fff8fd85e53449f566d19d2e9dff7e2ffce253 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 16:19:52 -0700 Subject: [PATCH 0084/1080] Fixing the --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e24e382c2..ab833cabe 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ javaee7-samples 1.0-SNAPSHOT pom - javaee7-samples + Java EE 7 Samples gfv3ee6 From c070ec1cf202c2b5e0feb01b72a7a5fe13af0137 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 12 Sep 2013 17:23:59 -0700 Subject: [PATCH 0085/1080] Adding extra module - first sample is Quartz scheduler --- extra/pom.xml | 19 ++ extra/quartz/nb-configuration.xml | 18 ++ extra/quartz/pom.xml | 23 +++ .../java/org/javaee7/extra/quartz/MyBean.java | 54 ++++++ .../org/javaee7/extra/quartz/MyCronJob.java | 57 ++++++ .../org/javaee7/extra/quartz/MySimpleJob.java | 57 ++++++ .../org/javaee7/extra/quartz/TestServlet.java | 167 ++++++++++++++++++ .../quartz/src/main/webapp/WEB-INF/beans.xml | 49 +++++ extra/quartz/src/main/webapp/index.jsp | 56 ++++++ pom.xml | 1 + 10 files changed, 501 insertions(+) create mode 100644 extra/pom.xml create mode 100644 extra/quartz/nb-configuration.xml create mode 100644 extra/quartz/pom.xml create mode 100644 extra/quartz/src/main/java/org/javaee7/extra/quartz/MyBean.java create mode 100644 extra/quartz/src/main/java/org/javaee7/extra/quartz/MyCronJob.java create mode 100644 extra/quartz/src/main/java/org/javaee7/extra/quartz/MySimpleJob.java create mode 100644 extra/quartz/src/main/java/org/javaee7/extra/quartz/TestServlet.java create mode 100644 extra/quartz/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/quartz/src/main/webapp/index.jsp diff --git a/extra/pom.xml b/extra/pom.xml new file mode 100644 index 000000000..05bf900f4 --- /dev/null +++ b/extra/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + org.javaee7 + javaee7-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + pom + + + quartz + + diff --git a/extra/quartz/nb-configuration.xml b/extra/quartz/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/extra/quartz/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/extra/quartz/pom.xml b/extra/quartz/pom.xml new file mode 100644 index 000000000..3702ea64d --- /dev/null +++ b/extra/quartz/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra + quartz + 1.0-SNAPSHOT + war + + + + org.quartz-scheduler + quartz + 2.2.0 + + + diff --git a/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyBean.java b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyBean.java new file mode 100644 index 000000000..991d85352 --- /dev/null +++ b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyBean.java @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.quartz; + +import java.io.Serializable; +import javax.transaction.TransactionScoped; + +/** + * @author Arun Gupta + */ +@TransactionScoped +public class MyBean implements Serializable { + + public String getId() { + return this + ""; + } +} diff --git a/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyCronJob.java b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyCronJob.java new file mode 100644 index 000000000..c588d228c --- /dev/null +++ b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MyCronJob.java @@ -0,0 +1,57 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.quartz; + +import java.util.Calendar; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * @author Arun Gupta + */ +public class MyCronJob implements Job { + + @Override + public void execute(JobExecutionContext jec) throws JobExecutionException { + System.out.println("MyCronJob.execute: " + Calendar.getInstance().getTime()); + } + +} diff --git a/extra/quartz/src/main/java/org/javaee7/extra/quartz/MySimpleJob.java b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MySimpleJob.java new file mode 100644 index 000000000..5b29f1d60 --- /dev/null +++ b/extra/quartz/src/main/java/org/javaee7/extra/quartz/MySimpleJob.java @@ -0,0 +1,57 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.quartz; + +import java.util.Calendar; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * @author Arun Gupta + */ +public class MySimpleJob implements Job { + + @Override + public void execute(JobExecutionContext jec) throws JobExecutionException { + System.out.println("MySimpleJob.execute: " + Calendar.getInstance().getTime()); + } + +} diff --git a/extra/quartz/src/main/java/org/javaee7/extra/quartz/TestServlet.java b/extra/quartz/src/main/java/org/javaee7/extra/quartz/TestServlet.java new file mode 100644 index 000000000..a017310e1 --- /dev/null +++ b/extra/quartz/src/main/java/org/javaee7/extra/quartz/TestServlet.java @@ -0,0 +1,167 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.quartz; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.quartz.CronScheduleBuilder; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SimpleScheduleBuilder; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.impl.StdSchedulerFactory; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Quartz Scheduler"); + out.println(""); + out.println(""); + out.println("

    Quartz Scheduler

    "); + + JobDetail simpleJob = JobBuilder.newJob(MySimpleJob.class).build(); + JobDetail cronJob = JobBuilder.newJob(MyCronJob.class).build(); + + Trigger simpleTrigger = TriggerBuilder + .newTrigger() + .withSchedule( + SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1).repeatForever() + ) + .build(); + + Trigger cronTrigger = TriggerBuilder + .newTrigger() + .withSchedule( + CronScheduleBuilder.cronSchedule("0/3 * * * * ?") + ) + .build(); + + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + + out.println("Starting the scheduler"); + scheduler.start(); + + out.println("

    Starting Simple Trigger - every 1 second

    "); + scheduler.scheduleJob(simpleJob, simpleTrigger); + out.println("

    Starting Cron Trigger - every 3 seconds

    "); + scheduler.scheduleJob(cronJob, cronTrigger); + + out.println("Sleeping for 7 seconds"); + Thread.sleep(7000); + + out.println("
    Shutting down the scheduler"); + scheduler.shutdown(); + + out.println("

    Check \"server.log\" for output - 8 outputs from simple trigger, 3 from cron trigger"); + out.println(""); + out.println(""); + } catch (SchedulerException | InterruptedException ex) { + Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/extra/quartz/src/main/webapp/WEB-INF/beans.xml b/extra/quartz/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/quartz/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/quartz/src/main/webapp/index.jsp b/extra/quartz/src/main/webapp/index.jsp new file mode 100644 index 000000000..dfbe5fb27 --- /dev/null +++ b/extra/quartz/src/main/webapp/index.jsp @@ -0,0 +1,56 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + + Quartz Scheduler + + +

    Quartz Scheduler

    + Trigger scheduler + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index ab833cabe..b1af2bfcf 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ servlet validation websocket + extras From 43f34d7fb80c17db727cc85425f5074018a177bf Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 09:21:13 -0700 Subject: [PATCH 0086/1080] Adding/Updating --- batch/pom.xml | 2 +- cdi/pom.xml | 3 ++- concurrency/pom.xml | 1 + ejb/pom.xml | 1 + el/pom.xml | 1 + extra/pom.xml | 1 + javamail/pom.xml | 1 + jaxrs/pom.xml | 3 ++- jca/pom.xml | 4 +++- jms/pom.xml | 1 + jpa/pom.xml | 2 ++ jsf/pom.xml | 1 + json/pom.xml | 1 + jta/pom.xml | 1 + servlet/pom.xml | 1 + validation/pom.xml | 3 ++- websocket/pom.xml | 3 ++- 17 files changed, 24 insertions(+), 6 deletions(-) diff --git a/batch/pom.xml b/batch/pom.xml index d8f716669..9a99f5eac 100644 --- a/batch/pom.xml +++ b/batch/pom.xml @@ -12,7 +12,7 @@ batch-samples 1.0-SNAPSHOT pom - ${project.artifactId} + Java EE 7 Batch Samples batchlet-simple diff --git a/cdi/pom.xml b/cdi/pom.xml index 5272a0feb..27ecc5d6c 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -12,6 +12,7 @@ cdi-samples 1.0-SNAPSHOT pom + Java EE 7 CDI Samples vetoed @@ -28,4 +29,4 @@ beanmanager extension - \ No newline at end of file + diff --git a/concurrency/pom.xml b/concurrency/pom.xml index 7fa2a525b..e1dd765f8 100644 --- a/concurrency/pom.xml +++ b/concurrency/pom.xml @@ -13,6 +13,7 @@ concurrency-samples 1.0-SNAPSHOT pom + Java EE 7 Concurrency Samples dynamicproxy diff --git a/ejb/pom.xml b/ejb/pom.xml index 37d1e25b6..ea36b19c5 100644 --- a/ejb/pom.xml +++ b/ejb/pom.xml @@ -12,6 +12,7 @@ ejb-samples 1.0-SNAPSHOT pom + Java EE 7 EJB Samples embeddable diff --git a/el/pom.xml b/el/pom.xml index dbe3763b7..8ec44494e 100644 --- a/el/pom.xml +++ b/el/pom.xml @@ -12,6 +12,7 @@ el-samples 1.0-SNAPSHOT pom + Java EE 7 Expression Language Samples standalone diff --git a/extra/pom.xml b/extra/pom.xml index 05bf900f4..d20b73443 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -12,6 +12,7 @@ extra-samples 1.0-SNAPSHOT pom + Java EE 7 Extra Samples quartz diff --git a/javamail/pom.xml b/javamail/pom.xml index d3be414df..42b4750fb 100644 --- a/javamail/pom.xml +++ b/javamail/pom.xml @@ -12,6 +12,7 @@ javamail-samples 1.0-SNAPSHOT pom + Java EE 7 JavaMail Samples definition diff --git a/jaxrs/pom.xml b/jaxrs/pom.xml index 647eeb7cd..729242f8d 100644 --- a/jaxrs/pom.xml +++ b/jaxrs/pom.xml @@ -12,6 +12,7 @@ jaxrs-samples 1.0-SNAPSHOT pom + Java EE 7 JAX-RS Samples @@ -51,4 +52,4 @@ readerwriter-injection - \ No newline at end of file + diff --git a/jca/pom.xml b/jca/pom.xml index 13299f54c..31c1fd6f5 100644 --- a/jca/pom.xml +++ b/jca/pom.xml @@ -12,7 +12,9 @@ jca-samples 1.0-SNAPSHOT pom + Java EE 7 JCA Samples + connector-simple - \ No newline at end of file + diff --git a/jms/pom.xml b/jms/pom.xml index e3c93d8bc..e7e5ac73f 100644 --- a/jms/pom.xml +++ b/jms/pom.xml @@ -12,6 +12,7 @@ jms-samples 1.0-SNAPSHOT pom + Java EE 7 JMS Samples send-receive-simple diff --git a/jpa/pom.xml b/jpa/pom.xml index 155a202bc..e0155348d 100644 --- a/jpa/pom.xml +++ b/jpa/pom.xml @@ -12,6 +12,8 @@ jpa-samples 1.0-SNAPSHOT pom + Java EE 7 JPA Samples + criteria entitygraph diff --git a/jsf/pom.xml b/jsf/pom.xml index c51670290..8c40bddac 100644 --- a/jsf/pom.xml +++ b/jsf/pom.xml @@ -13,6 +13,7 @@ jsf-samples 1.0-SNAPSHOT pom + Java EE 7 JSF Samples ajax diff --git a/json/pom.xml b/json/pom.xml index 7b07e4325..21eb04a8c 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -12,6 +12,7 @@ json-samples 1.0-SNAPSHOT pom + Java EE 7 JSON-P Samples object-builder diff --git a/jta/pom.xml b/jta/pom.xml index 5171ebb55..ba8a4bed9 100644 --- a/jta/pom.xml +++ b/jta/pom.xml @@ -12,6 +12,7 @@ jta-samples 1.0-SNAPSHOT pom + Java EE 7 JTA Samples transactional diff --git a/servlet/pom.xml b/servlet/pom.xml index 9bbc68994..02c01f57f 100644 --- a/servlet/pom.xml +++ b/servlet/pom.xml @@ -13,6 +13,7 @@ servlet-samples 1.0-SNAPSHOT pom + Java EE 7 Servlet Samples cookies diff --git a/validation/pom.xml b/validation/pom.xml index c08629815..b60a89801 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -13,10 +13,11 @@ validation-samples 1.0-SNAPSHOT pom + Java EE 7 Bean Validation Samples methods custom-constraint - \ No newline at end of file + diff --git a/websocket/pom.xml b/websocket/pom.xml index 293ea1e8d..eaf577ba1 100644 --- a/websocket/pom.xml +++ b/websocket/pom.xml @@ -12,6 +12,7 @@ websocket-samples 1.0-SNAPSHOT pom + Java EE 7 WebSocket Samples binary @@ -47,4 +48,4 @@ endpoint-singleton - \ No newline at end of file + From bf0198ba17556b2846d4a79a456af3f4d89eeb1d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 09:48:55 -0700 Subject: [PATCH 0087/1080] Moving json/twitter-search to extra/twitter-search --- extra/pom.xml | 7 ++++--- {json => extra}/twitter-search/pom.xml | 6 +++--- .../org/javaee7/extra}/twitter/search/TestServlet.java | 2 +- .../org/javaee7/extra}/twitter/search/TwitterSearch.java | 2 +- .../twitter-search/src/main/webapp/WEB-INF/beans.xml | 0 {json => extra}/twitter-search/src/main/webapp/index.jsp | 0 json/pom.xml | 1 - 7 files changed, 9 insertions(+), 9 deletions(-) rename {json => extra}/twitter-search/pom.xml (87%) rename {json/twitter-search/src/main/java/org/javaee7/json => extra/twitter-search/src/main/java/org/javaee7/extra}/twitter/search/TestServlet.java (99%) rename {json/twitter-search/src/main/java/org/javaee7/json => extra/twitter-search/src/main/java/org/javaee7/extra}/twitter/search/TwitterSearch.java (98%) rename {json => extra}/twitter-search/src/main/webapp/WEB-INF/beans.xml (100%) rename {json => extra}/twitter-search/src/main/webapp/index.jsp (100%) diff --git a/extra/pom.xml b/extra/pom.xml index d20b73443..438105413 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -14,7 +14,8 @@ pom Java EE 7 Extra Samples - - quartz - + + quartz + twitter-search + diff --git a/json/twitter-search/pom.xml b/extra/twitter-search/pom.xml similarity index 87% rename from json/twitter-search/pom.xml rename to extra/twitter-search/pom.xml index edc6f6d02..75aa4ef73 100644 --- a/json/twitter-search/pom.xml +++ b/extra/twitter-search/pom.xml @@ -2,13 +2,13 @@ 4.0.0 - org.javaee7.json - json-samples + org.javaee7.extra + extra-samples 1.0-SNAPSHOT ../pom.xml - org.javaee7.json + org.javaee7.extra twitter-search 1.0-SNAPSHOT war diff --git a/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java b/extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TestServlet.java similarity index 99% rename from json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java rename to extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TestServlet.java index 2b367100f..57dac711d 100644 --- a/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TestServlet.java +++ b/extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TestServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.json.twitter.search; +package org.javaee7.extra.twitter.search; import java.io.IOException; import java.io.PrintWriter; diff --git a/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java b/extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TwitterSearch.java similarity index 98% rename from json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java rename to extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TwitterSearch.java index 3eb2713a2..6d851356a 100644 --- a/json/twitter-search/src/main/java/org/javaee7/json/twitter/search/TwitterSearch.java +++ b/extra/twitter-search/src/main/java/org/javaee7/extra/twitter/search/TwitterSearch.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.json.twitter.search; +package org.javaee7.extra.twitter.search; import javax.inject.Inject; import org.glassfish.samples.twitter.api.SearchResults; diff --git a/json/twitter-search/src/main/webapp/WEB-INF/beans.xml b/extra/twitter-search/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from json/twitter-search/src/main/webapp/WEB-INF/beans.xml rename to extra/twitter-search/src/main/webapp/WEB-INF/beans.xml diff --git a/json/twitter-search/src/main/webapp/index.jsp b/extra/twitter-search/src/main/webapp/index.jsp similarity index 100% rename from json/twitter-search/src/main/webapp/index.jsp rename to extra/twitter-search/src/main/webapp/index.jsp diff --git a/json/pom.xml b/json/pom.xml index 21eb04a8c..f26dceda3 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -19,7 +19,6 @@ object-reader streaming-generate streaming-parser - twitter-search From ef28aaedbf2d60581725606f377323acb364f83f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 10:20:26 -0700 Subject: [PATCH 0088/1080] Naming the Servlets appropriately --- ...let.java => ExecutorInvokeAllServlet.java} | 6 ++--- ...let.java => ExecutorInvokeAnyServlet.java} | 6 ++--- ...IServlet.java => ExecutorJNDIServlet.java} | 6 ++--- ...vlet.java => ExecutorListenerServlet.java} | 4 +-- ...vlet.java => ExecutorResourceServlet.java} | 4 +-- ...> ExecutorTaskWithTransactionServlet.java} | 4 +-- ....java => ManagedExecutorInEJBServlet.java} | 8 +++--- .../concurrency/executor/MyCallableTask.java | 2 +- .../concurrency/executor/MyRunnableTask.java | 2 +- .../executor/MyTaskWithTransaction.java | 25 ++++--------------- .../executor/src/main/webapp/index.jsp | 16 ++++++------ 11 files changed, 33 insertions(+), 50 deletions(-) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestInvokeAllServlet.java => ExecutorInvokeAllServlet.java} (96%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestInvokeAnyServlet.java => ExecutorInvokeAnyServlet.java} (96%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestJNDIServlet.java => ExecutorJNDIServlet.java} (96%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestListenerServlet.java => ExecutorListenerServlet.java} (97%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestResourceServlet.java => ExecutorResourceServlet.java} (97%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestTransactionServlet.java => ExecutorTaskWithTransactionServlet.java} (97%) rename concurrency/executor/src/main/java/org/javaee7/concurrency/executor/{TestEJBServlet.java => ManagedExecutorInEJBServlet.java} (95%) diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAllServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java similarity index 96% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAllServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java index 73a5c9cc0..ffe00daea 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAllServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java @@ -60,8 +60,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestInvokeAllServlet"}) -public class TestInvokeAllServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorInvokeAllServlet"}) +public class ExecutorInvokeAllServlet extends HttpServlet { // @Resource(name = "concurrent/myExecutor2") @Resource(name = "DefaultManagedExecutorService") @@ -100,7 +100,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.format("got response: %d
    ", f.get().getId()); } } catch (InterruptedException | ExecutionException ex) { - Logger.getLogger(TestInvokeAllServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ExecutorInvokeAllServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("

    Check server.log for output"); diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAnyServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java similarity index 96% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAnyServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java index e1d34a674..4be7eea3b 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestInvokeAnyServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java @@ -58,8 +58,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestInvokeAnyServlet"}) -public class TestInvokeAnyServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorInvokeAnyServlet"}) +public class ExecutorInvokeAnyServlet extends HttpServlet { // @Resource(name = "concurrent/myExecutor2") @Resource(name = "DefaultManagedExecutorService") @@ -96,7 +96,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Product result = executor.invokeAny(tasks); out.format("got response: %d", result.getId()); } catch (InterruptedException | ExecutionException ex) { - Logger.getLogger(TestInvokeAnyServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ExecutorInvokeAnyServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("

    Check server.log for output"); diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestJNDIServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java similarity index 96% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestJNDIServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java index 2372e231d..27be2d2f7 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestJNDIServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java @@ -55,8 +55,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestJNDIServlet"}) -public class TestJNDIServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorJNDIServlet"}) +public class ExecutorJNDIServlet extends HttpServlet { /** * Processes requests for both HTTP @@ -92,7 +92,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re executor.submit(new MyCallableTask(i)); } } catch (NamingException ex) { - Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getAnonymousLogger().log(Level.SEVERE, null, ex); } out.println("all tasks submitted

    "); out.println("Check server.log for output from the task."); diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestListenerServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java similarity index 97% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestListenerServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java index 0493ff29d..6fe2f0a28 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestListenerServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java @@ -52,8 +52,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestListenerServlet"}) -public class TestListenerServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorListenerServlet"}) +public class ExecutorListenerServlet extends HttpServlet { // @Resource(name = "concurrent/myExecutor2") @Resource(name = "DefaultManagedExecutorService") diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestResourceServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java similarity index 97% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestResourceServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java index f2b2deb14..ab9554258 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestResourceServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java @@ -53,8 +53,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestResourceServlet"}) -public class TestResourceServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorResourceServlet"}) +public class ExecutorResourceServlet extends HttpServlet { // @Resource(name = "concurrent/myExecutor2") // @Resource(name = "DefaultManagedExecutorService") diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestTransactionServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java similarity index 97% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestTransactionServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java index ae976b050..2baf2e0a1 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestTransactionServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java @@ -52,8 +52,8 @@ /** * @author Arun Gupta */ -@WebServlet(urlPatterns = {"/TestTransactionServlet"}) -public class TestTransactionServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ExecutorTaskWithTransactionServlet"}) +public class ExecutorTaskWithTransactionServlet extends HttpServlet { // @Resource(name = "concurrent/myExecutor2") @Resource(name = "DefaultManagedExecutorService") diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestEJBServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java similarity index 95% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestEJBServlet.java rename to concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java index c0f113838..ce0744e7e 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestEJBServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java @@ -52,8 +52,8 @@ * * @author Arun */ -@WebServlet(urlPatterns = {"/TestEJBServlet"}) -public class TestEJBServlet extends HttpServlet { +@WebServlet(urlPatterns = {"/ManagedExecutorInEJBServlet"}) +public class ManagedExecutorInEJBServlet extends HttpServlet { @EJB TestBean bean; @@ -81,9 +81,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println("

    Run managed threads in EJB

    "); out.println("Submitting tasks using ManagedExecutorService in EJB
    "); bean.run(); - out.println("all tasks submitted

    "); - out.println("Check server.log for output from the task."); - + out.println("

    Check server.log for output from the task."); out.println(""); out.println(""); } diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java index bd51eae2c..6267db00e 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java @@ -62,7 +62,7 @@ public Product call() { Thread.sleep(2000); System.out.format("%d (callable): complete", id); } catch (InterruptedException ex) { - Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ExecutorResourceServlet.class.getName()).log(Level.SEVERE, null, ex); } return new Product(id); } diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java index b87a484cf..e7cac4352 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java @@ -61,7 +61,7 @@ public void run() { Thread.sleep(2000); System.out.format("%d (runnable): complete", id); } catch (InterruptedException ex) { - Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ExecutorResourceServlet.class.getName()).log(Level.SEVERE, null, ex); } } } diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java index 1f1c49988..023f57670 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java @@ -48,13 +48,14 @@ import javax.transaction.NotSupportedException; import javax.transaction.RollbackException; import javax.transaction.SystemException; +import javax.transaction.Transactional; import javax.transaction.UserTransaction; /** * @author Arun Gupta */ public class MyTaskWithTransaction implements Runnable { - + private int id; public MyTaskWithTransaction() { @@ -73,26 +74,10 @@ public void setId(int id) { } // @Resource UserTransaction tx; - @Override + @Transactional public void run() { - - try { - InitialContext context = new InitialContext(); - UserTransaction tx = (UserTransaction)context.lookup("java:comp/UserTransaction"); - - try { - System.out.format("%d (transaction): tx.start", id); - tx.begin(); - System.out.format("%d (transaction): running", id); - tx.commit(); - System.out.format("%d (transaction): tx.commit", id); - } catch (NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException | SecurityException | IllegalStateException ex) { - Logger.getLogger(MyTaskWithTransaction.class.getName()).log(Level.SEVERE, null, ex); - } - } catch (NamingException ex) { - Logger.getLogger(MyTaskWithTransaction.class.getName()).log(Level.SEVERE, null, ex); - } + System.out.format("%d (within a transaction): running", id); } - + } diff --git a/concurrency/executor/src/main/webapp/index.jsp b/concurrency/executor/src/main/webapp/index.jsp index d396b2811..92336138c 100644 --- a/concurrency/executor/src/main/webapp/index.jsp +++ b/concurrency/executor/src/main/webapp/index.jsp @@ -47,17 +47,17 @@ - Concurrency Utilities for Java EE + Concurrency Utilities for Java EE : ManagedExecutor

    Concurrency Utilities for Java EE : ManagedExecutor

    - Get ManagedExecutor using @Resource (in Servlet)
    - Get ManagedExecutor using JNDI Context (in Servlet)
    - Run managed threads in EJB
    - Submit tasks using invokeAll
    - Submit tasks using invokeAny
    - Submit tasks with ManagedTaskListener
    - Run task with a UserTransaction
    + Get ManagedExecutor using @Resource (in Servlet)
    + Get ManagedExecutor using JNDI Context (in Servlet)
    + Run managed threads in EJB
    + Submit tasks using invokeAll
    + Submit tasks using invokeAny
    + Submit tasks with ManagedTaskListener
    + Run task with a UserTransaction
    From 4d6b6baa34dbe7cbcd4fcaad7db1e743daf5b59c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 10:59:08 -0700 Subject: [PATCH 0089/1080] Getting the ManagedExecutor from web.xml --- .../org/javaee7/concurrency/executor/ExecutorJNDIServlet.java | 4 ++-- concurrency/executor/src/main/webapp/WEB-INF/web.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java index 27be2d2f7..168bc71c1 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java @@ -83,8 +83,8 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try { InitialContext ctx = new InitialContext(); -// ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("java:comp/env/concurrent/myExecutor2"); - ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService"); + ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("java:comp/env/concurrent/myExecutor2"); +// ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService"); for (int i = 0; i < 5; i++) { out.format("submitting runnable(%d)
    ", i); executor.submit(new MyRunnableTask(i)); diff --git a/concurrency/executor/src/main/webapp/WEB-INF/web.xml b/concurrency/executor/src/main/webapp/WEB-INF/web.xml index 58a527849..d22b467af 100644 --- a/concurrency/executor/src/main/webapp/WEB-INF/web.xml +++ b/concurrency/executor/src/main/webapp/WEB-INF/web.xml @@ -4,12 +4,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> - +
    From beb845ffadc8c1dc62b6c65eb13d99e9c09910a4 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 13:11:31 -0700 Subject: [PATCH 0090/1080] Using transport.sendMessage instead of transport.send did the trick. Thanks Bill! --- .../javamail/definition/AnnotatedEmailServlet.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java index 29c9c53ce..93183b205 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/AnnotatedEmailServlet.java @@ -47,10 +47,8 @@ import javax.mail.MailSessionDefinition; import javax.mail.Message; import javax.mail.MessagingException; -import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; -import javax.mail.URLName; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.ServletException; @@ -66,14 +64,7 @@ @MailSessionDefinition(name = "java:comp/myMailSession", host = "smtp.gmail.com", transportProtocol = "smtps", -// host = "stbeehive.oracle.com", - // transportProtocol = "smtps", properties = { - // "mail.smtp.host=smtp.gmail.com", - // "mail.smtp.host=stbeehive.oracle.com", - // "mail.smtp.ssl.enable=true", - // "mail.smtp.auth=true", -// "mail.transport.protocol=smtps", "mail.debug=true" }) public class AnnotatedEmailServlet extends HttpServlet { @@ -119,11 +110,9 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re + Calendar.getInstance().getTime()); message.setText("Java EE 7 is cool!"); -// session.setPasswordAuthentication(new URLName("smtp", "stbeehive.oracle.com", -1, "/", creds.getFrom(), creds.getTo()), -// new PasswordAuthentication(creds.getFrom(), creds.getPassword())); Transport t = session.getTransport(); t.connect(creds.getFrom(), creds.getPassword()); - t.send(message, message.getAllRecipients()); + t.sendMessage(message, message.getAllRecipients()); out.println("message sent!"); From 6acf2e3bb4bd25f1465ab7d9d7b84e2ff7cecdc0 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 13:11:54 -0700 Subject: [PATCH 0091/1080] Fixing the property names, although commented --- .../javamail/definition/ProgrammaticEmailServlet.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java index 691b9136d..b218bf8ca 100644 --- a/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java +++ b/javamail/definition/src/main/java/org/javaee7/javamail/definition/ProgrammaticEmailServlet.java @@ -88,7 +88,6 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); -// props.put("mail.smtp.host", "stbeehive.oracle.com"); props.put("mail.smtp.ssl.enable", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.transport.protocol", "smtp"); @@ -120,8 +119,8 @@ protected PasswordAuthentication getPasswordAuthentication() { message.setText("Java EE 7 is cool!"); // Transport t = session.getTransport(); -// t.connect(creds.getProperty("username"), creds.getProperty("password")); -// t.send(message); +// t.connect(creds.getFrom(), creds.getTo()); +// t.sendMessage(message, message.getAllRecipients()); Transport.send(message, message.getAllRecipients()); out.println("message sent!"); From c3c402a28674082f93deb32281a9cc11598b9fba Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 15:27:21 -0700 Subject: [PATCH 0092/1080] Default ManagedExecutor can be accessed using @Resource without specifying any name --- .../ExecutorResourceNoNameServlet.java | 141 ++++++++++++++++++ .../executor/src/main/webapp/index.jsp | 1 + 2 files changed, 142 insertions(+) create mode 100644 concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java new file mode 100644 index 000000000..4e1c75c11 --- /dev/null +++ b/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java @@ -0,0 +1,141 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.executor; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.concurrent.Future; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedExecutorService; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/ExecutorResourceNoNameServlet"}) +public class ExecutorResourceNoNameServlet extends HttpServlet { + + @Resource + ManagedExecutorService executor; + + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println("Servlet TestServlet"); + out.println(""); + out.println(""); + out.println("

    Get ManagedExecutor using @Resource with no name

    "); + + System.out.println("Getting ManagedExecutorService using @Resource with no name"); + for (int i = 0; i < 5; i++) { + out.format("submitting runnable(%d)
    ", i); + Future f = executor.submit(new MyRunnableTask(i)); + out.format("executing runnable(%d)
    ", i); + executor.execute(new MyRunnableTask(i)); + out.format("submitting callable(%d)
    ", i); + Future f2 = executor.submit(new MyCallableTask(i)); + } + out.println("all tasks submitted

    "); + out.println("Check server.log for output from the task."); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/concurrency/executor/src/main/webapp/index.jsp b/concurrency/executor/src/main/webapp/index.jsp index 92336138c..760d7de0f 100644 --- a/concurrency/executor/src/main/webapp/index.jsp +++ b/concurrency/executor/src/main/webapp/index.jsp @@ -53,6 +53,7 @@

    Concurrency Utilities for Java EE : ManagedExecutor

    Get ManagedExecutor using @Resource (in Servlet)
    + Get ManagedExecutor using @Resource (in Servlet, no name specified)
    Get ManagedExecutor using JNDI Context (in Servlet)
    Run managed threads in EJB
    Submit tasks using invokeAll
    From e84bd4527b3e0f02699f860df8022e636366fda6 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 15:36:31 -0700 Subject: [PATCH 0093/1080] Renaming the directory and artifactId --- concurrency/{executor => managedexecutor}/nb-configuration.xml | 0 concurrency/{executor => managedexecutor}/pom.xml | 3 ++- .../concurrency/managedexecutor}/ExecutorInvokeAllServlet.java | 2 +- .../concurrency/managedexecutor}/ExecutorInvokeAnyServlet.java | 2 +- .../concurrency/managedexecutor}/ExecutorJNDIServlet.java | 2 +- .../concurrency/managedexecutor}/ExecutorListenerServlet.java | 2 +- .../managedexecutor}/ExecutorResourceNoNameServlet.java | 2 +- .../concurrency/managedexecutor}/ExecutorResourceServlet.java | 2 +- .../managedexecutor}/ExecutorTaskWithTransactionServlet.java | 2 +- .../managedexecutor}/ManagedExecutorInEJBServlet.java | 2 +- .../javaee7/concurrency/managedexecutor}/MyCallableTask.java | 2 +- .../javaee7/concurrency/managedexecutor}/MyRunnableTask.java | 2 +- .../concurrency/managedexecutor}/MyTaskWithListener.java | 2 +- .../concurrency/managedexecutor}/MyTaskWithTransaction.java | 2 +- .../javaee7/concurrency/managedexecutor}/MyWaitingTask.java | 2 +- .../java/org/javaee7/concurrency/managedexecutor}/Product.java | 2 +- .../org/javaee7/concurrency/managedexecutor}/TestBean.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 0 .../{executor => managedexecutor}/src/main/webapp/index.jsp | 0 19 files changed, 17 insertions(+), 16 deletions(-) rename concurrency/{executor => managedexecutor}/nb-configuration.xml (100%) rename concurrency/{executor => managedexecutor}/pom.xml (88%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorInvokeAllServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorInvokeAnyServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorJNDIServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorListenerServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorResourceNoNameServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorResourceServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ExecutorTaskWithTransactionServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/ManagedExecutorInEJBServlet.java (99%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/MyCallableTask.java (98%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/MyRunnableTask.java (98%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/MyTaskWithListener.java (98%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/MyTaskWithTransaction.java (98%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/MyWaitingTask.java (97%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/Product.java (97%) rename concurrency/{executor/src/main/java/org/javaee7/concurrency/executor => managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor}/TestBean.java (98%) rename concurrency/{executor => managedexecutor}/src/main/webapp/WEB-INF/web.xml (100%) rename concurrency/{executor => managedexecutor}/src/main/webapp/index.jsp (100%) diff --git a/concurrency/executor/nb-configuration.xml b/concurrency/managedexecutor/nb-configuration.xml similarity index 100% rename from concurrency/executor/nb-configuration.xml rename to concurrency/managedexecutor/nb-configuration.xml diff --git a/concurrency/executor/pom.xml b/concurrency/managedexecutor/pom.xml similarity index 88% rename from concurrency/executor/pom.xml rename to concurrency/managedexecutor/pom.xml index cbd978a3f..440dc0ace 100644 --- a/concurrency/executor/pom.xml +++ b/concurrency/managedexecutor/pom.xml @@ -9,7 +9,8 @@ org.javaee7.concurrency - executor + managedexecutor 1.0-SNAPSHOT war + managedexecutor diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAllServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAllServlet.java index ffe00daea..e9a553f48 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAllServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAllServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAnyServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAnyServlet.java index 4be7eea3b..3463f5f4b 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorInvokeAnyServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorInvokeAnyServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorJNDIServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorJNDIServlet.java index 168bc71c1..489caa8dd 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorJNDIServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorJNDIServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorListenerServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorListenerServlet.java index 6fe2f0a28..05695de43 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorListenerServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorListenerServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceNoNameServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceNoNameServlet.java index 4e1c75c11..9ee01d66d 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceNoNameServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceNoNameServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceServlet.java index ab9554258..2e1d3caec 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorResourceServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorResourceServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorTaskWithTransactionServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorTaskWithTransactionServlet.java index 2baf2e0a1..889a05ced 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ExecutorTaskWithTransactionServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ExecutorTaskWithTransactionServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ManagedExecutorInEJBServlet.java similarity index 99% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ManagedExecutorInEJBServlet.java index ce0744e7e..db651e4c4 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/ManagedExecutorInEJBServlet.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/ManagedExecutorInEJBServlet.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.io.IOException; import java.io.PrintWriter; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyCallableTask.java similarity index 98% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyCallableTask.java index 6267db00e..0761dd48c 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyCallableTask.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyCallableTask.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.util.concurrent.Callable; import java.util.logging.Level; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyRunnableTask.java similarity index 98% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyRunnableTask.java index e7cac4352..48dfb2c9b 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyRunnableTask.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyRunnableTask.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithListener.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithListener.java similarity index 98% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithListener.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithListener.java index 52b30579e..b2c90d02b 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithListener.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithListener.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.util.Map; import java.util.concurrent.Future; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithTransaction.java similarity index 98% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithTransaction.java index 023f57670..f42619f73 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyTaskWithTransaction.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyTaskWithTransaction.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyWaitingTask.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyWaitingTask.java similarity index 97% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyWaitingTask.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyWaitingTask.java index bcd3a07c7..00531f35c 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/MyWaitingTask.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/MyWaitingTask.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; /** * @author Arun Gupta diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/Product.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/Product.java similarity index 97% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/Product.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/Product.java index b9466a6f6..66e8a6e3a 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/Product.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/Product.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; /** * @author Arun Gupta diff --git a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestBean.java b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/TestBean.java similarity index 98% rename from concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestBean.java rename to concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/TestBean.java index 9fbde5279..8ceb1f5aa 100644 --- a/concurrency/executor/src/main/java/org/javaee7/concurrency/executor/TestBean.java +++ b/concurrency/managedexecutor/src/main/java/org/javaee7/concurrency/managedexecutor/TestBean.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.concurrency.executor; +package org.javaee7.concurrency.managedexecutor; import javax.annotation.Resource; import javax.ejb.Stateless; diff --git a/concurrency/executor/src/main/webapp/WEB-INF/web.xml b/concurrency/managedexecutor/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from concurrency/executor/src/main/webapp/WEB-INF/web.xml rename to concurrency/managedexecutor/src/main/webapp/WEB-INF/web.xml diff --git a/concurrency/executor/src/main/webapp/index.jsp b/concurrency/managedexecutor/src/main/webapp/index.jsp similarity index 100% rename from concurrency/executor/src/main/webapp/index.jsp rename to concurrency/managedexecutor/src/main/webapp/index.jsp From ca795591b8898e430214c408b360b4ca3d582b4e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 15:42:25 -0700 Subject: [PATCH 0094/1080] Changing schedule to managedscheduledexecutor, also changed the servlet names to be more intuitive --- .../nb-configuration.xml | 18 ++ concurrency/managedscheduledexecutor/pom.xml | 16 ++ .../MyCallableTask.java | 71 ++++++++ .../MyRunnableTask.java | 57 +++++++ .../managedscheduledexecutor/MyTrigger.java | 61 +++++++ .../managedscheduledexecutor/Product.java | 62 +++++++ .../ScheduleFixedRateServlet.java | 140 +++++++++++++++ .../ScheduleServlet.java | 160 ++++++++++++++++++ .../ScheduleWithFixedDelayServlet.java | 135 +++++++++++++++ .../TestTriggerServlet.java | 133 +++++++++++++++ .../src/main/webapp/index.jsp | 59 +++++++ 11 files changed, 912 insertions(+) create mode 100644 concurrency/managedscheduledexecutor/nb-configuration.xml create mode 100644 concurrency/managedscheduledexecutor/pom.xml create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyCallableTask.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyRunnableTask.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyTrigger.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/Product.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleServlet.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleWithFixedDelayServlet.java create mode 100644 concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/TestTriggerServlet.java create mode 100644 concurrency/managedscheduledexecutor/src/main/webapp/index.jsp diff --git a/concurrency/managedscheduledexecutor/nb-configuration.xml b/concurrency/managedscheduledexecutor/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/concurrency/managedscheduledexecutor/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/concurrency/managedscheduledexecutor/pom.xml b/concurrency/managedscheduledexecutor/pom.xml new file mode 100644 index 000000000..8ef884bf0 --- /dev/null +++ b/concurrency/managedscheduledexecutor/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + + org.javaee7.concurrency + concurrency-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.concurrency + managedscheduledexecutor + 1.0-SNAPSHOT + war + managedscheduledexecutor + diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyCallableTask.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyCallableTask.java new file mode 100644 index 000000000..ae0a6be92 --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyCallableTask.java @@ -0,0 +1,71 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.util.concurrent.Callable; + +/** + * @author Arun Gupta + */ +public class MyCallableTask implements Callable { + + private int id; + + public MyCallableTask() { + } + + public MyCallableTask(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + public Product call() { + System.out.println("Running Callable Task: " + id); + return new Product(id); + } +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyRunnableTask.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyRunnableTask.java new file mode 100644 index 000000000..fe0cf107c --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyRunnableTask.java @@ -0,0 +1,57 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +/** + * @author Arun Gupta + */ +public class MyRunnableTask implements Runnable { + + private int id; + + public MyRunnableTask(int id) { + this.id = id; + } + + @Override + public void run() { + System.out.println("Running Runnable Task: " + id); + } +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyTrigger.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyTrigger.java new file mode 100644 index 000000000..5b45e3c5c --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/MyTrigger.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.util.Date; +import javax.enterprise.concurrent.LastExecution; +import javax.enterprise.concurrent.Trigger; + +/** + * @author Arun Gupta + */ +public class MyTrigger implements Trigger { + + @Override + public Date getNextRunTime(LastExecution le, Date date) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean skipRun(LastExecution le, Date date) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/Product.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/Product.java new file mode 100644 index 000000000..25e625d20 --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/Product.java @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +/** + * @author Arun Gupta + */ +public class Product { + private int id; + + public Product() { + } + + public Product(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java new file mode 100644 index 000000000..73fe6f921 --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java @@ -0,0 +1,140 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.concurrent.TimeUnit; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedScheduledExecutorService; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/ScheduleFixedRateServlet"}) +public class ScheduleFixedRateServlet extends HttpServlet { + +// @Resource(name = "concurrent/myScheduledExecutor2") + @Resource(name = "DefaultManagedScheduledExecutorService") + ManagedScheduledExecutorService executor; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Schedule at fixed rate"); + out.println(""); + out.println(""); + out.println("

    Schedule at fixed rate

    "); +// ScheduledFuture f = executor.scheduleAtFixedRate(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); +// try { +// Thread.sleep(1000); +// } catch (InterruptedException ex) { +// Logger.getLogger(TestScheduleFixedRateServlet.class.getName()).log(Level.SEVERE, null, ex); +// } +// f.cancel(true); + + executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); + System.out.println("Runnable Task completed"); + out.println("

    Check server.log for output"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleServlet.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleServlet.java new file mode 100644 index 000000000..c0f6628a3 --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleServlet.java @@ -0,0 +1,160 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedScheduledExecutorService; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author arungup + */ +@WebServlet(urlPatterns = {"/ScheduleServlet"}) +public class ScheduleServlet extends HttpServlet { + +// @Resource(name = "concurrent/myScheduledExecutor2") + @Resource(name = "DefaultManagedScheduledExecutorService") + ManagedScheduledExecutorService executor; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Schedule using Callable after 5 seconds"); + out.println(""); + out.println(""); + out.println("

    Schedule using Callable after 5 seconds

    "); + out.println("

    Scheduling tasks using Callable

    "); + ScheduledFuture future = executor.schedule(new MyCallableTask(5), 5, TimeUnit.SECONDS); + while (true) { + if (future.isDone()) { + break; + } else { + System.out.println("Checking Callable Future, waiting for 1 sec"); + Thread.sleep(1000); + } + } + out.println("Callable Task completed: " + future.get().getId()); + + out.println("

    Scheduling tasks using Runnable

    "); + ScheduledFuture f = executor.schedule(new MyRunnableTask(10), 5, TimeUnit.SECONDS); + while (true) { + if (f.isDone()) { + break; + } else { + System.out.println("Checking Runnable Future, waiting for 1 sec"); + Thread.sleep(1000); + } + } + out.println("Runnable Task completed: " + future.get().getId()); + out.println("

    Check server.log for output"); + out.println(""); + out.println(""); + } catch (InterruptedException | ExecutionException ex) { + Logger.getLogger(ScheduleServlet.class.getName()).log(Level.SEVERE, null, ex); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleWithFixedDelayServlet.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleWithFixedDelayServlet.java new file mode 100644 index 000000000..bbe40d5cf --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleWithFixedDelayServlet.java @@ -0,0 +1,135 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.concurrent.TimeUnit; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedScheduledExecutorService; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/ScheduleWithFixedDelayServlet"}) +public class ScheduleWithFixedDelayServlet extends HttpServlet { + +// @Resource(name = "concurrent/myScheduledExecutor2") +// @Resource(name = "DefaultManagedScheduledExecutorService") + @Resource + ManagedScheduledExecutorService executor; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Schedule with fixed delay"); + out.println(""); + out.println(""); + out.println("

    Schedule tasks with fixed delay

    "); + + executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); + out.println("

    Check server.log for output"); + System.out.println("Runnable Task submitted"); + + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/TestTriggerServlet.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/TestTriggerServlet.java new file mode 100644 index 000000000..808761ec7 --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/TestTriggerServlet.java @@ -0,0 +1,133 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.managedscheduledexecutor; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedScheduledExecutorService; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestTriggerServlet"}) +public class TestTriggerServlet extends HttpServlet { + +// @Resource(name = "concurrent/myScheduledExecutor2") + @Resource(name = "DefaultManagedScheduledExecutorService") + ManagedScheduledExecutorService executor; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet TestServlet"); + out.println(""); + out.println(""); + out.println("

    Schedule tasks with a trigger

    "); + for (int i=0; i<5; i++) { + executor.schedule(new MyRunnableTask(i), new MyTrigger()); + } + out.println("

    Check server.log for output"); + + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/concurrency/managedscheduledexecutor/src/main/webapp/index.jsp b/concurrency/managedscheduledexecutor/src/main/webapp/index.jsp new file mode 100644 index 000000000..449a20efa --- /dev/null +++ b/concurrency/managedscheduledexecutor/src/main/webapp/index.jsp @@ -0,0 +1,59 @@ + + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Concurrency Utilities for Java EE : ManagedScheduledExecutor + + +

    Concurrency Utilities for Java EE : ManagedScheduledExecutor

    + + Schedule using Callable after 5 seconds
    + Schedule at fixed rate
    + Schedule with fixed delay
    + + From 49c114298935cffe666c0ac7e7f4667b258c411c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 13 Sep 2013 16:00:34 -0700 Subject: [PATCH 0095/1080] Changing thread to manageablethreas, also added a new sample to show how default ManagedThreadFactory can be obtained using @Resource without specifying the name --- .../manageablethread/nb-configuration.xml | 18 +++ concurrency/manageablethread/pom.xml | 16 ++ .../concurrency/manageablethread/MyTask.java | 57 +++++++ .../manageablethread/TestJNDIServlet.java | 142 ++++++++++++++++++ .../TestResourceNoNameServlet.java | 135 +++++++++++++++++ .../manageablethread/TestResourceServlet.java | 136 +++++++++++++++++ .../src/main/webapp/index.jsp | 59 ++++++++ 7 files changed, 563 insertions(+) create mode 100644 concurrency/manageablethread/nb-configuration.xml create mode 100644 concurrency/manageablethread/pom.xml create mode 100644 concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/MyTask.java create mode 100644 concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestJNDIServlet.java create mode 100644 concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceNoNameServlet.java create mode 100644 concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceServlet.java create mode 100644 concurrency/manageablethread/src/main/webapp/index.jsp diff --git a/concurrency/manageablethread/nb-configuration.xml b/concurrency/manageablethread/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/concurrency/manageablethread/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/concurrency/manageablethread/pom.xml b/concurrency/manageablethread/pom.xml new file mode 100644 index 000000000..d9552c7b6 --- /dev/null +++ b/concurrency/manageablethread/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + + org.javaee7.concurrency + concurrency-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.concurrency + manageablethread + 1.0-SNAPSHOT + war + manageablethread + diff --git a/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/MyTask.java b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/MyTask.java new file mode 100644 index 000000000..7ea2b878b --- /dev/null +++ b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/MyTask.java @@ -0,0 +1,57 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.manageablethread; + +/** + * @author Arun Gupta + */ +public class MyTask implements Runnable { + + private int id; + + public MyTask(int id) { + this.id = id; + } + + @Override + public void run() { + System.out.println("Running Task: " + id); + } +} diff --git a/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestJNDIServlet.java b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestJNDIServlet.java new file mode 100644 index 000000000..ee0c209a6 --- /dev/null +++ b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestJNDIServlet.java @@ -0,0 +1,142 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.manageablethread; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.enterprise.concurrent.ManagedThreadFactory; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestJNDIServlet"}) +public class TestJNDIServlet extends HttpServlet { + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet TestJNDIServlet"); + out.println(""); + out.println(""); + out.println("

    Getting ManagedThreadFactory using JNDI lookup

    "); + try { + InitialContext ctx = new InitialContext(); + + ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/DefaultManagedThreadFactory"); +// ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("concurrent/myExecutor"); + out.println("Getting ManageableThread
    "); + Thread thread = factory.newThread(new MyTask(2)); + out.println("Starting thread
    "); + thread.start(); + out.println("Thread started

    "); + } catch (NamingException ex) { + Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex); + } + out.println("all tasks submitted

    "); + out.println("Check server.log for output from the task."); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceNoNameServlet.java b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceNoNameServlet.java new file mode 100644 index 000000000..09ceb81b2 --- /dev/null +++ b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceNoNameServlet.java @@ -0,0 +1,135 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.manageablethread; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedThreadFactory; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestResourceNoNameServlet"}) +public class TestResourceNoNameServlet extends HttpServlet { + + @Resource + ManagedThreadFactory factory; + + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println("Getting ManagedThreadFactory using @Resource with no name"); + out.println(""); + out.println(""); + out.println("

    Getting ManagedThreadFactory using @Resource with no name

    "); + + out.println("Getting ManageableThread
    "); + Thread thread = factory.newThread(new MyTask(1)); + out.println("Starting thread
    "); + thread.start(); + out.println("Thread started

    "); + out.println("Check server.log for output from the task."); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceServlet.java b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceServlet.java new file mode 100644 index 000000000..83c3329c3 --- /dev/null +++ b/concurrency/manageablethread/src/main/java/org/javaee7/concurrency/manageablethread/TestResourceServlet.java @@ -0,0 +1,136 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.concurrency.manageablethread; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.annotation.Resource; +import javax.enterprise.concurrent.ManagedThreadFactory; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestResourceServlet"}) +public class TestResourceServlet extends HttpServlet { + +// @Resource(name = "concurrent/myFactory") + @Resource(name = "DefaultManagedThreadFactory") + ManagedThreadFactory factory; + + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println("Servlet TestServlet"); + out.println(""); + out.println(""); + out.println("

    Getting ManagedThreadFactory using @Resource

    "); + + out.println("Getting ManageableThread
    "); + Thread thread = factory.newThread(new MyTask(1)); + out.println("Starting thread
    "); + thread.start(); + out.println("Thread started

    "); + out.println("Check server.log for output from the task."); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/concurrency/manageablethread/src/main/webapp/index.jsp b/concurrency/manageablethread/src/main/webapp/index.jsp new file mode 100644 index 000000000..62be6c265 --- /dev/null +++ b/concurrency/manageablethread/src/main/webapp/index.jsp @@ -0,0 +1,59 @@ + + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Concurrency Utilities for Java EE : ManageableThread and ManagedThreadFactory + + +

    Concurrency Utilities for Java EE : ManageableThread and ManagedThreadFactory

    + + Create a new ManagebleThread and run (using @Resource)
    + Create a new ManagebleThread and run (using @Resource, with no name)
    + Create a new ManagebleThread and run (using JNDI)
    + + From 58f1848ca1d58805949780247a55bbf03eb95c2e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sat, 14 Sep 2013 20:46:49 -0700 Subject: [PATCH 0096/1080] Changing to scheduleAtFixedRate --- .../ScheduleFixedRateServlet.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java index 73fe6f921..4c0bf71f3 100644 --- a/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java +++ b/concurrency/managedscheduledexecutor/src/main/java/org/javaee7/concurrency/managedscheduledexecutor/ScheduleFixedRateServlet.java @@ -41,6 +41,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; import javax.enterprise.concurrent.ManagedScheduledExecutorService; @@ -81,15 +82,15 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println("

    Schedule at fixed rate

    "); -// ScheduledFuture f = executor.scheduleAtFixedRate(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); -// try { -// Thread.sleep(1000); -// } catch (InterruptedException ex) { -// Logger.getLogger(TestScheduleFixedRateServlet.class.getName()).log(Level.SEVERE, null, ex); -// } -// f.cancel(true); - - executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); + ScheduledFuture f = executor.scheduleAtFixedRate(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); +//// try { +//// Thread.sleep(1000); +//// } catch (InterruptedException ex) { +//// Logger.getLogger(TestScheduleFixedRateServlet.class.getName()).log(Level.SEVERE, null, ex); +//// } +//// f.cancel(true); +// +// executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); System.out.println("Runnable Task completed"); out.println("

    Check server.log for output"); out.println(""); From 7534080a602ef1b1bbcb13e17becfa467ff68181 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sat, 14 Sep 2013 20:46:57 -0700 Subject: [PATCH 0097/1080] FIxing the module names --- concurrency/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/concurrency/pom.xml b/concurrency/pom.xml index e1dd765f8..fd2c32e12 100644 --- a/concurrency/pom.xml +++ b/concurrency/pom.xml @@ -16,10 +16,10 @@ Java EE 7 Concurrency Samples + managedexecutor + managedscheduledexecutor + manageablethread dynamicproxy - executor - schedule - threads From 91214142628b072b31e253d04c0844b190f75abc Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:51:10 -0700 Subject: [PATCH 0098/1080] Fixed the module name --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b1af2bfcf..3f48238cf 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ servlet validation websocket - extras + extra From e6ca20be6873011ba0fab24d01f61afb0a2f1e9c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:51:49 -0700 Subject: [PATCH 0099/1080] Removing stale module --- concurrency/schedule/pom.xml | 15 -- .../concurrency/schedule/MyCallableTask.java | 71 -------- .../concurrency/schedule/MyRunnableTask.java | 57 ------- .../concurrency/schedule/MyTrigger.java | 61 ------- .../javaee7/concurrency/schedule/Product.java | 62 ------- .../TestScheduleFixedRateServlet.java | 140 --------------- .../schedule/TestScheduleServlet.java | 160 ------------------ .../TestScheduleWithFixedDelayServlet.java | 134 --------------- .../schedule/TestTriggerServlet.java | 133 --------------- .../schedule/src/main/webapp/index.jsp | 59 ------- concurrency/threads/nb-configuration.xml | 18 -- concurrency/threads/pom.xml | 15 -- .../javaee7/concurrency/threads/MyTask.java | 57 ------- .../concurrency/threads/TestJNDIServlet.java | 142 ---------------- .../threads/TestResourceServlet.java | 136 --------------- concurrency/threads/src/main/webapp/index.jsp | 58 ------- 16 files changed, 1318 deletions(-) delete mode 100644 concurrency/schedule/pom.xml delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyCallableTask.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyRunnableTask.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyTrigger.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/Product.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleFixedRateServlet.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleServlet.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleWithFixedDelayServlet.java delete mode 100644 concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestTriggerServlet.java delete mode 100644 concurrency/schedule/src/main/webapp/index.jsp delete mode 100644 concurrency/threads/nb-configuration.xml delete mode 100644 concurrency/threads/pom.xml delete mode 100644 concurrency/threads/src/main/java/org/javaee7/concurrency/threads/MyTask.java delete mode 100644 concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestJNDIServlet.java delete mode 100644 concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestResourceServlet.java delete mode 100644 concurrency/threads/src/main/webapp/index.jsp diff --git a/concurrency/schedule/pom.xml b/concurrency/schedule/pom.xml deleted file mode 100644 index 865d4751c..000000000 --- a/concurrency/schedule/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - 4.0.0 - - org.javaee7.concurrency - concurrency-samples - 1.0-SNAPSHOT - ../pom.xml - - - org.javaee7.concurrency - schedule - 1.0-SNAPSHOT - war - diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyCallableTask.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyCallableTask.java deleted file mode 100644 index e345ab9fd..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyCallableTask.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.util.concurrent.Callable; - -/** - * @author Arun Gupta - */ -public class MyCallableTask implements Callable { - - private int id; - - public MyCallableTask() { - } - - public MyCallableTask(int id) { - this.id = id; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - public Product call() { - System.out.println("Running Callable Task: " + id); - return new Product(id); - } -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyRunnableTask.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyRunnableTask.java deleted file mode 100644 index f40048331..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyRunnableTask.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -/** - * @author Arun Gupta - */ -public class MyRunnableTask implements Runnable { - - private int id; - - public MyRunnableTask(int id) { - this.id = id; - } - - @Override - public void run() { - System.out.println("Running Runnable Task: " + id); - } -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyTrigger.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyTrigger.java deleted file mode 100644 index 272fefe45..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/MyTrigger.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.util.Date; -import javax.enterprise.concurrent.LastExecution; -import javax.enterprise.concurrent.Trigger; - -/** - * @author Arun Gupta - */ -public class MyTrigger implements Trigger { - - @Override - public Date getNextRunTime(LastExecution le, Date date) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public boolean skipRun(LastExecution le, Date date) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/Product.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/Product.java deleted file mode 100644 index b5b50f0eb..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/Product.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -/** - * @author Arun Gupta - */ -public class Product { - private int id; - - public Product() { - } - - public Product(int id) { - this.id = id; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleFixedRateServlet.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleFixedRateServlet.java deleted file mode 100644 index 9d02416b3..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleFixedRateServlet.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.concurrent.TimeUnit; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedScheduledExecutorService; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestScheduleFixedRateServlet"}) -public class TestScheduleFixedRateServlet extends HttpServlet { - -// @Resource(name = "concurrent/myScheduledExecutor2") - @Resource(name = "DefaultManagedScheduledExecutorService") - ManagedScheduledExecutorService executor; - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Schedule at fixed rate"); - out.println(""); - out.println(""); - out.println("

    Schedule at fixed rate

    "); -// ScheduledFuture f = executor.scheduleAtFixedRate(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); -// try { -// Thread.sleep(1000); -// } catch (InterruptedException ex) { -// Logger.getLogger(TestScheduleFixedRateServlet.class.getName()).log(Level.SEVERE, null, ex); -// } -// f.cancel(true); - - executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); - System.out.println("Runnable Task completed"); - out.println("

    Check server.log for output"); - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleServlet.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleServlet.java deleted file mode 100644 index a2da94b29..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleServlet.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedScheduledExecutorService; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author arungup - */ -@WebServlet(urlPatterns = {"/TestScheduleServlet"}) -public class TestScheduleServlet extends HttpServlet { - -// @Resource(name = "concurrent/myScheduledExecutor2") - @Resource(name = "DefaultManagedScheduledExecutorService") - ManagedScheduledExecutorService executor; - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Schedule using Callable after 5 seconds"); - out.println(""); - out.println(""); - out.println("

    Schedule using Callable after 5 seconds

    "); - out.println("

    Scheduling tasks using Callable

    "); - ScheduledFuture future = executor.schedule(new MyCallableTask(5), 5, TimeUnit.SECONDS); - while (true) { - if (future.isDone()) { - break; - } else { - System.out.println("Checking Callable Future, waiting for 1 sec"); - Thread.sleep(1000); - } - } - out.println("Callable Task completed: " + future.get().getId()); - - out.println("

    Scheduling tasks using Runnable

    "); - ScheduledFuture f = executor.schedule(new MyRunnableTask(10), 5, TimeUnit.SECONDS); - while (true) { - if (f.isDone()) { - break; - } else { - System.out.println("Checking Runnable Future, waiting for 1 sec"); - Thread.sleep(1000); - } - } - out.println("Runnable Task completed: " + future.get().getId()); - out.println("

    Check server.log for output"); - out.println(""); - out.println(""); - } catch (InterruptedException | ExecutionException ex) { - Logger.getLogger(TestScheduleServlet.class.getName()).log(Level.SEVERE, null, ex); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleWithFixedDelayServlet.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleWithFixedDelayServlet.java deleted file mode 100644 index aeb13b966..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestScheduleWithFixedDelayServlet.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.concurrent.TimeUnit; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedScheduledExecutorService; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestScheduleWithFixedDelayServlet"}) -public class TestScheduleWithFixedDelayServlet extends HttpServlet { - -// @Resource(name = "concurrent/myScheduledExecutor2") - @Resource(name = "DefaultManagedScheduledExecutorService") - ManagedScheduledExecutorService executor; - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Schedule with fixed delay"); - out.println(""); - out.println(""); - out.println("

    Schedule tasks with fixed delay

    "); - - executor.scheduleWithFixedDelay(new MyRunnableTask(5), 2, 3, TimeUnit.SECONDS); - out.println("

    Check server.log for output"); - System.out.println("Runnable Task submitted"); - - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestTriggerServlet.java b/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestTriggerServlet.java deleted file mode 100644 index 3a034f763..000000000 --- a/concurrency/schedule/src/main/java/org/javaee7/concurrency/schedule/TestTriggerServlet.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.schedule; - -import java.io.IOException; -import java.io.PrintWriter; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedScheduledExecutorService; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestTriggerServlet"}) -public class TestTriggerServlet extends HttpServlet { - -// @Resource(name = "concurrent/myScheduledExecutor2") - @Resource(name = "DefaultManagedScheduledExecutorService") - ManagedScheduledExecutorService executor; - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Servlet TestServlet"); - out.println(""); - out.println(""); - out.println("

    Schedule tasks with a trigger

    "); - for (int i=0; i<5; i++) { - executor.schedule(new MyRunnableTask(i), new MyTrigger()); - } - out.println("

    Check server.log for output"); - - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/concurrency/schedule/src/main/webapp/index.jsp b/concurrency/schedule/src/main/webapp/index.jsp deleted file mode 100644 index 6ef9da3bf..000000000 --- a/concurrency/schedule/src/main/webapp/index.jsp +++ /dev/null @@ -1,59 +0,0 @@ - - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - Concurrency Utilities for Java EE - - -

    Concurrency Utilities for Java EE : ManagedExecutor

    - - Schedule using Callable after 5 seconds
    - Schedule at fixed rate
    - Schedule with fixed delay
    - - diff --git a/concurrency/threads/nb-configuration.xml b/concurrency/threads/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/concurrency/threads/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/concurrency/threads/pom.xml b/concurrency/threads/pom.xml deleted file mode 100644 index 7f0ac285c..000000000 --- a/concurrency/threads/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - 4.0.0 - - org.javaee7.concurrency - concurrency-samples - 1.0-SNAPSHOT - ../pom.xml - - - org.javaee7.concurrency - threads - 1.0-SNAPSHOT - war - diff --git a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/MyTask.java b/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/MyTask.java deleted file mode 100644 index c09f6ca3b..000000000 --- a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/MyTask.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.threads; - -/** - * @author Arun Gupta - */ -public class MyTask implements Runnable { - - private int id; - - public MyTask(int id) { - this.id = id; - } - - @Override - public void run() { - System.out.println("Running Task: " + id); - } -} diff --git a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestJNDIServlet.java b/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestJNDIServlet.java deleted file mode 100644 index bbfd991fb..000000000 --- a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestJNDIServlet.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.threads; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.enterprise.concurrent.ManagedThreadFactory; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestJNDIServlet"}) -public class TestJNDIServlet extends HttpServlet { - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Servlet TestJNDIServlet"); - out.println(""); - out.println(""); - out.println("

    Getting ManagedThreadFactory using JNDI lookup

    "); - try { - InitialContext ctx = new InitialContext(); - - ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/DefaultManagedThreadFactory"); -// ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("concurrent/myExecutor"); - out.println("Getting ManageableThread
    "); - Thread thread = factory.newThread(new MyTask(2)); - out.println("Starting thread
    "); - thread.start(); - out.println("Thread started

    "); - } catch (NamingException ex) { - Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex); - } - out.println("all tasks submitted

    "); - out.println("Check server.log for output from the task."); - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestResourceServlet.java b/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestResourceServlet.java deleted file mode 100644 index 9dccfd4d9..000000000 --- a/concurrency/threads/src/main/java/org/javaee7/concurrency/threads/TestResourceServlet.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.concurrency.threads; - -import java.io.IOException; -import java.io.PrintWriter; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedThreadFactory; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestResourceServlet"}) -public class TestResourceServlet extends HttpServlet { - -// @Resource(name = "concurrent/myFactory") - @Resource(name = "DefaultManagedThreadFactory") - ManagedThreadFactory factory; - - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println("Servlet TestServlet"); - out.println(""); - out.println(""); - out.println("

    Getting ManagedThreadFactory using @Resource

    "); - - out.println("Getting ManageableThread
    "); - Thread thread = factory.newThread(new MyTask(1)); - out.println("Starting thread
    "); - thread.start(); - out.println("Thread started

    "); - out.println("Check server.log for output from the task."); - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// - -} diff --git a/concurrency/threads/src/main/webapp/index.jsp b/concurrency/threads/src/main/webapp/index.jsp deleted file mode 100644 index 1f32ad35f..000000000 --- a/concurrency/threads/src/main/webapp/index.jsp +++ /dev/null @@ -1,58 +0,0 @@ - - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - Concurrency Utilities for Java EE : ManagedThreadFactory - - -

    Concurrency Utilities for Java EE : ManagedThreadFactory

    - - Create a new ManagebleThread and run (using @Resource)
    - Create a new ManagebleThread and run (using JNDI)
    - - From f9276a6f70f88b820e5bd896a2ed61f06e27a5e0 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:53:16 -0700 Subject: [PATCH 0100/1080] Changing to all style beans.xml --- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++++++++++++-- 2 files changed, 96 insertions(+), 8 deletions(-) diff --git a/jta/tx-exception/src/main/webapp/WEB-INF/beans.xml b/jta/tx-exception/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jta/tx-exception/src/main/webapp/WEB-INF/beans.xml +++ b/jta/tx-exception/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file diff --git a/jta/user-transaction/src/main/webapp/WEB-INF/beans.xml b/jta/user-transaction/src/main/webapp/WEB-INF/beans.xml index 4ca8195be..aa81c7c3c 100644 --- a/jta/user-transaction/src/main/webapp/WEB-INF/beans.xml +++ b/jta/user-transaction/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,49 @@ - - + + + \ No newline at end of file From 4529f40baa2fbff16a9f38f1b2629335e1cd1b3d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:54:36 -0700 Subject: [PATCH 0101/1080] Adding NetBeans confgiguration file --- jpa/schema-gen/nb-configuration.xml | 18 ++++++++++++++++++ jpa/storedprocedure/nb-configuration.xml | 18 ++++++++++++++++++ websocket/binary/nb-configuration.xml | 18 ++++++++++++++++++ websocket/encoder/nb-configuration.xml | 18 ++++++++++++++++++ .../nb-configuration.xml | 18 ++++++++++++++++++ websocket/injection/nb-configuration.xml | 18 ++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 jpa/schema-gen/nb-configuration.xml create mode 100644 jpa/storedprocedure/nb-configuration.xml create mode 100644 websocket/binary/nb-configuration.xml create mode 100644 websocket/encoder/nb-configuration.xml create mode 100644 websocket/endpoint-programmatic-async/nb-configuration.xml create mode 100644 websocket/injection/nb-configuration.xml diff --git a/jpa/schema-gen/nb-configuration.xml b/jpa/schema-gen/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/jpa/schema-gen/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/jpa/storedprocedure/nb-configuration.xml b/jpa/storedprocedure/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/jpa/storedprocedure/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/websocket/binary/nb-configuration.xml b/websocket/binary/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/binary/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/websocket/encoder/nb-configuration.xml b/websocket/encoder/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/encoder/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/websocket/endpoint-programmatic-async/nb-configuration.xml b/websocket/endpoint-programmatic-async/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/endpoint-programmatic-async/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + diff --git a/websocket/injection/nb-configuration.xml b/websocket/injection/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/injection/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + From 21ecf7db2340ae965828a806ce9420a0df48050a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:55:18 -0700 Subject: [PATCH 0102/1080] Adding NetBeans configuration file --- .../endpoint-security/nb-configuration.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 websocket/endpoint-security/nb-configuration.xml diff --git a/websocket/endpoint-security/nb-configuration.xml b/websocket/endpoint-security/nb-configuration.xml new file mode 100644 index 000000000..e38c5dc5a --- /dev/null +++ b/websocket/endpoint-security/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + gfv3ee6 + + From 6d9bbf9f441dbe73d8b051bb68eedaca905b987f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 08:55:51 -0700 Subject: [PATCH 0103/1080] Adding .gitignore --- .gitignore | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7c0e5a651 --- /dev/null +++ b/.gitignore @@ -0,0 +1,120 @@ +/jaxrs/resource-validation/target/ +/jaxrs/mapping-exceptions/target/ +/jaxrs/server-negotiation/target/ +/jaxrs/async-client/target/ +/batch/flow/target/ +/batch/batchlet-simple/target/ +/batch/chunk-checkpoint/target/ +/batch/chunk-exception/target/ +/batch/chunk-mapper/target/ +/batch/decision/target/ +/batch/listeners/target/ +/batch/multiple-steps/target/ +/batch/split/target/ +/batch/chunk-simple-nobeans/target/ +/json/object-builder/target/ +/json/object-reader/target/ +/json/streaming-generate/target/ +/json/streaming-parser/target/ +/websocket/binary/target/ +/websocket/whiteboard/target/ +/cdi/vetoed/target/ +/cdi/pkg-level/target/ +/cdi/decorators/target/ +/cdi/bean-discovery-all/target/ +/cdi/bean-discovery-none/target/ +/cdi/bean-discovery-annotated/target/ +/cdi/exclude-filter/target/ +/cdi/built-in/target/ +/cdi/interceptors/target/ +/cdi/nobeans-xml/target/ +/cdi/beansxml-noversion/target/ +/cdi/beanmanager/target/ +/concurrency/dynamicproxy/target/ +/concurrency/executor/target/ +/concurrency/schedule/target/ +/concurrency/threads/target/ +/websocket/chat/target/ +/websocket/encoder/target/ +/websocket/encoder-client/target/ +/websocket/encoder-programmatic/target/ +/websocket/endpoint/target/ +/websocket/endpoint-async/target/ +/jaxrs/endpoint/target/ +/jaxrs/client/target/ +/jsf/server-extension/target/ +/jaxrs/jaxrs-endpoint/target/ +/jaxrs/jaxrs-client/target/ +/jsf/http-get/target/ +/websocket/endpoint-javatypes/target/ +/websocket/endpoint-config/target/ +/websocket/endpoint-programmatic/target/ +/websocket/endpoint-programmatic-async/target/ +/websocket/endpoint-programmatic-config/target/ +/websocket/endpoint-programmatic-injection/target/ +/websocket/endpoint-security/target/ +/websocket/httpsession/target/ +/websocket/injection/target/ +/websocket/messagesize/target/ +/websocket/parameters/target/ +/websocket/websocket-vs-rest/target/ +/websocket/subprotocol/target/ +/websocket/websocket-client/target/ +/websocket/websocket-client-config/target/ +/websocket/websocket-client-programmatic/target/ +/websocket/websocket-client-programmatic-config/target/ +/websocket/websocket-client-programmatic-encoders/target/ +/websocket/javase-client/target/ +/ejb/stateful/target/ +/jpa/pu-typesafe/target/ +/jpa/criteria/target/ +/jta/transactional/target/ +/jta/transaction-scope/target/ +/jta/tx-exception/target/ +/ejb/stateless/target/ +/servlet/cookies/target/ +/jpa/schema-gen-scripts/target/ +/jta/user-transaction/target/ +/ejb/singleton/target/ +/ejb/lifecycle/singleton/target/ +/servlet/async-servlet/target/ +/jms/send-receive-simple/target/ +/jms/send-receive/target/ +/servlet/error-mapping/target/ +/servlet/event-listeners/target/ +/servlet/metadata-complete/target/ +/servlet/nonblocking/target/ +/servlet/resource-packaging/target/ +/servlet/servlet-filters/target/ +/servlet/web-fragment/target/ +/servlet/servlet-security/target/ +/jsf/flows-simple/target/ +/jsf/flows-mixed/target/ +/jaxrs/client-negotiation/target/ +/jpa/schema-gen-scripts-generate/target/ +/jaxrs/readerwriter-injection/target/ +/jsf/flows-programmatic/target/ +/jsf/flows-declarative/target/ +/javamail/definition/target/ +/jta/transactional-scope/target/ +/cdi/extension-impl/target/ +/cdi/extension/target/ +/batch/chunk-csv-database/target/ +/batch/chunk-optional-processor/target/ +/batch/chunk-partition/target/ +/jpa/listeners/target/ +/jpa/multiple-pu/target/ +/json/twitter-search/target/ +/jsf/radio-buttons/target/ +/jsf/viewscoped/target/ +/ejb/lifecycle/target/ +/jpa/schema-gen/target/ +/jpa/storedprocedure/target/ +/jsf/contracts/target/ +/jsf/contracts-library/target/ +/jsf/file-upload/target/ +/extra/quartz/target/ +/extra/twitter-search/target/ +/concurrency/managedexecutor/target/ +/concurrency/managedscheduledexecutor/target/ +/concurrency/manageablethread/target/ \ No newline at end of file From a03b017d6c00d37187849560fd7ac3236f8b5430 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 09:15:36 -0700 Subject: [PATCH 0104/1080] Added some more explanation on how to run the samples --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dcd706f1..d4cf064a2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,32 @@ Java EE 7 Samples ================= -This workspace will provide different Java EE 7 Samples. +This workspace consists of Java EE 7 Samples. They are divided in different directories, one for each JSR. + +How to run ? +============ +How I run the samples ? +----------------------- + +1. Open the sample in NetBeans 7.4 beta+ +2. Click on "Run" (sample is built and deployed, main page shows up) +3. Main page tells what the feature is about and what to do to execute the sample and see the output + +Alternative way +--------------- +1. mvn clean package +2. asadmin deploy target/XXX.war +3. Access http://localhost:8080/XXX/ (main page shows up) +4. Same as 3 in the previous one + +TBD +--- + +1. Configure GlassFish Embedded to run the samples automatically +2. Configure Cargo to run the samples + +List of Samples +=============== The following script will generate the complete list of samples. From add599926e15062b01f92c39f694fa835fa98725 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 15 Sep 2013 09:17:42 -0700 Subject: [PATCH 0105/1080] Formatting updated --- README.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d4cf064a2..971f8b2db 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,27 @@ -Java EE 7 Samples -================= +# Java EE 7 Samples # This workspace consists of Java EE 7 Samples. They are divided in different directories, one for each JSR. -How to run ? -============ -How I run the samples ? ------------------------ +## How to run ? ## + +### How I run them ? ### 1. Open the sample in NetBeans 7.4 beta+ 2. Click on "Run" (sample is built and deployed, main page shows up) 3. Main page tells what the feature is about and what to do to execute the sample and see the output -Alternative way ---------------- +### Alternative way ### 1. mvn clean package 2. asadmin deploy target/XXX.war 3. Access http://localhost:8080/XXX/ (main page shows up) 4. Same as 3 in the previous one -TBD ---- +### TBD ### 1. Configure GlassFish Embedded to run the samples automatically 2. Configure Cargo to run the samples -List of Samples -=============== +## List of Samples ## The following script will generate the complete list of samples. From 6c7d1f16715fb565833c2a34cac9a6d03eb15193 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 15:30:48 -0700 Subject: [PATCH 0106/1080] Added Cargo instructions --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 971f8b2db..9aedf3dbf 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,27 @@ This workspace consists of Java EE 7 Samples. They are divided in different dire 1. Open the sample in NetBeans 7.4 beta+ 2. Click on "Run" (sample is built and deployed, main page shows up) -3. Main page tells what the feature is about and what to do to execute the sample and see the output +3. Main page provides feature name, what to do to run the sample, and displays the output -### Alternative way ### -1. mvn clean package -2. asadmin deploy target/XXX.war +### Cargo ### + +1. In one terminal, anywhere in the project with a pom.xml: "mvn cargo:run" to start GlassFish server +2. In another terminal, in the actual sample directory + 1. ``mvn package cargo:deploy`` to deploy for the first time + 2. ``mvn package cargo:redeploy`` to redeploy (or use this all the time) + 3. ``mvn cargo:undeploy`` to undeploy +3. Check for application name printed by Cargo output. Access the application at http://localhost:8080/ +4. Same as 3 in the first one + +### Manual ### +1. ``mvn clean package`` +2. ``asadmin deploy target/XXX.war`` to deploy the WAR file 3. Access http://localhost:8080/XXX/ (main page shows up) -4. Same as 3 in the previous one +4. Same as 3 in the first one ### TBD ### 1. Configure GlassFish Embedded to run the samples automatically -2. Configure Cargo to run the samples ## List of Samples ## From e1c339b362a21a24ffcbae2122483659cee765e5 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 15:31:24 -0700 Subject: [PATCH 0107/1080] Added Cargo plugin --- pom.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pom.xml b/pom.xml index 3f48238cf..ae6370b80 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,8 @@ Java EE 7 Samples + glassfish4x + /Users/arungup/tools/glassfish/4.0/final/glassfish4 gfv3ee6 @@ -40,6 +42,23 @@ false + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.4 + true + + + ${cargo.container.id} + installed + ${glassfish.home} + + + standalone + ${glassfish.home}/glassfish/domains + + + From a9c3ede20cf8f0f5bc7a3c897bcebf07557ad69f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 15:32:35 -0700 Subject: [PATCH 0108/1080] Added a statement about glassfish.home --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9aedf3dbf..0944c3358 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This workspace consists of Java EE 7 Samples. They are divided in different dire ### Cargo ### +Make sure to edit ``glassfish.home`` property value in the top-level pom.xml. + 1. In one terminal, anywhere in the project with a pom.xml: "mvn cargo:run" to start GlassFish server 2. In another terminal, in the actual sample directory 1. ``mvn package cargo:deploy`` to deploy for the first time From 9444acfb19cb1ff14357ae8f4639b70648d941d4 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:15:58 -0700 Subject: [PATCH 0109/1080] Adding profiles to run on GlassFish and Wildfly --- pom.xml | 76 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index ae6370b80..1b9a69ef5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,9 +9,10 @@ Java EE 7 Samples - glassfish4x + glassfish4x /Users/arungup/tools/glassfish/4.0/final/glassfish4 - gfv3ee6 + wildfly8x + /Users/arungup/tools/wildfly/wildfly-8.0.0.Alpha4 @@ -42,25 +43,62 @@ false - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.4 - true - - - ${cargo.container.id} - installed - ${glassfish.home} - - - standalone - ${glassfish.home}/glassfish/domains - - - + + + + glassfish + + true + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.4 + true + + + ${cargo.container.glassfish.id} + installed + ${glassfish.home} + + + standalone + ${glassfish.home}/glassfish/domains + + + + + + + + wildfly + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.4 + true + + + ${cargo.container.wildfly.id} + installed + ${wildfly.home} + + + standalone + ${wildfly.home}/glassfish/domains + + + + + + + batch From c59e267a3ae76267fb7e77a28294ad40554dc86f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:16:16 -0700 Subject: [PATCH 0110/1080] Adding instructions on how to run on GlassFish and Wildfly --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0944c3358..cef96f457 100644 --- a/README.md +++ b/README.md @@ -6,32 +6,31 @@ This workspace consists of Java EE 7 Samples. They are divided in different dire ### How I run them ? ### -1. Open the sample in NetBeans 7.4 beta+ -2. Click on "Run" (sample is built and deployed, main page shows up) -3. Main page provides feature name, what to do to run the sample, and displays the output +1. Open the sample in NetBeans 7.4 beta+ (Download from [http://bits.netbeans.org/dev/nightly/latest/]) +2. Click on "Run" (sample is built and deployed on GlassFish 4, main page shows up) +3. Main page provides feature name, how to run the sample, and displays the output ### Cargo ### -Make sure to edit ``glassfish.home`` property value in the top-level pom.xml. +By default, all samples are deployed on GlassFish 4. They can be deployed on Widlfly 8 by adding ``-P wildfly`` to all maven commands. + +Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the top-level pom.xml to point to your local GlassFish or Wildfly installations respectively. 1. In one terminal, anywhere in the project with a pom.xml: "mvn cargo:run" to start GlassFish server 2. In another terminal, in the actual sample directory 1. ``mvn package cargo:deploy`` to deploy for the first time - 2. ``mvn package cargo:redeploy`` to redeploy (or use this all the time) + 2. ``mvn package cargo:redeploy`` to redeploy subsequently 3. ``mvn cargo:undeploy`` to undeploy 3. Check for application name printed by Cargo output. Access the application at http://localhost:8080/ 4. Same as 3 in the first one ### Manual ### + 1. ``mvn clean package`` 2. ``asadmin deploy target/XXX.war`` to deploy the WAR file 3. Access http://localhost:8080/XXX/ (main page shows up) 4. Same as 3 in the first one -### TBD ### - -1. Configure GlassFish Embedded to run the samples automatically - ## List of Samples ## The following script will generate the complete list of samples. From f08fc4e2b73a2e7ef2f5b417f9121272dda16d64 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:21:55 -0700 Subject: [PATCH 0111/1080] Cleaned up some instructions --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cef96f457..e477feb95 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,9 @@ This workspace consists of Java EE 7 Samples. They are divided in different dire ### Cargo ### -By default, all samples are deployed on GlassFish 4. They can be deployed on Widlfly 8 by adding ``-P wildfly`` to all maven commands. +By default, all samples are deployed on GlassFish 4. They can be deployed on Widlfly 8 by adding ``-P wildfly`` to all maven commands. Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the top-level ``pom.xml`` to point to your local GlassFish or Wildfly directory respectively. -Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the top-level pom.xml to point to your local GlassFish or Wildfly installations respectively. - -1. In one terminal, anywhere in the project with a pom.xml: "mvn cargo:run" to start GlassFish server +1. In one terminal, anywhere in the project with a ``pom.xml``: ``mvn cargo:run`` to start GlassFish server or ``mvn -P wildfly`` to start Wildfly server. They are both configured to run on port 8080 so only one can run at a given time. 2. In another terminal, in the actual sample directory 1. ``mvn package cargo:deploy`` to deploy for the first time 2. ``mvn package cargo:redeploy`` to redeploy subsequently @@ -27,7 +25,7 @@ Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the t ### Manual ### 1. ``mvn clean package`` -2. ``asadmin deploy target/XXX.war`` to deploy the WAR file +2. Deploy on GlassFish using ``asadmin deploy target/XXX.war`` or deploy on Wildfly using ``TBD`` 3. Access http://localhost:8080/XXX/ (main page shows up) 4. Same as 3 in the first one From cf801e67d25ce96bf42aebb46727f74aeba18067 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:24:24 -0700 Subject: [PATCH 0112/1080] Adding more clarifications --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e477feb95..fd2e2e5ad 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # Java EE 7 Samples # -This workspace consists of Java EE 7 Samples. They are divided in different directories, one for each JSR. +This workspace consists of Java EE 7 Samples. They are categorized in different directories, one for each JSR. ## How to run ? ## ### How I run them ? ### -1. Open the sample in NetBeans 7.4 beta+ (Download from [http://bits.netbeans.org/dev/nightly/latest/]) +1. Open the sample in NetBeans 7.4 beta+ (Download from http://bits.netbeans.org/dev/nightly/latest) 2. Click on "Run" (sample is built and deployed on GlassFish 4, main page shows up) 3. Main page provides feature name, how to run the sample, and displays the output ### Cargo ### -By default, all samples are deployed on GlassFish 4. They can be deployed on Widlfly 8 by adding ``-P wildfly`` to all maven commands. Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the top-level ``pom.xml`` to point to your local GlassFish or Wildfly directory respectively. +By default, all samples are deployed on GlassFish 4. They can be deployed on Widlfly 8 by adding ``-P wildfly`` to all maven commands. Make sure to edit ``glassfish.home`` or ``wildfly.home`` property value in the top-level ``pom.xml`` to point to your local GlassFish or Wildfly directory respectively. Only one profile can be active at a given time otherwise there will be port conflicts. -1. In one terminal, anywhere in the project with a ``pom.xml``: ``mvn cargo:run`` to start GlassFish server or ``mvn -P wildfly`` to start Wildfly server. They are both configured to run on port 8080 so only one can run at a given time. +1. In one terminal, anywhere in the project with a ``pom.xml``: ``mvn cargo:run`` to start GlassFish server or ``mvn -P wildfly`` to start Wildfly server. 2. In another terminal, in the actual sample directory 1. ``mvn package cargo:deploy`` to deploy for the first time 2. ``mvn package cargo:redeploy`` to redeploy subsequently From d29f9d1179d4188d9f5c07dc51fa4ff28326ab05 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:25:58 -0700 Subject: [PATCH 0113/1080] Removed sample lists, it can be dynamically generated --- README.md | 159 +----------------------------------------------------- 1 file changed, 2 insertions(+), 157 deletions(-) diff --git a/README.md b/README.md index fd2e2e5ad..52f7ac37a 100644 --- a/README.md +++ b/README.md @@ -35,162 +35,7 @@ The following script will generate the complete list of samples. find . -name pom.xml -depth 3 -maxdepth 3 | sed 's|\./||g' | sed 's|\/pom.xml||g' +There are 161 samples as of 9/16. + I don't plan to write any formal documentation, let the code talk. [Java EE 7 Essentials](http://www.amazon.com/Java-EE-Essentials-Arun-Gupta/dp/1449370179/) refer to some of these samples and provide an extensive explanation. -+ batch/batchlet-simple -+ batch/chunk-checkpoint -+ batch/chunk-csv-database -+ batch/chunk-csv-database.clean -+ batch/chunk-exception -+ batch/chunk-mapper -+ batch/chunk-optional-processor -+ batch/chunk-partition -+ batch/chunk-simple -+ batch/chunk-simple-nobeans -+ batch/decision -+ batch/flow -+ batch/listeners -+ batch/multiple-steps -+ batch/split -+ cdi/bean-discovery-all -+ cdi/bean-discovery-annotated -+ cdi/bean-discovery-none -+ cdi/beanmanager -+ cdi/beansxml-noversion -+ cdi/built-in -+ cdi/decorators -+ cdi/exclude-filter -+ cdi/interceptors -+ cdi/nobeans-xml -+ cdi/pkg-level -+ cdi/vetoed -+ concurrency/dynamicproxy -+ concurrency/executor -+ concurrency/schedule -+ concurrency/threads -+ ejb/embeddable -+ ejb/lifecycle -+ ejb/singleton -+ ejb/stateful -+ ejb/stateless -+ ejb/timer -+ el/standalone -+ javamail/definition -+ jaxrs/async-client -+ jaxrs/async-server -+ jaxrs/beanvalidation -+ jaxrs/client-negotiation -+ jaxrs/dynamicfilter -+ jaxrs/filter -+ jaxrs/filter-interceptor -+ jaxrs/interceptor -+ jaxrs/invocation -+ jaxrs/invocation-async -+ jaxrs/jaxrs-client -+ jaxrs/jaxrs-endpoint -+ jaxrs/jsonp -+ jaxrs/link -+ jaxrs/mapping-exceptions -+ jaxrs/moxy -+ jaxrs/readerwriter -+ jaxrs/readerwriter-json -+ jaxrs/request-binding -+ jaxrs/resource-validation -+ jaxrs/server-negotiation -+ jaxrs/server-sent-event -+ jaxrs/singleton-annotation -+ jaxrs/singleton-application -+ jaxrs/singleton-application.old -+ jca/connector-simple -+ jms/jmscontext-cdi -+ jms/send-receive -+ jms/send-receive-simple -+ jms/temp-destination -+ jpa/criteria -+ jpa/entitygraph -+ jpa/jndi-context -+ jpa/listeners -+ jpa/locking-optimistic -+ jpa/locking-pessimistic -+ jpa/multiple-pu -+ jpa/native-sql -+ jpa/native-sql-resultset-mapping -+ jpa/pu-typesafe -+ jpa/schema-gen -+ jpa/schema-gen-scripts -+ jpa/schema-gen-scripts-external -+ jpa/schema-gen-scripts-generate -+ jpa/storedprocedure -+ jsf/ajax -+ jsf/bean-validation -+ jsf/components -+ jsf/composite-component -+ jsf/contracts -+ jsf/contracts-library -+ jsf/contracts-library-impl -+ jsf/file-upload -+ jsf/flows-declarative -+ jsf/flows-mixed -+ jsf/flows-programmatic -+ jsf/flows-simple -+ jsf/http-get -+ jsf/passthrough -+ jsf/radio-buttons -+ jsf/resource-handling -+ jsf/server-extension -+ jsf/simple-facelet -+ jsf/viewscoped -+ json/object-builder -+ json/object-reader -+ json/streaming-generate -+ json/streaming-parser -+ json/twitter-search -+ jta/transaction-scope -+ jta/transactional -+ jta/tx-exception -+ jta/user-transaction -+ servlet/async-servlet -+ servlet/cookies -+ servlet/error-mapping -+ servlet/event-listeners -+ servlet/file-upload -+ servlet/form-based-security -+ servlet/metadata-complete -+ servlet/nonblocking -+ servlet/protocol-handler -+ servlet/resource-packaging -+ servlet/servlet-filters -+ servlet/servlet-security -+ servlet/web-fragment -+ validation/custom-constraint -+ validation/methods -+ websocket/binary -+ websocket/chat -+ websocket/encoder -+ websocket/encoder-client -+ websocket/encoder-programmatic -+ websocket/endpoint -+ websocket/endpoint-async -+ websocket/endpoint-config -+ websocket/endpoint-javatypes -+ websocket/endpoint-partial -+ websocket/endpoint-programmatic -+ websocket/endpoint-programmatic-async -+ websocket/endpoint-programmatic-config -+ websocket/endpoint-programmatic-injection -+ websocket/endpoint-programmatic-partial -+ websocket/endpoint-security -+ websocket/httpsession -+ websocket/injection -+ websocket/javase-client -+ websocket/messagesize -+ websocket/parameters -+ websocket/properties -+ websocket/subprotocol -+ websocket/websocket-client -+ websocket/websocket-client-config -+ websocket/websocket-client-programmatic -+ websocket/websocket-client-programmatic-config -+ websocket/websocket-client-programmatic-encoders -+ websocket/websocket-vs-rest -+ websocket/whiteboard From 42cd4184e0f94192c442e1136b7f609a993d8014 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:33:16 -0700 Subject: [PATCH 0114/1080] Formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52f7ac37a..0f034de08 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ By default, all samples are deployed on GlassFish 4. They can be deployed on Wid The following script will generate the complete list of samples. -find . -name pom.xml -depth 3 -maxdepth 3 | sed 's|\./||g' | sed 's|\/pom.xml||g' +``find . -name pom.xml -depth 3 -maxdepth 3 | sed 's|\./||g' | sed 's|\/pom.xml||g'`` There are 161 samples as of 9/16. From a7211266857308dfdda90f5b852c5c3a35869612 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:41:19 -0700 Subject: [PATCH 0115/1080] Improving output messages, adding copyrights and @author --- .../batch/batchlet/simple/TestServlet.java | 2 +- .../batch/chunk/checkpoint/TestServlet.java | 2 +- .../batch/chunk/csv/database/TestServlet.java | 2 +- .../batch/chunk/exception/TestServlet.java | 2 +- .../sample/chunk/mapper/TestServlet.java | 2 +- .../chunk/optional/processor/TestServlet.java | 43 +++++++++++++++++-- .../sample/chunk/partition/TestServlet.java | 2 +- .../chunk/simple/nobeans/TestServlet.java | 6 +-- .../javaee7/batch/listeners/TestServlet.java | 2 +- .../org/javaee7/batch/split/TestServlet.java | 6 +-- 10 files changed, 52 insertions(+), 17 deletions(-) diff --git a/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java b/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java index 18e6e1ff4..f1d474b1b 100644 --- a/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java +++ b/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java @@ -84,7 +84,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println("Got the job operator: " + jo + "
    "); jo.start("myJob", new Properties()); out.println("Job submitted
    "); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException ex) { diff --git a/batch/chunk-checkpoint/src/main/java/org/javaee7/batch/chunk/checkpoint/TestServlet.java b/batch/chunk-checkpoint/src/main/java/org/javaee7/batch/chunk/checkpoint/TestServlet.java index ef104148b..568b108f2 100644 --- a/batch/chunk-checkpoint/src/main/java/org/javaee7/batch/chunk/checkpoint/TestServlet.java +++ b/batch/chunk-checkpoint/src/main/java/org/javaee7/batch/chunk/checkpoint/TestServlet.java @@ -89,7 +89,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("Job submitted
    "); - out.println("Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException ex) { diff --git a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java index 3299a1ada..f66898eed 100644 --- a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java +++ b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java @@ -87,7 +87,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re JobOperator jo = BatchRuntime.getJobOperator(); long jid = jo.start("myJob", new Properties()); out.println("Job submitted: " + jid + "
    "); - out.println("Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/chunk-exception/src/main/java/org/javaee7/batch/chunk/exception/TestServlet.java b/batch/chunk-exception/src/main/java/org/javaee7/batch/chunk/exception/TestServlet.java index 84f9addea..b2f077c06 100644 --- a/batch/chunk-exception/src/main/java/org/javaee7/batch/chunk/exception/TestServlet.java +++ b/batch/chunk-exception/src/main/java/org/javaee7/batch/chunk/exception/TestServlet.java @@ -89,7 +89,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("Job submitted"); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException ex) { diff --git a/batch/chunk-mapper/src/main/java/org/javaee7/batch/sample/chunk/mapper/TestServlet.java b/batch/chunk-mapper/src/main/java/org/javaee7/batch/sample/chunk/mapper/TestServlet.java index 3bb6e4ad7..3699d8e6b 100644 --- a/batch/chunk-mapper/src/main/java/org/javaee7/batch/sample/chunk/mapper/TestServlet.java +++ b/batch/chunk-mapper/src/main/java/org/javaee7/batch/sample/chunk/mapper/TestServlet.java @@ -95,7 +95,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (String j : jo.getJobNames()) { out.println("--> " + j + "
    "); } - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/chunk-optional-processor/src/main/java/org/javaee7/batch/chunk/optional/processor/TestServlet.java b/batch/chunk-optional-processor/src/main/java/org/javaee7/batch/chunk/optional/processor/TestServlet.java index 60f1c462e..a9a0e17aa 100644 --- a/batch/chunk-optional-processor/src/main/java/org/javaee7/batch/chunk/optional/processor/TestServlet.java +++ b/batch/chunk-optional-processor/src/main/java/org/javaee7/batch/chunk/optional/processor/TestServlet.java @@ -1,6 +1,41 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. */ package org.javaee7.batch.chunk.optional.processor; @@ -20,8 +55,7 @@ import javax.servlet.http.HttpServletResponse; /** - * - * @author arungup + * @author Arun Gupta */ @WebServlet(urlPatterns = {"/TestServlet"}) public class TestServlet extends HttpServlet { @@ -55,6 +89,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("Job submitted
    "); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException ex) { diff --git a/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java b/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java index 989fa34ac..0a6d2b2d8 100644 --- a/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java +++ b/batch/chunk-partition/src/main/java/org/javaee7/batch/sample/chunk/partition/TestServlet.java @@ -95,7 +95,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (String j : jo.getJobNames()) { out.println("--> " + j + "
    "); } - out.println("

    Check \"server.log\" for out"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/chunk-simple-nobeans/src/main/java/org/javaee7/batch/samples/chunk/simple/nobeans/TestServlet.java b/batch/chunk-simple-nobeans/src/main/java/org/javaee7/batch/samples/chunk/simple/nobeans/TestServlet.java index 5b3650ef8..29ec54c08 100644 --- a/batch/chunk-simple-nobeans/src/main/java/org/javaee7/batch/samples/chunk/simple/nobeans/TestServlet.java +++ b/batch/chunk-simple-nobeans/src/main/java/org/javaee7/batch/samples/chunk/simple/nobeans/TestServlet.java @@ -77,10 +77,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Batch - No beans.xml, default injection of beans"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Batch - No beans.xml, default injection of beans

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); @@ -95,7 +95,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (String j : jo.getJobNames()) { out.println("--> " + j + "
    "); } - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/listeners/src/main/java/org/javaee7/batch/listeners/TestServlet.java b/batch/listeners/src/main/java/org/javaee7/batch/listeners/TestServlet.java index fe3c04e97..921b31e9a 100644 --- a/batch/listeners/src/main/java/org/javaee7/batch/listeners/TestServlet.java +++ b/batch/listeners/src/main/java/org/javaee7/batch/listeners/TestServlet.java @@ -90,7 +90,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex); } out.println("Job submitted
    "); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException ex) { diff --git a/batch/split/src/main/java/org/javaee7/batch/split/TestServlet.java b/batch/split/src/main/java/org/javaee7/batch/split/TestServlet.java index 94e062c94..c47b60b5d 100644 --- a/batch/split/src/main/java/org/javaee7/batch/split/TestServlet.java +++ b/batch/split/src/main/java/org/javaee7/batch/split/TestServlet.java @@ -76,17 +76,17 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Batch Split"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Batch Split

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); long jid = jo.start("myJob", new Properties()); out.println("Job submitted: " + jid + "
    "); out.println(jo.getJobInstanceCount("myJob") + " job instance found
    "); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { From 400200c5b4b499c525eae4612411bfb789553873 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 16 Sep 2013 16:46:57 -0700 Subject: [PATCH 0116/1080] Forgot to include some files - Improving output messages, adding copyrights and @author --- .../java/org/javaee7/batch/chunk/simple/TestServlet.java | 2 +- .../main/java/org/javaee7/batch/decision/TestServlet.java | 6 +++--- .../src/main/java/org/javaee7/batch/flow/TestServlet.java | 4 ++-- .../java/org/javaee7/batch/multiple/steps/TestServlet.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/batch/chunk-simple/src/main/java/org/javaee7/batch/chunk/simple/TestServlet.java b/batch/chunk-simple/src/main/java/org/javaee7/batch/chunk/simple/TestServlet.java index c3ae6230c..66b28bb7c 100644 --- a/batch/chunk-simple/src/main/java/org/javaee7/batch/chunk/simple/TestServlet.java +++ b/batch/chunk-simple/src/main/java/org/javaee7/batch/chunk/simple/TestServlet.java @@ -95,7 +95,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re for (String j : jo.getJobNames()) { out.println("--> " + j + "
    "); } - out.println("

    Check server.log for output."); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/decision/src/main/java/org/javaee7/batch/decision/TestServlet.java b/batch/decision/src/main/java/org/javaee7/batch/decision/TestServlet.java index ca117a2fe..57903af31 100644 --- a/batch/decision/src/main/java/org/javaee7/batch/decision/TestServlet.java +++ b/batch/decision/src/main/java/org/javaee7/batch/decision/TestServlet.java @@ -76,16 +76,16 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Batch Decision"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Batch Decision

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); jo.start("myJob", new Properties()); out.println("Job submitted
    "); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { diff --git a/batch/flow/src/main/java/org/javaee7/batch/flow/TestServlet.java b/batch/flow/src/main/java/org/javaee7/batch/flow/TestServlet.java index 153462358..e18f4741c 100644 --- a/batch/flow/src/main/java/org/javaee7/batch/flow/TestServlet.java +++ b/batch/flow/src/main/java/org/javaee7/batch/flow/TestServlet.java @@ -76,10 +76,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Batch Flow"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Batch Flow

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); diff --git a/batch/multiple-steps/src/main/java/org/javaee7/batch/multiple/steps/TestServlet.java b/batch/multiple-steps/src/main/java/org/javaee7/batch/multiple/steps/TestServlet.java index c3a495044..b1b78bec7 100644 --- a/batch/multiple-steps/src/main/java/org/javaee7/batch/multiple/steps/TestServlet.java +++ b/batch/multiple-steps/src/main/java/org/javaee7/batch/multiple/steps/TestServlet.java @@ -76,17 +76,17 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Batch Multiple Steps"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Batch Multiple Steps

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); long jid = jo.start("myJob", new Properties()); out.println("Job submitted: " + jid + "
    "); out.println(jo.getJobInstanceCount("myJob") + " job instance found
    "); - out.println("

    Check server.log for output"); + out.println("

    Check server.log for output, also look at \"myJob.xml\" for Job XML."); out.println(""); out.println(""); } catch (JobStartException | JobSecurityException ex) { From ff950e62f3ea3c40588ecca444ee57421a4d9236 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 12:53:18 -0700 Subject: [PATCH 0117/1080] Cleaning up titles --- batch/batchlet-simple/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/batchlet-simple/src/main/webapp/index.jsp b/batch/batchlet-simple/src/main/webapp/index.jsp index e341b6611..a5e50da94 100644 --- a/batch/batchlet-simple/src/main/webapp/index.jsp +++ b/batch/batchlet-simple/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - Batch - Simple Batchlet! + Batch - Simple Batchlet -

    Batch - Simple Batchlet!

    +

    Batch - Simple Batchlet

    Start the job. From c77ae3373d8d22411c8d3234caa8d26248228cd6 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 12:54:02 -0700 Subject: [PATCH 0118/1080] Cleaning up output messages --- .../java/org/javaee7/batch/batchlet/simple/TestServlet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java b/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java index f1d474b1b..45947a212 100644 --- a/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java +++ b/batch/batchlet-simple/src/main/java/org/javaee7/batch/batchlet/simple/TestServlet.java @@ -75,10 +75,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("Starting a Batchlet"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    Starting a Batchlet

    "); out.println("About to start the job
    "); JobOperator jo = BatchRuntime.getJobOperator(); out.println("Got the job operator: " + jo + "
    "); From 959b80600c538a16c85ab9691ef0055281634064 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 12:58:39 -0700 Subject: [PATCH 0119/1080] Cleaning up titles --- batch/chunk-checkpoint/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/chunk-checkpoint/src/main/webapp/index.jsp b/batch/chunk-checkpoint/src/main/webapp/index.jsp index bd988f900..262bd8592 100644 --- a/batch/chunk-checkpoint/src/main/webapp/index.jsp +++ b/batch/chunk-checkpoint/src/main/webapp/index.jsp @@ -46,10 +46,10 @@ - Batch - Custom Checkpoint! + Batch - Custom Checkpoint -

    Batch - Custom Checkpoint!

    +

    Batch - Custom Checkpoint

    Start the job. From 013eb6375191abbe0332f95ecaa71c76ce13f8e0 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 12:59:28 -0700 Subject: [PATCH 0120/1080] Removing NetBeans configuration files --- batch/batchlet-simple/nb-configuration.xml | 18 ------------------ batch/chunk-checkpoint/nb-configuration.xml | 18 ------------------ 2 files changed, 36 deletions(-) delete mode 100644 batch/batchlet-simple/nb-configuration.xml delete mode 100644 batch/chunk-checkpoint/nb-configuration.xml diff --git a/batch/batchlet-simple/nb-configuration.xml b/batch/batchlet-simple/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/batchlet-simple/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-checkpoint/nb-configuration.xml b/batch/chunk-checkpoint/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-checkpoint/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - From 09f0d4b5ced436e39d515b18f8de2cccd370a52e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 13:00:03 -0700 Subject: [PATCH 0121/1080] Adding NetBeans deployment hints --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 1b9a69ef5..ec4011670 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ /Users/arungup/tools/glassfish/4.0/final/glassfish4 wildfly8x /Users/arungup/tools/wildfly/wildfly-8.0.0.Alpha4 + gfv3ee6
    From 9f6c7a54be9aefffcd09deffdcfabbaf4ff3f8c1 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 13:01:16 -0700 Subject: [PATCH 0122/1080] Removing NetBeans configuration file --- cdi/bean-discovery-all/nb-configuration.xml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 cdi/bean-discovery-all/nb-configuration.xml diff --git a/cdi/bean-discovery-all/nb-configuration.xml b/cdi/bean-discovery-all/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/bean-discovery-all/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - From 199fb310942863fc8c6f7f0c71e709499b50097c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 13:03:00 -0700 Subject: [PATCH 0123/1080] Cleaning up output messages --- .../main/java/org/javaee7/cdi/interceptors/TestServlet.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cdi/interceptors/src/main/java/org/javaee7/cdi/interceptors/TestServlet.java b/cdi/interceptors/src/main/java/org/javaee7/cdi/interceptors/TestServlet.java index 9ca240eaf..8f2d08ced 100644 --- a/cdi/interceptors/src/main/java/org/javaee7/cdi/interceptors/TestServlet.java +++ b/cdi/interceptors/src/main/java/org/javaee7/cdi/interceptors/TestServlet.java @@ -73,12 +73,12 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re out.println(""); out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("CDI Interceptors"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    CDI Interceptors

    "); out.println(greeting.greet("Duke")); - out.println("

    Look for output in server.log"); + out.println("

    Look for output in \"server.log\"."); out.println(""); out.println(""); } From c811ff93db0f3ecdb6c43539968ec8c95dfec1d3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 13:05:19 -0700 Subject: [PATCH 0124/1080] Removing NetBeans configuration file --- .gitignore | 3 ++- batch/chunk-csv-database/nb-configuration.xml | 18 ----------------- batch/chunk-exception/nb-configuration.xml | 18 ----------------- batch/chunk-mapper/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- batch/chunk-partition/nb-configuration.xml | 18 ----------------- .../chunk-simple-nobeans/nb-configuration.xml | 18 ----------------- batch/decision/nb-configuration.xml | 18 ----------------- batch/flow/nb-configuration.xml | 18 ----------------- batch/multiple-steps/nb-configuration.xml | 18 ----------------- batch/split/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- cdi/bean-discovery-none/nb-configuration.xml | 18 ----------------- cdi/beanmanager/nb-configuration.xml | 19 ------------------ cdi/beansxml-noversion/nb-configuration.xml | 18 ----------------- cdi/built-in/nb-configuration.xml | 18 ----------------- cdi/decorators/nb-configuration.xml | 18 ----------------- cdi/exclude-filter/nb-configuration.xml | 18 ----------------- cdi/extension-impl/nb-configuration.xml | 18 ----------------- cdi/extension/nb-configuration.xml | 18 ----------------- cdi/interceptors/nb-configuration.xml | 18 ----------------- cdi/nobeans-xml/nb-configuration.xml | 18 ----------------- cdi/pkg-level/nb-configuration.xml | 18 ----------------- cdi/vetoed/nb-configuration.xml | 18 ----------------- concurrency/dynamicproxy/nb-configuration.xml | 18 ----------------- .../manageablethread/nb-configuration.xml | 18 ----------------- .../managedexecutor/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- ejb/lifecycle/nb-configuration.xml | 18 ----------------- ejb/singleton/nb-configuration.xml | 18 ----------------- ejb/stateful/nb-configuration.xml | 18 ----------------- ejb/stateless/nb-configuration.xml | 18 ----------------- ejb/timer/nb-configuration.xml | 18 ----------------- el/standalone/nb-configuration.xml | 18 ----------------- extra/quartz/nb-configuration.xml | 18 ----------------- javamail/definition/nb-configuration.xml | 18 ----------------- jaxrs/async-client/nb-configuration.xml | 19 ------------------ jaxrs/async-server/nb-configuration.xml | 19 ------------------ jaxrs/beanvalidation/nb-configuration.xml | 19 ------------------ jaxrs/client-negotiation/nb-configuration.xml | 19 ------------------ jaxrs/dynamicfilter/nb-configuration.xml | 19 ------------------ jaxrs/filter-interceptor/nb-configuration.xml | 19 ------------------ jaxrs/filter/nb-configuration.xml | 19 ------------------ jaxrs/interceptor/nb-configuration.xml | 19 ------------------ jaxrs/invocation-async/nb-configuration.xml | 18 ----------------- jaxrs/invocation/nb-configuration.xml | 19 ------------------ jaxrs/jaxrs-client/nb-configuration.xml | 19 ------------------ jaxrs/jaxrs-endpoint/nb-configuration.xml | 19 ------------------ jaxrs/jsonp/nb-configuration.xml | 19 ------------------ jaxrs/link/nb-configuration.xml | 18 ----------------- jaxrs/mapping-exceptions/nb-configuration.xml | 19 ------------------ jaxrs/moxy/nb-configuration.xml | 19 ------------------ .../nb-configuration.xml | 19 ------------------ jaxrs/readerwriter-json/nb-configuration.xml | 19 ------------------ jaxrs/readerwriter/nb-configuration.xml | 19 ------------------ jaxrs/request-binding/nb-configuration.xml | 19 ------------------ .../resource-validation/nb-configuration.xml | 19 ------------------ jaxrs/server-negotiation/nb-configuration.xml | 19 ------------------ jaxrs/server-sent-event/nb-configuration.xml | 19 ------------------ .../singleton-annotation/nb-configuration.xml | 20 ------------------- .../nb-configuration.xml | 20 ------------------- .../nb-configuration.xml | 20 ------------------- jms/jmscontext-cdi/nb-configuration.xml | 18 ----------------- jms/send-receive-simple/nb-configuration.xml | 18 ----------------- jms/send-receive/nb-configuration.xml | 18 ----------------- jpa/criteria/nb-configuration.xml | 18 ----------------- jpa/entitygraph/nb-configuration.xml | 18 ----------------- jpa/listeners/nb-configuration.xml | 18 ----------------- jpa/locking-optimistic/nb-configuration.xml | 18 ----------------- jpa/locking-pessimistic/nb-configuration.xml | 18 ----------------- jpa/multiple-pu/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- jpa/native-sql/nb-configuration.xml | 18 ----------------- jpa/pu-typesafe/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- jpa/schema-gen-scripts/nb-configuration.xml | 18 ----------------- jpa/schema-gen/nb-configuration.xml | 18 ----------------- jpa/storedprocedure/nb-configuration.xml | 18 ----------------- jsf/ajax/nb-configuration.xml | 18 ----------------- jsf/bean-validation/nb-configuration.xml | 18 ----------------- jsf/components/nb-configuration.xml | 18 ----------------- jsf/composite-component/nb-configuration.xml | 18 ----------------- jsf/contracts-library/nb-configuration.xml | 18 ----------------- jsf/file-upload/nb-configuration.xml | 18 ----------------- jsf/flows-declarative/nb-configuration.xml | 18 ----------------- jsf/flows-programmatic/nb-configuration.xml | 18 ----------------- jsf/flows-simple/nb-configuration.xml | 18 ----------------- jsf/http-get/nb-configuration.xml | 18 ----------------- jsf/passthrough/nb-configuration.xml | 18 ----------------- jsf/radio-buttons/nb-configuration.xml | 18 ----------------- jsf/resource-handling/nb-configuration.xml | 19 ------------------ jsf/server-extension/nb-configuration.xml | 18 ----------------- jsf/simple-facelet/nb-configuration.xml | 19 ------------------ jsf/viewscoped/nb-configuration.xml | 18 ----------------- json/object-builder/nb-configuration.xml | 18 ----------------- json/object-reader/nb-configuration.xml | 18 ----------------- json/streaming-generate/nb-configuration.xml | 18 ----------------- json/streaming-parser/nb-configuration.xml | 18 ----------------- jta/transaction-scope/nb-configuration.xml | 18 ----------------- jta/transactional/nb-configuration.xml | 18 ----------------- jta/tx-exception/nb-configuration.xml | 18 ----------------- jta/user-transaction/nb-configuration.xml | 18 ----------------- servlet/async-servlet/nb-configuration.xml | 18 ----------------- servlet/cookies/nb-configuration.xml | 18 ----------------- servlet/error-mapping/nb-configuration.xml | 18 ----------------- servlet/event-listeners/nb-configuration.xml | 18 ----------------- servlet/file-upload/nb-configuration.xml | 18 ----------------- .../form-based-security/nb-configuration.xml | 18 ----------------- .../metadata-complete/nb-configuration.xml | 18 ----------------- servlet/nonblocking/nb-configuration.xml | 18 ----------------- servlet/protocol-handler/nb-configuration.xml | 18 ----------------- .../resource-packaging/nb-configuration.xml | 18 ----------------- servlet/servlet-filters/nb-configuration.xml | 18 ----------------- servlet/servlet-security/nb-configuration.xml | 18 ----------------- servlet/web-fragment/nb-configuration.xml | 18 ----------------- .../custom-constraint/nb-configuration.xml | 19 ------------------ validation/methods/nb-configuration.xml | 18 ----------------- websocket/binary/nb-configuration.xml | 18 ----------------- websocket/chat/nb-configuration.xml | 18 ----------------- websocket/encoder-client/nb-configuration.xml | 18 ----------------- .../encoder-programmatic/nb-configuration.xml | 18 ----------------- websocket/encoder/nb-configuration.xml | 18 ----------------- websocket/endpoint-async/nb-configuration.xml | 18 ----------------- .../endpoint-config/nb-configuration.xml | 18 ----------------- .../endpoint-javatypes/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 19 ------------------ .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../endpoint-security/nb-configuration.xml | 18 ----------------- .../endpoint-singleton/nb-configuration.xml | 18 ----------------- websocket/endpoint/nb-configuration.xml | 18 ----------------- websocket/httpsession/nb-configuration.xml | 18 ----------------- websocket/injection/nb-configuration.xml | 18 ----------------- websocket/messagesize/nb-configuration.xml | 18 ----------------- websocket/parameters/nb-configuration.xml | 18 ----------------- websocket/properties/nb-configuration.xml | 18 ----------------- websocket/subprotocol/nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../nb-configuration.xml | 18 ----------------- .../websocket-client/nb-configuration.xml | 18 ----------------- .../websocket-vs-rest/nb-configuration.xml | 19 ------------------ websocket/whiteboard/nb-configuration.xml | 18 ----------------- 146 files changed, 2 insertions(+), 2644 deletions(-) delete mode 100644 batch/chunk-csv-database/nb-configuration.xml delete mode 100644 batch/chunk-exception/nb-configuration.xml delete mode 100644 batch/chunk-mapper/nb-configuration.xml delete mode 100644 batch/chunk-optional-processor/nb-configuration.xml delete mode 100644 batch/chunk-partition/nb-configuration.xml delete mode 100644 batch/chunk-simple-nobeans/nb-configuration.xml delete mode 100644 batch/decision/nb-configuration.xml delete mode 100644 batch/flow/nb-configuration.xml delete mode 100644 batch/multiple-steps/nb-configuration.xml delete mode 100644 batch/split/nb-configuration.xml delete mode 100644 cdi/bean-discovery-annotated/nb-configuration.xml delete mode 100644 cdi/bean-discovery-none/nb-configuration.xml delete mode 100644 cdi/beanmanager/nb-configuration.xml delete mode 100644 cdi/beansxml-noversion/nb-configuration.xml delete mode 100644 cdi/built-in/nb-configuration.xml delete mode 100644 cdi/decorators/nb-configuration.xml delete mode 100644 cdi/exclude-filter/nb-configuration.xml delete mode 100644 cdi/extension-impl/nb-configuration.xml delete mode 100644 cdi/extension/nb-configuration.xml delete mode 100644 cdi/interceptors/nb-configuration.xml delete mode 100644 cdi/nobeans-xml/nb-configuration.xml delete mode 100644 cdi/pkg-level/nb-configuration.xml delete mode 100644 cdi/vetoed/nb-configuration.xml delete mode 100644 concurrency/dynamicproxy/nb-configuration.xml delete mode 100644 concurrency/manageablethread/nb-configuration.xml delete mode 100644 concurrency/managedexecutor/nb-configuration.xml delete mode 100644 concurrency/managedscheduledexecutor/nb-configuration.xml delete mode 100644 ejb/lifecycle/nb-configuration.xml delete mode 100644 ejb/singleton/nb-configuration.xml delete mode 100644 ejb/stateful/nb-configuration.xml delete mode 100644 ejb/stateless/nb-configuration.xml delete mode 100644 ejb/timer/nb-configuration.xml delete mode 100644 el/standalone/nb-configuration.xml delete mode 100644 extra/quartz/nb-configuration.xml delete mode 100644 javamail/definition/nb-configuration.xml delete mode 100644 jaxrs/async-client/nb-configuration.xml delete mode 100644 jaxrs/async-server/nb-configuration.xml delete mode 100644 jaxrs/beanvalidation/nb-configuration.xml delete mode 100644 jaxrs/client-negotiation/nb-configuration.xml delete mode 100644 jaxrs/dynamicfilter/nb-configuration.xml delete mode 100644 jaxrs/filter-interceptor/nb-configuration.xml delete mode 100644 jaxrs/filter/nb-configuration.xml delete mode 100644 jaxrs/interceptor/nb-configuration.xml delete mode 100644 jaxrs/invocation-async/nb-configuration.xml delete mode 100644 jaxrs/invocation/nb-configuration.xml delete mode 100644 jaxrs/jaxrs-client/nb-configuration.xml delete mode 100644 jaxrs/jaxrs-endpoint/nb-configuration.xml delete mode 100644 jaxrs/jsonp/nb-configuration.xml delete mode 100644 jaxrs/link/nb-configuration.xml delete mode 100644 jaxrs/mapping-exceptions/nb-configuration.xml delete mode 100644 jaxrs/moxy/nb-configuration.xml delete mode 100644 jaxrs/readerwriter-injection/nb-configuration.xml delete mode 100644 jaxrs/readerwriter-json/nb-configuration.xml delete mode 100644 jaxrs/readerwriter/nb-configuration.xml delete mode 100644 jaxrs/request-binding/nb-configuration.xml delete mode 100644 jaxrs/resource-validation/nb-configuration.xml delete mode 100644 jaxrs/server-negotiation/nb-configuration.xml delete mode 100644 jaxrs/server-sent-event/nb-configuration.xml delete mode 100644 jaxrs/singleton-annotation/nb-configuration.xml delete mode 100644 jaxrs/singleton-application.old/nb-configuration.xml delete mode 100644 jaxrs/singleton-application/nb-configuration.xml delete mode 100644 jms/jmscontext-cdi/nb-configuration.xml delete mode 100644 jms/send-receive-simple/nb-configuration.xml delete mode 100644 jms/send-receive/nb-configuration.xml delete mode 100644 jpa/criteria/nb-configuration.xml delete mode 100644 jpa/entitygraph/nb-configuration.xml delete mode 100644 jpa/listeners/nb-configuration.xml delete mode 100644 jpa/locking-optimistic/nb-configuration.xml delete mode 100644 jpa/locking-pessimistic/nb-configuration.xml delete mode 100644 jpa/multiple-pu/nb-configuration.xml delete mode 100644 jpa/native-sql-resultset-mapping/nb-configuration.xml delete mode 100644 jpa/native-sql/nb-configuration.xml delete mode 100644 jpa/pu-typesafe/nb-configuration.xml delete mode 100644 jpa/schema-gen-scripts-external/nb-configuration.xml delete mode 100644 jpa/schema-gen-scripts-generate/nb-configuration.xml delete mode 100644 jpa/schema-gen-scripts/nb-configuration.xml delete mode 100644 jpa/schema-gen/nb-configuration.xml delete mode 100644 jpa/storedprocedure/nb-configuration.xml delete mode 100644 jsf/ajax/nb-configuration.xml delete mode 100644 jsf/bean-validation/nb-configuration.xml delete mode 100644 jsf/components/nb-configuration.xml delete mode 100644 jsf/composite-component/nb-configuration.xml delete mode 100644 jsf/contracts-library/nb-configuration.xml delete mode 100644 jsf/file-upload/nb-configuration.xml delete mode 100644 jsf/flows-declarative/nb-configuration.xml delete mode 100644 jsf/flows-programmatic/nb-configuration.xml delete mode 100644 jsf/flows-simple/nb-configuration.xml delete mode 100644 jsf/http-get/nb-configuration.xml delete mode 100644 jsf/passthrough/nb-configuration.xml delete mode 100644 jsf/radio-buttons/nb-configuration.xml delete mode 100644 jsf/resource-handling/nb-configuration.xml delete mode 100644 jsf/server-extension/nb-configuration.xml delete mode 100644 jsf/simple-facelet/nb-configuration.xml delete mode 100644 jsf/viewscoped/nb-configuration.xml delete mode 100644 json/object-builder/nb-configuration.xml delete mode 100644 json/object-reader/nb-configuration.xml delete mode 100644 json/streaming-generate/nb-configuration.xml delete mode 100644 json/streaming-parser/nb-configuration.xml delete mode 100644 jta/transaction-scope/nb-configuration.xml delete mode 100644 jta/transactional/nb-configuration.xml delete mode 100644 jta/tx-exception/nb-configuration.xml delete mode 100644 jta/user-transaction/nb-configuration.xml delete mode 100644 servlet/async-servlet/nb-configuration.xml delete mode 100644 servlet/cookies/nb-configuration.xml delete mode 100644 servlet/error-mapping/nb-configuration.xml delete mode 100644 servlet/event-listeners/nb-configuration.xml delete mode 100644 servlet/file-upload/nb-configuration.xml delete mode 100644 servlet/form-based-security/nb-configuration.xml delete mode 100644 servlet/metadata-complete/nb-configuration.xml delete mode 100644 servlet/nonblocking/nb-configuration.xml delete mode 100644 servlet/protocol-handler/nb-configuration.xml delete mode 100644 servlet/resource-packaging/nb-configuration.xml delete mode 100644 servlet/servlet-filters/nb-configuration.xml delete mode 100644 servlet/servlet-security/nb-configuration.xml delete mode 100644 servlet/web-fragment/nb-configuration.xml delete mode 100644 validation/custom-constraint/nb-configuration.xml delete mode 100644 validation/methods/nb-configuration.xml delete mode 100644 websocket/binary/nb-configuration.xml delete mode 100644 websocket/chat/nb-configuration.xml delete mode 100644 websocket/encoder-client/nb-configuration.xml delete mode 100644 websocket/encoder-programmatic/nb-configuration.xml delete mode 100644 websocket/encoder/nb-configuration.xml delete mode 100644 websocket/endpoint-async/nb-configuration.xml delete mode 100644 websocket/endpoint-config/nb-configuration.xml delete mode 100644 websocket/endpoint-javatypes/nb-configuration.xml delete mode 100644 websocket/endpoint-programmatic-async/nb-configuration.xml delete mode 100644 websocket/endpoint-programmatic-config/nb-configuration.xml delete mode 100644 websocket/endpoint-programmatic-injection/nb-configuration.xml delete mode 100644 websocket/endpoint-programmatic/nb-configuration.xml delete mode 100644 websocket/endpoint-security/nb-configuration.xml delete mode 100644 websocket/endpoint-singleton/nb-configuration.xml delete mode 100644 websocket/endpoint/nb-configuration.xml delete mode 100644 websocket/httpsession/nb-configuration.xml delete mode 100644 websocket/injection/nb-configuration.xml delete mode 100644 websocket/messagesize/nb-configuration.xml delete mode 100644 websocket/parameters/nb-configuration.xml delete mode 100644 websocket/properties/nb-configuration.xml delete mode 100644 websocket/subprotocol/nb-configuration.xml delete mode 100644 websocket/websocket-client-config/nb-configuration.xml delete mode 100644 websocket/websocket-client-programmatic-config/nb-configuration.xml delete mode 100644 websocket/websocket-client-programmatic-encoders/nb-configuration.xml delete mode 100644 websocket/websocket-client-programmatic/nb-configuration.xml delete mode 100644 websocket/websocket-client/nb-configuration.xml delete mode 100644 websocket/websocket-vs-rest/nb-configuration.xml delete mode 100644 websocket/whiteboard/nb-configuration.xml diff --git a/.gitignore b/.gitignore index 7c0e5a651..4da7b0943 100644 --- a/.gitignore +++ b/.gitignore @@ -117,4 +117,5 @@ /extra/twitter-search/target/ /concurrency/managedexecutor/target/ /concurrency/managedscheduledexecutor/target/ -/concurrency/manageablethread/target/ \ No newline at end of file +/concurrency/manageablethread/target/ +/batch/chunk-simple/target/ \ No newline at end of file diff --git a/batch/chunk-csv-database/nb-configuration.xml b/batch/chunk-csv-database/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-csv-database/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-exception/nb-configuration.xml b/batch/chunk-exception/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-exception/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-mapper/nb-configuration.xml b/batch/chunk-mapper/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-mapper/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-optional-processor/nb-configuration.xml b/batch/chunk-optional-processor/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-optional-processor/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-partition/nb-configuration.xml b/batch/chunk-partition/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-partition/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/chunk-simple-nobeans/nb-configuration.xml b/batch/chunk-simple-nobeans/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/chunk-simple-nobeans/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/decision/nb-configuration.xml b/batch/decision/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/decision/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/flow/nb-configuration.xml b/batch/flow/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/flow/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/multiple-steps/nb-configuration.xml b/batch/multiple-steps/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/multiple-steps/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/batch/split/nb-configuration.xml b/batch/split/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/batch/split/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/bean-discovery-annotated/nb-configuration.xml b/cdi/bean-discovery-annotated/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/bean-discovery-annotated/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/bean-discovery-none/nb-configuration.xml b/cdi/bean-discovery-none/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/bean-discovery-none/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/beanmanager/nb-configuration.xml b/cdi/beanmanager/nb-configuration.xml deleted file mode 100644 index 2edcd9286..000000000 --- a/cdi/beanmanager/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - 1.6-web - gfv3ee6 - - diff --git a/cdi/beansxml-noversion/nb-configuration.xml b/cdi/beansxml-noversion/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/beansxml-noversion/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/built-in/nb-configuration.xml b/cdi/built-in/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/built-in/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/decorators/nb-configuration.xml b/cdi/decorators/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/decorators/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/exclude-filter/nb-configuration.xml b/cdi/exclude-filter/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/exclude-filter/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/extension-impl/nb-configuration.xml b/cdi/extension-impl/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/extension-impl/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/extension/nb-configuration.xml b/cdi/extension/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/extension/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/interceptors/nb-configuration.xml b/cdi/interceptors/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/interceptors/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/nobeans-xml/nb-configuration.xml b/cdi/nobeans-xml/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/nobeans-xml/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/pkg-level/nb-configuration.xml b/cdi/pkg-level/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/pkg-level/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/cdi/vetoed/nb-configuration.xml b/cdi/vetoed/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/cdi/vetoed/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/concurrency/dynamicproxy/nb-configuration.xml b/concurrency/dynamicproxy/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/concurrency/dynamicproxy/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/concurrency/manageablethread/nb-configuration.xml b/concurrency/manageablethread/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/concurrency/manageablethread/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/concurrency/managedexecutor/nb-configuration.xml b/concurrency/managedexecutor/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/concurrency/managedexecutor/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/concurrency/managedscheduledexecutor/nb-configuration.xml b/concurrency/managedscheduledexecutor/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/concurrency/managedscheduledexecutor/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/ejb/lifecycle/nb-configuration.xml b/ejb/lifecycle/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/ejb/lifecycle/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/ejb/singleton/nb-configuration.xml b/ejb/singleton/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/ejb/singleton/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/ejb/stateful/nb-configuration.xml b/ejb/stateful/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/ejb/stateful/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/ejb/stateless/nb-configuration.xml b/ejb/stateless/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/ejb/stateless/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/ejb/timer/nb-configuration.xml b/ejb/timer/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/ejb/timer/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/el/standalone/nb-configuration.xml b/el/standalone/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/el/standalone/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/extra/quartz/nb-configuration.xml b/extra/quartz/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/extra/quartz/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/javamail/definition/nb-configuration.xml b/javamail/definition/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/javamail/definition/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jaxrs/async-client/nb-configuration.xml b/jaxrs/async-client/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/async-client/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/async-server/nb-configuration.xml b/jaxrs/async-server/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/async-server/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/beanvalidation/nb-configuration.xml b/jaxrs/beanvalidation/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/beanvalidation/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/client-negotiation/nb-configuration.xml b/jaxrs/client-negotiation/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/client-negotiation/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/dynamicfilter/nb-configuration.xml b/jaxrs/dynamicfilter/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/dynamicfilter/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/filter-interceptor/nb-configuration.xml b/jaxrs/filter-interceptor/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/filter-interceptor/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/filter/nb-configuration.xml b/jaxrs/filter/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/filter/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/interceptor/nb-configuration.xml b/jaxrs/interceptor/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/interceptor/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/invocation-async/nb-configuration.xml b/jaxrs/invocation-async/nb-configuration.xml deleted file mode 100644 index 4da1f6c9b..000000000 --- a/jaxrs/invocation-async/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - ide - - diff --git a/jaxrs/invocation/nb-configuration.xml b/jaxrs/invocation/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/invocation/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/jaxrs-client/nb-configuration.xml b/jaxrs/jaxrs-client/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/jaxrs-client/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/jaxrs-endpoint/nb-configuration.xml b/jaxrs/jaxrs-endpoint/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/jaxrs-endpoint/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/jsonp/nb-configuration.xml b/jaxrs/jsonp/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/jsonp/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/link/nb-configuration.xml b/jaxrs/link/nb-configuration.xml deleted file mode 100644 index 4da1f6c9b..000000000 --- a/jaxrs/link/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - ide - - diff --git a/jaxrs/mapping-exceptions/nb-configuration.xml b/jaxrs/mapping-exceptions/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/mapping-exceptions/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/moxy/nb-configuration.xml b/jaxrs/moxy/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/moxy/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/readerwriter-injection/nb-configuration.xml b/jaxrs/readerwriter-injection/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/readerwriter-injection/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/readerwriter-json/nb-configuration.xml b/jaxrs/readerwriter-json/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/readerwriter-json/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/readerwriter/nb-configuration.xml b/jaxrs/readerwriter/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/readerwriter/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/request-binding/nb-configuration.xml b/jaxrs/request-binding/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/request-binding/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/resource-validation/nb-configuration.xml b/jaxrs/resource-validation/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/resource-validation/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/server-negotiation/nb-configuration.xml b/jaxrs/server-negotiation/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/server-negotiation/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/server-sent-event/nb-configuration.xml b/jaxrs/server-sent-event/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/jaxrs/server-sent-event/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/jaxrs/singleton-annotation/nb-configuration.xml b/jaxrs/singleton-annotation/nb-configuration.xml deleted file mode 100644 index 186bd512c..000000000 --- a/jaxrs/singleton-annotation/nb-configuration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - 1.7-web - gfv3ee6 - ide - - diff --git a/jaxrs/singleton-application.old/nb-configuration.xml b/jaxrs/singleton-application.old/nb-configuration.xml deleted file mode 100644 index 186bd512c..000000000 --- a/jaxrs/singleton-application.old/nb-configuration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - 1.7-web - gfv3ee6 - ide - - diff --git a/jaxrs/singleton-application/nb-configuration.xml b/jaxrs/singleton-application/nb-configuration.xml deleted file mode 100644 index 186bd512c..000000000 --- a/jaxrs/singleton-application/nb-configuration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - 1.7-web - gfv3ee6 - ide - - diff --git a/jms/jmscontext-cdi/nb-configuration.xml b/jms/jmscontext-cdi/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jms/jmscontext-cdi/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jms/send-receive-simple/nb-configuration.xml b/jms/send-receive-simple/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jms/send-receive-simple/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jms/send-receive/nb-configuration.xml b/jms/send-receive/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jms/send-receive/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/criteria/nb-configuration.xml b/jpa/criteria/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/criteria/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/entitygraph/nb-configuration.xml b/jpa/entitygraph/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/entitygraph/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/listeners/nb-configuration.xml b/jpa/listeners/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/listeners/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/locking-optimistic/nb-configuration.xml b/jpa/locking-optimistic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/locking-optimistic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/locking-pessimistic/nb-configuration.xml b/jpa/locking-pessimistic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/locking-pessimistic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/multiple-pu/nb-configuration.xml b/jpa/multiple-pu/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/multiple-pu/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/native-sql-resultset-mapping/nb-configuration.xml b/jpa/native-sql-resultset-mapping/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/native-sql-resultset-mapping/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/native-sql/nb-configuration.xml b/jpa/native-sql/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/native-sql/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/pu-typesafe/nb-configuration.xml b/jpa/pu-typesafe/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/pu-typesafe/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/schema-gen-scripts-external/nb-configuration.xml b/jpa/schema-gen-scripts-external/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/schema-gen-scripts-external/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/schema-gen-scripts-generate/nb-configuration.xml b/jpa/schema-gen-scripts-generate/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/schema-gen-scripts-generate/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/schema-gen-scripts/nb-configuration.xml b/jpa/schema-gen-scripts/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/schema-gen-scripts/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/schema-gen/nb-configuration.xml b/jpa/schema-gen/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/schema-gen/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jpa/storedprocedure/nb-configuration.xml b/jpa/storedprocedure/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jpa/storedprocedure/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/ajax/nb-configuration.xml b/jsf/ajax/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/ajax/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/bean-validation/nb-configuration.xml b/jsf/bean-validation/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/bean-validation/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/components/nb-configuration.xml b/jsf/components/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/components/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/composite-component/nb-configuration.xml b/jsf/composite-component/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/composite-component/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/contracts-library/nb-configuration.xml b/jsf/contracts-library/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/contracts-library/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/file-upload/nb-configuration.xml b/jsf/file-upload/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/file-upload/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/flows-declarative/nb-configuration.xml b/jsf/flows-declarative/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/flows-declarative/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/flows-programmatic/nb-configuration.xml b/jsf/flows-programmatic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/flows-programmatic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/flows-simple/nb-configuration.xml b/jsf/flows-simple/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/flows-simple/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/http-get/nb-configuration.xml b/jsf/http-get/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/http-get/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/passthrough/nb-configuration.xml b/jsf/passthrough/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/passthrough/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/radio-buttons/nb-configuration.xml b/jsf/radio-buttons/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/radio-buttons/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/resource-handling/nb-configuration.xml b/jsf/resource-handling/nb-configuration.xml deleted file mode 100644 index acb1fbf63..000000000 --- a/jsf/resource-handling/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - gfv3ee6 - Facelets - - diff --git a/jsf/server-extension/nb-configuration.xml b/jsf/server-extension/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/server-extension/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jsf/simple-facelet/nb-configuration.xml b/jsf/simple-facelet/nb-configuration.xml deleted file mode 100644 index acb1fbf63..000000000 --- a/jsf/simple-facelet/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - gfv3ee6 - Facelets - - diff --git a/jsf/viewscoped/nb-configuration.xml b/jsf/viewscoped/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jsf/viewscoped/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/json/object-builder/nb-configuration.xml b/json/object-builder/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/json/object-builder/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/json/object-reader/nb-configuration.xml b/json/object-reader/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/json/object-reader/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/json/streaming-generate/nb-configuration.xml b/json/streaming-generate/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/json/streaming-generate/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/json/streaming-parser/nb-configuration.xml b/json/streaming-parser/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/json/streaming-parser/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jta/transaction-scope/nb-configuration.xml b/jta/transaction-scope/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jta/transaction-scope/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jta/transactional/nb-configuration.xml b/jta/transactional/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jta/transactional/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jta/tx-exception/nb-configuration.xml b/jta/tx-exception/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jta/tx-exception/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/jta/user-transaction/nb-configuration.xml b/jta/user-transaction/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/jta/user-transaction/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/async-servlet/nb-configuration.xml b/servlet/async-servlet/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/async-servlet/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/cookies/nb-configuration.xml b/servlet/cookies/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/cookies/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/error-mapping/nb-configuration.xml b/servlet/error-mapping/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/error-mapping/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/event-listeners/nb-configuration.xml b/servlet/event-listeners/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/event-listeners/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/file-upload/nb-configuration.xml b/servlet/file-upload/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/file-upload/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/form-based-security/nb-configuration.xml b/servlet/form-based-security/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/form-based-security/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/metadata-complete/nb-configuration.xml b/servlet/metadata-complete/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/metadata-complete/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/nonblocking/nb-configuration.xml b/servlet/nonblocking/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/nonblocking/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/protocol-handler/nb-configuration.xml b/servlet/protocol-handler/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/protocol-handler/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/resource-packaging/nb-configuration.xml b/servlet/resource-packaging/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/resource-packaging/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/servlet-filters/nb-configuration.xml b/servlet/servlet-filters/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/servlet-filters/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/servlet-security/nb-configuration.xml b/servlet/servlet-security/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/servlet-security/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/servlet/web-fragment/nb-configuration.xml b/servlet/web-fragment/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/servlet/web-fragment/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/validation/custom-constraint/nb-configuration.xml b/validation/custom-constraint/nb-configuration.xml deleted file mode 100644 index 7c3067b41..000000000 --- a/validation/custom-constraint/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - 1.7-web - gfv3ee6 - - diff --git a/validation/methods/nb-configuration.xml b/validation/methods/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/validation/methods/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/binary/nb-configuration.xml b/websocket/binary/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/binary/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/chat/nb-configuration.xml b/websocket/chat/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/chat/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/encoder-client/nb-configuration.xml b/websocket/encoder-client/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/encoder-client/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/encoder-programmatic/nb-configuration.xml b/websocket/encoder-programmatic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/encoder-programmatic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/encoder/nb-configuration.xml b/websocket/encoder/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/encoder/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-async/nb-configuration.xml b/websocket/endpoint-async/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-async/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-config/nb-configuration.xml b/websocket/endpoint-config/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-config/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-javatypes/nb-configuration.xml b/websocket/endpoint-javatypes/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-javatypes/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-programmatic-async/nb-configuration.xml b/websocket/endpoint-programmatic-async/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-programmatic-async/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-programmatic-config/nb-configuration.xml b/websocket/endpoint-programmatic-config/nb-configuration.xml deleted file mode 100644 index 7c3067b41..000000000 --- a/websocket/endpoint-programmatic-config/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - 1.7-web - gfv3ee6 - - diff --git a/websocket/endpoint-programmatic-injection/nb-configuration.xml b/websocket/endpoint-programmatic-injection/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-programmatic-injection/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-programmatic/nb-configuration.xml b/websocket/endpoint-programmatic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-programmatic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-security/nb-configuration.xml b/websocket/endpoint-security/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-security/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint-singleton/nb-configuration.xml b/websocket/endpoint-singleton/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint-singleton/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/endpoint/nb-configuration.xml b/websocket/endpoint/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/endpoint/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/httpsession/nb-configuration.xml b/websocket/httpsession/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/httpsession/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/injection/nb-configuration.xml b/websocket/injection/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/injection/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/messagesize/nb-configuration.xml b/websocket/messagesize/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/messagesize/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/parameters/nb-configuration.xml b/websocket/parameters/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/parameters/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/properties/nb-configuration.xml b/websocket/properties/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/properties/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/subprotocol/nb-configuration.xml b/websocket/subprotocol/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/subprotocol/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-client-config/nb-configuration.xml b/websocket/websocket-client-config/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/websocket-client-config/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-client-programmatic-config/nb-configuration.xml b/websocket/websocket-client-programmatic-config/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/websocket-client-programmatic-config/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-client-programmatic-encoders/nb-configuration.xml b/websocket/websocket-client-programmatic-encoders/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/websocket-client-programmatic-encoders/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-client-programmatic/nb-configuration.xml b/websocket/websocket-client-programmatic/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/websocket-client-programmatic/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-client/nb-configuration.xml b/websocket/websocket-client/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/websocket-client/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - diff --git a/websocket/websocket-vs-rest/nb-configuration.xml b/websocket/websocket-vs-rest/nb-configuration.xml deleted file mode 100644 index 38c192ec6..000000000 --- a/websocket/websocket-vs-rest/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - ide - gfv3ee6 - - diff --git a/websocket/whiteboard/nb-configuration.xml b/websocket/whiteboard/nb-configuration.xml deleted file mode 100644 index e38c5dc5a..000000000 --- a/websocket/whiteboard/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - gfv3ee6 - - From e995668906f39416c4b2377490fac08b8a02e61c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 14:55:38 -0700 Subject: [PATCH 0125/1080] Adding links to NetBeans nightly --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f034de08..dcdf59deb 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ This workspace consists of Java EE 7 Samples. They are categorized in different directories, one for each JSR. +I don't plan to write any formal documentation, read the code. [Java EE 7 Essentials](http://www.amazon.com/Java-EE-Essentials-Arun-Gupta/dp/1449370179/) refer to some of these samples and provide an extensive explanation. However if you are interested in adding javadocs, send a pull request. + ## How to run ? ## ### How I run them ? ### -1. Open the sample in NetBeans 7.4 beta+ (Download from http://bits.netbeans.org/dev/nightly/latest) +1. Open the sample in [NetBeans 7.4 nightly](http://bits.netbeans.org/dev/nightly/latest) 2. Click on "Run" (sample is built and deployed on GlassFish 4, main page shows up) 3. Main page provides feature name, how to run the sample, and displays the output @@ -37,5 +39,3 @@ The following script will generate the complete list of samples. There are 161 samples as of 9/16. -I don't plan to write any formal documentation, let the code talk. [Java EE 7 Essentials](http://www.amazon.com/Java-EE-Essentials-Arun-Gupta/dp/1449370179/) refer to some of these samples and provide an extensive explanation. - From fbba4ef1dc09d3e25ef1083a4bdbf54b4a090b36 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 17 Sep 2013 15:00:09 -0700 Subject: [PATCH 0126/1080] slight typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcdf59deb..e22afafeb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This workspace consists of Java EE 7 Samples. They are categorized in different directories, one for each JSR. -I don't plan to write any formal documentation, read the code. [Java EE 7 Essentials](http://www.amazon.com/Java-EE-Essentials-Arun-Gupta/dp/1449370179/) refer to some of these samples and provide an extensive explanation. However if you are interested in adding javadocs, send a pull request. +I don't plan to write any formal documentation, read the code. The [Java EE 7 Essentials](http://www.amazon.com/Java-EE-Essentials-Arun-Gupta/dp/1449370179/) book refer to some of these samples and provide an explanation. However if you are interested in adding javadocs, send a pull request. ## How to run ? ## From 1f5abf4bd4c7442f8a9b6caa90bba43d8102ac27 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 18 Sep 2013 17:24:49 -0700 Subject: [PATCH 0127/1080] Adding Tomcat configuration --- pom.xml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec4011670..e3ab7b1cb 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,8 @@ /Users/arungup/tools/glassfish/4.0/final/glassfish4 wildfly8x /Users/arungup/tools/wildfly/wildfly-8.0.0.Alpha4 + tomcat8x + /Users/arungup/tools/tomcat/apache-tomcat-8.0.0-RC1 gfv3ee6 @@ -92,7 +94,31 @@ standalone - ${wildfly.home}/glassfish/domains + ${wildfly.home} + + + + + + + + tomcat + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.4 + true + + + ${cargo.container.tomcat.id} + installed + ${tomcat.home} + + + standalone + ${tomcat.home}/temp From 9c3df5c04d979925e360c570b5c386f0757fe662 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 08:53:29 -0700 Subject: [PATCH 0128/1080] Removing redundant imports --- .../main/java/org/javaee7/jaxrs/readerwriter/json/MyReader.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyReader.java b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyReader.java index 5b8d1b32e..189fb0f49 100644 --- a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyReader.java +++ b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyReader.java @@ -43,8 +43,6 @@ import java.io.InputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.json.Json; import javax.json.stream.JsonParser; import javax.ws.rs.Consumes; From fcc596b2f03925751217595262e0bd17c680eccf Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 08:54:13 -0700 Subject: [PATCH 0129/1080] Removing redundant attributes from @WebServlet --- .../java/org/javaee7/jaxrs/readerwriter/json/TestServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/TestServlet.java b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/TestServlet.java index 117c32828..f54afda77 100644 --- a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/TestServlet.java +++ b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/TestServlet.java @@ -55,7 +55,7 @@ /** * @author Arun Gupta */ -@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"}) +@WebServlet(urlPatterns = {"/TestServlet"}) public class TestServlet extends HttpServlet { /** From 48c9a3caecbcaf758df9602326bcfd02cfc386be Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 09:12:51 -0700 Subject: [PATCH 0130/1080] Adding @Produces --- .../java/org/javaee7/jaxrs/readerwriter/json/MyResource.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyResource.java b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyResource.java index 139ca1c82..2d95bebd0 100644 --- a/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyResource.java +++ b/jaxrs/readerwriter-json/src/main/java/org/javaee7/jaxrs/readerwriter/json/MyResource.java @@ -42,6 +42,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; /** @@ -50,6 +51,7 @@ @Path("endpoint") public class MyResource { @POST + @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public MyObject echoObject(MyObject mo) { return mo; From e17ac323d0bf2b3cc824dbed598d7553acb00433 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 09:58:53 -0700 Subject: [PATCH 0131/1080] Starting work on a new sample to show CDI scopes --- cdi/scopes/pom.xml | 16 +++ .../cdi/bean/scopes/ClientServlet.java | 126 +++++++++++++++++ .../bean/scopes/MyApplicationScopedBean.java | 52 +++++++ .../cdi/bean/scopes/MyRequestScopedBean.java | 52 +++++++ .../cdi/bean/scopes/MySessionScopedBean.java | 52 +++++++ .../bean/scopes/MySingletonScopedBean.java | 52 +++++++ .../cdi/bean/scopes/ServerServlet.java | 132 ++++++++++++++++++ cdi/scopes/src/main/webapp/WEB-INF/beans.xml | 49 +++++++ cdi/scopes/src/main/webapp/index.jsp | 55 ++++++++ 9 files changed, 586 insertions(+) create mode 100644 cdi/scopes/pom.xml create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ClientServlet.java create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyApplicationScopedBean.java create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyRequestScopedBean.java create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySessionScopedBean.java create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySingletonScopedBean.java create mode 100644 cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ServerServlet.java create mode 100644 cdi/scopes/src/main/webapp/WEB-INF/beans.xml create mode 100644 cdi/scopes/src/main/webapp/index.jsp diff --git a/cdi/scopes/pom.xml b/cdi/scopes/pom.xml new file mode 100644 index 000000000..bf36f6a14 --- /dev/null +++ b/cdi/scopes/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + org.javaee7.cdi + cdi-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.cdi + scopes + 1.0-SNAPSHOT + war + scopes + diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ClientServlet.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ClientServlet.java new file mode 100644 index 000000000..6b6a1e29d --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ClientServlet.java @@ -0,0 +1,126 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author arungup + */ +@WebServlet(urlPatterns = {"/ClientServlet"}) +public class ClientServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("CDI Scopes"); + out.println(""); + out.println(""); + out.println("

    CDI Scopes

    "); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/ServerServlet"); + out.println("

    First request

    "); + dispatcher.include(request, response); + out.println("

    Second request

    "); + dispatcher.include(request, response); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyApplicationScopedBean.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyApplicationScopedBean.java new file mode 100644 index 000000000..85f17b193 --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyApplicationScopedBean.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import javax.enterprise.context.RequestScoped; + +/** + * @author Arun Gupta + */ +@RequestScoped +public class MyApplicationScopedBean { + public String getID() { + return this + ""; + } +} diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyRequestScopedBean.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyRequestScopedBean.java new file mode 100644 index 000000000..49ae6d2fa --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MyRequestScopedBean.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import javax.enterprise.context.RequestScoped; + +/** + * @author Arun Gupta + */ +@RequestScoped +public class MyRequestScopedBean { + public String getID() { + return this + ""; + } +} diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySessionScopedBean.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySessionScopedBean.java new file mode 100644 index 000000000..46632758c --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySessionScopedBean.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import javax.enterprise.context.RequestScoped; + +/** + * @author Arun Gupta + */ +@RequestScoped +public class MySessionScopedBean { + public String getID() { + return this + ""; + } +} diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySingletonScopedBean.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySingletonScopedBean.java new file mode 100644 index 000000000..fffaf8218 --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/MySingletonScopedBean.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import javax.enterprise.context.RequestScoped; + +/** + * @author Arun Gupta + */ +@RequestScoped +public class MySingletonScopedBean { + public String getID() { + return this + ""; + } +} diff --git a/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ServerServlet.java b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ServerServlet.java new file mode 100644 index 000000000..055d4ae5d --- /dev/null +++ b/cdi/scopes/src/main/java/org/javaee7/cdi/bean/scopes/ServerServlet.java @@ -0,0 +1,132 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.bean.scopes; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author arungup + */ +@WebServlet(urlPatterns = {"/ServerServlet"}) +public class ServerServlet extends HttpServlet { + + @Inject MyRequestScopedBean requestBean; + @Inject MyRequestScopedBean requestBean2; + + @Inject MySessionScopedBean sessionBean; + @Inject MySessionScopedBean sessionBean2; + + @Inject MyApplicationScopedBean applicationBean; + @Inject MySingletonScopedBean singletonBean; + + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + try (PrintWriter out = response.getWriter()) { + out.println("Request-scoped bean"); + out.println("

    (1): " + requestBean.getID()); + out.println("
    (2): " + requestBean2.getID()); + out.println("

    Session-scoped bean"); + out.println("

    (1): " + sessionBean.getID()); + out.println("
    (2): " + sessionBean2.getID()); + out.println("

    Application-scoped bean: " + applicationBean.getID()); + out.println("

    Singleton-scoped bean: " + singletonBean.getID()); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/cdi/scopes/src/main/webapp/WEB-INF/beans.xml b/cdi/scopes/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/cdi/scopes/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/cdi/scopes/src/main/webapp/index.jsp b/cdi/scopes/src/main/webapp/index.jsp new file mode 100644 index 000000000..d69c19f6b --- /dev/null +++ b/cdi/scopes/src/main/webapp/index.jsp @@ -0,0 +1,55 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + CDI : Scopes + + +

    CDI : Scopes

    + Invoke the Greeting. + + From acd761a7314f10ca8f379a8e0aac67508cb60c80 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 09:59:22 -0700 Subject: [PATCH 0132/1080] Added the new sample --- cdi/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/cdi/pom.xml b/cdi/pom.xml index 27ecc5d6c..bf10b1f41 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -28,5 +28,6 @@ beansxml-noversion beanmanager extension + scopes From bb3d42fedea03dadbac225ba14807563a4652d02 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 14:55:13 -0700 Subject: [PATCH 0133/1080] Adding a final qualifier --- .../main/java/org/javaee7/jaxrs/readerwriter/MyResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/MyResource.java b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/MyResource.java index a524d4758..f1b49bfc6 100644 --- a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/MyResource.java +++ b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/MyResource.java @@ -48,7 +48,7 @@ */ @Path("fruits") public class MyResource { - private String[] response = { "apple", "banana", "mango" }; + private final String[] response = { "apple", "banana", "mango" }; @POST @Consumes(value=MyObject.MIME_TYPE) From 679c6e8941ad43278d4df26d1d34f1c219895978 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 14:56:56 -0700 Subject: [PATCH 0134/1080] Removing redundant attributes from @WebServlet --- .../main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java index d1c95fe63..9c026f866 100644 --- a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java +++ b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java @@ -54,7 +54,7 @@ /** * @author Arun Gupta */ -@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"}) +@WebServlet(urlPatterns = {"/TestServlet"}) public class TestServlet extends HttpServlet { /** From da779601a9ab05152dc42066e6d8b46c711a8a29 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 14:58:45 -0700 Subject: [PATCH 0135/1080] Adding better output messages --- .../org/javaee7/jaxrs/readerwriter/TestServlet.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java index 9c026f866..51369f5f1 100644 --- a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java +++ b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java @@ -73,10 +73,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re PrintWriter out = response.getWriter(); out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("JAX-RS Entity Providers"); out.println(""); out.println(""); - out.println("

    Servlet TestServlet at " + request.getContextPath() + "

    "); + out.println("

    JAX-RS Entity Providers

    "); Client client = ClientBuilder.newClient(); client .register(MyReader.class) @@ -88,18 +88,20 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re + request.getServerPort() + request.getContextPath() + "/webresources/fruits"); - System.out.println("POST request"); + out.println("

    POST request

    "); + out.println("Sending an object of custom mimetype"); String fruit = target .request() .post(Entity.entity(new MyObject(1), MyObject.MIME_TYPE), String.class); - out.println("Received response: " + fruit + "

    "); + out.println("Received response (with custom mime type): " + fruit + "

    "); + out.println("Another POST..."); fruit = target .path("fruitInt") .request() .post(Entity.text("1"), String.class); out.println("Received response: " + fruit + "

    "); - out.println("Check server.log for client/server interceptor output."); + out.println("Check \"server.log\" for client/server interceptor output."); out.println(""); out.println(""); } From d31a0b11e0289b14f899944e0bc98c8c619cbe46 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 20 Sep 2013 14:59:57 -0700 Subject: [PATCH 0136/1080] Better formatting of output messages --- .../java/org/javaee7/jaxrs/readerwriter/TestServlet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java index 51369f5f1..6e1d34772 100644 --- a/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java +++ b/jaxrs/readerwriter/src/main/java/org/javaee7/jaxrs/readerwriter/TestServlet.java @@ -93,15 +93,15 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re String fruit = target .request() .post(Entity.entity(new MyObject(1), MyObject.MIME_TYPE), String.class); - out.println("Received response (with custom mime type): " + fruit + "

    "); - out.println("Another POST..."); + out.println("
    Received response (with custom mime type): " + fruit + "

    "); + out.println("

    Another POST request

    "); fruit = target .path("fruitInt") .request() .post(Entity.text("1"), String.class); - out.println("Received response: " + fruit + "

    "); + out.println("
    Received response: " + fruit); - out.println("Check \"server.log\" for client/server interceptor output."); + out.println("

    Check \"server.log\" for client/server interceptor output."); out.println(""); out.println(""); } From 4ba03ea997b1e7f49f7e26a2f79b4fb01eeaa586 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 27 Sep 2013 14:52:58 -0700 Subject: [PATCH 0137/1080] Interim capability to start the database server as well (still not working) --- pom.xml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e3ab7b1cb..de772b4fb 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,12 @@ 7.0 provided + + org.apache.derby + derby + 10.8.2.2 + provided +
    @@ -46,6 +52,31 @@ false + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.5-SNAPSHOT + + + + + org.apache.derby + derby + + + + ${project.build.directory}/derby + + + + + + cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDriver| cargo.datasource.url=jdbc:derby:derbyDB;create=true| cargo.datasource.jndi=jdbc/__default| cargo.datasource.username=APP| cargo.datasource.password=APP + + + + + @@ -60,18 +91,30 @@ org.codehaus.cargo cargo-maven2-plugin - 1.4.4 + 1.4.5-SNAPSHOT true ${cargo.container.glassfish.id} installed ${glassfish.home} + + org.glassfish.main.distributions + glassfish + 4.0 + - + + + org.apache.derby + derby + none + + + @@ -84,7 +127,7 @@ org.codehaus.cargo cargo-maven2-plugin - 1.4.4 + 1.4.5-SNAPSHOT true @@ -108,7 +151,7 @@ org.codehaus.cargo cargo-maven2-plugin - 1.4.4 + 1.4.5-SNAPSHOT true From 15abba871a5f9f6253e0dc7f8a1649dd6ee2cc4f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 27 Sep 2013 15:31:17 -0700 Subject: [PATCH 0138/1080] Adding snapshot repositories for Cargo (now working) --- pom.xml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pom.xml b/pom.xml index de772b4fb..0fa1122e5 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,34 @@ provided + + + + codehaus-snapshots + Codehaus Snapshots + http://nexus.codehaus.org/snapshots/ + + false + + + true + + + + + + + codehaus-snapshots + Codehaus Snapshots + http://nexus.codehaus.org/snapshots/ + + false + + + true + + + From 5159b1587703d559c341ce5890ea4e3917adcbd2 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 29 Sep 2013 07:54:53 -0700 Subject: [PATCH 0139/1080] Cleaned by S. Ali Tomken to be Cargo-compatible --- pom.xml | 428 +++++++++++++++++++++++++++----------------------------- 1 file changed, 207 insertions(+), 221 deletions(-) diff --git a/pom.xml b/pom.xml index 0fa1122e5..b44bbaec6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,221 +1,207 @@ - - 4.0.0 - - org.javaee7 - javaee7-samples - 1.0-SNAPSHOT - pom - Java EE 7 Samples - - - glassfish4x - /Users/arungup/tools/glassfish/4.0/final/glassfish4 - wildfly8x - /Users/arungup/tools/wildfly/wildfly-8.0.0.Alpha4 - tomcat8x - /Users/arungup/tools/tomcat/apache-tomcat-8.0.0-RC1 - gfv3ee6 - - - - - javax - javaee-api - 7.0 - provided - - - org.apache.derby - derby - 10.8.2.2 - provided - - - - - - codehaus-snapshots - Codehaus Snapshots - http://nexus.codehaus.org/snapshots/ - - false - - - true - - - - - - - codehaus-snapshots - Codehaus Snapshots - http://nexus.codehaus.org/snapshots/ - - false - - - true - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-war-plugin - 2.1.1 - - false - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.5-SNAPSHOT - - - - - org.apache.derby - derby - - - - ${project.build.directory}/derby - - - - - - cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDriver| cargo.datasource.url=jdbc:derby:derbyDB;create=true| cargo.datasource.jndi=jdbc/__default| cargo.datasource.username=APP| cargo.datasource.password=APP - - - - - - - - - - - glassfish - - true - - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.5-SNAPSHOT - true - - - ${cargo.container.glassfish.id} - installed - ${glassfish.home} - - org.glassfish.main.distributions - glassfish - 4.0 - - - - - org.apache.derby - derby - none - - - - - - - - - - wildfly - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.5-SNAPSHOT - true - - - ${cargo.container.wildfly.id} - installed - ${wildfly.home} - - - standalone - ${wildfly.home} - - - - - - - - tomcat - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.4.5-SNAPSHOT - true - - - ${cargo.container.tomcat.id} - installed - ${tomcat.home} - - - standalone - ${tomcat.home}/temp - - - - - - - - - - batch - cdi - concurrency - ejb - el - javamail - jaxrs - jca - jms - jpa - jta - jsf - json - servlet - validation - websocket - extra - - - + + 4.0.0 + + org.javaee7 + javaee7-samples + 1.0-SNAPSHOT + pom + Java EE 7 Samples + + + glassfish4x + wildfly8x + tomcat8x + gfv3ee6 + + + + + javax + javaee-api + 7.0 + provided + + + org.apache.derby + derby + 10.8.2.2 + provided + + + + + + codehaus-snapshots + Codehaus Snapshots + http://nexus.codehaus.org/snapshots/ + + false + + + true + + + + + + + codehaus-snapshots + Codehaus Snapshots + http://nexus.codehaus.org/snapshots/ + + false + + + true + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + false + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.5-SNAPSHOT + + + + + org.apache.derby + derby + + + + ${project.build.directory}/derby + + + + + + cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDriver| + cargo.datasource.url=jdbc:derby:derbyDB;create=true| + cargo.datasource.jndi=jdbc/__default| + cargo.datasource.username=APP| + cargo.datasource.password=APP + + + + + + + + + + + glassfish + + true + + + + + org.codehaus.cargo + cargo-maven2-plugin + + + ${cargo.container.glassfish.id} + + org.glassfish.main.distributions + glassfish + 4.0 + + + + org.apache.derby + derby + none + + + + + + + + + + wildfly + + + + org.codehaus.cargo + cargo-maven2-plugin + + + ${cargo.container.wildfly.id} + + org.wildfly + wildfly-dist + 8.0.0.Alpha4 + + + + + + + + + tomcat + + + + org.codehaus.cargo + cargo-maven2-plugin + + + ${cargo.container.tomcat.id} + + http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.0-RC3/bin/apache-tomcat-8.0.0-RC3.zip + + + + + + + + + + + batch + cdi + concurrency + ejb + el + javamail + jaxrs + jca + jms + jpa + jta + jsf + json + servlet + validation + websocket + extra + + + + From dbfcc73f045ce0cc323d51c0d0a6987e4b7bc0fb Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 30 Sep 2013 13:09:16 -0700 Subject: [PATCH 0140/1080] Adding to - this will ensure a clean archive name is generated --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index b44bbaec6..19ce671ac 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,7 @@ + ${project.artifactId} org.apache.maven.plugins From 963f38f22311b9fa329215d7f673a0c10d167ddd Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 30 Sep 2013 14:54:30 -0700 Subject: [PATCH 0141/1080] Added pre-installed versions of GlassFish and Wildfly. Also added WebLogic profile, although none of the samples would run on it right now as the DD are Java EE 7 compliant. --- pom.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pom.xml b/pom.xml index 19ce671ac..d688cba82 100644 --- a/pom.xml +++ b/pom.xml @@ -10,8 +10,12 @@ glassfish4x + /Users/arungup/tools/glassfish/4.0/final/glassfish4 wildfly8x + /Users/arungup/tools/wildfly/wildfly-8.0.0.Alpha4 tomcat8x + weblogic12x + /Users/arungup/tools/weblogic/12c/wlserver gfv3ee6 @@ -121,14 +125,20 @@ org.codehaus.cargo cargo-maven2-plugin + 1.4.5-SNAPSHOT ${cargo.container.glassfish.id} + installed + ${cargo.container.glassfish.home} + org.apache.derby @@ -152,11 +162,16 @@ ${cargo.container.wildfly.id} + installed + ${cargo.container.wildfly.home} + @@ -182,6 +197,24 @@ + + weblogic + + + + org.codehaus.cargo + cargo-maven2-plugin + + + ${cargo.container.weblogic.id} + installed + ${cargo.container.weblogic.home} + + + + + + From 800b82e65b4ece2711d31a8bc9b938cf2560f8bd Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 30 Sep 2013 16:33:58 -0700 Subject: [PATCH 0142/1080] New sample to show basic usage of Mongo in a Java EE application --- extra/mongo/pom.xml | 28 ++++ .../java/org/javaee7/extra/mongo/Person.java | 104 +++++++++++++ .../extra/mongo/PersonSessionBean.java | 127 +++++++++++++++ .../org/javaee7/extra/mongo/TestServlet.java | 146 ++++++++++++++++++ extra/mongo/src/main/webapp/WEB-INF/beans.xml | 49 ++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 ++++ extra/mongo/src/main/webapp/WEB-INF/web.xml | 24 +++ extra/mongo/src/main/webapp/index.xhtml | 25 +++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++ .../src/main/webapp/resources/css/default.css | 29 ++++ extra/mongo/src/main/webapp/show.xhtml | 22 +++ 11 files changed, 641 insertions(+) create mode 100644 extra/mongo/pom.xml create mode 100644 extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java create mode 100644 extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java create mode 100644 extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java create mode 100644 extra/mongo/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/mongo/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/mongo/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/mongo/src/main/webapp/index.xhtml create mode 100644 extra/mongo/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/mongo/src/main/webapp/resources/css/default.css create mode 100644 extra/mongo/src/main/webapp/show.xhtml diff --git a/extra/mongo/pom.xml b/extra/mongo/pom.xml new file mode 100644 index 000000000..00fd31e5b --- /dev/null +++ b/extra/mongo/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra + mongo + 1.0-SNAPSHOT + war + + + + org.mongodb + mongo-java-driver + 1.3 + + + de.flapdoodle.embed + de.flapdoodle.embed.mongo + 1.36 + + + diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java b/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java new file mode 100644 index 000000000..7b4620f3e --- /dev/null +++ b/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java @@ -0,0 +1,104 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.mongo; + +import com.mongodb.BasicDBObject; +import com.mongodb.DBObject; +import javax.enterprise.inject.Model; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Model +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public BasicDBObject toDBObject() { + BasicDBObject doc = new BasicDBObject(); + + doc.put("name", name); + doc.put("age", age); + + return doc; + } + + public static Person fromDBObject(DBObject doc) { + Person m = new Person(); + + m.name = (String) doc.get("name"); + m.age = (int) doc.get("age"); + + return m; + } + + @Override + public String toString() { + return name + ", " + age; + } +} diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java b/extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java new file mode 100644 index 000000000..504fbf884 --- /dev/null +++ b/extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java @@ -0,0 +1,127 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.mongo; + +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; +import com.mongodb.Mongo; +import com.mongodb.MongoException; +import de.flapdoodle.embed.mongo.MongodExecutable; +import de.flapdoodle.embed.mongo.MongodProcess; +import de.flapdoodle.embed.mongo.MongodStarter; +import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; +import de.flapdoodle.embed.mongo.config.Net; +import de.flapdoodle.embed.mongo.distribution.Version; +import de.flapdoodle.embed.process.runtime.Network; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.Stateless; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author Arun Gupta + */ +@Named +@Stateless +public class PersonSessionBean { + + @Inject + Person person; + + DBCollection personCollection; + + private MongodExecutable mongodExe; + private MongodProcess mongod; + private final int MONGO_PORT = 12345; + + @PostConstruct + private void initDB() { + try { + // Start embedded Mongo + MongodStarter runtime = MongodStarter.getDefaultInstance(); + mongodExe = runtime.prepare(new MongodConfigBuilder() + .version(Version.Main.PRODUCTION) + .net(new Net(MONGO_PORT, Network.localhostIsIPv6())) + .build()); + mongod = mongodExe.start(); + + // Get an instance of Mongo + Mongo m = new Mongo("localhost", MONGO_PORT); + DB db = m.getDB("personDB"); + personCollection = db.getCollection("persons"); + if (personCollection == null) { + personCollection = db.createCollection("persons", null); + } + } catch (MongoException | IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @PreDestroy + private void stopDB() { + mongod.stop(); + mongodExe.stop(); + } + + public void createPerson() { + BasicDBObject doc = person.toDBObject(); + personCollection.insert(doc); + } + + public List getPersons() { + List persons = new ArrayList(); + DBCursor cur = personCollection.find(); + System.out.println("getPersons: Found " + cur.length() + " person(s)"); + for (DBObject dbo : cur.toArray()) { + persons.add(Person.fromDBObject(dbo)); + } + + return persons; + } +} diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java b/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java new file mode 100644 index 000000000..7236eadfb --- /dev/null +++ b/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java @@ -0,0 +1,146 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.mongo; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("Mongo with Java EE 7"); + out.println(""); + out.println(""); + out.println("

    Mongo with Java EE 7

    "); + +// Mongo m = new Mongo(); +// DB db = m.getDB("movieDB"); +// DBCollection coll = db.getCollection("test"); +// if (coll == null) { +// System.out.println("Creating a new test collection"); +// coll = db.createCollection("test", null); +// } +// BasicDBObject bdbo = new BasicDBObject(); +// bdbo.put("name", "mario"); +// coll.insert(bdbo); +// bdbo.clear(); +// bdbo.put("name", "luigi"); +// coll.insert(bdbo); +// +// out.println("Found " + coll.getCount() + " elements
    "); +// DBCursor cur = coll.find(); +// for (DBObject o : cur.toArray()) { +// out.println(o.get("name") + "
    "); +// } + + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet + (HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost + (HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo + + () { + return "Short description"; + }// + } diff --git a/extra/mongo/src/main/webapp/WEB-INF/beans.xml b/extra/mongo/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/mongo/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/mongo/src/main/webapp/WEB-INF/template.xhtml b/extra/mongo/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..dd1a75ece --- /dev/null +++ b/extra/mongo/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Mongo using Java EE 7 + + + + +
    +

    Mongo using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/mongo/src/main/webapp/WEB-INF/web.xml b/extra/mongo/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/mongo/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/mongo/src/main/webapp/index.xhtml b/extra/mongo/src/main/webapp/index.xhtml new file mode 100644 index 000000000..db1c9bca4 --- /dev/null +++ b/extra/mongo/src/main/webapp/index.xhtml @@ -0,0 +1,25 @@ + + + + + + + + + + + Name:
    + Age:
    + +
    +
    + +
    + + + diff --git a/extra/mongo/src/main/webapp/resources/css/cssLayout.css b/extra/mongo/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/mongo/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/mongo/src/main/webapp/resources/css/default.css b/extra/mongo/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/mongo/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/mongo/src/main/webapp/show.xhtml b/extra/mongo/src/main/webapp/show.xhtml new file mode 100644 index 000000000..19203f612 --- /dev/null +++ b/extra/mongo/src/main/webapp/show.xhtml @@ -0,0 +1,22 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + + + + + + + From 8575f61212509c301fda4345bfd56e638fd6a598 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 30 Sep 2013 16:34:11 -0700 Subject: [PATCH 0143/1080] Adding mongo module --- extra/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/pom.xml b/extra/pom.xml index 438105413..5d49f9138 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -17,5 +17,6 @@ quartz twitter-search + mongo From b90ae0b100d976798ce6b0b9646eb3a40e9fd156 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 11:11:40 -0700 Subject: [PATCH 0144/1080] Removing a redundant parentheses --- .../src/main/java/org/javaee7/jpa/schemagen/Employee.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/Employee.java b/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/Employee.java index 2f4dc4d38..fd1cb84af 100644 --- a/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/Employee.java +++ b/jpa/schema-gen/src/main/java/org/javaee7/jpa/schemagen/Employee.java @@ -52,7 +52,7 @@ /** * @author Arun Gupta */ -@Entity() +@Entity @Table(name = "EMPLOYEE_SCHEMA_GEN") @NamedQueries({ @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e") From 77b6dc95ffc42c0be3c1b34bc92b074c43cff4e3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 11:12:35 -0700 Subject: [PATCH 0145/1080] Adding better output messages --- .../org/javaee7/batch/chunk/csv/database/TestServlet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java index f66898eed..77f5fb77f 100644 --- a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java +++ b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/TestServlet.java @@ -80,10 +80,10 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re try (PrintWriter out = response.getWriter()) { out.println(""); out.println(""); - out.println("Servlet TestServlet"); + out.println("CSV-to-Database Chunk Job"); out.println(""); out.println(""); - out.println("

    Running the job

    "); + out.println("

    CSV-to-Database Chunk Job

    "); JobOperator jo = BatchRuntime.getJobOperator(); long jid = jo.start("myJob", new Properties()); out.println("Job submitted: " + jid + "
    "); From 6d0a1b4a4f199503f953ea33cd038dd3c1a416f4 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 11:12:51 -0700 Subject: [PATCH 0146/1080] Removing redundant imports --- .../java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java index 7c8a810bb..70cccce70 100644 --- a/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java +++ b/batch/chunk-csv-database/src/main/java/org/javaee7/batch/chunk/csv/database/MyItemWriter.java @@ -44,7 +44,6 @@ import javax.inject.Named; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import javax.transaction.Transactional; /** * @author Arun Gupta From e75eef0a7563f690bad2d09a2b8d0418ab5b5094 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 14:59:40 -0700 Subject: [PATCH 0147/1080] Explicitly specifying application/* media type --- .../java/org/javaee7/jaxrs/server/negotiation/TestServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaxrs/server-negotiation/src/main/java/org/javaee7/jaxrs/server/negotiation/TestServlet.java b/jaxrs/server-negotiation/src/main/java/org/javaee7/jaxrs/server/negotiation/TestServlet.java index a0b9b236d..6a804779a 100644 --- a/jaxrs/server-negotiation/src/main/java/org/javaee7/jaxrs/server/negotiation/TestServlet.java +++ b/jaxrs/server-negotiation/src/main/java/org/javaee7/jaxrs/server/negotiation/TestServlet.java @@ -90,7 +90,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re // GET out.print("GETTing...
    "); - String string = target.request().get(String.class); + String string = target.request().accept("application/*").get(String.class); out.format("GOT the representation: " + string); out.format("

    Did you get the JSON representation ?"); out.println("

    ... done.
    "); From 44ecab6db022e33d2e74183c434809c3d7b3bc19 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 15:00:43 -0700 Subject: [PATCH 0148/1080] "mvn embedded-glassfish run" to run the samples in embedded GlassFish. TBD: how to connect with database. --- pom.xml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pom.xml b/pom.xml index d688cba82..7f3ca6bb4 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,48 @@
    + + org.glassfish.embedded + maven-embedded-glassfish-plugin + 4.0 + + target/${project.artifactId}.war + 8080 + + 8181 + + + + + org.glassfish.main.common + simple-glassfish-api + 4.0 + + + org.glassfish.main.extras + glassfish-embedded-all + 4.0 + + + + + start + integration-test + + start + deploy + + + + stop + post-integration-test + + undeploy + stop + + + + From 0d8444d4716e798cdf2f7d0c4c879fbed928c75d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 16:31:14 -0700 Subject: [PATCH 0149/1080] Fixing a variable name --- .../src/main/java/org/javaee7/extra/mongo/Person.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java b/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java index 7b4620f3e..eb9c48f21 100644 --- a/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java +++ b/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java @@ -89,12 +89,12 @@ public BasicDBObject toDBObject() { } public static Person fromDBObject(DBObject doc) { - Person m = new Person(); + Person p = new Person(); - m.name = (String) doc.get("name"); - m.age = (int) doc.get("age"); + p.name = (String) doc.get("name"); + p.age = (int) doc.get("age"); - return m; + return p; } @Override From 05e77c3e02d37f226414e74a72e30dd111635f00 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 17:22:05 -0700 Subject: [PATCH 0150/1080] New Couchbase sample - getBulk does not seem to be returning correct values, needs further investigation --- extra/couchbase/pom.xml | 23 ++++ .../org/javaee7/extra/couchbase/Person.java | 86 +++++++++++++ .../extra/couchbase/PersonSessionBean.java | 114 ++++++++++++++++++ .../src/main/webapp/WEB-INF/beans.xml | 49 ++++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 ++++ .../couchbase/src/main/webapp/WEB-INF/web.xml | 24 ++++ extra/couchbase/src/main/webapp/index.xhtml | 37 ++++++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++++ .../src/main/webapp/resources/css/default.css | 29 +++++ extra/couchbase/src/main/webapp/show.xhtml | 22 ++++ 10 files changed, 471 insertions(+) create mode 100644 extra/couchbase/pom.xml create mode 100644 extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java create mode 100644 extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java create mode 100644 extra/couchbase/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/couchbase/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/couchbase/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/couchbase/src/main/webapp/index.xhtml create mode 100644 extra/couchbase/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/couchbase/src/main/webapp/resources/css/default.css create mode 100644 extra/couchbase/src/main/webapp/show.xhtml diff --git a/extra/couchbase/pom.xml b/extra/couchbase/pom.xml new file mode 100644 index 000000000..9f4768057 --- /dev/null +++ b/extra/couchbase/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra + couchbase + 1.0-SNAPSHOT + war + + + + com.couchbase.client + couchbase-client + 1.2.0 + + + diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java new file mode 100644 index 000000000..690c2ebb7 --- /dev/null +++ b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java @@ -0,0 +1,86 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.couchbase; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } +} diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java new file mode 100644 index 000000000..bef1549ee --- /dev/null +++ b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java @@ -0,0 +1,114 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.couchbase; + +import com.couchbase.client.CouchbaseClient; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +/** + * @author Arun Gupta + */ +@Named +@Singleton +public class PersonSessionBean { + + @Inject + Person person; + + CouchbaseClient client; + + Set set = new HashSet<>(); + + @PostConstruct + private void initDB() { + try { + // Get an instance of Couchbase + List hosts = Arrays.asList( + new URI("http://localhost:8091/pools") + ); + + // Get an instance of Couchbase + // Name of the Bucket to connect to + String bucket = "default"; + + // Password of the bucket (empty) string if none + String password = ""; + + // Connect to the Cluster + client = new CouchbaseClient(hosts, bucket, password); + } catch (URISyntaxException | IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @PreDestroy + private void stopDB() { + client.shutdown(); + } + + public void createPerson() { + client.set(person.getName(), person); + set.add(person.getName()); + } + + public List getPersons() { + List persons = new ArrayList(); + Map map = client.getBulk(set.iterator()); + for (String key : map.keySet()) { + persons.add((Person)map.get(key)); + } + return persons; + } +} diff --git a/extra/couchbase/src/main/webapp/WEB-INF/beans.xml b/extra/couchbase/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/couchbase/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/couchbase/src/main/webapp/WEB-INF/template.xhtml b/extra/couchbase/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..9eb7c0652 --- /dev/null +++ b/extra/couchbase/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Couchbase using Java EE 7 + + + + +
    +

    Couchbase using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/couchbase/src/main/webapp/WEB-INF/web.xml b/extra/couchbase/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/couchbase/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/couchbase/src/main/webapp/index.xhtml b/extra/couchbase/src/main/webapp/index.xhtml new file mode 100644 index 000000000..16b846aef --- /dev/null +++ b/extra/couchbase/src/main/webapp/index.xhtml @@ -0,0 +1,37 @@ + + + + + + + + + + + Name:
    + Age:
    + +
    +
    + Make sure to start Couchbase server. Confirm by visiting pools and look for output as: + +
    +"pools": [
    +    {
    +        "name": "default",
    +        "uri": "/pools/default?uuid=21041e11772b15d7c64f3451e1293215",
    +        "streamingUri": "/poolsStreaming/default?uuid=21041e11772b15d7c64f3451e1293215"
    +    }
    +],
    +                
    +
    + +
    + + + diff --git a/extra/couchbase/src/main/webapp/resources/css/cssLayout.css b/extra/couchbase/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/couchbase/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/couchbase/src/main/webapp/resources/css/default.css b/extra/couchbase/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/couchbase/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/couchbase/src/main/webapp/show.xhtml b/extra/couchbase/src/main/webapp/show.xhtml new file mode 100644 index 000000000..19203f612 --- /dev/null +++ b/extra/couchbase/src/main/webapp/show.xhtml @@ -0,0 +1,22 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + + + + + + + From 52b4b7c4356c06f92178e6ccb4ed22ce58730f80 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Wed, 2 Oct 2013 17:22:15 -0700 Subject: [PATCH 0151/1080] Adding couchbase module --- extra/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/pom.xml b/extra/pom.xml index 5d49f9138..6e78376ca 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -18,5 +18,6 @@ quartz twitter-search mongo + couchbase From 0ba5d04c7cdea62e726743122f572cbdfdc430ed Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 09:50:32 -0700 Subject: [PATCH 0152/1080] Making the object serializable so that it can be persisted in Couchbase --- .../src/main/java/org/javaee7/extra/couchbase/Person.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java index 690c2ebb7..1a72e8409 100644 --- a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java +++ b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java @@ -39,6 +39,7 @@ */ package org.javaee7.extra.couchbase; +import java.io.Serializable; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.validation.constraints.Size; @@ -48,7 +49,7 @@ */ @Named @ApplicationScoped -public class Person { +public class Person implements Serializable { @Size(min = 1, max = 20) private String name; From 6a0def18faa6a0581d645b040baeb977db7af82c Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 09:50:51 -0700 Subject: [PATCH 0153/1080] Persisting object instance instead of proxy --- .../java/org/javaee7/extra/couchbase/PersonSessionBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java index bef1549ee..e4fb4ccf6 100644 --- a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java +++ b/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java @@ -99,7 +99,7 @@ private void stopDB() { } public void createPerson() { - client.set(person.getName(), person); + client.set(person.getName(), new Person(person.getName(), person.getAge())); set.add(person.getName()); } From 31392a6b136a2f2d23b47f835834b128d90081d2 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 09:51:16 -0700 Subject: [PATCH 0154/1080] Adding Back button and some formatting --- extra/couchbase/src/main/webapp/index.xhtml | 5 ++--- extra/couchbase/src/main/webapp/show.xhtml | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extra/couchbase/src/main/webapp/index.xhtml b/extra/couchbase/src/main/webapp/index.xhtml index 16b846aef..daf471c32 100644 --- a/extra/couchbase/src/main/webapp/index.xhtml +++ b/extra/couchbase/src/main/webapp/index.xhtml @@ -11,11 +11,10 @@ Name:
    - Age:
    + Age:

    + value="Add"/>

    Make sure to start Couchbase server. Confirm by visiting pools and look for output as: diff --git a/extra/couchbase/src/main/webapp/show.xhtml b/extra/couchbase/src/main/webapp/show.xhtml index 19203f612..8f1d60f31 100644 --- a/extra/couchbase/src/main/webapp/show.xhtml +++ b/extra/couchbase/src/main/webapp/show.xhtml @@ -14,6 +14,11 @@ Name#{p.name} Age#{p.age} +

    + + + +
    From 12a236eb4147bc2d8dc5fe58a395e325707e811d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:05:31 -0700 Subject: [PATCH 0155/1080] New sample that shows Redis and Java EE integration --- extra/redis/pom.xml | 23 +++++ .../java/org/javaee7/extra/redis/Person.java | 92 +++++++++++++++++++ .../extra/redis/PersonSessionBean.java | 90 ++++++++++++++++++ extra/redis/src/main/webapp/WEB-INF/beans.xml | 49 ++++++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 ++++++ extra/redis/src/main/webapp/WEB-INF/web.xml | 24 +++++ extra/redis/src/main/webapp/index.xhtml | 28 ++++++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++++++ .../src/main/webapp/resources/css/default.css | 29 ++++++ extra/redis/src/main/webapp/show.xhtml | 29 ++++++ 10 files changed, 451 insertions(+) create mode 100644 extra/redis/pom.xml create mode 100644 extra/redis/src/main/java/org/javaee7/extra/redis/Person.java create mode 100644 extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java create mode 100644 extra/redis/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/redis/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/redis/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/redis/src/main/webapp/index.xhtml create mode 100644 extra/redis/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/redis/src/main/webapp/resources/css/default.css create mode 100644 extra/redis/src/main/webapp/show.xhtml diff --git a/extra/redis/pom.xml b/extra/redis/pom.xml new file mode 100644 index 000000000..ce6b57832 --- /dev/null +++ b/extra/redis/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra + redis + 1.0-SNAPSHOT + war + + + + redis.clients + jedis + 2.2.0 + + + diff --git a/extra/redis/src/main/java/org/javaee7/extra/redis/Person.java b/extra/redis/src/main/java/org/javaee7/extra/redis/Person.java new file mode 100644 index 000000000..83a5781fd --- /dev/null +++ b/extra/redis/src/main/java/org/javaee7/extra/redis/Person.java @@ -0,0 +1,92 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.redis; + +import java.util.StringTokenizer; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + return new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + } +} diff --git a/extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java b/extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java new file mode 100644 index 000000000..efdd3b669 --- /dev/null +++ b/extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java @@ -0,0 +1,90 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.redis; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.Stateless; +import javax.inject.Inject; +import javax.inject.Named; +import redis.clients.jedis.Jedis; + +/** + * @author Arun Gupta + */ +@Named +@Stateless +public class PersonSessionBean { + + @Inject + Person person; + + Jedis jedis; + + Set set = new HashSet<>(); + + @PostConstruct + private void initDB() { +// Start embedded Redis + jedis = new Jedis("localhost", 6379); + } + + @PreDestroy + private void stopDB() { + jedis.shutdown(); + } + + public void createPerson() { + jedis.set(person.getName(), new Person(person.getName(), person.getAge()).toString()); + set.add(person.getName()); + } + + public List getPersons() { + List persons = new ArrayList<>(); + for (String key : set) { + persons.add(Person.fromString(jedis.get(key))); + } + return persons; + } +} diff --git a/extra/redis/src/main/webapp/WEB-INF/beans.xml b/extra/redis/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/redis/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/redis/src/main/webapp/WEB-INF/template.xhtml b/extra/redis/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..c0d6c22b3 --- /dev/null +++ b/extra/redis/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Redis using Java EE 7 + + + + +
    +

    Redis using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/redis/src/main/webapp/WEB-INF/web.xml b/extra/redis/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/redis/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/redis/src/main/webapp/index.xhtml b/extra/redis/src/main/webapp/index.xhtml new file mode 100644 index 000000000..0adf58b04 --- /dev/null +++ b/extra/redis/src/main/webapp/index.xhtml @@ -0,0 +1,28 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    + Make sure to download latest stable release, compile, and run it. Look for a message like: + +
    * The server is now ready to accept connections on port 6379
    +
    + +
    + + + diff --git a/extra/redis/src/main/webapp/resources/css/cssLayout.css b/extra/redis/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/redis/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/redis/src/main/webapp/resources/css/default.css b/extra/redis/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/redis/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/redis/src/main/webapp/show.xhtml b/extra/redis/src/main/webapp/show.xhtml new file mode 100644 index 000000000..342b4446b --- /dev/null +++ b/extra/redis/src/main/webapp/show.xhtml @@ -0,0 +1,29 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + From c73b40556a946fa05de3e887e9ae4262afde842d Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:05:45 -0700 Subject: [PATCH 0156/1080] Adding redis module --- extra/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/pom.xml b/extra/pom.xml index 6e78376ca..775db0336 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -19,5 +19,6 @@ twitter-search mongo couchbase + redis From d87cc280026b5317a98610b86ae23baab567a5fe Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:11:11 -0700 Subject: [PATCH 0157/1080] Moving NoSQL samples to a separate module --- .../org/javaee7/extra/mongo/TestServlet.java | 146 ------------------ extra/{ => nosql}/couchbase/pom.xml | 6 +- .../org/javaee7/extra/couchbase/Person.java | 0 .../extra/couchbase/PersonSessionBean.java | 0 .../src/main/webapp/WEB-INF/beans.xml | 0 .../src/main/webapp/WEB-INF/template.xhtml | 0 .../couchbase/src/main/webapp/WEB-INF/web.xml | 0 .../couchbase/src/main/webapp/index.xhtml | 0 .../main/webapp/resources/css/cssLayout.css | 0 .../src/main/webapp/resources/css/default.css | 0 .../couchbase/src/main/webapp/show.xhtml | 0 extra/{ => nosql}/mongo/pom.xml | 6 +- .../java/org/javaee7/extra/mongo/Person.java | 0 .../extra/mongo/PersonSessionBean.java | 0 .../mongo/src/main/webapp/WEB-INF/beans.xml | 0 .../src/main/webapp/WEB-INF/template.xhtml | 0 .../mongo/src/main/webapp/WEB-INF/web.xml | 0 .../mongo/src/main/webapp/index.xhtml | 0 .../main/webapp/resources/css/cssLayout.css | 0 .../src/main/webapp/resources/css/default.css | 0 .../mongo/src/main/webapp/show.xhtml | 0 extra/nosql/pom.xml | 22 +++ extra/{ => nosql}/redis/pom.xml | 6 +- .../java/org/javaee7/extra/redis/Person.java | 0 .../extra/redis/PersonSessionBean.java | 0 .../redis/src/main/webapp/WEB-INF/beans.xml | 0 .../src/main/webapp/WEB-INF/template.xhtml | 0 .../redis/src/main/webapp/WEB-INF/web.xml | 0 .../redis/src/main/webapp/index.xhtml | 0 .../main/webapp/resources/css/cssLayout.css | 0 .../src/main/webapp/resources/css/default.css | 0 .../redis/src/main/webapp/show.xhtml | 0 extra/pom.xml | 4 +- 33 files changed, 32 insertions(+), 158 deletions(-) delete mode 100644 extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java rename extra/{ => nosql}/couchbase/pom.xml (81%) rename extra/{ => nosql}/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java (100%) rename extra/{ => nosql}/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/WEB-INF/beans.xml (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/WEB-INF/template.xhtml (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/WEB-INF/web.xml (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/index.xhtml (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/resources/css/cssLayout.css (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/resources/css/default.css (100%) rename extra/{ => nosql}/couchbase/src/main/webapp/show.xhtml (100%) rename extra/{ => nosql}/mongo/pom.xml (83%) rename extra/{ => nosql}/mongo/src/main/java/org/javaee7/extra/mongo/Person.java (100%) rename extra/{ => nosql}/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java (100%) rename extra/{ => nosql}/mongo/src/main/webapp/WEB-INF/beans.xml (100%) rename extra/{ => nosql}/mongo/src/main/webapp/WEB-INF/template.xhtml (100%) rename extra/{ => nosql}/mongo/src/main/webapp/WEB-INF/web.xml (100%) rename extra/{ => nosql}/mongo/src/main/webapp/index.xhtml (100%) rename extra/{ => nosql}/mongo/src/main/webapp/resources/css/cssLayout.css (100%) rename extra/{ => nosql}/mongo/src/main/webapp/resources/css/default.css (100%) rename extra/{ => nosql}/mongo/src/main/webapp/show.xhtml (100%) create mode 100644 extra/nosql/pom.xml rename extra/{ => nosql}/redis/pom.xml (80%) rename extra/{ => nosql}/redis/src/main/java/org/javaee7/extra/redis/Person.java (100%) rename extra/{ => nosql}/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java (100%) rename extra/{ => nosql}/redis/src/main/webapp/WEB-INF/beans.xml (100%) rename extra/{ => nosql}/redis/src/main/webapp/WEB-INF/template.xhtml (100%) rename extra/{ => nosql}/redis/src/main/webapp/WEB-INF/web.xml (100%) rename extra/{ => nosql}/redis/src/main/webapp/index.xhtml (100%) rename extra/{ => nosql}/redis/src/main/webapp/resources/css/cssLayout.css (100%) rename extra/{ => nosql}/redis/src/main/webapp/resources/css/default.css (100%) rename extra/{ => nosql}/redis/src/main/webapp/show.xhtml (100%) diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java b/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java deleted file mode 100644 index 7236eadfb..000000000 --- a/extra/mongo/src/main/java/org/javaee7/extra/mongo/TestServlet.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.javaee7.extra.mongo; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author Arun Gupta - */ -@WebServlet(urlPatterns = {"/TestServlet"}) -public class TestServlet extends HttpServlet { - - /** - * Processes requests for both HTTP GET and POST - * methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { - out.println(""); - out.println(""); - out.println(""); - out.println("Mongo with Java EE 7"); - out.println(""); - out.println(""); - out.println("

    Mongo with Java EE 7

    "); - -// Mongo m = new Mongo(); -// DB db = m.getDB("movieDB"); -// DBCollection coll = db.getCollection("test"); -// if (coll == null) { -// System.out.println("Creating a new test collection"); -// coll = db.createCollection("test", null); -// } -// BasicDBObject bdbo = new BasicDBObject(); -// bdbo.put("name", "mario"); -// coll.insert(bdbo); -// bdbo.clear(); -// bdbo.put("name", "luigi"); -// coll.insert(bdbo); -// -// out.println("Found " + coll.getCount() + " elements
    "); -// DBCursor cur = coll.find(); -// for (DBObject o : cur.toArray()) { -// out.println(o.get("name") + "
    "); -// } - - out.println(""); - out.println(""); - } - } - - // - /** - * Handles the HTTP GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet - (HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost - (HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo - - () { - return "Short description"; - }// - } diff --git a/extra/couchbase/pom.xml b/extra/nosql/couchbase/pom.xml similarity index 81% rename from extra/couchbase/pom.xml rename to extra/nosql/couchbase/pom.xml index 9f4768057..3e19cae10 100644 --- a/extra/couchbase/pom.xml +++ b/extra/nosql/couchbase/pom.xml @@ -2,13 +2,13 @@ 4.0.0 - org.javaee7.extra - extra-samples + org.javaee7.extra.nosql + extra-nosql-samples 1.0-SNAPSHOT ../pom.xml - org.javaee7.extra + org.javaee7.extra.nosql couchbase 1.0-SNAPSHOT war diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java similarity index 100% rename from extra/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java rename to extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java diff --git a/extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java similarity index 100% rename from extra/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java rename to extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java diff --git a/extra/couchbase/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/couchbase/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from extra/couchbase/src/main/webapp/WEB-INF/beans.xml rename to extra/nosql/couchbase/src/main/webapp/WEB-INF/beans.xml diff --git a/extra/couchbase/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/couchbase/src/main/webapp/WEB-INF/template.xhtml similarity index 100% rename from extra/couchbase/src/main/webapp/WEB-INF/template.xhtml rename to extra/nosql/couchbase/src/main/webapp/WEB-INF/template.xhtml diff --git a/extra/couchbase/src/main/webapp/WEB-INF/web.xml b/extra/nosql/couchbase/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from extra/couchbase/src/main/webapp/WEB-INF/web.xml rename to extra/nosql/couchbase/src/main/webapp/WEB-INF/web.xml diff --git a/extra/couchbase/src/main/webapp/index.xhtml b/extra/nosql/couchbase/src/main/webapp/index.xhtml similarity index 100% rename from extra/couchbase/src/main/webapp/index.xhtml rename to extra/nosql/couchbase/src/main/webapp/index.xhtml diff --git a/extra/couchbase/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/couchbase/src/main/webapp/resources/css/cssLayout.css similarity index 100% rename from extra/couchbase/src/main/webapp/resources/css/cssLayout.css rename to extra/nosql/couchbase/src/main/webapp/resources/css/cssLayout.css diff --git a/extra/couchbase/src/main/webapp/resources/css/default.css b/extra/nosql/couchbase/src/main/webapp/resources/css/default.css similarity index 100% rename from extra/couchbase/src/main/webapp/resources/css/default.css rename to extra/nosql/couchbase/src/main/webapp/resources/css/default.css diff --git a/extra/couchbase/src/main/webapp/show.xhtml b/extra/nosql/couchbase/src/main/webapp/show.xhtml similarity index 100% rename from extra/couchbase/src/main/webapp/show.xhtml rename to extra/nosql/couchbase/src/main/webapp/show.xhtml diff --git a/extra/mongo/pom.xml b/extra/nosql/mongo/pom.xml similarity index 83% rename from extra/mongo/pom.xml rename to extra/nosql/mongo/pom.xml index 00fd31e5b..793d799c6 100644 --- a/extra/mongo/pom.xml +++ b/extra/nosql/mongo/pom.xml @@ -2,13 +2,13 @@ 4.0.0 - org.javaee7.extra - extra-samples + org.javaee7.extra.nosql + extra-nosql-samples 1.0-SNAPSHOT ../pom.xml - org.javaee7.extra + org.javaee7.extra.nosql mongo 1.0-SNAPSHOT war diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java b/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/Person.java similarity index 100% rename from extra/mongo/src/main/java/org/javaee7/extra/mongo/Person.java rename to extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/Person.java diff --git a/extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java b/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java similarity index 100% rename from extra/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java rename to extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java diff --git a/extra/mongo/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/mongo/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from extra/mongo/src/main/webapp/WEB-INF/beans.xml rename to extra/nosql/mongo/src/main/webapp/WEB-INF/beans.xml diff --git a/extra/mongo/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/mongo/src/main/webapp/WEB-INF/template.xhtml similarity index 100% rename from extra/mongo/src/main/webapp/WEB-INF/template.xhtml rename to extra/nosql/mongo/src/main/webapp/WEB-INF/template.xhtml diff --git a/extra/mongo/src/main/webapp/WEB-INF/web.xml b/extra/nosql/mongo/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from extra/mongo/src/main/webapp/WEB-INF/web.xml rename to extra/nosql/mongo/src/main/webapp/WEB-INF/web.xml diff --git a/extra/mongo/src/main/webapp/index.xhtml b/extra/nosql/mongo/src/main/webapp/index.xhtml similarity index 100% rename from extra/mongo/src/main/webapp/index.xhtml rename to extra/nosql/mongo/src/main/webapp/index.xhtml diff --git a/extra/mongo/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/mongo/src/main/webapp/resources/css/cssLayout.css similarity index 100% rename from extra/mongo/src/main/webapp/resources/css/cssLayout.css rename to extra/nosql/mongo/src/main/webapp/resources/css/cssLayout.css diff --git a/extra/mongo/src/main/webapp/resources/css/default.css b/extra/nosql/mongo/src/main/webapp/resources/css/default.css similarity index 100% rename from extra/mongo/src/main/webapp/resources/css/default.css rename to extra/nosql/mongo/src/main/webapp/resources/css/default.css diff --git a/extra/mongo/src/main/webapp/show.xhtml b/extra/nosql/mongo/src/main/webapp/show.xhtml similarity index 100% rename from extra/mongo/src/main/webapp/show.xhtml rename to extra/nosql/mongo/src/main/webapp/show.xhtml diff --git a/extra/nosql/pom.xml b/extra/nosql/pom.xml new file mode 100644 index 000000000..b11f5f7f6 --- /dev/null +++ b/extra/nosql/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + org.javaee7.extra + extra-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + pom + Java EE 7 Extra NoSQL Samples + + + mongo + couchbase + redis + + diff --git a/extra/redis/pom.xml b/extra/nosql/redis/pom.xml similarity index 80% rename from extra/redis/pom.xml rename to extra/nosql/redis/pom.xml index ce6b57832..bb38e5f06 100644 --- a/extra/redis/pom.xml +++ b/extra/nosql/redis/pom.xml @@ -2,13 +2,13 @@ 4.0.0 - org.javaee7.extra - extra-samples + org.javaee7.extra.nosql + extra-nosql-samples 1.0-SNAPSHOT ../pom.xml - org.javaee7.extra + org.javaee7.extra.nosql redis 1.0-SNAPSHOT war diff --git a/extra/redis/src/main/java/org/javaee7/extra/redis/Person.java b/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/Person.java similarity index 100% rename from extra/redis/src/main/java/org/javaee7/extra/redis/Person.java rename to extra/nosql/redis/src/main/java/org/javaee7/extra/redis/Person.java diff --git a/extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java b/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java similarity index 100% rename from extra/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java rename to extra/nosql/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java diff --git a/extra/redis/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/redis/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from extra/redis/src/main/webapp/WEB-INF/beans.xml rename to extra/nosql/redis/src/main/webapp/WEB-INF/beans.xml diff --git a/extra/redis/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/redis/src/main/webapp/WEB-INF/template.xhtml similarity index 100% rename from extra/redis/src/main/webapp/WEB-INF/template.xhtml rename to extra/nosql/redis/src/main/webapp/WEB-INF/template.xhtml diff --git a/extra/redis/src/main/webapp/WEB-INF/web.xml b/extra/nosql/redis/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from extra/redis/src/main/webapp/WEB-INF/web.xml rename to extra/nosql/redis/src/main/webapp/WEB-INF/web.xml diff --git a/extra/redis/src/main/webapp/index.xhtml b/extra/nosql/redis/src/main/webapp/index.xhtml similarity index 100% rename from extra/redis/src/main/webapp/index.xhtml rename to extra/nosql/redis/src/main/webapp/index.xhtml diff --git a/extra/redis/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/redis/src/main/webapp/resources/css/cssLayout.css similarity index 100% rename from extra/redis/src/main/webapp/resources/css/cssLayout.css rename to extra/nosql/redis/src/main/webapp/resources/css/cssLayout.css diff --git a/extra/redis/src/main/webapp/resources/css/default.css b/extra/nosql/redis/src/main/webapp/resources/css/default.css similarity index 100% rename from extra/redis/src/main/webapp/resources/css/default.css rename to extra/nosql/redis/src/main/webapp/resources/css/default.css diff --git a/extra/redis/src/main/webapp/show.xhtml b/extra/nosql/redis/src/main/webapp/show.xhtml similarity index 100% rename from extra/redis/src/main/webapp/show.xhtml rename to extra/nosql/redis/src/main/webapp/show.xhtml diff --git a/extra/pom.xml b/extra/pom.xml index 775db0336..3538abb30 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -17,8 +17,6 @@ quartz twitter-search - mongo - couchbase - redis + nosql From e7ad02df7d049c4ed90b854a67a412a7dff0e972 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:13:54 -0700 Subject: [PATCH 0158/1080] Fixing the package name --- .../java/org/javaee7/extra/{ => nosql}/couchbase/Person.java | 2 +- .../javaee7/extra/{ => nosql}/couchbase/PersonSessionBean.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename extra/nosql/couchbase/src/main/java/org/javaee7/extra/{ => nosql}/couchbase/Person.java (98%) rename extra/nosql/couchbase/src/main/java/org/javaee7/extra/{ => nosql}/couchbase/PersonSessionBean.java (98%) diff --git a/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/Person.java similarity index 98% rename from extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java rename to extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/Person.java index 1a72e8409..fa3c3e477 100644 --- a/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/Person.java +++ b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/Person.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.couchbase; +package org.javaee7.extra.nosql.couchbase; import java.io.Serializable; import javax.enterprise.context.ApplicationScoped; diff --git a/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/PersonSessionBean.java similarity index 98% rename from extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java rename to extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/PersonSessionBean.java index e4fb4ccf6..1c591a168 100644 --- a/extra/nosql/couchbase/src/main/java/org/javaee7/extra/couchbase/PersonSessionBean.java +++ b/extra/nosql/couchbase/src/main/java/org/javaee7/extra/nosql/couchbase/PersonSessionBean.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.couchbase; +package org.javaee7.extra.nosql.couchbase; import com.couchbase.client.CouchbaseClient; import java.io.IOException; From b6c5a686d6fef71458976769ef42abbafe49db5a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:14:11 -0700 Subject: [PATCH 0159/1080] Fixing the package name --- .../main/java/org/javaee7/extra/{ => nosql}/mongo/Person.java | 2 +- .../org/javaee7/extra/{ => nosql}/mongo/PersonSessionBean.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename extra/nosql/mongo/src/main/java/org/javaee7/extra/{ => nosql}/mongo/Person.java (98%) rename extra/nosql/mongo/src/main/java/org/javaee7/extra/{ => nosql}/mongo/PersonSessionBean.java (99%) diff --git a/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/Person.java b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/Person.java similarity index 98% rename from extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/Person.java rename to extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/Person.java index eb9c48f21..52c203032 100644 --- a/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/Person.java +++ b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/Person.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.mongo; +package org.javaee7.extra.nosql.mongo; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; diff --git a/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java similarity index 99% rename from extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java rename to extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java index 504fbf884..64ab51cda 100644 --- a/extra/nosql/mongo/src/main/java/org/javaee7/extra/mongo/PersonSessionBean.java +++ b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.mongo; +package org.javaee7.extra.nosql.mongo; import com.mongodb.BasicDBObject; import com.mongodb.DB; From 40e21237069b2dc9e8a69ccad2a190ee227ce6ec Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 14:14:22 -0700 Subject: [PATCH 0160/1080] Fixing the package name --- .../main/java/org/javaee7/extra/{ => nosql}/redis/Person.java | 2 +- .../org/javaee7/extra/{ => nosql}/redis/PersonSessionBean.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename extra/nosql/redis/src/main/java/org/javaee7/extra/{ => nosql}/redis/Person.java (98%) rename extra/nosql/redis/src/main/java/org/javaee7/extra/{ => nosql}/redis/PersonSessionBean.java (98%) diff --git a/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/Person.java b/extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/Person.java similarity index 98% rename from extra/nosql/redis/src/main/java/org/javaee7/extra/redis/Person.java rename to extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/Person.java index 83a5781fd..dfbee998a 100644 --- a/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/Person.java +++ b/extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/Person.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.redis; +package org.javaee7.extra.nosql.redis; import java.util.StringTokenizer; import javax.enterprise.context.ApplicationScoped; diff --git a/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java b/extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/PersonSessionBean.java similarity index 98% rename from extra/nosql/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java rename to extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/PersonSessionBean.java index efdd3b669..5f6884bdf 100644 --- a/extra/nosql/redis/src/main/java/org/javaee7/extra/redis/PersonSessionBean.java +++ b/extra/nosql/redis/src/main/java/org/javaee7/extra/nosql/redis/PersonSessionBean.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.javaee7.extra.redis; +package org.javaee7.extra.nosql.redis; import java.util.ArrayList; import java.util.HashSet; From 772dfcec54e52af97ed01ad9c00f372d3c3759f3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 16:26:45 -0700 Subject: [PATCH 0161/1080] Added a new profile to download s source and javadoc bundles from Maven repository --- pom.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pom.xml b/pom.xml index 7f3ca6bb4..a47a3bf76 100644 --- a/pom.xml +++ b/pom.xml @@ -257,6 +257,32 @@ + + javadocs + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + sources + process-resources + + sources + resolve + + + javadoc + false + + + + + + + From 0689f22dd0a89c07d16796a8b1ebf95f6a64a2b5 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 17:32:29 -0700 Subject: [PATCH 0162/1080] New sample to show Cassandra usage --- extra/nosql/cassandra/pom.xml | 23 ++++ .../javaee7/extra/nosql/cassandra/Person.java | 92 +++++++++++++ .../nosql/cassandra/PersonSessionBean.java | 127 ++++++++++++++++++ .../src/main/webapp/WEB-INF/beans.xml | 49 +++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 ++++ .../cassandra/src/main/webapp/WEB-INF/web.xml | 24 ++++ .../cassandra/src/main/webapp/index.xhtml | 43 ++++++ .../main/webapp/resources/css/cssLayout.css | 61 +++++++++ .../src/main/webapp/resources/css/default.css | 29 ++++ .../cassandra/src/main/webapp/show.xhtml | 27 ++++ extra/nosql/pom.xml | 1 + 11 files changed, 502 insertions(+) create mode 100644 extra/nosql/cassandra/pom.xml create mode 100644 extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/Person.java create mode 100644 extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java create mode 100644 extra/nosql/cassandra/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/nosql/cassandra/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/nosql/cassandra/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/nosql/cassandra/src/main/webapp/index.xhtml create mode 100644 extra/nosql/cassandra/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/nosql/cassandra/src/main/webapp/resources/css/default.css create mode 100644 extra/nosql/cassandra/src/main/webapp/show.xhtml diff --git a/extra/nosql/cassandra/pom.xml b/extra/nosql/cassandra/pom.xml new file mode 100644 index 000000000..cf5864490 --- /dev/null +++ b/extra/nosql/cassandra/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + cassandra + 1.0-SNAPSHOT + war + + + + com.datastax.cassandra + cassandra-driver-core + 2.0.0-beta2 + + + diff --git a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/Person.java b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/Person.java new file mode 100644 index 000000000..eb527a41e --- /dev/null +++ b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/Person.java @@ -0,0 +1,92 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.cassandra; + +import java.util.StringTokenizer; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + return new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + } +} diff --git a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java new file mode 100644 index 000000000..23d0677e6 --- /dev/null +++ b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java @@ -0,0 +1,127 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.cassandra; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Host; +import com.datastax.driver.core.Metadata; +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Row; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.exceptions.AlreadyExistsException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.Singleton; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author Arun Gupta + */ +@Named +@Singleton +public class PersonSessionBean { + + @Inject + Person person; + + Set set = new HashSet<>(); + + private Cluster cluster; + private Session session; + + @PostConstruct + private void initDB() { + cluster = Cluster.builder() + .addContactPoint("localhost") + // .withSSL() // Uncomment if using client to node encryption + .build(); + Metadata metadata = cluster.getMetadata(); + System.out.printf("Connected to cluster: %s\n", metadata.getClusterName()); + for (Host host : metadata.getAllHosts()) { + System.out.printf("Datacenter: %s; Host: %s; Rack: %s\n", + host.getDatacenter(), host.getAddress(), host.getRack()); + } + session = cluster.connect(); + try { + session.execute("CREATE KEYSPACE test WITH replication " + + "= {'class':'SimpleStrategy', 'replication_factor':3};"); + } catch (AlreadyExistsException e) { + System.out.println(e.getLocalizedMessage() + " ... keep moving!"); + } + try { + session.execute( + "CREATE TABLE test.person (" + + "name text PRIMARY KEY," + + "age int" + + ");"); + } catch (AlreadyExistsException e) { + System.out.println(e.getLocalizedMessage() + " ... keep moving!"); + } + } + + @PreDestroy + private void stopDB() { + cluster.shutdown(); + } + + public void createPerson() { + session.execute( + "INSERT INTO test.person (name, age) " + + "VALUES (" + + "'" + person.getName() + "'," + + person.getAge() + ")" + + ";"); +// set.add(person.getName()); + } + + public List getPersons() { + List persons = new ArrayList<>(); + ResultSet results = session.execute("SELECT * FROM test.person;"); + for (Row row : results) { + persons.add(new Person(row.getString("name"), row.getInt("age"))); + } + return persons; + } +} diff --git a/extra/nosql/cassandra/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/cassandra/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/nosql/cassandra/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/cassandra/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..82f183175 --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Cassandra using Java EE 7 + + + + +
    +

    Cassandra using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/cassandra/src/main/webapp/WEB-INF/web.xml b/extra/nosql/cassandra/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/cassandra/src/main/webapp/index.xhtml b/extra/nosql/cassandra/src/main/webapp/index.xhtml new file mode 100644 index 000000000..f9d6dd768 --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/index.xhtml @@ -0,0 +1,43 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    +
      +
    • Make sure to download latest Cassandra server and untar.
    • +
    • Follow the instructions in the bundled README.txt to start the server: +
        +
      • sudo mkdir -p /var/log/cassandra
      • +
      • sudo chown -R `whoami` /var/log/cassandra
      • +
      • sudo mkdir -p /var/lib/cassandra
      • +
      • sudo chown -R `whoami` /var/lib/cassandra
      • +
      • bin/cassandra -f
      +
    • +
    • Look for message as: +
      +INFO 16:39:08,258 Binding thrift service to localhost/127.0.0.1:9160
      +INFO 16:39:08,266 Using synchronous/threadpool thrift server on localhost : 9160
      +INFO 16:39:08,293 Listening for thrift clients...
      +                        
      +
    • +
    +
    + +
    + + + diff --git a/extra/nosql/cassandra/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/cassandra/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/cassandra/src/main/webapp/resources/css/default.css b/extra/nosql/cassandra/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/cassandra/src/main/webapp/show.xhtml b/extra/nosql/cassandra/src/main/webapp/show.xhtml new file mode 100644 index 000000000..8f1d60f31 --- /dev/null +++ b/extra/nosql/cassandra/src/main/webapp/show.xhtml @@ -0,0 +1,27 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + diff --git a/extra/nosql/pom.xml b/extra/nosql/pom.xml index b11f5f7f6..f00b553af 100644 --- a/extra/nosql/pom.xml +++ b/extra/nosql/pom.xml @@ -18,5 +18,6 @@ mongo couchbase redis + cassandra
    From 3ca5d0639a6f7d8c9e64da676e3622b3366c5b52 Mon Sep 17 00:00:00 2001 From: Michael Figuiere Date: Thu, 3 Oct 2013 19:01:53 -0700 Subject: [PATCH 0163/1080] Uses PreparedStatements instead of contatenated strings. Replaces AlreadyExistsException with "IF NOT EXISTS" DDL statements added in Cassandra 2.0. --- .../nosql/cassandra/PersonSessionBean.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java index 23d0677e6..649d01e1d 100644 --- a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java +++ b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java @@ -42,14 +42,16 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Host; import com.datastax.driver.core.Metadata; +import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; -import com.datastax.driver.core.exceptions.AlreadyExistsException; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; + import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.ejb.Singleton; @@ -71,6 +73,9 @@ public class PersonSessionBean { private Cluster cluster; private Session session; + private PreparedStatement selectAllPersons; + private PreparedStatement insertPerson; + @PostConstruct private void initDB() { cluster = Cluster.builder() @@ -84,21 +89,19 @@ private void initDB() { host.getDatacenter(), host.getAddress(), host.getRack()); } session = cluster.connect(); - try { - session.execute("CREATE KEYSPACE test WITH replication " - + "= {'class':'SimpleStrategy', 'replication_factor':3};"); - } catch (AlreadyExistsException e) { - System.out.println(e.getLocalizedMessage() + " ... keep moving!"); - } - try { + session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH replication " + + "= {'class':'SimpleStrategy', 'replication_factor':1};"); + session.execute( - "CREATE TABLE test.person (" + "CREATE TABLE IF NOT EXISTS test.person (" + "name text PRIMARY KEY," + "age int" + ");"); - } catch (AlreadyExistsException e) { - System.out.println(e.getLocalizedMessage() + " ... keep moving!"); - } + + selectAllPersons = session.prepare("SELECT * FROM test.person"); + insertPerson = session.prepare( + "INSERT INTO test.person (name, age) VALUES (?, ?);" + ); } @PreDestroy @@ -107,18 +110,13 @@ private void stopDB() { } public void createPerson() { - session.execute( - "INSERT INTO test.person (name, age) " - + "VALUES (" - + "'" + person.getName() + "'," - + person.getAge() + ")" - + ";"); -// set.add(person.getName()); + session.execute(insertPerson.bind(person.getName(), person.getAge())); +// set.add(person.getName()); } public List getPersons() { List persons = new ArrayList<>(); - ResultSet results = session.execute("SELECT * FROM test.person;"); + ResultSet results = session.execute(selectAllPersons.bind()); for (Row row : results) { persons.add(new Person(row.getString("name"), row.getInt("age"))); } From 12cffb361b1bc3b62f964129632e8bb9b6af7fd0 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:06:07 -0700 Subject: [PATCH 0164/1080] Removing some redundant code --- .../org/javaee7/extra/nosql/cassandra/PersonSessionBean.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java index 649d01e1d..5cf4c67d2 100644 --- a/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java +++ b/extra/nosql/cassandra/src/main/java/org/javaee7/extra/nosql/cassandra/PersonSessionBean.java @@ -48,9 +48,7 @@ import com.datastax.driver.core.Session; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -68,8 +66,6 @@ public class PersonSessionBean { @Inject Person person; - Set set = new HashSet<>(); - private Cluster cluster; private Session session; @@ -111,7 +107,6 @@ private void stopDB() { public void createPerson() { session.execute(insertPerson.bind(person.getName(), person.getAge())); -// set.add(person.getName()); } public List getPersons() { From bfc51422b58d5e3e87a14dd80236a676de39294b Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:19:04 -0700 Subject: [PATCH 0165/1080] Adding navigation to the previous page --- extra/nosql/mongo/src/main/webapp/show.xhtml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extra/nosql/mongo/src/main/webapp/show.xhtml b/extra/nosql/mongo/src/main/webapp/show.xhtml index 19203f612..5ffc5aae0 100644 --- a/extra/nosql/mongo/src/main/webapp/show.xhtml +++ b/extra/nosql/mongo/src/main/webapp/show.xhtml @@ -14,6 +14,10 @@ Name#{p.name} Age#{p.age} +

    + + + From ee5b4c4dd3e37716732dd180cdc5ab0bd42bf70e Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:19:21 -0700 Subject: [PATCH 0166/1080] Adding instructions to download, configure and start Mongo --- extra/nosql/mongo/src/main/webapp/index.xhtml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extra/nosql/mongo/src/main/webapp/index.xhtml b/extra/nosql/mongo/src/main/webapp/index.xhtml index db1c9bca4..aaf6bc1f3 100644 --- a/extra/nosql/mongo/src/main/webapp/index.xhtml +++ b/extra/nosql/mongo/src/main/webapp/index.xhtml @@ -17,6 +17,13 @@ title="Add" value="Submit"/> +
    + Make sure to download Mongo. Follow the quick start to start the server: +
      +
    • sudo mkdir -p /data/db
    • +
    • sudo chown `id -u` /data/db
    • +
    • ./bin/mongod
    • +
    From e9714584600488f98bfa879b6f6b193b6da9e6dc Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:20:35 -0700 Subject: [PATCH 0167/1080] Removing the usage of embedded Mongo, asking the users to explicitly start Mongo --- .../extra/nosql/mongo/PersonSessionBean.java | 35 +++---------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java index 64ab51cda..0532ed813 100644 --- a/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java +++ b/extra/nosql/mongo/src/main/java/org/javaee7/extra/nosql/mongo/PersonSessionBean.java @@ -45,21 +45,12 @@ import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mongodb.Mongo; -import com.mongodb.MongoException; -import de.flapdoodle.embed.mongo.MongodExecutable; -import de.flapdoodle.embed.mongo.MongodProcess; -import de.flapdoodle.embed.mongo.MongodStarter; -import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; -import de.flapdoodle.embed.mongo.config.Net; -import de.flapdoodle.embed.mongo.distribution.Version; -import de.flapdoodle.embed.process.runtime.Network; -import java.io.IOException; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; import javax.ejb.Stateless; import javax.inject.Inject; import javax.inject.Named; @@ -76,39 +67,21 @@ public class PersonSessionBean { DBCollection personCollection; - private MongodExecutable mongodExe; - private MongodProcess mongod; - private final int MONGO_PORT = 12345; - @PostConstruct private void initDB() { - try { - // Start embedded Mongo - MongodStarter runtime = MongodStarter.getDefaultInstance(); - mongodExe = runtime.prepare(new MongodConfigBuilder() - .version(Version.Main.PRODUCTION) - .net(new Net(MONGO_PORT, Network.localhostIsIPv6())) - .build()); - mongod = mongodExe.start(); - + try { // Get an instance of Mongo - Mongo m = new Mongo("localhost", MONGO_PORT); + Mongo m = new Mongo("localhost", 27017); DB db = m.getDB("personDB"); personCollection = db.getCollection("persons"); if (personCollection == null) { personCollection = db.createCollection("persons", null); } - } catch (MongoException | IOException ex) { + } catch (UnknownHostException ex) { Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); } } - @PreDestroy - private void stopDB() { - mongod.stop(); - mongodExe.stop(); - } - public void createPerson() { BasicDBObject doc = person.toDBObject(); personCollection.insert(doc); From a488d82c80b82f6ede0dab47b5636a1d328d6574 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:20:51 -0700 Subject: [PATCH 0168/1080] Removing the redundant dependency --- extra/nosql/mongo/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/extra/nosql/mongo/pom.xml b/extra/nosql/mongo/pom.xml index 793d799c6..152582c7c 100644 --- a/extra/nosql/mongo/pom.xml +++ b/extra/nosql/mongo/pom.xml @@ -19,10 +19,5 @@ mongo-java-driver 1.3 - - de.flapdoodle.embed - de.flapdoodle.embed.mongo - 1.36 -
    From cbd39b89f4e1d9393ccf2fa8eec8f7116ddb42c7 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 3 Oct 2013 22:30:19 -0700 Subject: [PATCH 0169/1080] Samples can run using Embedded GlassFish using "embedded-glassfish" profile --- pom.xml | 91 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index a47a3bf76..72dd86b90 100644 --- a/pom.xml +++ b/pom.xml @@ -111,48 +111,6 @@ - - org.glassfish.embedded - maven-embedded-glassfish-plugin - 4.0 - - target/${project.artifactId}.war - 8080 - - 8181 - - - - - org.glassfish.main.common - simple-glassfish-api - 4.0 - - - org.glassfish.main.extras - glassfish-embedded-all - 4.0 - - - - - start - integration-test - - start - deploy - - - - stop - post-integration-test - - undeploy - stop - - - - @@ -194,6 +152,55 @@ + + embedded-glassfish + + + + org.glassfish.embedded + maven-embedded-glassfish-plugin + 4.0 + + target/${project.artifactId}.war + 8080 + + 8181 + + + + + org.glassfish.main.common + simple-glassfish-api + 4.0 + + + org.glassfish.main.extras + glassfish-embedded-all + 4.0 + + + + + start + integration-test + + start + deploy + + + + stop + post-integration-test + + undeploy + stop + + + + + + + wildfly From fa5c17910442ae3f76f06e6bf39264ba15730a56 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 4 Oct 2013 17:40:58 -0700 Subject: [PATCH 0170/1080] Starting work on Neo4j sample --- extra/nosql/neo4j/pom.xml | 23 +++ .../extra/nosql/neo4j/BackingBean.java | 119 ++++++++++++++ .../org/javaee7/extra/nosql/neo4j/Person.java | 90 +++++++++++ .../extra/nosql/neo4j/PersonSessionBean.java | 148 ++++++++++++++++++ .../neo4j/src/main/webapp/WEB-INF/beans.xml | 49 ++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 +++ .../neo4j/src/main/webapp/WEB-INF/web.xml | 24 +++ extra/nosql/neo4j/src/main/webapp/index.xhtml | 36 +++++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++ .../src/main/webapp/resources/css/default.css | 29 ++++ extra/nosql/neo4j/src/main/webapp/show.xhtml | 28 ++++ 11 files changed, 633 insertions(+) create mode 100644 extra/nosql/neo4j/pom.xml create mode 100644 extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/BackingBean.java create mode 100644 extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/Person.java create mode 100644 extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java create mode 100644 extra/nosql/neo4j/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/nosql/neo4j/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/nosql/neo4j/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/nosql/neo4j/src/main/webapp/index.xhtml create mode 100644 extra/nosql/neo4j/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/nosql/neo4j/src/main/webapp/resources/css/default.css create mode 100644 extra/nosql/neo4j/src/main/webapp/show.xhtml diff --git a/extra/nosql/neo4j/pom.xml b/extra/nosql/neo4j/pom.xml new file mode 100644 index 000000000..3abd78f3d --- /dev/null +++ b/extra/nosql/neo4j/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + neo4j + 1.0-SNAPSHOT + war + + + + org.neo4j + neo4j + 2.0.0-M05 + + + diff --git a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/BackingBean.java b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/BackingBean.java new file mode 100644 index 000000000..2b13229f8 --- /dev/null +++ b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/BackingBean.java @@ -0,0 +1,119 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.neo4j; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class BackingBean { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + private String name2; + + private int age2; + + private String relationship; + + public BackingBean() { + } + + public BackingBean(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getName2() { + return name2; + } + + public void setName2(String name2) { + this.name2 = name2; + } + + public int getAge2() { + return age2; + } + + public void setAge2(int age2) { + this.age2 = age2; + } + + public String getRelationship() { + return relationship; + } + + public void setRelationship(String relationship) { + this.relationship = relationship; + } + + public String person1String() { + return name + ", " + age; + } + + public String person2String() { + return name2 + ", " + age2; + } +} diff --git a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/Person.java b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/Person.java new file mode 100644 index 000000000..cf4323903 --- /dev/null +++ b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/Person.java @@ -0,0 +1,90 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.neo4j; + +import java.util.StringTokenizer; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static final Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + Person p = new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + + return p; + } +} diff --git a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java new file mode 100644 index 000000000..f86b4bc00 --- /dev/null +++ b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java @@ -0,0 +1,148 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.neo4j; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Relationship; +import org.neo4j.graphdb.RelationshipType; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseFactory; + +/** + * @author Arun Gupta + */ +@Named +@Singleton +public class PersonSessionBean { + + @Inject + BackingBean backingBean; + + GraphDatabaseService graphDb; + Node firstNode; + Node secondNode; + + private static enum RelTypes implements RelationshipType { + + SPOUSE, BROTHER, SISTER + } + + Set set = new HashSet<>(); + + @PostConstruct + private void initDB() { + try { + Path tempDir = Files.createTempDirectory("test-neo4j"); +// Set perms = PosixFilePermissions.fromString("rwxr-x---"); +// FileAttribute> attr = PosixFilePermissions.asFileAttribute(perms); +// Files.createDirectories(DB_PATH, attr); + graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(tempDir.toString()); + try (Transaction tx = graphDb.beginTx()) { + firstNode = graphDb.createNode(); + secondNode = graphDb.createNode(); + } + } catch (IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @PreDestroy + private void stopDB() { + graphDb.shutdown(); + } + + public void createPerson() { + try (Transaction tx = graphDb.beginTx()) { + firstNode.setProperty(backingBean.getName(), backingBean.person1String()); + secondNode.setProperty(backingBean.getName2(), backingBean.person2String()); + switch (backingBean.getRelationship()) { + case "spouse": + firstNode.createRelationshipTo(secondNode, RelTypes.SPOUSE); + break; + case "brother": + firstNode.createRelationshipTo(secondNode, RelTypes.BROTHER); + break; + case "sister": + firstNode.createRelationshipTo(secondNode, RelTypes.SISTER); + break; + } + tx.success(); + } + } + + public List getPersons() { + List beans = new ArrayList(); + for (String key : firstNode.getPropertyKeys()) { + BackingBean bean = new BackingBean(); + Person p = Person.fromString((String)firstNode.getProperty(key)); + bean.setName(p.getName()); + bean.setAge(p.getAge()); + for (Relationship r : firstNode.getRelationships(RelTypes.SPOUSE, RelTypes.SISTER, RelTypes.BROTHER)) { + if (r.isType(RelTypes.SPOUSE)) { + bean.setRelationship("spouse"); + } else if (r.isType(RelTypes.SISTER)) { + bean.setRelationship("sister"); + } else if (r.isType(RelTypes.BROTHER)) { + bean.setRelationship("brother"); + } + } + beans.add(bean); + } + return beans; + } +} diff --git a/extra/nosql/neo4j/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/neo4j/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/nosql/neo4j/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/neo4j/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..9eb7c0652 --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Couchbase using Java EE 7 + + + + +
    +

    Couchbase using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/neo4j/src/main/webapp/WEB-INF/web.xml b/extra/nosql/neo4j/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/neo4j/src/main/webapp/index.xhtml b/extra/nosql/neo4j/src/main/webapp/index.xhtml new file mode 100644 index 000000000..6995adb2a --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/index.xhtml @@ -0,0 +1,36 @@ + + + + + + + + + + + Name:
    + Age:

    + Related as: + + + + +

    + + Name2:
    + Age2:

    + +
    +
    + Download Neo4j Community version. Untar and start the server as "bin/neo4j start". +
    + +
    + + + diff --git a/extra/nosql/neo4j/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/neo4j/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/neo4j/src/main/webapp/resources/css/default.css b/extra/nosql/neo4j/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/neo4j/src/main/webapp/show.xhtml b/extra/nosql/neo4j/src/main/webapp/show.xhtml new file mode 100644 index 000000000..48b1ea71c --- /dev/null +++ b/extra/nosql/neo4j/src/main/webapp/show.xhtml @@ -0,0 +1,28 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + Relationship#{p.relationship} + +

    + + + + +
    + +
    + + + From cacbe635fdd3be2122e8123d5d9f402f3c86ed00 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 4 Oct 2013 23:12:18 -0700 Subject: [PATCH 0171/1080] Marking transactions for committing during close --- .../extra/nosql/neo4j/PersonSessionBean.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java index f86b4bc00..f4e2ffba7 100644 --- a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java +++ b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java @@ -42,9 +42,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.attribute.FileAttribute; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -78,7 +75,6 @@ public class PersonSessionBean { Node secondNode; private static enum RelTypes implements RelationshipType { - SPOUSE, BROTHER, SISTER } @@ -88,15 +84,13 @@ private static enum RelTypes implements RelationshipType { private void initDB() { try { Path tempDir = Files.createTempDirectory("test-neo4j"); -// Set perms = PosixFilePermissions.fromString("rwxr-x---"); -// FileAttribute> attr = PosixFilePermissions.asFileAttribute(perms); -// Files.createDirectories(DB_PATH, attr); graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(tempDir.toString()); try (Transaction tx = graphDb.beginTx()) { firstNode = graphDb.createNode(); secondNode = graphDb.createNode(); + tx.success(); } - } catch (IOException ex) { + } catch (IOException ex) { Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); } } @@ -127,21 +121,24 @@ public void createPerson() { public List getPersons() { List beans = new ArrayList(); - for (String key : firstNode.getPropertyKeys()) { - BackingBean bean = new BackingBean(); - Person p = Person.fromString((String)firstNode.getProperty(key)); - bean.setName(p.getName()); - bean.setAge(p.getAge()); - for (Relationship r : firstNode.getRelationships(RelTypes.SPOUSE, RelTypes.SISTER, RelTypes.BROTHER)) { - if (r.isType(RelTypes.SPOUSE)) { - bean.setRelationship("spouse"); - } else if (r.isType(RelTypes.SISTER)) { - bean.setRelationship("sister"); - } else if (r.isType(RelTypes.BROTHER)) { - bean.setRelationship("brother"); + try (Transaction tx = graphDb.beginTx()) { + for (String key : firstNode.getPropertyKeys()) { + BackingBean bean = new BackingBean(); + Person p = Person.fromString((String) firstNode.getProperty(key)); + bean.setName(p.getName()); + bean.setAge(p.getAge()); + for (Relationship r : firstNode.getRelationships(RelTypes.SPOUSE, RelTypes.SISTER, RelTypes.BROTHER)) { + if (r.isType(RelTypes.SPOUSE)) { + bean.setRelationship("spouse"); + } else if (r.isType(RelTypes.SISTER)) { + bean.setRelationship("sister"); + } else if (r.isType(RelTypes.BROTHER)) { + bean.setRelationship("brother"); + } } + beans.add(bean); } - beans.add(bean); + tx.success(); } return beans; } From 24b94b6bb1ff816ce6838928a3e8df896fe9875f Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 4 Oct 2013 23:12:40 -0700 Subject: [PATCH 0172/1080] Adding neo4j sample --- extra/nosql/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/nosql/pom.xml b/extra/nosql/pom.xml index f00b553af..b18f17bf3 100644 --- a/extra/nosql/pom.xml +++ b/extra/nosql/pom.xml @@ -19,5 +19,6 @@ couchbase redis cassandra + neo4j From 5131a1d9c14398ed44e0d7615fe94a00832a7402 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Fri, 4 Oct 2013 23:20:55 -0700 Subject: [PATCH 0173/1080] Adding a break to avoid redundant evaluation --- .../java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java index f4e2ffba7..407917d58 100644 --- a/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java +++ b/extra/nosql/neo4j/src/main/java/org/javaee7/extra/nosql/neo4j/PersonSessionBean.java @@ -130,10 +130,13 @@ public List getPersons() { for (Relationship r : firstNode.getRelationships(RelTypes.SPOUSE, RelTypes.SISTER, RelTypes.BROTHER)) { if (r.isType(RelTypes.SPOUSE)) { bean.setRelationship("spouse"); + break; } else if (r.isType(RelTypes.SISTER)) { bean.setRelationship("sister"); + break; } else if (r.isType(RelTypes.BROTHER)) { bean.setRelationship("brother"); + break; } } beans.add(bean); From 21179a3dabb85695f95a7b17c3e923bf077f17b3 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Sun, 6 Oct 2013 21:50:44 -0700 Subject: [PATCH 0174/1080] Starting work on HBase sample --- extra/nosql/hbase/pom.xml | 28 +++ .../org/javaee7/extra/nosql/hbase/Person.java | 92 ++++++++++ .../extra/nosql/hbase/PersonSessionBean.java | 162 ++++++++++++++++++ .../hbase/src/main/webapp/WEB-INF/beans.xml | 49 ++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 +++ .../hbase/src/main/webapp/WEB-INF/web.xml | 24 +++ extra/nosql/hbase/src/main/webapp/index.xhtml | 33 ++++ .../main/webapp/resources/css/cssLayout.css | 61 +++++++ .../src/main/webapp/resources/css/default.css | 29 ++++ extra/nosql/hbase/src/main/webapp/show.xhtml | 29 ++++ 10 files changed, 533 insertions(+) create mode 100644 extra/nosql/hbase/pom.xml create mode 100644 extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/Person.java create mode 100644 extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/PersonSessionBean.java create mode 100644 extra/nosql/hbase/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/nosql/hbase/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/nosql/hbase/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/nosql/hbase/src/main/webapp/index.xhtml create mode 100644 extra/nosql/hbase/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/nosql/hbase/src/main/webapp/resources/css/default.css create mode 100644 extra/nosql/hbase/src/main/webapp/show.xhtml diff --git a/extra/nosql/hbase/pom.xml b/extra/nosql/hbase/pom.xml new file mode 100644 index 000000000..574b06db3 --- /dev/null +++ b/extra/nosql/hbase/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + hbase + 1.0-SNAPSHOT + war + + + + org.apache.hadoop + hadoop-core + 0.20.2 + + + org.apache.hbase + hbase + 0.90.2 + + + diff --git a/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/Person.java b/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/Person.java new file mode 100644 index 000000000..0842f0198 --- /dev/null +++ b/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/Person.java @@ -0,0 +1,92 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.hbase; + +import java.util.StringTokenizer; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + return new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + } +} diff --git a/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/PersonSessionBean.java b/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/PersonSessionBean.java new file mode 100644 index 000000000..10643fd11 --- /dev/null +++ b/extra/nosql/hbase/src/main/java/org/javaee7/extra/nosql/hbase/PersonSessionBean.java @@ -0,0 +1,162 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.hbase; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.Stateless; +import javax.inject.Inject; +import javax.inject.Named; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.client.HBaseAdmin; +import org.apache.hadoop.hbase.client.HTableInterface; +import org.apache.hadoop.hbase.client.HTablePool; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.util.Bytes; + +/** + * @author Arun Gupta + */ +@Named +@Stateless +public class PersonSessionBean { + + @Inject + Person person; + + Set set = new HashSet<>(); + + private static final String personsColumnFamily = "person"; + private static final String personsTable = "persons"; + HTablePool pool; + + @PostConstruct + private void initDB() { + try { + // By default, it's localhost, don't worry. + Configuration config = HBaseConfiguration.create(); + + // Without pooling, the connection to a table will be reinitialized. + // Creating a new connection to a table might take up to 5-10 seconds! + pool = new HTablePool(config, 10); + + HBaseAdmin admin = new HBaseAdmin(config); + HTableDescriptor blogstable = new HTableDescriptor(personsTable); + admin.createTable(blogstable); + + // Cannot edit a stucture on an active table. + admin.disableTable(personsTable); + + HColumnDescriptor userCol = new HColumnDescriptor("name"); + admin.addColumn(personsTable, userCol); + + HColumnDescriptor ageCol = new HColumnDescriptor("age"); + admin.addColumn(personsTable, ageCol); + + // For readin, it needs to be re-enabled. + admin.enableTable(personsTable); + } catch (IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @PreDestroy + private void stopDB() { + } + + public void createPerson() { + try { + HTableInterface table = pool.getTable(personsTable); + Put put = new Put(Bytes.toBytes(person.getName())); + put.add( + Bytes.toBytes(personsColumnFamily), + Bytes.toBytes(person.getName()), + Bytes.toBytes(person.getAge())); + table.put(put); + table.close(); + } catch (IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public List getPersons() { + List persons = new ArrayList<>(); + + try { + HTableInterface table = pool.getTable(personsTable); + Scan scan = new Scan(); + scan.addFamily(Bytes.toBytes(personsColumnFamily)); + + ResultScanner resultScanner = table.getScanner(scan); + +// For each row + for (Result result : resultScanner) { + for (KeyValue kv : result.raw()) { + Person p = new Person(); +// p.setTitle(Bytes.toString(kv.getQualifier())); +// p.setBody(Bytes.toString(kv.getValue())); +// p.setId(Bytes.toString(result.getRow())); + persons.add(person); + } + } + + resultScanner.close(); + table.close(); + } catch (IOException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + + return persons; + } +} diff --git a/extra/nosql/hbase/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/hbase/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/nosql/hbase/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/hbase/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..c0d6c22b3 --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Redis using Java EE 7 + + + + +
    +

    Redis using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/hbase/src/main/webapp/WEB-INF/web.xml b/extra/nosql/hbase/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/hbase/src/main/webapp/index.xhtml b/extra/nosql/hbase/src/main/webapp/index.xhtml new file mode 100644 index 000000000..e2f909985 --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/index.xhtml @@ -0,0 +1,33 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    +

    +
      +
    • Download HBase stable and tar xzvf.
    • +
    • Start HBase: ./bin/start-hbase.sh
    • +
    • Look for messages like:
      + starting master, logging to /Users/arungup/tools/hbase/hbase-0.94.12/bin/../logs/hbase-arungup-master-arungup-mac.local.out +
    • +
    +
    + +
    + + + diff --git a/extra/nosql/hbase/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/hbase/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/hbase/src/main/webapp/resources/css/default.css b/extra/nosql/hbase/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/hbase/src/main/webapp/show.xhtml b/extra/nosql/hbase/src/main/webapp/show.xhtml new file mode 100644 index 000000000..342b4446b --- /dev/null +++ b/extra/nosql/hbase/src/main/webapp/show.xhtml @@ -0,0 +1,29 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + From 743c01967074ad713a9b42d78bc4f304f5af471e Mon Sep 17 00:00:00 2001 From: Heiko Scherrer Date: Mon, 7 Oct 2013 09:15:39 +0200 Subject: [PATCH 0175/1080] Fixed javadocs and sources download --- .gitignore | 198 +++++++++++++++++++++-------------------------------- pom.xml | 11 ++- 2 files changed, 87 insertions(+), 122 deletions(-) diff --git a/.gitignore b/.gitignore index 4da7b0943..4f469494d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,121 +1,77 @@ -/jaxrs/resource-validation/target/ -/jaxrs/mapping-exceptions/target/ -/jaxrs/server-negotiation/target/ -/jaxrs/async-client/target/ -/batch/flow/target/ -/batch/batchlet-simple/target/ -/batch/chunk-checkpoint/target/ -/batch/chunk-exception/target/ -/batch/chunk-mapper/target/ -/batch/decision/target/ -/batch/listeners/target/ -/batch/multiple-steps/target/ -/batch/split/target/ -/batch/chunk-simple-nobeans/target/ -/json/object-builder/target/ -/json/object-reader/target/ -/json/streaming-generate/target/ -/json/streaming-parser/target/ -/websocket/binary/target/ -/websocket/whiteboard/target/ -/cdi/vetoed/target/ -/cdi/pkg-level/target/ -/cdi/decorators/target/ -/cdi/bean-discovery-all/target/ -/cdi/bean-discovery-none/target/ -/cdi/bean-discovery-annotated/target/ -/cdi/exclude-filter/target/ -/cdi/built-in/target/ -/cdi/interceptors/target/ -/cdi/nobeans-xml/target/ -/cdi/beansxml-noversion/target/ -/cdi/beanmanager/target/ -/concurrency/dynamicproxy/target/ -/concurrency/executor/target/ -/concurrency/schedule/target/ -/concurrency/threads/target/ -/websocket/chat/target/ -/websocket/encoder/target/ -/websocket/encoder-client/target/ -/websocket/encoder-programmatic/target/ -/websocket/endpoint/target/ -/websocket/endpoint-async/target/ -/jaxrs/endpoint/target/ -/jaxrs/client/target/ -/jsf/server-extension/target/ -/jaxrs/jaxrs-endpoint/target/ -/jaxrs/jaxrs-client/target/ -/jsf/http-get/target/ -/websocket/endpoint-javatypes/target/ -/websocket/endpoint-config/target/ -/websocket/endpoint-programmatic/target/ -/websocket/endpoint-programmatic-async/target/ -/websocket/endpoint-programmatic-config/target/ -/websocket/endpoint-programmatic-injection/target/ -/websocket/endpoint-security/target/ -/websocket/httpsession/target/ -/websocket/injection/target/ -/websocket/messagesize/target/ -/websocket/parameters/target/ -/websocket/websocket-vs-rest/target/ -/websocket/subprotocol/target/ -/websocket/websocket-client/target/ -/websocket/websocket-client-config/target/ -/websocket/websocket-client-programmatic/target/ -/websocket/websocket-client-programmatic-config/target/ -/websocket/websocket-client-programmatic-encoders/target/ -/websocket/javase-client/target/ -/ejb/stateful/target/ -/jpa/pu-typesafe/target/ -/jpa/criteria/target/ -/jta/transactional/target/ -/jta/transaction-scope/target/ -/jta/tx-exception/target/ -/ejb/stateless/target/ -/servlet/cookies/target/ -/jpa/schema-gen-scripts/target/ -/jta/user-transaction/target/ -/ejb/singleton/target/ -/ejb/lifecycle/singleton/target/ -/servlet/async-servlet/target/ -/jms/send-receive-simple/target/ -/jms/send-receive/target/ -/servlet/error-mapping/target/ -/servlet/event-listeners/target/ -/servlet/metadata-complete/target/ -/servlet/nonblocking/target/ -/servlet/resource-packaging/target/ -/servlet/servlet-filters/target/ -/servlet/web-fragment/target/ -/servlet/servlet-security/target/ -/jsf/flows-simple/target/ -/jsf/flows-mixed/target/ -/jaxrs/client-negotiation/target/ -/jpa/schema-gen-scripts-generate/target/ -/jaxrs/readerwriter-injection/target/ -/jsf/flows-programmatic/target/ -/jsf/flows-declarative/target/ -/javamail/definition/target/ -/jta/transactional-scope/target/ -/cdi/extension-impl/target/ -/cdi/extension/target/ -/batch/chunk-csv-database/target/ -/batch/chunk-optional-processor/target/ -/batch/chunk-partition/target/ -/jpa/listeners/target/ -/jpa/multiple-pu/target/ -/json/twitter-search/target/ -/jsf/radio-buttons/target/ -/jsf/viewscoped/target/ -/ejb/lifecycle/target/ -/jpa/schema-gen/target/ -/jpa/storedprocedure/target/ -/jsf/contracts/target/ -/jsf/contracts-library/target/ -/jsf/file-upload/target/ -/extra/quartz/target/ -/extra/twitter-search/target/ -/concurrency/managedexecutor/target/ -/concurrency/managedscheduledexecutor/target/ -/concurrency/manageablethread/target/ -/batch/chunk-simple/target/ \ No newline at end of file +# Directories # +/build/ +/bin/ +target/ +libs/ + +# OS Files # +.DS_Store + +*.class + +# Package Files # +*.jar +*.war +*.ear +*.db +rebel.xml + +###################### +# Windows +###################### + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# OSX +###################### + +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +###################### +# IDEA +###################### +*.iml + +###################### +# Eclipse +###################### + +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +/src/main/resources/rebel.xml +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath \ No newline at end of file diff --git a/pom.xml b/pom.xml index 72dd86b90..0bda70765 100644 --- a/pom.xml +++ b/pom.xml @@ -266,12 +266,21 @@
    javadocs + javadocs + org.apache.maven.plugins maven-dependency-plugin - 2.8 + 2.4 sources From d85165f994535b37466b5521fc8c691ecc5523ab Mon Sep 17 00:00:00 2001 From: Heiko Scherrer Date: Mon, 7 Oct 2013 19:49:17 +0200 Subject: [PATCH 0176/1080] Added maven-enforcer-plugin to take care of Maven in version 3.x and Java 1.7, to avoid clashes on developer environment --- pom.xml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 0bda70765..44267415d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.javaee7 @@ -9,6 +9,8 @@ Java EE 7 Samples + 1.7 + 3.0.0 glassfish4x /Users/arungup/tools/glassfish/4.0/final/glassfish4 wildfly8x @@ -17,8 +19,11 @@ weblogic12x /Users/arungup/tools/weblogic/12c/wlserver gfv3ee6 + + + 1.3.1 - + javax @@ -33,7 +38,7 @@ provided - + codehaus-snapshots @@ -70,8 +75,8 @@ maven-compiler-plugin 2.3.2 - 1.7 - 1.7 + ${java.min.version} + ${java.min.version} @@ -111,9 +116,36 @@ + + maven-enforcer-plugin + + + + At least Maven in version ${maven.min.version} is required. + ${maven.min.version} + + + At least a JDK in version ${java.min.version} is required. + ${java.min.version} + + + + + enforce + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${plugin.enforcer.version} + + + - + glassfish @@ -165,14 +197,14 @@ 8080 8181 - + org.glassfish.main.common simple-glassfish-api 4.0 - + org.glassfish.main.extras glassfish-embedded-all @@ -266,7 +298,11 @@ javadocs - javadocs + + + javadocs + + + + \ No newline at end of file diff --git a/extra/nosql/voldemort/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/voldemort/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..31d2e3aeb --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Voldemort using Java EE 7 + + + + +
    +

    Voldemort using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/voldemort/src/main/webapp/WEB-INF/web.xml b/extra/nosql/voldemort/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/voldemort/src/main/webapp/index.xhtml b/extra/nosql/voldemort/src/main/webapp/index.xhtml new file mode 100644 index 000000000..457c3dba9 --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/index.xhtml @@ -0,0 +1,29 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    + +
    + +
    + + + diff --git a/extra/nosql/voldemort/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/voldemort/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/voldemort/src/main/webapp/resources/css/default.css b/extra/nosql/voldemort/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/voldemort/src/main/webapp/show.xhtml b/extra/nosql/voldemort/src/main/webapp/show.xhtml new file mode 100644 index 000000000..8f1d60f31 --- /dev/null +++ b/extra/nosql/voldemort/src/main/webapp/show.xhtml @@ -0,0 +1,27 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + From 3a36540c684f577daa89c3e32d798dcf0cb0f267 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Mon, 7 Oct 2013 17:32:55 -0700 Subject: [PATCH 0180/1080] Starting work on Alternatives sample --- cdi/alternatives/pom.xml | 15 +++ .../org/javaee7/cdi/alternatives/Fancy.java | 58 ++++++++ .../cdi/alternatives/FancyGreeting.java | 56 ++++++++ .../javaee7/cdi/alternatives/Greeting.java | 47 +++++++ .../cdi/alternatives/SimpleGreeting.java | 55 ++++++++ .../javaee7/cdi/alternatives/TestServlet.java | 127 ++++++++++++++++++ .../src/main/webapp/WEB-INF/beans.xml | 52 +++++++ cdi/alternatives/src/main/webapp/index.jsp | 55 ++++++++ 8 files changed, 465 insertions(+) create mode 100644 cdi/alternatives/pom.xml create mode 100644 cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Fancy.java create mode 100644 cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/FancyGreeting.java create mode 100644 cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Greeting.java create mode 100644 cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/SimpleGreeting.java create mode 100644 cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/TestServlet.java create mode 100644 cdi/alternatives/src/main/webapp/WEB-INF/beans.xml create mode 100644 cdi/alternatives/src/main/webapp/index.jsp diff --git a/cdi/alternatives/pom.xml b/cdi/alternatives/pom.xml new file mode 100644 index 000000000..6f1fcf381 --- /dev/null +++ b/cdi/alternatives/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.javaee7.cdi + cdi-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.cdi + alternatives + 1.0-SNAPSHOT + war + diff --git a/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Fancy.java b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Fancy.java new file mode 100644 index 000000000..a30c0f6d3 --- /dev/null +++ b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Fancy.java @@ -0,0 +1,58 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.alternatives; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import javax.inject.Qualifier; + +/** + * @author Arun Gupta + */ +@Qualifier +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +public @interface Fancy { +} diff --git a/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/FancyGreeting.java b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/FancyGreeting.java new file mode 100644 index 000000000..c08874349 --- /dev/null +++ b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/FancyGreeting.java @@ -0,0 +1,56 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.alternatives; + +import javax.enterprise.inject.Alternative; + +/** + * @author Arun Gupta + */ +@Fancy +@Alternative +public class FancyGreeting implements Greeting { + + @Override + public String greet(String name) { + return "Nice to meet you, hello" + name; + } + +} diff --git a/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Greeting.java b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Greeting.java new file mode 100644 index 000000000..7c65d641f --- /dev/null +++ b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/Greeting.java @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.alternatives; + +/** + * @author Arun Gupta + */ +public interface Greeting { + public String greet(String name); +} diff --git a/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/SimpleGreeting.java b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/SimpleGreeting.java new file mode 100644 index 000000000..9ea9b18ea --- /dev/null +++ b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/SimpleGreeting.java @@ -0,0 +1,55 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.alternatives; + +import javax.enterprise.inject.Alternative; + +/** + * @author Arun Gupta + */ +@Alternative +public class SimpleGreeting implements Greeting { + + @Override + public String greet(String name) { + return "Hello " + name; + } + +} diff --git a/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/TestServlet.java b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/TestServlet.java new file mode 100644 index 000000000..821fb7fec --- /dev/null +++ b/cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/TestServlet.java @@ -0,0 +1,127 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.cdi.alternatives; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Arun Gupta + */ +@WebServlet(urlPatterns = {"/TestServlet"}) +public class TestServlet extends HttpServlet { + + @Inject Greeting greeting; + + /** + * Processes requests for both HTTP + * GET and + * POST methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + out.println(""); + out.println(""); + out.println(""); + out.println("CDI Interceptors"); + out.println(""); + out.println(""); + out.println("

    CDI Interceptors

    "); + out.println(greeting.greet("Duke")); + out.println("

    Look for output in \"server.log\"."); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/cdi/alternatives/src/main/webapp/WEB-INF/beans.xml b/cdi/alternatives/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..ea66c22d0 --- /dev/null +++ b/cdi/alternatives/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,52 @@ + + + + + org.javaee7.cdi.alternatives.FancyGreeting + + diff --git a/cdi/alternatives/src/main/webapp/index.jsp b/cdi/alternatives/src/main/webapp/index.jsp new file mode 100644 index 000000000..fc02ee19d --- /dev/null +++ b/cdi/alternatives/src/main/webapp/index.jsp @@ -0,0 +1,55 @@ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + CDI : Alternatives + + +

    CDI : Alternatives

    + Invoke the client. + + From 8be988cfce0bc882b0caaea6bc4b22b9c9025937 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 8 Oct 2013 14:41:19 -0700 Subject: [PATCH 0181/1080] Adding alternatives module --- cdi/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/cdi/pom.xml b/cdi/pom.xml index bf10b1f41..6d9a4bd77 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -29,5 +29,6 @@ beanmanager extension scopes + alternatives From b327f697479562fa3572071b0ead1df7e5fefe8a Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 8 Oct 2013 16:57:25 -0700 Subject: [PATCH 0182/1080] Adding riak module --- extra/nosql/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/nosql/pom.xml b/extra/nosql/pom.xml index cc3b0bd64..4c3088fa7 100644 --- a/extra/nosql/pom.xml +++ b/extra/nosql/pom.xml @@ -22,5 +22,6 @@ neo4j hbase voldemort + riak From aa2b1a46d499fee4635f89c845329a367aed7b53 Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Tue, 8 Oct 2013 16:57:34 -0700 Subject: [PATCH 0183/1080] Adding Riak module --- extra/nosql/riak/pom.xml | 30 +++++ .../org/javaee7/extra/nosql/riak/Person.java | 95 +++++++++++++++ .../extra/nosql/riak/PersonSessionBean.java | 109 ++++++++++++++++++ .../riak/src/main/webapp/WEB-INF/beans.xml | 49 ++++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 +++++ .../riak/src/main/webapp/WEB-INF/web.xml | 24 ++++ extra/nosql/riak/src/main/webapp/index.xhtml | 49 ++++++++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++++ .../src/main/webapp/resources/css/default.css | 29 +++++ extra/nosql/riak/src/main/webapp/show.xhtml | 27 +++++ 10 files changed, 499 insertions(+) create mode 100644 extra/nosql/riak/pom.xml create mode 100644 extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/Person.java create mode 100644 extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/PersonSessionBean.java create mode 100644 extra/nosql/riak/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/nosql/riak/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/nosql/riak/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/nosql/riak/src/main/webapp/index.xhtml create mode 100644 extra/nosql/riak/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/nosql/riak/src/main/webapp/resources/css/default.css create mode 100644 extra/nosql/riak/src/main/webapp/show.xhtml diff --git a/extra/nosql/riak/pom.xml b/extra/nosql/riak/pom.xml new file mode 100644 index 000000000..73eb681e1 --- /dev/null +++ b/extra/nosql/riak/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + riak + 1.0-SNAPSHOT + war + + + + voldemort-repo + http://repo.springsource.org/plugins-release/ + + + + + + com.basho.riak + riak-client + 1.4.1 + + + diff --git a/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/Person.java b/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/Person.java new file mode 100644 index 000000000..154f2a246 --- /dev/null +++ b/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/Person.java @@ -0,0 +1,95 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.riak; + +import java.io.Serializable; +import java.util.StringTokenizer; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person implements Serializable { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + + return new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + } + +} diff --git a/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/PersonSessionBean.java b/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/PersonSessionBean.java new file mode 100644 index 000000000..85d04d6ad --- /dev/null +++ b/extra/nosql/riak/src/main/java/org/javaee7/extra/nosql/riak/PersonSessionBean.java @@ -0,0 +1,109 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.riak; + +import com.basho.riak.client.IRiakClient; +import com.basho.riak.client.RiakException; +import com.basho.riak.client.RiakFactory; +import com.basho.riak.client.RiakRetryFailedException; +import com.basho.riak.client.bucket.Bucket; +import com.basho.riak.client.cap.UnresolvedConflictException; +import com.basho.riak.client.convert.ConversionException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +/** + * @author Arun Gupta + */ +@Named +@Singleton +public class PersonSessionBean { + + @Inject + Person person; + + Set set = new HashSet<>(); + Bucket myBucket; + + @PostConstruct + private void initDB() { + try { + IRiakClient client = RiakFactory.pbcClient("localhost", 8087); + myBucket = client.fetchBucket("test").execute(); + } catch (RiakException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @PreDestroy + private void stopDB() { + } + + public void createPerson() { + try { + myBucket.store(person.getName(), new Person(person.getName(), person.getAge())).execute(); + set.add(person.getName()); + } catch (RiakRetryFailedException | UnresolvedConflictException | ConversionException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public List getPersons() { + List persons = new ArrayList(); + for (String key : set) { + try { + Person p = myBucket.fetch(key, Person.class).execute(); + persons.add(p); + } catch (UnresolvedConflictException | RiakRetryFailedException | ConversionException ex) { + Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex); + } + } + return persons; + } +} diff --git a/extra/nosql/riak/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/riak/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/nosql/riak/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/riak/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..730271b63 --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Riak using Java EE 7 + + + + +
    +

    Riak using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/riak/src/main/webapp/WEB-INF/web.xml b/extra/nosql/riak/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/riak/src/main/webapp/index.xhtml b/extra/nosql/riak/src/main/webapp/index.xhtml new file mode 100644 index 000000000..b05d3200a --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/index.xhtml @@ -0,0 +1,49 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    + + +
      Build from source (more details) +
    • Install Erlang (more details)
    • +
        +
      • curl -O http://erlang.org/download/otp_src_R15B01.tar.gz
      • +
      • tar zxvf otp_src_R15B01.tar.gz
      • +
      • cd otp_src_R15B01
      • +
      • export CFLAGS=-O0
      • +
      • ./configure --disable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --enable-darwin-64bit
      • +
      • unset CFLAGS
      • +
      • make
      • +
      • make install
      • +
      +
    • wget http://s3.amazonaws.com/downloads.basho.com/riak/1.4/1.4.2/riak-1.4.2.tar.gz
    • +
    • tar zxvf riak-1.4.2.tar.gz
    • +
    • cd riak-1.4.2
    • +
    • make rel
    • +
    • cd rel/riak
    • +
    • ./bin/riak start
    • +
    • ./bin/riak ping (to verify)
    • +
    +
    + +
    + + + diff --git a/extra/nosql/riak/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/riak/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/riak/src/main/webapp/resources/css/default.css b/extra/nosql/riak/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/riak/src/main/webapp/show.xhtml b/extra/nosql/riak/src/main/webapp/show.xhtml new file mode 100644 index 000000000..8f1d60f31 --- /dev/null +++ b/extra/nosql/riak/src/main/webapp/show.xhtml @@ -0,0 +1,27 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + From 2d3edb86f95c0154885ac673e01e25f9c15c93ef Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 10 Oct 2013 14:04:06 -0700 Subject: [PATCH 0184/1080] Adding new sample for Oracle NoSQL --- extra/nosql/oracle/pom.xml | 23 +++++ .../javaee7/extra/nosql/oracle/Person.java | 95 +++++++++++++++++++ .../extra/nosql/oracle/PersonSessionBean.java | 94 ++++++++++++++++++ .../oracle/src/main/webapp/WEB-INF/beans.xml | 49 ++++++++++ .../src/main/webapp/WEB-INF/template.xhtml | 26 +++++ .../oracle/src/main/webapp/WEB-INF/web.xml | 24 +++++ .../nosql/oracle/src/main/webapp/index.xhtml | 33 +++++++ .../main/webapp/resources/css/cssLayout.css | 61 ++++++++++++ .../src/main/webapp/resources/css/default.css | 29 ++++++ extra/nosql/oracle/src/main/webapp/show.xhtml | 27 ++++++ 10 files changed, 461 insertions(+) create mode 100644 extra/nosql/oracle/pom.xml create mode 100644 extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/Person.java create mode 100644 extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/PersonSessionBean.java create mode 100644 extra/nosql/oracle/src/main/webapp/WEB-INF/beans.xml create mode 100644 extra/nosql/oracle/src/main/webapp/WEB-INF/template.xhtml create mode 100644 extra/nosql/oracle/src/main/webapp/WEB-INF/web.xml create mode 100644 extra/nosql/oracle/src/main/webapp/index.xhtml create mode 100644 extra/nosql/oracle/src/main/webapp/resources/css/cssLayout.css create mode 100644 extra/nosql/oracle/src/main/webapp/resources/css/default.css create mode 100644 extra/nosql/oracle/src/main/webapp/show.xhtml diff --git a/extra/nosql/oracle/pom.xml b/extra/nosql/oracle/pom.xml new file mode 100644 index 000000000..125b0685b --- /dev/null +++ b/extra/nosql/oracle/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7.extra.nosql + extra-nosql-samples + 1.0-SNAPSHOT + ../pom.xml + + + org.javaee7.extra.nosql + oracle + 1.0-SNAPSHOT + war + + + + com.oracle.nosql + oracle-nosql + 2.1.19 + + + diff --git a/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/Person.java b/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/Person.java new file mode 100644 index 000000000..bec1295d5 --- /dev/null +++ b/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/Person.java @@ -0,0 +1,95 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.oracle; + +import java.io.Serializable; +import java.util.StringTokenizer; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.validation.constraints.Size; + +/** + * @author Arun Gupta + */ +@Named +@ApplicationScoped +public class Person implements Serializable { + + @Size(min = 1, max = 20) + private String name; + + private int age; + + public Person() { + } + + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return name + ", " + age; + } + + public static Person fromString(String string) { + StringTokenizer tokens = new StringTokenizer(string, ","); + + return new Person(tokens.nextToken(), Integer.parseInt(tokens.nextToken().trim())); + } + +} diff --git a/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/PersonSessionBean.java b/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/PersonSessionBean.java new file mode 100644 index 000000000..bc1a17a53 --- /dev/null +++ b/extra/nosql/oracle/src/main/java/org/javaee7/extra/nosql/oracle/PersonSessionBean.java @@ -0,0 +1,94 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.javaee7.extra.nosql.oracle; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import oracle.kv.KVStore; +import oracle.kv.KVStoreConfig; +import oracle.kv.KVStoreFactory; +import oracle.kv.Key; +import oracle.kv.Value; + +/** + * @author Arun Gupta + */ +@Named +@Singleton +public class PersonSessionBean { + + @Inject + Person person; + + Set set = new HashSet<>(); + + private KVStore store; + + @PostConstruct + private void initDB() { + // bootstrap + store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "localhost:5000")); + } + + @PreDestroy + private void stopDB() { + } + + public void createPerson() { + store.put(Key.createKey(person.getName()), Value.createValue(new Person(person.getName(), person.getAge()).toString().getBytes())); + set.add(person.getName()); + } + + public List getPersons() { + List persons = new ArrayList(); + for (String key : set) { + persons.add(Person.fromString(new String(store.get(Key.createKey(key)).getValue().getValue()))); + } + return persons; + } +} diff --git a/extra/nosql/oracle/src/main/webapp/WEB-INF/beans.xml b/extra/nosql/oracle/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 000000000..aa81c7c3c --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/extra/nosql/oracle/src/main/webapp/WEB-INF/template.xhtml b/extra/nosql/oracle/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 000000000..3418cda01 --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + Oracle NoSQL using Java EE 7 + + + + +
    +

    Oracle NoSQL using Java EE 7

    +
    + +
    + Content +
    + +
    + + diff --git a/extra/nosql/oracle/src/main/webapp/WEB-INF/web.xml b/extra/nosql/oracle/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c5e7c7381 --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/extra/nosql/oracle/src/main/webapp/index.xhtml b/extra/nosql/oracle/src/main/webapp/index.xhtml new file mode 100644 index 000000000..eae2f204d --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/index.xhtml @@ -0,0 +1,33 @@ + + + + + + + + + + + Name:
    + Age:

    + +
    +
    +
      +
    • Download Oracle NoSQL Community Edition and unzip.
    • +
    • Install the NoSQL Client jar: mvn install:install-file -Dfile=/Users/arungup/tools/oracle/nosql/kv-2.1.19/lib/kvclient.jar -DgroupId=com.oracle.nosql -DartifactId=oracle-nosql -Dversion=2.1.19 -Dpackaging=jar
    • +
    • Start the server as: java -jar lib/kvstore.jar kvlite to see the output as:
      +Created new kvlite store with args:
      +-root ./kvroot -store kvstore -host arungup-mac.local -port 5000 -admin 5001 +
    • +
    +
    + +
    + + + diff --git a/extra/nosql/oracle/src/main/webapp/resources/css/cssLayout.css b/extra/nosql/oracle/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 000000000..8ee7cebe3 --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/extra/nosql/oracle/src/main/webapp/resources/css/default.css b/extra/nosql/oracle/src/main/webapp/resources/css/default.css new file mode 100644 index 000000000..6cbc3d18e --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} diff --git a/extra/nosql/oracle/src/main/webapp/show.xhtml b/extra/nosql/oracle/src/main/webapp/show.xhtml new file mode 100644 index 000000000..8f1d60f31 --- /dev/null +++ b/extra/nosql/oracle/src/main/webapp/show.xhtml @@ -0,0 +1,27 @@ + + + + + + + + + + + Name#{p.name} + Age#{p.age} + +

    + + + + +
    + +
    + + + From 3214cca7f2c614e74dbe39c214fa63a730d8305b Mon Sep 17 00:00:00 2001 From: Arun Gupta Date: Thu, 10 Oct 2013 15:41:05 -0700 Subject: [PATCH 0185/1080] Adding a line break --- extra/nosql/oracle/src/main/webapp/index.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/nosql/oracle/src/main/webapp/index.xhtml b/extra/nosql/oracle/src/main/webapp/index.xhtml index eae2f204d..5e1c6d271 100644 --- a/extra/nosql/oracle/src/main/webapp/index.xhtml +++ b/extra/nosql/oracle/src/main/webapp/index.xhtml @@ -20,7 +20,7 @@