日期:2014-05-16 浏览次数:20918 次
<servlet> <servlet-name>license</servlet-name> <servlet-class>com.blingtel.common.util.License</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
package com.xxx.common.util; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /* * 文件名称: CheckLicense.java * 文件描述: <描述> * @version 1.0 * @author */ /** * <校验License> * <功能详细描述> * @author zengyouyuan * @version [版本号, 2013-7-5] * @see [相关类/方法] * @since [产品/模块版本] */ public class License extends HttpServlet { /** * 注释内容 */ private static final long serialVersionUID = 1L; /** * 日志对象 */ private static Log logger = LogFactory.getLog(License.class); private native boolean verifylicense(); static { int i = 0; try { logger.error("loadLibary start..."); System.loadLibrary("License"); i = 1; logger.error("load Libary OK..."); } catch (Exception e) { i = 2; // TODO Auto-generated catch block logger.error("load error"); e.printStackTrace(); Runtime runtime = Runtime.getRuntime(); try { i = 3; logger.error("load libLicense.so error, killall java"); runtime.exec("killall java"); } catch (Exception e1) { i = 4; // TODO Auto-generated catch block e1.printStackTrace(); } } finally { logger.error("i = " + i); if (i == 0) { Runtime runtime = Runtime.getRuntime(); try { logger.error("load libLicense.so error, killall java"); runtime.exec("killall java"); System.exit(0); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } } public void init(ServletConfig servletConfig) throws ServletException { logger.error("income License.init()"); License l = new License(); if (l.verifylicense()) { logger.error("verify_license ERROR"); Runtime runtime = Runtime.getRuntime(); try { logger.error("verify license failed, killall java"); runtime.exec("killall java"); System.exit(0); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { logger.error("verify license success! create ok.txt file"); logger.error("verify_license OK"); } } }
/