Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit e1f0606

Browse files
committed
chore: initial commit
0 parents commit e1f0606

File tree

12 files changed

+510
-0
lines changed

12 files changed

+510
-0
lines changed

‎.gitignore

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,java,maven
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,java,maven
4+
5+
### Java ###
6+
# Compiled class file
7+
*.class
8+
9+
# Log file
10+
*.log
11+
12+
# BlueJ files
13+
*.ctxt
14+
15+
# Mobile Tools for Java (J2ME)
16+
.mtj.tmp/
17+
18+
# Package Files #
19+
*.jar
20+
*.war
21+
*.nar
22+
*.ear
23+
*.zip
24+
*.tar.gz
25+
*.rar
26+
27+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
28+
hs_err_pid*
29+
replay_pid*
30+
31+
### Linux ###
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
### macOS ###
47+
# General
48+
.DS_Store
49+
.AppleDouble
50+
.LSOverride
51+
52+
# Icon must end with two \r
53+
Icon
54+
55+
56+
# Thumbnails
57+
._*
58+
59+
# Files that might appear in the root of a volume
60+
.DocumentRevisions-V100
61+
.fseventsd
62+
.Spotlight-V100
63+
.TemporaryItems
64+
.Trashes
65+
.VolumeIcon.icns
66+
.com.apple.timemachine.donotpresent
67+
68+
# Directories potentially created on remote AFP share
69+
.AppleDB
70+
.AppleDesktop
71+
Network Trash Folder
72+
Temporary Items
73+
.apdisk
74+
75+
### macOS Patch ###
76+
# iCloud generated files
77+
*.icloud
78+
79+
### Maven ###
80+
target/
81+
pom.xml.tag
82+
pom.xml.releaseBackup
83+
pom.xml.versionsBackup
84+
pom.xml.next
85+
release.properties
86+
dependency-reduced-pom.xml
87+
buildNumber.properties
88+
.mvn/timing.properties
89+
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
90+
.mvn/wrapper/maven-wrapper.jar
91+
92+
# Eclipse m2e generated files
93+
# Eclipse Core
94+
.project
95+
# JDT-specific (Eclipse Java Development Tools)
96+
.classpath
97+
98+
### Windows ###
99+
# Windows thumbnail cache files
100+
Thumbs.db
101+
Thumbs.db:encryptable
102+
ehthumbs.db
103+
ehthumbs_vista.db
104+
105+
# Dump file
106+
*.stackdump
107+
108+
# Folder config file
109+
[Dd]esktop.ini
110+
111+
# Recycle Bin used on file shares
112+
$RECYCLE.BIN/
113+
114+
# Windows Installer files
115+
*.cab
116+
*.msi
117+
*.msix
118+
*.msm
119+
*.msp
120+
121+
# Windows shortcuts
122+
*.lnk
123+
124+
# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,java,maven

‎Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM jboss/wildfly
2+
3+
COPY target/jax-rs-service-1.0.0.war /opt/jboss/wildfly/standalone/deployments/backend.war

