forked from waylau/rest-in-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
73 deletions.
There are no files selected for viewing
76 changes: 38 additions & 38 deletions
76
samples/javase-rest-jetty/src/main/java/com/waylau/rest/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
package com.waylau.rest; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.logging.Logger; | ||
|
||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.glassfish.jersey.jetty.JettyHttpContainerFactory; | ||
|
||
/** | ||
* Main class. | ||
* | ||
*/ | ||
public class App { | ||
// HTTP server 所要监听的 uri | ||
public static final String BASE_URI = "http://192.168.11.125:8081/"; | ||
private static Logger logger = Logger.getLogger(App.class.toString()); | ||
/** | ||
* Main method. | ||
* | ||
* @param args | ||
* @throws IOException | ||
*/ | ||
public static void main(String[] args) throws IOException { | ||
WebAppContext context = new WebAppContext(); | ||
//context.setDescriptor("./webapp/WEB-INF/web.xml"); | ||
context.setParentLoaderPriority(true); | ||
context.setResourceBase("./webapp"); | ||
context.setContextPath("/"); | ||
|
||
// 使用 Jetty Http Server | ||
Server server = JettyHttpContainerFactory.createServer(URI.create(BASE_URI), | ||
new RestApplication()); | ||
server.setHandler(context); | ||
logger.info("server start"); | ||
} | ||
} | ||
package com.waylau.rest; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.logging.Logger; | ||
|
||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.glassfish.jersey.jetty.JettyHttpContainerFactory; | ||
|
||
/** | ||
* Main class. | ||
* | ||
*/ | ||
public class App { | ||
// HTTP server 所要监听的 uri | ||
public static final String BASE_URI = "http://192.168.11.125:8081/"; | ||
private static Logger logger = Logger.getLogger(App.class.toString()); | ||
/** | ||
* Main method. | ||
* | ||
* @param args | ||
* @throws IOException | ||
*/ | ||
public static void main(String[] args) throws IOException { | ||
WebAppContext context = new WebAppContext(); | ||
context.setDescriptor("./webapp/WEB-INF/web.xml"); | ||
context.setParentLoaderPriority(true); | ||
context.setResourceBase("./webapp"); | ||
context.setContextPath("/"); | ||
|
||
// 使用 Jetty Http Server | ||
Server server = JettyHttpContainerFactory.createServer(URI.create(BASE_URI), | ||
new RestApplication()); | ||
server.setHandler(context); | ||
logger.info("server start"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | ||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
<servlet> | ||
<servlet-name>jm</servlet-name> | ||
<servlet-class>com.nice.common.jmonitor.JMDispatcher</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
<init-param> | ||
<param-name>config</param-name> | ||
<param-value>config.json</param-value> | ||
</init-param> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>jm-longpolling</servlet-name> | ||
<servlet-class>com.nice.common.jmonitor.JMPollingServer</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>jm-longpolling</servlet-name> | ||
<url-pattern>/jmsg</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>jm</servlet-name> | ||
<url-pattern>/jm/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
<session-config> | ||
<session-timeout>10</session-timeout> | ||
</session-config> | ||
<welcome-file-list> | ||
<welcome-file>/index.html</welcome-file> | ||
</welcome-file-list> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | ||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
<welcome-file-list> | ||
<welcome-file>/index.html</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters