File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ** /target /
2+ nb- * .xml
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+ <groupId >org.javaee7.sample</groupId >
5+ <artifactId >javaee7-docker-maven</artifactId >
6+ <version >1.0-SNAPSHOT</version >
7+ <packaging >war</packaging >
8+ <name >javaee7-docker-maven</name >
9+
10+ <dependencies >
11+ <dependency >
12+ <groupId >javax</groupId >
13+ <artifactId >javaee-api</artifactId >
14+ <version >7.0</version >
15+ <scope >provided</scope >
16+ </dependency >
17+ </dependencies >
18+ <build >
19+ <finalName >javaee7-docker-maven</finalName >
20+ <plugins >
21+ <plugin >
22+ <artifactId >maven-compiler-plugin</artifactId >
23+ <version >3.1</version >
24+ <configuration >
25+ <source >1.7</source >
26+ <target >1.7</target >
27+ </configuration >
28+ </plugin >
29+ <plugin >
30+ <artifactId >maven-war-plugin</artifactId >
31+ <version >2.3</version >
32+ <configuration >
33+ <failOnMissingWebXml >false</failOnMissingWebXml >
34+ </configuration >
35+ </plugin >
36+ <plugin >
37+ <groupId >org.wildfly.plugins</groupId >
38+ <artifactId >wildfly-maven-plugin</artifactId >
39+ <version >1.0.2.Final</version >
40+ <!-- <executions>
41+ <execution>
42+ <phase>install</phase>
43+ <goals>
44+ <goal>deploy</goal>
45+ </goals>
46+ </execution>
47+ </executions>-->
48+ </plugin >
49+ </plugins >
50+ </build >
51+ </project >
Original file line number Diff line number Diff line change 1+ package org .javaee7 .sample ;
2+
3+ import javax .ws .rs .ApplicationPath ;
4+ import javax .ws .rs .core .Application ;
5+
6+ /**
7+ * @author arungupta
8+ */
9+ @ ApplicationPath ("/resources" )
10+ public class MyApplication extends Application {
11+
12+ }
Original file line number Diff line number Diff line change 1+ package org .javaee7 .sample ;
2+
3+ import javax .xml .bind .annotation .XmlRootElement ;
4+
5+ /**
6+ * @author arungupta
7+ */
8+ @ XmlRootElement
9+ public class Person {
10+ private String name ;
11+
12+ public Person () {
13+ }
14+
15+ public Person (String name ) {
16+ this .name = name ;
17+ }
18+
19+ public String getName () {
20+ return name ;
21+ }
22+
23+ public void setName (String name ) {
24+ this .name = name ;
25+ }
26+
27+ @ Override
28+ public String toString () {
29+ return name ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package org .javaee7 .sample ;
2+
3+ import java .util .Arrays ;
4+ import java .util .List ;
5+
6+ import javax .annotation .PostConstruct ;
7+ import javax .inject .Singleton ;
8+ import javax .ws .rs .NotFoundException ;
9+
10+ /**
11+ * @author arungupta
12+ */
13+ @ Singleton
14+ public class PersonDatabase {
15+
16+ List <Person > persons ;
17+
18+ @ PostConstruct
19+ public void init () {
20+ persons = Arrays .asList (
21+ new Person ("Penny" ),
22+ new Person ("Leonard" ),
23+ new Person ("Sheldon" ),
24+ new Person ("Amy" ),
25+ new Person ("Howard" ),
26+ new Person ("Bernadette" ),
27+ new Person ("Raj" ),
28+ new Person ("Priya" ));
29+ }
30+
31+ public Person [] currentList () {
32+ return persons .toArray (new Person [0 ]);
33+ }
34+
35+ public Person getPerson (int id ) {
36+ if (id < persons .size ()) {
37+ return persons .get (id );
38+ }
39+
40+ throw new NotFoundException ("Person with id \" " + id + "\" not found." );
41+ }
42+ }
Original file line number Diff line number Diff line change 1+ package org .javaee7 .sample ;
2+
3+ import javax .inject .Inject ;
4+ import javax .ws .rs .GET ;
5+ import javax .ws .rs .Path ;
6+ import javax .ws .rs .PathParam ;
7+ import javax .ws .rs .Produces ;
8+
9+ /**
10+ * @author arungupta
11+ */
12+ @ Path ("persons" )
13+ public class PersonResource {
14+
15+ @ Inject
16+ PersonDatabase database ;
17+
18+ @ GET
19+ @ Produces ("application/xml" )
20+ public Person [] get () {
21+ return database .currentList ();
22+ }
23+
24+ @ GET
25+ @ Path ("{id}" )
26+ @ Produces ("application/xml" )
27+ public Person get (@ PathParam ("id" ) int id ) {
28+ return database .getPerson (id );
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <beans xmlns =" http://xmlns.jcp.org/xml/ns/javaee"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
5+ bean-discovery-mode =" all" >
6+ </beans >
Original file line number Diff line number Diff line change 1+ <%@page contentType =" text/html" pageEncoding =" UTF-8" %>
2+ <!DOCTYPE html>
3+ <html >
4+ <head >
5+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
6+ <title >Java EE 7 Docker Maven Sample</title >
7+ </head >
8+ <body >
9+ <h1 >Java EE 7 Docker Maven Sample!</h1 >
10+
11+ GET all the <a href =" ${ pageContext. request. contextPath } /resources/persons" />persons</a >.
12+ </body >
13+ </html >
You can’t perform that action at this time.
0 commit comments