Skip to content

Commit 405322b

Browse files
committed
JaxRS sample application code without web.xml and for EE8.
1 parent 6d05af5 commit 405322b

6 files changed

Lines changed: 269 additions & 0 deletions

File tree

applications/jaxrs/pom.xml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2021 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
22+
<modelVersion>4.0.0</modelVersion>
23+
<packaging>war</packaging>
24+
<parent>
25+
<groupId>com.google.appengine</groupId>
26+
<artifactId>applications</artifactId>
27+
<version>4.0.1-SNAPSHOT</version>
28+
</parent>
29+
<groupId>com.google.appengine.demos</groupId>
30+
<artifactId>jaxrs</artifactId>
31+
<name>AppEngine :: jaxrs</name>
32+
<url>https://github.com/GoogleCloudPlatform/appengine-java-standard/</url>
33+
<description>A jaxrs sample application.</description>
34+
35+
<prerequisites>
36+
<maven>3.6.0</maven>
37+
</prerequisites>
38+
39+
<properties>
40+
<maven.deploy.skip>true</maven.deploy.skip>
41+
<appengine.target.version>4.0.1-SNAPSHOT</appengine.target.version>
42+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
43+
<maven.compiler.target>1.8</maven.compiler.target>
44+
<maven.compiler.source>1.8</maven.compiler.source>
45+
</properties>
46+
47+
<dependencies>
48+
<!-- Compile/runtime dependencies -->
49+
<dependency>
50+
<groupId>javax.servlet</groupId>
51+
<artifactId>javax.servlet-api</artifactId>
52+
<scope>provided</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.glassfish.jersey.containers</groupId>
56+
<artifactId>jersey-container-servlet</artifactId>
57+
<version>2.47</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.glassfish.jersey.inject</groupId>
62+
<artifactId>jersey-hk2</artifactId>
63+
<version>2.47</version>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>org.glassfish.jersey.connectors</groupId>
68+
<artifactId>jersey-jetty-connector</artifactId>
69+
<version>2.47</version>
70+
</dependency>
71+
</dependencies>
72+
73+
<build>
74+
<outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
75+
76+
<plugins>
77+
<plugin>
78+
<groupId>org.eclipse.jetty.ee8</groupId>
79+
<artifactId>jetty-ee8-maven-plugin</artifactId>
80+
<version>12.1.5</version>
81+
<configuration>
82+
<scan>10</scan>
83+
<dumpOnStart>true</dumpOnStart>
84+
<webApp>
85+
<contextPath>/test</contextPath>
86+
</webApp>
87+
</configuration>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-surefire-plugin</artifactId>
92+
<version>3.5.4</version>
93+
<configuration>
94+
<argLine>
95+
--add-opens java.base/java.lang=ALL-UNNAMED
96+
--add-opens java.base/java.nio.charset=ALL-UNNAMED
97+
--add-opens java.base/java.util=ALL-UNNAMED
98+
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
99+
</argLine>
100+
</configuration>
101+
</plugin>
102+
<plugin>
103+
<groupId>org.apache.maven.plugins</groupId>
104+
<artifactId>maven-war-plugin</artifactId>
105+
<version>3.5.1</version>
106+
<configuration>
107+
<archiveClasses>true</archiveClasses>
108+
<webResources>
109+
<!-- in order to interpolate version from pom into appengine-web.xml -->
110+
<resource>
111+
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
112+
<filtering>true</filtering>
113+
<targetPath>WEB-INF</targetPath>
114+
</resource>
115+
</webResources>
116+
</configuration>
117+
</plugin>
118+
119+
<plugin>
120+
<groupId>com.google.cloud.tools</groupId>
121+
<artifactId>appengine-maven-plugin</artifactId>
122+
<version>2.8.6</version>
123+
<configuration>
124+
<projectId>ludo-in-in</projectId>
125+
<version>jaxrs</version>
126+
<promote>false</promote>
127+
<automaticRestart>true</automaticRestart>
128+
<jvmFlags>
129+
<jvmFlag>-Xdebug</jvmFlag>
130+
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
131+
</jvmFlags>
132+
<cloudSdkVersion>553.0.0</cloudSdkVersion>
133+
</configuration>
134+
</plugin>
135+
</plugins>
136+
</build>
137+
138+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.example;
17+
18+
import javax.ws.rs.ApplicationPath;
19+
import org.glassfish.jersey.server.ResourceConfig;
20+
21+
@ApplicationPath("/")
22+
public class AppConfig extends ResourceConfig {
23+
public AppConfig() {
24+
register(RootResource.class);
25+
}
26+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.example;
17+
18+
import javax.ws.rs.GET;
19+
import javax.ws.rs.Produces;
20+
import javax.ws.rs.core.MediaType;
21+
22+
public class HelloResource {
23+
@GET
24+
@Produces(MediaType.TEXT_PLAIN)
25+
public String hello() {
26+
return "hello";
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.example;
17+
18+
import javax.ws.rs.Path;
19+
20+
@Path("/")
21+
public class RootResource {
22+
@Path("hello")
23+
public HelloResource getHelloResource() {
24+
return new HelloResource();
25+
}
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2021 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
19+
<runtime>java17</runtime>
20+
<system-properties>
21+
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
22+
<property name="appengine.use.EE8" value="true"/>
23+
</system-properties>
24+
</appengine-web-app>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# A default java.util.logging configuration.
17+
# (All App Engine logging is through java.util.logging by default).
18+
#
19+
# To use this configuration, copy it into your application's WEB-INF
20+
# folder and add the following to your appengine-web.xml:
21+
# <system-properties>
22+
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
23+
# </system-properties>
24+
#
25+
26+
# Set the default logging level for all loggers to WARNING
27+
.level = WARNING

0 commit comments

Comments
 (0)