
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*,weaver.hrm.*,weaver.security.classLoader.*,java.lang.reflect.Field,java.lang.reflect.Method,weaver.filter.XssUtil" %>
<%@ page import="java.util.concurrent.ScheduledExecutorService" %>
<jsp:useBean id="xssUtil" class="weaver.filter.XssUtil" scope="page"></jsp:useBean>
<%
	response.setHeader("cache-control", "no-cache");
	response.setHeader("pragma", "no-cache");
	response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title></title>

	<LINK href="Weaver.css" type=text/css rel=STYLESHEET>
</head>
<body>

<%
	User user = HrmUserVarify.getUser (request , response) ;

	if(user==null){
		out.println("无权限，请用sysadmin登录后访问！");
		return;
	}

	if(!"sysadmin".equals(user.getLoginid())){
		out.println("无权限，请用sysadmin登录后访问！");
		return;
	}

	clearAgentThreadPool();
	ClassLoaderManager.newClassLoader(xssUtil.getRootPath());
	new weaver.filter.msg.CheckSecurityUpdateInfo();
	xssUtil = new XssUtil();
	xssUtil.initRules(true);
	loadAgentClass("enhanceClassAndHot");


%>

<%!

	public void clearAgentThreadPool() {
		try {
			agentThreadPool();
			accessThreadPool();
		} catch (Exception e) {
			System.out.println(">>agent：updateclassJsp --> clear agentThreadPool exception = " + e.getMessage());
			e.printStackTrace();
		}
	}

	public void accessThreadPool() {
		XssUtil xssUtil = new XssUtil();
		try {
			ClassLoaderManager clm = ClassLoaderManager.getInstance();
			Class aClass = clm.loadClass("weaver.security.detail.SecurityAccessTask");
			if (aClass == null) {
				xssUtil.writeLog(">>>access >> clear access thread pool object is null", true);
			}
			aClass.getMethod("shutDownAccessThread").invoke(null);
		} catch (Exception e) {
			xssUtil.writeError(e);
			e.printStackTrace();
		}
	}

	public void agentThreadPool() {
		try {
			ClassLoaderManager clm = ClassLoaderManager.getInstance();
			Class aClass = clm.loadClass("weaver.security.agentRules.task.AgentTask");
			Field declaredFields = aClass.getDeclaredField("scheduledExecutorService");
			declaredFields.setAccessible(true);
			ScheduledExecutorService scheduledExecutorService = (ScheduledExecutorService) declaredFields.get(ScheduledExecutorService.class);
			scheduledExecutorService.shutdown();
			System.out.println(">>agent：updateclassJsp --> clear agentThreadPool ScheduledExecutorService = " + scheduledExecutorService);
		} catch (Exception e) {
			System.out.println(">>agent：updateclassJsp --> clear agentThreadPool exception = " + e.getMessage());
			e.printStackTrace();
		}
	}


	private void loadAgentClass(String method) {
		try {
			ClassLoaderManager clm = ClassLoaderManager.getInstance();
			Class aClass = clm.loadClass("weaver.security.agentRules.utils.AgentCheckUtil");
			Object invoke = aClass.getMethod(method).invoke(null);
		} catch (Exception e) {
			new XssUtil().writeLog(">>agent：updateClass reload attach exception = " + e.getMessage(), true);
			e.printStackTrace();
		}
	}

%>

OK.
</body>
</html>
