├── .gitignore ├── HelloJavaEE7 ├── .gitignore ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.jpt.core.prefs │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.common.component │ └── .jsdtscope ├── WebContent │ ├── META-INF │ │ └── MANIFEST.MF │ └── index.html ├── .tern-project ├── src │ ├── org │ │ ├── sample │ │ │ ├── Greeting.java │ │ │ ├── SimpleGreeting.java │ │ │ ├── FancyGreeting.java │ │ │ ├── batch │ │ │ │ ├── MyItemWriter.java │ │ │ │ ├── MyItemProcessor.java │ │ │ │ ├── MyInputRecord.java │ │ │ │ ├── MyOutputRecord.java │ │ │ │ └── MyItemReader.java │ │ │ ├── Fancy.java │ │ │ ├── Student.java │ │ │ └── TestServlet.java │ │ └── rest │ │ │ └── StudentEndpoint.java │ ├── rest │ │ └── RestApplication.java │ └── META-INF │ │ ├── batch-jobs │ │ └── myJob.xml │ │ └── persistence.xml ├── .classpath └── .project └── README.asciidoc /.gitignore: -------------------------------------------------------------------------------- 1 | **/build/* 2 | -------------------------------------------------------------------------------- /HelloJavaEE7/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /HelloJavaEE7/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /HelloJavaEE7/.tern-project: -------------------------------------------------------------------------------- 1 | {"ide":{},"libs":["ecma5","browser"],"plugins":{"guess-types":{},"angular":{}}} -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/Greeting.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | public interface Greeting { 4 | public String sayHello(); 5 | } 6 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.jpt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jpt.core.platform=generic2_1 3 | org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false 4 | -------------------------------------------------------------------------------- /HelloJavaEE7/WebContent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Java EE 7 World! 6 | 7 | 8 |

Hello Java EE 7 World!

9 | 10 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/rest/RestApplication.java: -------------------------------------------------------------------------------- 1 | package rest; 2 | 3 | import javax.ws.rs.ApplicationPath; 4 | import javax.ws.rs.core.Application; 5 | 6 | @ApplicationPath("/rest") 7 | public class RestApplication extends Application { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/SimpleGreeting.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | import javax.enterprise.context.Dependent; 4 | 5 | @Dependent 6 | public class SimpleGreeting implements Greeting { 7 | 8 | @Override 9 | public String sayHello() { 10 | // TODO Auto-generated method stub 11 | return "Hello World"; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/FancyGreeting.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | import javax.enterprise.context.Dependent; 4 | 5 | @Dependent 6 | @Fancy 7 | public class FancyGreeting implements Greeting { 8 | 9 | @Override 10 | public String sayHello() { 11 | // TODO Auto-generated method stub 12 | return "Hello fancy world"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/META-INF/batch-jobs/myJob.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/batch/MyItemWriter.java: -------------------------------------------------------------------------------- 1 | package org.sample.batch; 2 | 3 | import java.util.List; 4 | import javax.batch.api.chunk.AbstractItemWriter; 5 | import javax.inject.Named; 6 | 7 | /** 8 | * @author Arun Gupta 9 | */ 10 | @Named 11 | public class MyItemWriter extends AbstractItemWriter { 12 | 13 | @Override 14 | public void writeItems(List list) { 15 | System.out.println("writeItems: " + list); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/batch/MyItemProcessor.java: -------------------------------------------------------------------------------- 1 | package org.sample.batch; 2 | 3 | import javax.batch.api.chunk.ItemProcessor; 4 | import javax.inject.Named; 5 | 6 | /** 7 | * @author Arun Gupta 8 | */ 9 | @Named 10 | public class MyItemProcessor implements ItemProcessor { 11 | 12 | @Override 13 | public MyOutputRecord processItem(Object t) { 14 | System.out.println("processItem: " + t); 15 | 16 | return (((MyInputRecord)t).getId() % 2 == 0) ? null : new MyOutputRecord(((MyInputRecord)t).getId() * 2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /HelloJavaEE7/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/batch/MyInputRecord.java: -------------------------------------------------------------------------------- 1 | package org.sample.batch; 2 | 3 | /** 4 | * @author Arun Gupta 5 | */ 6 | public class MyInputRecord { 7 | private int id; 8 | 9 | public MyInputRecord() { } 10 | 11 | public MyInputRecord(int id) { 12 | this.id = id; 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "MyInputRecord: " + id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/batch/MyOutputRecord.java: -------------------------------------------------------------------------------- 1 | package org.sample.batch; 2 | 3 | /** 4 | * @author Arun Gupta 5 | */ 6 | public class MyOutputRecord { 7 | private int id; 8 | 9 | public MyOutputRecord() { } 10 | 11 | public MyOutputRecord(int id) { 12 | this.id = id; 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "MyOutputRecord: " + id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/Fancy.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import javax.inject.Qualifier; 8 | 9 | import static java.lang.annotation.ElementType.FIELD; 10 | import static java.lang.annotation.ElementType.METHOD; 11 | import static java.lang.annotation.ElementType.PARAMETER; 12 | import static java.lang.annotation.ElementType.TYPE; 13 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 14 | 15 | @Qualifier 16 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 17 | @Retention(RUNTIME) 18 | @Documented 19 | public @interface Fancy { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/Student.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.*; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | @Entity 9 | @XmlRootElement 10 | @NamedQuery(name="findAllStudents", query="select s from Student s") 11 | public class Student implements Serializable { 12 | 13 | @Id 14 | private long id; 15 | private static final long serialVersionUID = 1L; 16 | 17 | public Student() { 18 | super(); 19 | } 20 | 21 | public Student(long id) { 22 | this.id = id; 23 | } 24 | public long getId() { 25 | return this.id; 26 | } 27 | 28 | public void setId(long id) { 29 | this.id = id; 30 | } 31 | 32 | public String toString() { 33 | return "Student[" + id + "]"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/batch/MyItemReader.java: -------------------------------------------------------------------------------- 1 | package org.sample.batch; 2 | 3 | import java.io.Serializable; 4 | import java.util.StringTokenizer; 5 | import javax.batch.api.chunk.AbstractItemReader; 6 | import javax.inject.Named; 7 | 8 | /** 9 | * @author Arun Gupta 10 | */ 11 | @Named 12 | public class MyItemReader extends AbstractItemReader { 13 | 14 | private StringTokenizer tokens; 15 | 16 | 17 | @Override 18 | public void open(Serializable checkpoint) throws Exception { 19 | tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ","); 20 | } 21 | 22 | @Override 23 | public MyInputRecord readItem() { 24 | if (tokens.hasMoreTokens()) { 25 | return new MyInputRecord(Integer.valueOf(tokens.nextToken())); 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 9 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /HelloJavaEE7/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /HelloJavaEE7/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloJavaEE7 4 | 5 | 6 | 7 | 8 | 9 | tern.eclipse.ide.core.ternBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.jsdt.core.javascriptValidator 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.common.project.facet.core.builder 25 | 26 | 27 | 28 | 29 | org.jboss.tools.jst.web.kb.kbbuilder 30 | 31 | 32 | 33 | 34 | org.jboss.tools.cdi.core.cdibuilder 35 | 36 | 37 | 38 | 39 | org.eclipse.wst.validation.validationbuilder 40 | 41 | 42 | 43 | 44 | 45 | org.eclipse.jem.workbench.JavaEMFNature 46 | org.eclipse.wst.common.modulecore.ModuleCoreNature 47 | org.eclipse.wst.common.project.facet.core.nature 48 | org.eclipse.jdt.core.javanature 49 | org.jboss.tools.jst.web.kb.kbnature 50 | org.jboss.tools.cdi.core.cdinature 51 | org.eclipse.wst.jsdt.core.jsNature 52 | 53 | 54 | -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/rest/StudentEndpoint.java: -------------------------------------------------------------------------------- 1 | package org.rest; 2 | 3 | import java.util.List; 4 | 5 | import javax.enterprise.context.RequestScoped; 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.PersistenceContext; 8 | import javax.persistence.TypedQuery; 9 | import javax.transaction.Transactional; 10 | import javax.validation.constraints.Min; 11 | import javax.ws.rs.Consumes; 12 | import javax.ws.rs.GET; 13 | import javax.ws.rs.POST; 14 | import javax.ws.rs.Path; 15 | import javax.ws.rs.PathParam; 16 | import javax.ws.rs.Produces; 17 | import javax.ws.rs.QueryParam; 18 | import javax.ws.rs.core.Response; 19 | import javax.ws.rs.core.Response.Status; 20 | import javax.ws.rs.core.UriBuilder; 21 | 22 | import org.sample.Student; 23 | 24 | @RequestScoped 25 | @Path("/students") 26 | public class StudentEndpoint { 27 | 28 | @PersistenceContext EntityManager em; 29 | 30 | @Transactional 31 | @POST 32 | @Consumes({ "application/xml", "application/json", "text/plain" }) 33 | public void create(@Min(1) final long id) { 34 | Student student = new Student(id); 35 | em.persist(student); 36 | } 37 | 38 | @GET 39 | @Path("/{id:[0-9][0-9]*}") 40 | @Produces({ "application/xml", "application/json" }) 41 | public Response findById(@PathParam("id") final Long id) { 42 | Student student = em.find(Student.class, id); 43 | if (student == null) { 44 | return Response.status(Status.NOT_FOUND).build(); 45 | } 46 | return Response.ok(student).build(); 47 | } 48 | 49 | @GET 50 | @Produces("application/xml") 51 | public Student[] listAll( 52 | @QueryParam("start") final Integer startPosition, 53 | @QueryParam("max") final Integer maxResult) { 54 | TypedQuery query = em.createNamedQuery("findAllStudents", Student.class); 55 | final List students = query.getResultList(); 56 | return students.toArray(new Student[0]); 57 | } 58 | } -------------------------------------------------------------------------------- /HelloJavaEE7/src/org/sample/TestServlet.java: -------------------------------------------------------------------------------- 1 | package org.sample; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.inject.Inject; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.ServletOutputStream; 8 | import javax.servlet.annotation.WebServlet; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import javax.ws.rs.client.Client; 13 | import javax.ws.rs.client.ClientBuilder; 14 | 15 | /** 16 | * Servlet implementation class TestServlet 17 | */ 18 | @WebServlet("/TestServlet") 19 | public class TestServlet extends HttpServlet { 20 | private static final long serialVersionUID = 1L; 21 | 22 | @Inject 23 | Greeting greeting; 24 | 25 | /** 26 | * @see HttpServlet#HttpServlet() 27 | */ 28 | public TestServlet() { 29 | super(); 30 | // TODO Auto-generated constructor stub 31 | } 32 | 33 | /** 34 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse 35 | * response) 36 | */ 37 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 38 | response.getOutputStream().println(greeting.sayHello()); 39 | 40 | ServletOutputStream out = response.getOutputStream(); 41 | out.print("Retrieving results ..."); 42 | Client client = ClientBuilder.newClient(); 43 | Student[] result = client.target("http://localhost:8080/HelloJavaEE7/rest/students").request() 44 | .get(Student[].class); 45 | for (Student s : result) { 46 | out.print(s.toString()); 47 | } 48 | 49 | } 50 | 51 | /** 52 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse 53 | * response) 54 | */ 55 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, 56 | IOException { 57 | doGet(request, response); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /README.asciidoc: -------------------------------------------------------------------------------- 1 | Java EE 7 using Eclipse 2 | ======================= 3 | 4 | Project creation 5 | ---------------- 6 | 7 | * Create a simple Dynamic Web Project 8 | ** Choose the module version as ``3.1'' 9 | ** Add a new configuration for WildFly 10 | ** Add `index.html` in ``WebContent'' 11 | ** ``Run as'', ``Run on Server'' 12 | ** Change content on `index.html` and show http://docs.jboss.org/tools/whatsnew/livereload/livereload-news-1.0.0.Alpha2.html[LiveReload] 13 | 14 | Servlet 15 | ------- 16 | 17 | * Add a new Servlet 18 | ** In Servers tab, select the module, right-click and select ``Restart'' to restart the module 19 | ** Show http://localhost:8080/HelloJavaEE7/TestServlet 20 | 21 | Persistence 22 | ----------- 23 | 24 | * Right-click on project, select ``Properties'', search for ``facet'', enable ``JPA'', click on ``Apply'' 25 | ** Talk about ``Further configuration available'' and default data source (no configuration required) 26 | * Right-click on project, select ``New'', ``JPA Entity'' and give the name as `Student` 27 | * Add a primary key in the wizard. Use `long` datatype and `id` name. 28 | * Generate Getter/Setter by clicking ``Source'', ``Getters and Setters''. 29 | * Add `toString` implementation 30 | * The updated class should look like: 31 | + 32 | [source, java] 33 | ---- 34 | @Entity 35 | @XmlRootElement 36 | @NamedQuery(name="findAllStudents", query="select s from Student s") 37 | public class Student implements Serializable { 38 | 39 | @Id 40 | private long id; 41 | private static final long serialVersionUID = 1L; 42 | 43 | public Student() { 44 | super(); 45 | } 46 | 47 | public Student(long id) { 48 | this.id = id; 49 | } 50 | public long getId() { 51 | return this.id; 52 | } 53 | 54 | public void setId(long id) { 55 | this.id = id; 56 | } 57 | 58 | public String toString() { 59 | return "Student[" + id + "]"; 60 | } 61 | } 62 | ---- 63 | + 64 | ** `@XmlRootElement` in `Student` entity enables XML <-> Java conversion. 65 | ** `@NamedQuery(name="findAllStudents", query="select s from Student s")` in `Student` enables querying all students. 66 | * Add the following properties to `persistence.xml`: 67 | + 68 | [source.xml] 69 | ---- 70 | 71 | 73 | 75 | 77 | 78 | 79 | 80 | ---- 81 | + 82 | * Show ``server console'' when the application is deployed. Show the generated SQL statements. 83 | 84 | Setup console to watch database 85 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 86 | 87 | * Download 88 | https://github.com/jboss-developer/jboss-eap-quickstarts/blob/6.3.0.GA/h2-console/h2console.war?raw=true[H2 console war] to WildFly's `standalone/deployments` directory 89 | + 90 | [source,text] 91 | ---- 92 | curl -L https://github.com/jboss-developer/jboss-eap-quickstarts/blob/6.3.0.GA/h2-console/h2console.war?raw=true -o h2console.war 93 | ---- 94 | + 95 | * Start the server and access http://localhost:8080/h2console 96 | * Enter the JDBC URL and credentials. To access the "test" database your application uses, enter these details (everything else is default): 97 | ** JDBC URL: `jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1` 98 | ** User Name: `sa` 99 | ** Password: `sa` 100 | 101 | RESTful Web Services 102 | -------------------- 103 | 104 | * Create a JAX-RS resource `StudentEndpoint` 105 | ** `rest.RestApplication` is added and specifies the base URI for REST resoures as `/rest`. 106 | ** Use `Student` entity as the basis, select `create`, `findById`, `listAll` methods to be generated. 107 | * Update the class so that it looks like as shown: 108 | + 109 | [source,java] 110 | ---- 111 | @RequestScoped 112 | @Path("/students") 113 | public class StudentEndpoint { 114 | 115 | @PersistenceContext EntityManager em; 116 | 117 | @Transactional 118 | @POST 119 | @Consumes({ "application/xml", "application/json", "text/plain" }) 120 | public void create(final long id) { 121 | Student student = new Student(id); 122 | em.persist(student); 123 | } 124 | 125 | @GET 126 | @Path("/{id:[0-9][0-9]*}") 127 | @Produces({ "application/xml", "application/json" }) 128 | public Response findById(@PathParam("id") final Long id) { 129 | Student student = em.find(Student.class, id); 130 | if (student == null) { 131 | return Response.status(Status.NOT_FOUND).build(); 132 | } 133 | return Response.ok(student).build(); 134 | } 135 | 136 | @GET 137 | @Produces("application/xml") 138 | public Student[] listAll( 139 | @QueryParam("start") final Integer startPosition, 140 | @QueryParam("max") final Integer maxResult) { 141 | TypedQuery query = em.createNamedQuery("findAllStudents", Student.class); 142 | final List students = query.getResultList(); 143 | return students.toArray(new Student[0]); 144 | } 145 | } 146 | ---- 147 | + 148 | * Use ``Advanced REST Client'' in Chrome 149 | ** Make a GET request to http://localhost:8080/HelloJavaEE7/rest/students 150 | *** Add Accept: application/xml 151 | *** Show empty response 152 | ** Make a POST request 153 | *** Payload as `1` 154 | *** ``Content-Type'' header to `text/plain` 155 | ** Make a GET request to validate the data is posted 156 | * Edit `doGet` of `TestServlet` to match the code given below 157 | + 158 | [source,java] 159 | ---- 160 | ServletOutputStream out = response.getOutputStream(); 161 | out.print("Retrieving results ..."); 162 | Client client = ClientBuilder.newClient(); 163 | Student[] result = client 164 | .target("http://localhost:8080/HelloJavaEE7/rest/students") 165 | .request() 166 | .get(Student[].class); 167 | for (Student s : result) { 168 | out.print(s.toString()); 169 | } 170 | ---- 171 | * Access the Servlet in the browser to show the results and explain JAX-RS Client API 172 | 173 | 174 | Bean Validation 175 | --------------- 176 | 177 | * Change `create` method to add Bean Validation constraint 178 | + 179 | [source,java] 180 | ---- 181 | public void create(@Min(10) final long id) { 182 | ---- 183 | + 184 | * Make a POST request with payload as `1` and show an error is being received 185 | 186 | 187 | CDI 188 | --- 189 | 190 | * Generate an interface `Greeting` 191 | + 192 | [source,java] 193 | ---- 194 | public interface Greeting { 195 | public String sayHello(); 196 | } 197 | ---- 198 | + 199 | * Create a new class `SimpleGreeting`, implement the interface as: 200 | + 201 | [source, java] 202 | ---- 203 | public class SimpleGreeting implements Greeting { 204 | 205 | @Override 206 | public String sayHello() { 207 | return "Hello World"; 208 | } 209 | 210 | } 211 | ---- 212 | + 213 | * Inject the bean in Servlet as `@Inject Greeting greeting;` 214 | * Print the output as `response.getOutputStream().print(greeting.sayHello());` 215 | * Show ``New missing/unsatisfied dependencies'' error and explain default injection 216 | * Add `@Dependent` on bean 217 | * Create a new class `FancyGreeting`, implement the interface, add `@Dependent` 218 | * Create a new qualifier using ``New'', ``Qualifier Annotation Type'' 219 | 220 | Advanced CDI 221 | ------------ 222 | 223 | * Wizards: 224 | http://docs.jboss.org/tools/4.1.x.Final/en/cdi_tools_reference_guide/html/chap-CDI_Tools_Reference_Guide-Creating_a_CDI_Web_Project.html[New CDI Web Project Wizard], 225 | http://docs.jboss.org/tools/4.1.x.Final/en/cdi_tools_reference_guide/html/chap-CDI_Tools_Reference_Guide-Wizards_and_Dialogs.html#d0e555[CDI Wizards] 226 | * Content assist: CDI Named Beans are available in JSF EL #{} content assist in XHTML/Java/XML files (See JSF) 227 | * Validation: 228 | http://docs.jboss.org/tools/4.1.x.Final/en/cdi_tools_reference_guide/html/chap-CDI_Tools_Reference_Guide-Validation.html 229 | * Navigation (open the bean producer from the @Inject annotation for example): 230 | http://docs.jboss.org/tools/4.1.x.Final/en/cdi_tools_reference_guide/html/chap-CDI_Tools_Reference_Guide-Hyperlink_Navigation.html[Java source navigation], from EL #{} to CDI bean (See JSF) 231 | * Open CDI Named bean: http://docs.jboss.org/tools/4.1.x.Final/en/cdi_tools_reference_guide/html_single/index.html#d0e597 232 | * Beans.xml editor: Content assist, Navigation, Validation 233 | http://docs.jboss.org/tools/whatsnew/cdi/cdi-news-3.2.0.Beta1.html 234 | * Search usage: https://issues.jboss.org/browse/JBIDE-8705[Injection Points], EL #{} (See JSF) 235 | * CDI 1.2 support was introduced in JBoss Tools 4.3.0.Alpha1: http://tools.jboss.org/documentation/whatsnew/jbosstools/4.3.0.Alpha1.html#cdi 236 | But it's mostly about showing CDI 1.2 as available in our wizards (New CDI Project wizard for example) + minor bug fixing. In JBoss Tools 4.2 (Eclipse Luna) you can use CDI 1.1 in wizards for CDI 1.2 projects since 1.2 is just a maintenance release and CDI Tools relays on actual CDI jars from the project's class path. 237 | 238 | Batch 239 | ----- 240 | 241 | * Open https://github.com/javaee-samples/javaee7-samples/[Java EE 7 Samples project] and show Job XML 242 | * http://tools.jboss.org/documentation/whatsnew/jbosstools/4.3.0.Alpha1.html#batch[Batch job XML editor] - available in JBoss Tools 4.3.0.Alpha1 243 | * Upcoming 4.3.0.Alpha2 features: Validation, Content Assist, Navigation, - https://issues.jboss.org/browse/JBIDE-18857 244 | 245 | JavaServer Faces 246 | ---------------- 247 | 248 | * EL content assist in XHTML: http://docs.jboss.org/tools/whatsnew/jst/jst-news-3.3.0.M3.html 249 | * Navigation from/to bean 250 | * Search usage 251 | * Refactoring: 252 | http://docs.jboss.org/tools/whatsnew/jst/jst-news-3.2.0.M1.html 253 | * New JSF project wizard (JSF 2.2 or older) 254 | * Composite component code assist: 255 | https://issues.jboss.org/browse/JBIDE-4970, http://docs.jboss.org/tools/whatsnew/jst/jst-news-3.2.0.Beta2.html, Validation and refactoring are also available 256 | * EL Validation: http://docs.jboss.org/tools/whatsnew/jst/jst-news-3.2.0.M2.html 257 | 258 | OpenShift 259 | --------- 260 | 261 | * Create a new server adapter from ``OpenShift Explorer'' 262 | * More details at http://blog.arungupta.me/getting-started-wildfly-openshift-jboss-developer-studio/ 263 | 264 | Forge 265 | ----- 266 | 267 | * Switch to JBoss perspective 268 | * Go to ``Forge Console'', click on play button to start it 269 | * `project-new --named sample` 270 | * `javaee-setup --javaEEVersion 7` 271 | * `jpa-setup --jpaVersion 2.1` 272 | * Install plugin: `addon-install-from-git --url https://github.com/forge/addon-batch` 273 | ** Create new Job XML: `batch-new-jobxml --jobXML myJob.xml --reader org.svcc.MyReader --writer org.svcc.MyWriter` 274 | * More details about Batch and Forge at: http://blog.arungupta.me/javaee7-batch-addon-jboss-forge-part1/ 275 | * More details about other technologies at: http://blog.arungupta.me/rapid-javaee-development-forge2/ 276 | 277 | Continuous Delivery 278 | ------------------- 279 | 280 | --------------------------------------------------------------------------------