diff --git a/yin-control/WebRoot/old.jsp b/yin-control/WebRoot/old.jsp
deleted file mode 100644
index d21938d..0000000
--- a/yin-control/WebRoot/old.jsp
+++ /dev/null
@@ -1,173 +0,0 @@
-<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
-<%@page import="com.yin.ycontrol.screenShotter.GuiCamera"%>
-<% %>
-<%
-String path = request.getContextPath();
-String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
-%>
-
-
-
-
-
-
- 监控-不支持HTML5的浏览器,费流量(建议改用chrome浏览器)
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/yin-control/pom.xml b/yin-control/pom.xml
index f41afec..56ea74c 100644
--- a/yin-control/pom.xml
+++ b/yin-control/pom.xml
@@ -1,48 +1,82 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- com.yin.ycontrol
- yin-control
- 0.0.1-SNAPSHOT
- jar
+ com.yin.ycontrol
+ yin-control
+ 0.0.1-SNAPSHOT
+ jar
- yin-control
- http://maven.apache.org
+ yin-control
+ http://maven.apache.org
-
- UTF-8
- 6
- 6
- 6
-
+
+ UTF-8
+ 8
+ 8
+ 8
+ 9.2.9.v20150224
+
-
-
- junit
- junit
- 3.8.1
- test
-
-
- org.eclipse.jetty
- jetty-server
- 8.1.0.RC1
-
-
- org.eclipse.jetty
- jetty-webapp
- 8.1.0.RC1
-
-
- javax.servlet.jsp
- jsp-api
- 2.1
-
-
- org.glassfish.web
- jsp-impl
- 2.2
-
-
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ org.eclipse.jetty
+ jetty-server
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-webapp
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-jsp
+ ${jetty.version}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ y-control
+
+
+ maven-assembly-plugin
+
+
+
+ jetty.JettyServer
+
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
diff --git a/yin-control/src/main/java/com/yin/common/util/ConfigUtil.java b/yin-control/src/main/java/com/yin/common/util/ConfigUtil.java
deleted file mode 100644
index 6f70c24..0000000
--- a/yin-control/src/main/java/com/yin/common/util/ConfigUtil.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.yin.common.util;
-
-import java.io.InputStream;
-import java.util.Properties;
-
-public final class ConfigUtil {
-
- static Properties p = null;
-
- static void init() {
- try {
- InputStream in = ConfigUtil.class.getClassLoader()
- .getResourceAsStream("config.properties");
- p = new Properties();
- p.load(in);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- public static String get(String key){
- if(p==null){
- init();
- }
- return p.getProperty(key);
-
- }
-}
diff --git a/yin-control/src/main/java/com/yin/ycontrol/listener/ContextListener.java b/yin-control/src/main/java/com/yin/ycontrol/listener/ContextListener.java
deleted file mode 100644
index b0acee8..0000000
--- a/yin-control/src/main/java/com/yin/ycontrol/listener/ContextListener.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.yin.ycontrol.listener;
-
-import java.util.Timer;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-
-public class ContextListener implements ServletContextListener {
- private Timer timer = null;
- private Timer mac_timer = null;
- /**
- * @方法名:contextDestroyed
- * @功能描述:应用关闭时执行此方法
- * @参数:@param arg0
- * @throws
- */
- public void contextDestroyed(ServletContextEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @方法名:contextInitialized
- * @功能描述:当应用启动时执行此方法
- * @参数:@param event
- * @throws
- */
- public void contextInitialized(ServletContextEvent event) {
- try {
- timer = new Timer(true);
-// event.getServletContext().log("定时器已启动");//添加日志,可在tomcat日志中查看到
-// timer.schedule(new SendEmailTask(event.getServletContext()),0,60*1000);
-// Thread.sleep(1000);
-// while(SendEmailTask.isRunning){
-// Thread.sleep(1000);
-// }
-// mac_timer = new Timer(true);
-// mac_timer.schedule(new UpdateMacTask(event.getServletContext()),0,23*60*60*1000);
-// event.getServletContext().log("已经添加任务");
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
-
-}
\ No newline at end of file
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GifExample.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GifExample.java
deleted file mode 100644
index e30b312..0000000
--- a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GifExample.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.yin.ycontrol.screenShotter;
-import java.awt.*;
-import java.awt.image.*;
-import java.io.*;
-import javax.imageio.*;
-
-/**
- * 创建透明的GIF图像
- * @author Winter Lau (javayou@gmail.com)
- * @url http://www.oschina.net
- * @date 2009-8-10 上午09:58:16
- */
-public class GifExample {
- public static void main(String[] args) throws IOException {
- boolean ok = ImageIO.write(createImage(), "gif", new File("C://test.gif"));
- System.out.println("success=" + ok);
- }
-
- static BufferedImage createImage() {
- IndexColorModel cm = createIndexColorModel();;
- BufferedImage im = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_INDEXED, cm);
- Graphics2D g = im.createGraphics();
- g.setColor(new Color(0,0,0,0)); //transparent
- g.fillRect(0, 0, 100, 100);
- g.setColor(Color.RED);
- g.fillRect(0, 0, 50, 50);
- g.setColor(Color.GREEN);
- g.fillRect(50, 50, 50, 50);
- g.dispose();
- return im;
- }
-
- static IndexColorModel createIndexColorModel() {
- BufferedImage ex = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
- IndexColorModel icm = (IndexColorModel) ex.getColorModel();
- int SIZE = 256;
- byte[] r = new byte[SIZE];
- byte[] g = new byte[SIZE];
- byte[] b = new byte[SIZE];
- byte[] a = new byte[SIZE];
- icm.getReds(r);
- icm.getGreens(g);
- icm.getBlues(b);
- java.util.Arrays.fill(a, (byte)255);
- r[0] = g[0] = b[0] = a[0] = 0; //transparent
- return new IndexColorModel(8, SIZE, r, g, b, a);
- }
-}
\ No newline at end of file
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GuiCamera.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GuiCamera.java
index 1f1ed5a..45da19b 100644
--- a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GuiCamera.java
+++ b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/GuiCamera.java
@@ -9,43 +9,37 @@
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
-
import javax.imageio.ImageIO;
-
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-
-/*******************************************************************
- * ��JavaBean����ֱ��������JavaӦ�ó����е��ã�ʵ����Ļ��"����"
- * This JavaBean is used to snapshot the GUI in a
- * Java application! You can embeded
- * it in to your java application source code, and us
- * it to snapshot the right GUI of the application
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+/*******************************************************************
+ * This JavaBean is used to snapshot the GUI in a
+ * Java application! You can embeded
+ * it in to your java application source code, and us
+ * it to snapshot the right GUI of the application
*
*****************************************************/
public class GuiCamera
{
- private String fileName; //�ļ���ǰ
+ private String fileName;
private String defaultName = "GuiCamera";
static int serialNum=0;
- private String imageFormat; //ͼ���ļ��ĸ�ʽ
+ private String imageFormat;
private String defaultImageFormat="png";
static Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
static BufferedImage screenshot;
static Date lasttime=new Date(new Date().getTime()-10000);
- /****************************************************************
- * Ĭ�ϵ��ļ�ǰΪGuiCamera���ļ���ʽΪPNG��ʽ
- * The default construct will use the default
- * Image file surname "GuiCamera",
- * and default image format "png"
+ /****************************************************************
+ * The default construct will use the default
+ * Image file surname "GuiCamera",
+ * and default image format "png"
****************************************************************/
public GuiCamera() {
fileName = defaultName;
@@ -53,11 +47,10 @@ public GuiCamera() {
}
- /****************************************************************
- * @param s the surname of the snapshot file
- * @param format the format of the image file,
- * it can be "jpg" or "png"
- * ������֧��JPG��PNG�ļ��Ĵ洢
+ /****************************************************************
+ * @param s the surname of the snapshot file
+ * @param format the format of the image file,
+ * it can be "jpg" or "png"
****************************************************************/
public GuiCamera(String s,String format) {
@@ -65,33 +58,31 @@ public GuiCamera(String s,String format) {
imageFormat=format;
}
- /****************************************************************
- * ����Ļ��������
- * snapShot the Gui once
+ /****************************************************************
+ * snapShot the Gui once
****************************************************************/
public void snapShot(BufferedImage screenshot,String format) {
try {
- //������Ļ��һ��BufferedImage����screenshot
- //�����ļ�ǰ�������ļ���ʽ�������Զ������ļ���
Date start=new Date();
String name=fileName+String.valueOf(serialNum)+"."+format;
File f = new File(name);
OutputStream jos = new FileOutputStream( f );
System.out.print("Save File "+name);
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( jos );
- JPEGEncodeParam jpegEP = JPEGCodec.getDefaultJPEGEncodeParam( screenshot );
- jpegEP.setQuality( (float) 0.1 , true );
- encoder.encode( screenshot , jpegEP );
-
+// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( jos );
+// JPEGEncodeParam jpegEP = JPEGCodec.getDefaultJPEGEncodeParam( screenshot );
+// jpegEP.setQuality( (float) 0.1 , true );
+// encoder.encode( screenshot , jpegEP );
+
+ ImageOutputStream ios = ImageIO.createImageOutputStream(jos);
+ ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("png").next();
+ imageWriter.setOutput(ios);
+ imageWriter.write(screenshot);
+ jos.close();
+ imageWriter.dispose();
serialNum++;
-
- jos.flush();
- jos.close();
- //��screenshot����д��ͼ���ļ�
-
//ImageIO.write(screenshot, format, f);
Date end=new Date();
System.out.print("..Finished! Cost "+(end.getTime()-start.getTime())+"\n");
@@ -112,14 +103,11 @@ public static BufferedImage screenShot() {
screenshot = robot
.createScreenCapture(new Rectangle(0, 0,
(int) d.getWidth(), (int) d.getHeight()));
- //�������
- //��ȡ���λ��
Point p=java.awt.MouseInfo.getPointerInfo().getLocation();
Graphics g = screenshot.getGraphics();
g.setColor(Color.red);
g.fillRoundRect(p.x-10, p.y-10, 20, 20,40,40);
g.dispose();
- //ѹ��
screenshot=getConvertedImage(screenshot);
}
return screenshot;
@@ -137,13 +125,11 @@ public static BufferedImage screenShot() {
}
}
- //ѹ��ͼ��
private static BufferedImage getConvertedImage(BufferedImage image){
int width=image.getWidth();
int height=image.getHeight();
- BufferedImage convertedImage=null;
- Graphics2D g2D=null;
- //���ô�1 �ֽ�alpha��TYPE_4BYTE_ABGR�����������صIJ�����
+ BufferedImage convertedImage;
+ Graphics2D g2D;
convertedImage=new BufferedImage(width, height, BufferedImage.TYPE_USHORT_555_RGB);
g2D = (Graphics2D) convertedImage.getGraphics();
g2D.drawImage(image, 0, 0, null);
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageServlet.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageServlet.java
index 51a22e6..2ceb0f4 100644
--- a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageServlet.java
+++ b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageServlet.java
@@ -1,27 +1,14 @@
package com.yin.ycontrol.screenShotter;
import java.awt.image.BufferedImage;
-import java.io.File;
import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-import java.util.HashMap;
import javax.imageio.ImageIO;
-import javax.imageio.spi.ImageWriterSpi;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import sun.awt.image.PNGImageDecoder;
-
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-import com.sun.imageio.plugins.png.PNGImageWriter;
public class ImageServlet extends HttpServlet {
/**
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageUtil.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageUtil.java
index 82aa8b4..49dd80a 100644
--- a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageUtil.java
+++ b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/ImageUtil.java
@@ -1,9 +1,6 @@
package com.yin.ycontrol.screenShotter;
-import java.awt.AlphaComposite;
import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.util.Date;
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/IndexServlet.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/IndexServlet.java
new file mode 100644
index 0000000..6aa1e75
--- /dev/null
+++ b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/IndexServlet.java
@@ -0,0 +1,52 @@
+package com.yin.ycontrol.screenShotter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * 主页
+ *
+ * @author yinzhennan
+ * @version V1.0
+ * @since 2020-05-22 15:39
+ */
+public class IndexServlet extends HttpServlet {
+ private static final long serialVersionUID = 8193565819750469797L;
+
+ /**
+ * 执行登陆的业务处理
+ *
+ * @param request:发送上来的请求 destJsp:目标URL
+ */
+ public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ //设置页面不缓存
+ response.setHeader("Content-Type", "text/html; charset=utf-8");
+ response.setHeader("Pragma", "No-cache");
+ response.setHeader("Cache-Control", "no-cache");
+ response.setDateHeader("Expires", 0);
+
+ ServletOutputStream output = response.getOutputStream();
+ try {
+ final InputStream resourceAsStream = IndexServlet.class.getResourceAsStream("/webapp/index.vm");
+ int i = resourceAsStream.available();
+ byte[] content = new byte[i];
+ resourceAsStream.read(content);
+ String indexHTML = new String(content, StandardCharsets.UTF_8);
+ indexHTML = indexHTML.replaceAll("SCREEN_WIDTH", ""+GuiCamera.getWidth());
+ indexHTML = indexHTML.replaceAll("SCREEN_HEIGHT", ""+GuiCamera.getHeight());
+ output.write(indexHTML.getBytes(StandardCharsets.UTF_8));
+ output.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ output.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/VedioServlet.java b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/VideoServlet.java
similarity index 61%
rename from yin-control/src/main/java/com/yin/ycontrol/screenShotter/VedioServlet.java
rename to yin-control/src/main/java/com/yin/ycontrol/screenShotter/VideoServlet.java
index 669f302..81300a5 100644
--- a/yin-control/src/main/java/com/yin/ycontrol/screenShotter/VedioServlet.java
+++ b/yin-control/src/main/java/com/yin/ycontrol/screenShotter/VideoServlet.java
@@ -1,31 +1,26 @@
package com.yin.ycontrol.screenShotter;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
-import java.util.Random;
import javax.imageio.ImageIO;
-import javax.servlet.ServletException;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
+public class VideoServlet extends HttpServlet {
+ private static final long serialVersionUID = 8193565819750469797L;
-public class VedioServlet extends HttpServlet {
/**
* 执行登陆的业务处理
* @param request:发送上来的请求
- * @return destJsp:目标URL
+ * destJsp:目标URL
*/
public void service(HttpServletRequest request,
- HttpServletResponse response) throws IOException,ServletException{
+ HttpServletResponse response) throws IOException {
//设置页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
@@ -38,12 +33,12 @@ public void service(HttpServletRequest request,
try {
while(true){
BufferedImage image = GuiCamera.screenShot();
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( output );
- JPEGEncodeParam jpegEP = JPEGCodec.getDefaultJPEGEncodeParam( image );
- jpegEP.setQuality( (float) 0.3 , true );
- encoder.encode( image , jpegEP );
// 输出图象到页面
- output.flush();
+ ImageOutputStream ios = ImageIO.createImageOutputStream(output);
+ ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("png").next();
+ imageWriter.setOutput(ios);
+ imageWriter.write(image);
+
try{
Thread.sleep(200);
}catch(InterruptedException e){
diff --git a/yin-control/src/main/java/com/yin/ycontrol/task/UpdateMacTask.java b/yin-control/src/main/java/com/yin/ycontrol/task/UpdateMacTask.java
deleted file mode 100644
index 2af91c9..0000000
--- a/yin-control/src/main/java/com/yin/ycontrol/task/UpdateMacTask.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.yin.ycontrol.task;
-
-import java.util.TimerTask;
-import javax.servlet.ServletContext;
-
-
-public class UpdateMacTask extends TimerTask {
- public static boolean isRunning = false;
- private ServletContext context = null;
-
- public UpdateMacTask(ServletContext context) {
- this.context = context;
- }
-
- public void run() {
- if (!isRunning) {
- isRunning = true;
- // -------------------开始保存当日历史记录
-
- //RegistryUtil.updateMac();
- //NetUtil.restartNet();
- // -------------------结束
- isRunning = false;
- }else {
- context.log("上一次任务执行还未结束");
- }
- }
-
-}
diff --git a/yin-control/src/main/java/com/yin/ycontrol/util/NetUtil.java b/yin-control/src/main/java/com/yin/ycontrol/util/NetUtil.java
deleted file mode 100644
index 0fbdd38..0000000
--- a/yin-control/src/main/java/com/yin/ycontrol/util/NetUtil.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.yin.ycontrol.util;
-
-public class NetUtil {
- public static void restartNet(){
- try{
- Runtime.getRuntime().exec("netsh interface set interface name=\"本地连接\" admin=DISABLED");
- Thread.sleep(20000);
- Runtime.getRuntime().exec("netsh interface set interface name=\"本地连接\" admin=ENABLED");
- }catch(Exception e){
- System.out.println(e.getMessage());
- }
- }
- public static void main(String[] args){
- restartNet();
- }
-}
diff --git a/yin-control/src/main/java/jetty/JettyServer.java b/yin-control/src/main/java/jetty/JettyServer.java
index f519b54..d184de0 100644
--- a/yin-control/src/main/java/jetty/JettyServer.java
+++ b/yin-control/src/main/java/jetty/JettyServer.java
@@ -1,63 +1,76 @@
package jetty;
-import javax.naming.ConfigurationException;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.log.StdErrLog;
+import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
-import com.yin.common.util.ConfigUtil;
-
/**
* @author hongxia.huhx GuahaoJettyServer for Jetty
*/
public class JettyServer {
- /** port */
- private static int port = 11056;
-
- public static int getPort() {
- return port;
- }
+ public static final int DEFAULT_PORT = 11056;
+ /**
+ * port
+ */
+ private int port = DEFAULT_PORT;
- protected String charset = "UTF-8";
+ public JettyServer(String port) {
+ if(port != null && port.matches("\\d+")){
+ this.port = Integer.parseInt(port);
+ }else{
+ System.out.println("端口设置有误, 将使用默认端口:"+this.port);
+ }
- public JettyServer() {
}
/**
* 服务器启动。
- *
- * @throws ConfigurationException
*/
public void start() {
- try{
- port=Integer.parseInt(ConfigUtil.get("port"));
- }catch(Exception ex){}
- // 设置Jetty日志
- System.setProperty("org.eclipse.jetty.util.log.class", StdErrLog.class.getName());
-
- Server server = new Server();
-
- // 设置连接器
- Connector connector = new SelectChannelConnector();
- connector.setPort(port);
- connector.setRequestHeaderSize(16246);
- server.setConnectors(new Connector[] { connector });
-
- // 设置context
- WebAppContext context = new WebAppContext();
- context.setResourceBase("./WebRoot");
- context.setContextPath("/");
- // PS:嵌入式的Jetty,应用当前工程的ClassPath,如果不设置将使用WebAppClassLoder,WEB-INF/lib目录加载jar。
- context.setClassLoader(Thread.currentThread().getContextClassLoader());
- context.setParentLoaderPriority(true);
- server.setHandler(context);
-
- // 启动Server
try {
+ // 设置Jetty日志
+ System.setProperty("org.eclipse.jetty.util.log.class", StdErrLog.class.getName());
+
+ Server server = new Server();
+
+ // 设置连接器
+ HttpConfiguration config = new HttpConfiguration();
+ config.setRequestHeaderSize(16246);
+ ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(config));
+ connector.setReuseAddress(true);
+ connector.setIdleTimeout(30000);
+ connector.setPort(port);
+ server.setConnectors(new Connector[] { connector });
+
+ // Connector connector = new SelectChannelConnector();
+ // connector.setPort(port);
+ // connector.setRequestHeaderSize(16246);
+ // server.setConnectors(new Connector[] { connector });
+
+ // 设置context
+ WebAppContext context = new WebAppContext();
+ // context.setResourceBase("./WebRoot");
+ URL webRootLocation = JettyServer.class.getResource("/webapp/");
+ System.out.println(webRootLocation.toString());
+ // context.setResourceBase(new ClassPathResource("classpath:templates/publicTemplete.xml"););
+ context.setBaseResource(Resource.newResource(webRootLocation));
+ context.setContextPath("/");
+ // PS:嵌入式的Jetty,应用当前工程的ClassPath,如果不设置将使用WebAppClassLoder,WEB-INF/lib目录加载jar。
+ context.setClassLoader(Thread.currentThread().getContextClassLoader());
+ context.setParentLoaderPriority(true);
+ server.setHandler(context);
+
server.start();
server.join();
} catch (Exception e) {
@@ -66,8 +79,19 @@ public void start() {
}
public static void main(String[] args) {
- JettyServer userServer = new JettyServer();
+
+ String port = getArgValue("-port", args);
+ JettyServer userServer = new JettyServer(port);
userServer.start();
}
+
+ public static String getArgValue(String argName, String[] args) {
+ final List argsList = Arrays.asList(args);
+ final int portIndex = argsList.indexOf(argName);
+ if (argsList.size() > portIndex + 1) {
+ return argsList.get(portIndex + 1);
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/yin-control/src/main/resources/config.properties b/yin-control/src/main/resources/config.properties
deleted file mode 100644
index 4c4c9a2..0000000
--- a/yin-control/src/main/resources/config.properties
+++ /dev/null
@@ -1 +0,0 @@
-port=11056
\ No newline at end of file
diff --git a/yin-control/WebRoot/META-INF/MANIFEST.MF b/yin-control/src/main/resources/webapp/META-INF/MANIFEST.MF
similarity index 100%
rename from yin-control/WebRoot/META-INF/MANIFEST.MF
rename to yin-control/src/main/resources/webapp/META-INF/MANIFEST.MF
diff --git a/yin-control/WebRoot/WEB-INF/web.xml b/yin-control/src/main/resources/webapp/WEB-INF/web.xml
similarity index 76%
rename from yin-control/WebRoot/WEB-INF/web.xml
rename to yin-control/src/main/resources/webapp/WEB-INF/web.xml
index c78e3d9..1fb852d 100644
--- a/yin-control/WebRoot/WEB-INF/web.xml
+++ b/yin-control/src/main/resources/webapp/WEB-INF/web.xml
@@ -1,44 +1,44 @@
-
-
-
- index.jsp
-
-
-
-
- com.yin.ycontrol.listener.ContextListener
-
-
-
-
-
- ImageServlet
- com.yin.ycontrol.screenShotter.ImageServlet
-
-
- ImageServlet
- /ImageServlet
-
-
-
- ControlServlet
- com.yin.ycontrol.screenShotter.ControlServlet
-
-
- ControlServlet
- /ControlServlet
-
-
-
- VedioServlet
- com.yin.ycontrol.screenShotter.VedioServlet
-
-
- VedioServlet
- /VedioServlet
-
-
+
+
+
+
+
+ IndexServlet
+ com.yin.ycontrol.screenShotter.IndexServlet
+
+
+ IndexServlet
+ /
+
+
+
+ ImageServlet
+ com.yin.ycontrol.screenShotter.ImageServlet
+
+
+ ImageServlet
+ /ImageServlet
+
+
+
+ ControlServlet
+ com.yin.ycontrol.screenShotter.ControlServlet
+
+
+ ControlServlet
+ /ControlServlet
+
+
+
+ VedioServlet
+ com.yin.ycontrol.screenShotter.VideoServlet
+
+
+ VedioServlet
+ /VedioServlet
+
+
diff --git a/yin-control/WebRoot/index.jsp b/yin-control/src/main/resources/webapp/index.vm
similarity index 77%
rename from yin-control/WebRoot/index.jsp
rename to yin-control/src/main/resources/webapp/index.vm
index 33f31ba..7dfefcc 100644
--- a/yin-control/WebRoot/index.jsp
+++ b/yin-control/src/main/resources/webapp/index.vm
@@ -1,157 +1,149 @@
-<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
-<%@page import="com.yin.ycontrol.screenShotter.GuiCamera" %>
-<%
- String path = request.getContextPath();
- String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
-%>
-
-
-
-
-
- 监控-支持HTML5的浏览器
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 监控-支持HTML5的浏览器
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/yin-control/WebRoot/js/jquery-1.4.4.min.js b/yin-control/src/main/resources/webapp/js/jquery-1.4.4.min.js
similarity index 100%
rename from yin-control/WebRoot/js/jquery-1.4.4.min.js
rename to yin-control/src/main/resources/webapp/js/jquery-1.4.4.min.js