Skip to content

Commit 5e2e9ad

Browse files
committed
Added sample app
1 parent 799d921 commit 5e2e9ad

File tree

13 files changed

+647
-0
lines changed

13 files changed

+647
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<module>cf-java-logging-support-log4j2</module>
4949
<module>cf-java-logging-support-servlet</module>
5050
<module>cf-java-logging-support-jersey</module>
51+
<module>sample</module>
5152
</modules>
5253

5354
<dependencies>

sample/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 James Bayer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sample/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logging Sample Application
2+
3+
4+
5+
A simple CF sample application that we cloned from [cloudfoundry-sticky-session](https://github.com/jbayer/cloudfoundry-sticky-session) and tweaked to provide a sample for the logging and instrumentation features.
6+
7+
Currently configured to use `logback` as the logging implementation.
8+
9+
## Running it locally
10+
11+
You can use the following Maven target to run the application locally
12+
13+
```sh
14+
mvn tomcat7:run
15+
```
16+
17+
Once the tomcat container has started, you can access the application via [http://localhost:8080/logging-sample-app](http://localhost:8080/logging-sample-app)
18+
19+
Here's a table of "interesting" request URLs you may want to load:
20+
21+
| URL | Comment |
22+
| ------------------------ | ---------------------------------------- |
23+
| `/` | Handled by standard servlet. Prints all environment variables, HTTP request headers and a random "greeting" message. |
24+
| `/<n>` | Like the one above, but also computes the `<n>`th Fibonacci number. Computation happens recursively, so you can use higher values for `n` to get long response times or even crash the application |
25+
| `/stacktrace` | Handled by standard servlet. Generates a `500` response and prints a stack trace |
26+
| `/jersey?greeting=<msg>` | Handled by Jersey container. Will print the line `Hello from Jersey: <msg>` |
27+
| `/jersey/forward` | Handled by Jersey container. Will use a Jersey client to "forward" to default servlet. |
28+
| `/jersey/forward?q=<n>` | Again handled by Jersey container and forwarded to default servlet as `/<n>`. |

sample/manifest.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
applications:
3+
#
4+
# You may want/need to change these to avoid naming conflicts
5+
#
6+
- name: logging-sample-app
7+
host: logging-sample-app
8+
instances: 1
9+
memory: 256M
10+
path: target/logging-sample-app-2.0.8.war

sample/pom.xml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
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+
<artifactId>logging-sample-app</artifactId>
5+
<packaging>war</packaging>
6+
<parent>
7+
<groupId>com.sap.hcp.cf.logging</groupId>
8+
<artifactId>cf-java-logging-support-parent</artifactId>
9+
<version>2.0.8</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<properties>
14+
<tomcat.version>7.0.65</tomcat.version>
15+
<log4j2.version>2.4.1</log4j2.version>
16+
<logback.version>1.1.3</logback.version>
17+
<jackson.version>2.5.4</jackson.version>
18+
<slf4j.version>1.7.12</slf4j.version>
19+
<jersey.version>2.22.2</jersey.version>
20+
<javax.ws.version>2.0.1</javax.ws.version>
21+
</properties>
22+
<dependencies>
23+
<dependency>
24+
<groupId>javax.servlet</groupId>
25+
<artifactId>javax.servlet-api</artifactId>
26+
<version>3.0.1</version>
27+
<scope>provided</scope>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>javax.ws.rs</groupId>
32+
<artifactId>javax.ws.rs-api</artifactId>
33+
<version>${javax.ws.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.glassfish.jersey.containers</groupId>
37+
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
38+
<artifactId>jersey-container-servlet</artifactId>
39+
<version>${jersey.version}</version>
40+
</dependency>
41+
<!-- Required only when you are using JAX-RS Client -->
42+
<dependency>
43+
<groupId>org.glassfish.jersey.core</groupId>
44+
<artifactId>jersey-client</artifactId>
45+
<version>${jersey.version}</version>
46+
</dependency>
47+
<!-- we're using org.slf4j.api for logging -->
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-api</artifactId>
51+
<version>${slf4j.version}</version>
52+
</dependency>
53+
54+
<!-- need these as xs-object-factory is referring to them with scope "provider" -->
55+
<dependency>
56+
<groupId>com.fasterxml.jackson.core</groupId>
57+
<artifactId>jackson-core</artifactId>
58+
<version>${jackson.version}</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.core</groupId>
62+
<artifactId>jackson-databind</artifactId>
63+
<version>${jackson.version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>com.fasterxml.jackson.core</groupId>
67+
<artifactId>jackson-annotations</artifactId>
68+
<version>${jackson.version}</version>
69+
</dependency>
70+
71+
<!-- We're using the Servlet Filter instrumentation -->
72+
<dependency>
73+
<groupId>com.sap.hcp.cf.logging</groupId>
74+
<artifactId>cf-java-logging-support-servlet</artifactId>
75+
<version>${project.version}</version>
76+
</dependency>
77+
<!-- We're using the Servlet Filter instrumentation -->
78+
<dependency>
79+
<groupId>com.sap.hcp.cf.logging</groupId>
80+
<artifactId>cf-java-logging-support-jersey</artifactId>
81+
<version>${project.version}</version>
82+
</dependency>
83+
84+
<!-- Use logback as the slf4j implementation -->
85+
<dependency>
86+
<groupId>com.sap.hcp.cf.logging</groupId>
87+
<artifactId>cf-java-logging-support-logback</artifactId>
88+
<version>${project.version}</version>
89+
</dependency>
90+
<dependency>
91+
<groupId>ch.qos.logback</groupId>
92+
<artifactId>logback-classic</artifactId>
93+
<version>${logback.version}</version>
94+
</dependency>
95+
96+
<!-- LOG4J2 VERSION
97+
98+
<dependency>
99+
<groupId>com.sap.hcp.cf-logging.logging</groupId>
100+
<artifactId>java-logging-support-log4j2</artifactId>
101+
<version>${cf-logging.version}</version>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.apache.logging.log4j</groupId>
105+
<artifactId>log4j-slf4j-impl</artifactId>
106+
<version>${log4j2.version}</version>
107+
</dependency>
108+
<dependency>
109+
<groupId>org.apache.logging.log4j</groupId>
110+
<artifactId>log4j-core</artifactId>
111+
<version>${log4j2.version}</version>
112+
</dependency>
113+
-->
114+
</dependencies>
115+
116+
<build>
117+
<plugins>
118+
<!-- add mvn tomcat7:run, so we can easily test locally -->
119+
<plugin>
120+
<groupId>org.apache.tomcat.maven</groupId>
121+
<artifactId>tomcat7-maven-plugin</artifactId>
122+
<version>2.3-SNAPSHOT</version>
123+
<dependencies>
124+
<dependency>
125+
<groupId>org.apache.tomcat.embed</groupId>
126+
<artifactId>tomcat-embed-core</artifactId>
127+
<version>${tomcat.version}</version>
128+
</dependency>
129+
<dependency>
130+
<groupId>org.apache.tomcat</groupId>
131+
<artifactId>tomcat-util</artifactId>
132+
<version>${tomcat.version}</version>
133+
</dependency>
134+
<dependency>
135+
<groupId>org.apache.tomcat</groupId>
136+
<artifactId>tomcat-coyote</artifactId>
137+
<version>${tomcat.version}</version>
138+
</dependency>
139+
<dependency>
140+
<groupId>org.apache.tomcat</groupId>
141+
<artifactId>tomcat-api</artifactId>
142+
<version>${tomcat.version}</version>
143+
</dependency>
144+
145+
<dependency>
146+
<groupId>org.apache.tomcat</groupId>
147+
<artifactId>tomcat-jdbc</artifactId>
148+
<version>${tomcat.version}</version>
149+
</dependency>
150+
151+
<dependency>
152+
<groupId>org.apache.tomcat</groupId>
153+
<artifactId>tomcat-dbcp</artifactId>
154+
<version>${tomcat.version}</version>
155+
</dependency>
156+
157+
<dependency>
158+
<groupId>org.apache.tomcat</groupId>
159+
<artifactId>tomcat-servlet-api</artifactId>
160+
<version>${tomcat.version}</version>
161+
</dependency>
162+
163+
<dependency>
164+
<groupId>org.apache.tomcat</groupId>
165+
<artifactId>tomcat-jsp-api</artifactId>
166+
<version>${tomcat.version}</version>
167+
</dependency>
168+
169+
<dependency>
170+
<groupId>org.apache.tomcat</groupId>
171+
<artifactId>tomcat-jasper</artifactId>
172+
<version>${tomcat.version}</version>
173+
</dependency>
174+
175+
<dependency>
176+
<groupId>org.apache.tomcat</groupId>
177+
<artifactId>tomcat-jasper-el</artifactId>
178+
<version>${tomcat.version}</version>
179+
</dependency>
180+
181+
<dependency>
182+
<groupId>org.apache.tomcat</groupId>
183+
<artifactId>tomcat-el-api</artifactId>
184+
<version>${tomcat.version}</version>
185+
</dependency>
186+
187+
<dependency>
188+
<groupId>org.apache.tomcat</groupId>
189+
<artifactId>tomcat-catalina</artifactId>
190+
<version>${tomcat.version}</version>
191+
</dependency>
192+
193+
<dependency>
194+
<groupId>org.apache.tomcat</groupId>
195+
<artifactId>tomcat-tribes</artifactId>
196+
<version>${tomcat.version}</version>
197+
</dependency>
198+
199+
<dependency>
200+
<groupId>org.apache.tomcat</groupId>
201+
<artifactId>tomcat-catalina-ha</artifactId>
202+
<version>${tomcat.version}</version>
203+
</dependency>
204+
205+
<dependency>
206+
<groupId>org.apache.tomcat</groupId>
207+
<artifactId>tomcat-annotations-api</artifactId>
208+
<version>${tomcat.version}</version>
209+
</dependency>
210+
211+
<dependency>
212+
<groupId>org.apache.tomcat</groupId>
213+
<artifactId>tomcat-juli</artifactId>
214+
<version>${tomcat.version}</version>
215+
</dependency>
216+
217+
<dependency>
218+
<groupId>org.apache.tomcat.embed</groupId>
219+
<artifactId>tomcat-embed-logging-juli</artifactId>
220+
<version>${tomcat.version}</version>
221+
</dependency>
222+
<dependency>
223+
<groupId>org.apache.tomcat.embed</groupId>
224+
<artifactId>tomcat-embed-logging-log4j</artifactId>
225+
<version>${tomcat.version}</version>
226+
</dependency>
227+
</dependencies>
228+
</plugin>
229+
<plugin>
230+
<artifactId>maven-compiler-plugin</artifactId>
231+
<version>2.0.2</version>
232+
<configuration>
233+
<source>1.7</source>
234+
<target>1.7</target>
235+
</configuration>
236+
</plugin>
237+
<plugin>
238+
<artifactId>maven-war-plugin</artifactId>
239+
<version>2.6</version>
240+
<configuration>
241+
<attachClasses>true</attachClasses>
242+
</configuration>
243+
</plugin>
244+
</plugins>
245+
</build>
246+
</project>

0 commit comments

Comments
 (0)