‎pom.xml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.backend.api</groupId>
6+
<artifactId>jax-rs-service</artifactId>
7+
<name>JAX-RS Integration Example</name>
8+
<version>1.0.0</version>
9+
<packaging>war</packaging>
10+
11+
<properties>
12+
<failOnMissingWebXml>false</failOnMissingWebXml>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
<version.arquillian>1.6.0.Final</version.arquillian>
16+
<version.wildfly>20.0.1.Final</version.wildfly>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>javax</groupId>
22+
<artifactId>javaee-api</artifactId>
23+
<version>8.0.1</version>
24+
<scope>provided</scope>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.slf4j</groupId>
29+
<artifactId>slf4j-api</artifactId>
30+
<version>1.7.30</version>
31+
<scope>provided</scope>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>com.fasterxml.jackson.core</groupId>
36+
<artifactId>jackson-core</artifactId>
37+
<version>2.12.3</version>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>com.google.code.gson</groupId>
42+
<artifactId>gson</artifactId>
43+
<version>2.8.6</version>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>com.fasterxml.jackson.core</groupId>
48+
<artifactId>jackson-databind</artifactId>
49+
<version>2.12.3</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>commons-io</groupId>
54+
<artifactId>commons-io</artifactId>
55+
<version>2.8.0</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.apache.commons</groupId>
60+
<artifactId>commons-lang3</artifactId>
61+
<version>3.11</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>org.jboss.resteasy</groupId>
66+
<artifactId>resteasy-jaxrs</artifactId>
67+
<version>3.12.1.Final</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>org.jboss.logging</groupId>
73+
<artifactId>jboss-logging</artifactId>
74+
<version>3.4.1.Final</version>
75+
<scope>provided</scope>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>org.jboss.arquillian</groupId>
80+
<artifactId>arquillian-bom</artifactId>
81+
<version>${version.arquillian}</version>
82+
<type>pom</type>
83+
</dependency>
84+
</dependencies>
85+
86+
<dependencyManagement>
87+
<dependencies>
88+
<dependency>
89+
<groupId>org.jboss.shrinkwrap.resolver</groupId>
90+
<artifactId>shrinkwrap-resolver-bom</artifactId>
91+
<version>3.1.4</version>
92+
<type>pom</type>
93+
<scope>import</scope>
94+
</dependency>
95+
</dependencies>
96+
</dependencyManagement>
97+
98+
<build>
99+
<plugins>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-compiler-plugin</artifactId>
103+
<version>3.8.1</version>
104+
105+
<configuration>
106+
<release>11</release>
107+
<showDeprecation>true</showDeprecation>
108+
<showWarnings>true</showWarnings>
109+
<compilerArgument>-Xlint:all</compilerArgument>
110+
<compilerArgument>-Xlint:-processing</compilerArgument>
111+
</configuration>
112+
</plugin>
113+
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-surefire-plugin</artifactId>
117+
<version>2.22.2</version>
118+
</plugin>
119+
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-war-plugin</artifactId>
123+
<version>3.2.3</version>
124+
</plugin>
125+
</plugins>
126+
</build>
127+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.backend.sample;
2+
3+
import javax.ws.rs.ApplicationPath;
4+
import javax.ws.rs.core.Application;
5+
6+
@ApplicationPath("/")
7+
public class App extends Application {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.backend.sample.listener;
2+
3+
import javax.servlet.ServletContextEvent;
4+
import javax.servlet.ServletContextListener;
5+
import javax.servlet.annotation.WebListener;
6+
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
@WebListener
11+
public class BaseContextListener implements ServletContextListener
12+
{
13+
private static final Logger logger = LoggerFactory.getLogger(BaseContextListener.class);
14+
15+
@Override
16+
public void contextInitialized(ServletContextEvent sce)
17+
{
18+
logger.info("in BaseContextListener.contextInitialized");
19+
}
20+
21+
@Override
22+
public void contextDestroyed(ServletContextEvent sce)
23+
{
24+
logger.info( "in BaseContextListener.contextDestroyed" );
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.backend.sample.logging;
2+
3+
import static java.lang.annotation.ElementType.METHOD;
4+
import static java.lang.annotation.ElementType.TYPE;
5+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
6+
7+
import java.lang.annotation.Retention;
8+
import java.lang.annotation.Target;
9+
10+
import javax.ws.rs.NameBinding;
11+
12+
/**
13+
* Marks a method something we want to log.
14+
*/
15+
@NameBinding
16+
@Retention(RUNTIME)
17+
@Target({TYPE, METHOD})
18+
public @interface Logged { }
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.backend.sample.logging;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
5+
import java.io.StringWriter;
6+
7+
import javax.ws.rs.container.ContainerRequestContext;
8+
import javax.ws.rs.container.ContainerRequestFilter;
9+
import javax.ws.rs.ext.Provider;
10+
11+
import org.apache.commons.io.IOUtils;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
15+
/**
16+
* Logs requests to the services if they are marked with the Logged annotation.
17+
* This class is marked with @Logged so that it pays attention to the annotation.
18+
*
19+
*/
20+
@Provider
21+
@Logged
22+
public class RequestLoggingFilter implements ContainerRequestFilter
23+
{
24+
private static Logger logger = LoggerFactory.getLogger(RequestLoggingFilter.class);
25+
26+
@Override
27+
public void filter(ContainerRequestContext requestContext) throws IOException
28+
{
29+
logger.info("got a " + requestContext.getMethod() + " request to " + requestContext.getUriInfo().getPath());
30+
31+
StringWriter writer = new StringWriter();
32+
IOUtils.copy(requestContext.getEntityStream(), writer, "UTF-8");
33+
34+
requestContext.setEntityStream(new ByteArrayInputStream(writer.toString().getBytes()));
35+
36+
if(!requestContext.getMethod().toLowerCase().equals("get"))
37+
logger.info("input string is \"" + writer.toString() + "\"" );
38+
}
39+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /