Skip to content

Commit 8c34744

Browse files
committed
restorng repositroy from backup
0 parents  commit 8c34744

File tree

317 files changed

+13973
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+13973
-0
lines changed

JAXRS-Jersey/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
.idea
3+
*.iml*

JAXRS-Jersey/Procfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#web: java -cp target/classes:target/dependency/* ${package}.heroku.Main
2+
web: mvn clean package; mvn tomcat:run
3+

JAXRS-Jersey/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REFERENCES:https://jersey.java.net/documentation/latest/getting-started.html

JAXRS-Jersey/pom.xml

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>jaxrs-jersery</groupId>
8+
<artifactId>jaxrs-jersey</artifactId>
9+
<version>1.0</version>
10+
<packaging>war</packaging>
11+
<name>jaxrs</name>
12+
13+
<properties>
14+
<tomcat.version>7.0.34</tomcat.version>
15+
</properties>
16+
17+
<repositories>
18+
<repository>
19+
<id>maven2-repository.java.net</id>
20+
<name>Java.net Repository for Maven</name>
21+
<url>http://download.java.net/maven/2/</url>
22+
<layout>default</layout>
23+
</repository>
24+
</repositories>
25+
26+
<dependencies>
27+
<!--JAX-RS 2.0-->
28+
<dependency>
29+
<groupId>javax.ws.rs</groupId>
30+
<artifactId>javax.ws.rs-api</artifactId>
31+
<version>2.0</version>
32+
</dependency>
33+
34+
<!--Jersery-2.11; JAX-RS2.0 Reference Implementation-->
35+
<!-- Required only when you are using JAX-RS Client -->
36+
<dependency>
37+
<groupId>org.glassfish.jersey.containers</groupId>
38+
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
39+
<artifactId>jersey-container-servlet</artifactId>
40+
<version>2.11</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.glassfish.jersey.core</groupId>
44+
<artifactId>jersey-client</artifactId>
45+
<version>2.11</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.glassfish.jersey.containers</groupId>
49+
<artifactId>jersey-container-grizzly2-http</artifactId>
50+
<version>2.11</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>junit</groupId>
55+
<artifactId>junit</artifactId>
56+
<version>4.4</version>
57+
<scope>test</scope>
58+
</dependency>
59+
60+
<!--Embeded Tomcat-->
61+
<dependency>
62+
<groupId>org.apache.tomcat.embed</groupId>
63+
<artifactId>tomcat-embed-core</artifactId>
64+
<version>${tomcat.version}</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.apache.tomcat.embed</groupId>
68+
<artifactId>tomcat-embed-logging-juli</artifactId>
69+
<version>${tomcat.version}</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.apache.tomcat.embed</groupId>
73+
<artifactId>tomcat-embed-jasper</artifactId>
74+
<version>${tomcat.version}</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.apache.tomcat</groupId>
78+
<artifactId>tomcat-jasper</artifactId>
79+
<version>${tomcat.version}</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>org.apache.tomcat</groupId>
83+
<artifactId>tomcat-jasper-el</artifactId>
84+
<version>${tomcat.version}</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.apache.tomcat</groupId>
88+
<artifactId>tomcat-jsp-api</artifactId>
89+
<version>${tomcat.version}</version>
90+
</dependency>
91+
</dependencies>
92+
93+
<build>
94+
<plugins>
95+
<!-- For running maven based embedded Tomcat -->
96+
<plugin>
97+
<groupId>org.apache.tomcat.maven</groupId>
98+
<artifactId>tomcat7-maven-plugin</artifactId>
99+
<version>2.0</version>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.apache.maven.plugins</groupId>
103+
<artifactId>maven-compiler-plugin</artifactId>
104+
<version>3.1</version>
105+
<configuration>
106+
<source>1.6</source>
107+
<target>1.6</target>
108+
</configuration>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.codehaus.mojo</groupId>
112+
<artifactId>appassembler-maven-plugin</artifactId>
113+
<version>1.1.1</version>
114+
<configuration>
115+
<assembleDirectory>target</assembleDirectory>
116+
<programs>
117+
<program>
118+
<mainClass>jaxrs.App</mainClass>
119+
<name>launch</name>
120+
</program>
121+
</programs>
122+
</configuration>
123+
<executions>
124+
<execution>
125+
<phase>package</phase>
126+
<goals>
127+
<goal>assemble</goal>
128+
</goals>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
</plugins>
133+
</build>
134+
135+
</project>
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package jaxrs;
2+
3+
import org.apache.catalina.startup.Tomcat;
4+
5+
import java.io.File;
6+
7+
/**
8+
* @author Hikamt Dhamee
9+
* @email me.hemant.available@gmail.com
10+
*/
11+
public class App {
12+
public static void main(String[] args) throws Exception {
13+
14+
String webappDirLocation = "src/main/webapp/";
15+
Tomcat tomcat = new Tomcat();
16+
17+
//The port that we should run on can be set into an environment variable
18+
//Look for that variable and default to 8080 if it isn't there.
19+
String webPort = System.getenv("PORT");
20+
if(webPort == null || webPort.isEmpty()) {
21+
webPort = "9090";
22+
}
23+
24+
tomcat.setPort(Integer.valueOf(webPort));
25+
26+
tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
27+
System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
28+
29+
tomcat.start();
30+
tomcat.getServer().await();
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package jaxrs;
2+
3+
import javax.ws.rs.GET;
4+
import javax.ws.rs.Path;
5+
import javax.ws.rs.PathParam;
6+
7+
import javax.ws.rs.core.Response;
8+
9+
/**
10+
* @author Hikamt Dhamee
11+
* @email me.hemant.available@gmail.com
12+
*/
13+
@Path("/hello")
14+
public class HelloRESTService {
15+
16+
@GET
17+
@Path("/{param}")
18+
public Response getMsg(@PathParam("param") String msg) {
19+
String output = "Jersey says, You sent : " + msg;
20+
return Response.status(200).entity(output).build();
21+
22+
}
23+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package jaxrs;
2+
import org.glassfish.grizzly.http.server.HttpServer;
3+
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
4+
import org.glassfish.jersey.server.ResourceConfig;
5+
6+
import java.io.IOException;
7+
import java.net.URI;
8+
9+
/**
10+
* Main class.
11+
*
12+
*/
13+
public class Main {
14+
// Base URI the Grizzly HTTP server will listen on
15+
public static final String BASE_URI = "http://localhost:8080/jaxrs-jersey/";
16+
17+
/**
18+
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
19+
* @return Grizzly HTTP server.
20+
*/
21+
public static HttpServer startServer() {
22+
// create a resource config that scans for JAX-RS resources and providers
23+
// in $package package
24+
final ResourceConfig rc = new ResourceConfig().packages("jaxrs");
25+
26+
// create and start a new instance of grizzly http server
27+
// exposing the Jersey application at BASE_URI
28+
return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
29+
}
30+
31+
/**
32+
* Main method.
33+
* @param args
34+
* @throws IOException
35+
*/
36+
public static void main(String[] args) throws IOException {
37+
final HttpServer server = startServer();
38+
System.out.println(String.format("Jersey app started with WADL available at "
39+
+ "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
40+
System.in.read();
41+
server.stop();
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package jaxrs;
2+
3+
import javax.ws.rs.GET;
4+
import javax.ws.rs.Path;
5+
import javax.ws.rs.Produces;
6+
import javax.ws.rs.core.MediaType;
7+
8+
/**
9+
* @author Hikamt Dhamee
10+
* @email me.hemant.available@gmail.com
11+
*
12+
* Root resource (exposed at "myresource" path)
13+
*
14+
* A JAX-RS resource is an annotated POJO that provides so-called
15+
* resource methods that are able to handle HTTP requests for
16+
* URI paths that the resource is bound to.
17+
*/
18+
@Path("myresource")
19+
public class MyResource {
20+
21+
/**
22+
* Method handling HTTP GET requests. The returned object will be sent
23+
* to the client as "text/plain" media type.
24+
*
25+
* @return String that will be returned as a text/plain response.
26+
*/
27+
@GET
28+
@Produces(MediaType.TEXT_PLAIN)
29+
public String getIt() {
30+
return "Got it!";
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<web-app id="WebApp_ID" version="2.4"
2+
xmlns="http://java.sun.com/xml/ns/j2ee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
5+
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
6+
<display-name>Restful Web Application</display-name>
7+
8+
<servlet>
9+
<servlet-name>jersey-serlvet</servlet-name>
10+
<servlet-class>
11+
org.glassfish.jersey.servlet.ServletContainer
12+
</servlet-class>
13+
<init-param>
14+
<param-name>org.glassfish.jersey.config.property.packages</param-name>
15+
<param-value>jaxrs</param-value>
16+
</init-param>
17+
<load-on-startup>1</load-on-startup>
18+
</servlet>
19+
20+
<servlet-mapping>
21+
<servlet-name>jersey-serlvet</servlet-name>
22+
<url-pattern>/api/*</url-pattern>
23+
</servlet-mapping>
24+
25+
</web-app>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package jaxrs;
2+
3+
4+
import junit.framework.TestCase;
5+
import org.glassfish.grizzly.http.server.HttpServer;
6+
import org.junit.After;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
import javax.ws.rs.client.Client;
11+
import javax.ws.rs.client.ClientBuilder;
12+
import javax.ws.rs.client.WebTarget;
13+
14+
public class MyResourceUnitTest extends TestCase{
15+
16+
private HttpServer server;
17+
private WebTarget target;
18+
19+
@Before
20+
public void setUp() throws Exception {
21+
server = Main.startServer();
22+
23+
Client c = ClientBuilder.newClient();
24+
target = c.target(Main.BASE_URI);
25+
}
26+
27+
@After
28+
public void tearDown() throws Exception {
29+
server.shutdownNow();
30+
}
31+
32+
@Test
33+
public void testGetIt() {
34+
String responseMsg = target.path("myresource").request().get(String.class);
35+
assertEquals("Got it!", responseMsg);
36+
}
37+
}

JAXRS-Jersey/system.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java.runtime.version=1.6

JAXWS-demo/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
target
3+
.idea
4+
*.iml*

0 commit comments

Comments
 (0)