Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
waylau committed Sep 24, 2015
1 parent 27141e6 commit 75995f0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 73 deletions.
76 changes: 38 additions & 38 deletions samples/javase-rest-jetty/src/main/java/com/waylau/rest/App.java
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");
}
}
43 changes: 9 additions & 34 deletions samples/javase-rest-jetty/webapp/WEB-INF/web.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//判断浏览器是否支持 EventSource
if (typeof (EventSource) !== "undefined") {
var source = new EventSource("http://192.168.11.125:8081/webapi/alarm-events?entId="+22);
var source = new EventSource("http://192.168.11.220:8081/webapi/alarm-events?entId="+22);

// 当通往服务器的连接被打开
source.onopen = function(event) {
Expand Down

0 comments on commit 75995f0

Please sign in to comment.