当前位置: 首页 > 工具软件 > Jwebap > 使用案例 >

学习使用Jwebap来监测程序性能

朱宏爽
2023-12-01

一:web.xml配置文件 (带注释的)

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
 version="2.5">
 <display-name>chea</display-name>
 <distributable />

 <!-- start 程序性能监测参数配置 -->
 <context-param>
  <param-name>jwebap-config</param-name>
  <param-value>/WEB-INF/jwebap.xml</param-value>
 </context-param>
 <!-- end -->

 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath*:/spring-context.xml</param-value>
 </context-param>
 <filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>JspFilter</filter-name>
  <filter-class>com.easybiz.ssi.web.filter.JspFilter</filter-class>
  <init-param>
   <param-name>allowedJsp</param-name>
   <param-value>/default.jsp,/timeout.jsp,/403.jsp,/404.jsp,/500.jsp,/daoException.jsp</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>JspFilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>managerFilter</filter-name>
  <filter-class>com.easybiz.ssi.web.filter.SimpleAuthenticateFilter</filter-class>
  <init-param>
   <param-name>sessionKey</param-name>
   <param-value>user_info</param-value>
  </init-param>
  <init-param>
   <param-name>userType</param-name>
   <param-value>9</param-value>
  </init-param>
  <init-param>
   <param-name>loginPage</param-name>
   <param-value>/admin/timeout.jsp</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>managerFilter</filter-name>
  <url-pattern>/admin/manager/*</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>individualFilter</filter-name>
  <filter-class>com.easybiz.ssi.web.filter.SimpleAuthenticateFilter</filter-class>
  <init-param>
   <param-name>sessionKey</param-name>
   <param-value>user_info</param-value>
  </init-param>
  <init-param>
   <param-name>userType</param-name>
   <param-value>0</param-value>
  </init-param>
  <init-param>
   <param-name>loginPage</param-name>
   <param-value>/Register/timeout.jsp</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>individualFilter</filter-name>
  <url-pattern>/individual/*</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>dealerFilter</filter-name>
  <filter-class>com.easybiz.ssi.web.filter.SimpleAuthenticateFilter</filter-class>
  <init-param>
   <param-name>sessionKey</param-name>
   <param-value>user_info</param-value>
  </init-param>
  <init-param>
   <param-name>userType</param-name>
   <param-value>1,2</param-value>
  </init-param>
  <init-param>
   <param-name>loginPage</param-name>
   <param-value>/Register/timeout.jsp</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>dealerFilter</filter-name>
  <url-pattern>/dealer/*</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>urlRewriteFilter</filter-name>
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  <init-param>
   <param-name>confPath</param-name>
   <param-value>/WEB-INF/config/urlrewrite/urlrewrite.xml</param-value>
  </init-param>
  <init-param>
   <param-name>logLevel</param-name>
   <param-value>WARN</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>urlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
 </filter-mapping>

 <!-- start 程序性能监测,为Tracer插件增加Filter -->
 <filter>
  <filter-name>PageDetectFilter</filter-name>
  <filter-class>org.jwebap.plugin.tracer.http.DetectFilter</filter-class>
  <init-param>
   <param-name>excludeUrls</param-name>
   <param-value>/detect;/detect/*;*.js;*.jpg;*.htm;*.html;*.gif;*.png;*.css;*.swf</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>PageDetectFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <!-- end -->


 <!-- start 建议放在所有listener之前,程序性能监测 -->
 <listener>
  <listener-class>org.jwebap.startup.JwebapListener</listener-class>
 </listener>
 <!-- end -->


 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <listener>
  <listener-class>com.easybiz.ssi.web.listener.ResourceListener</listener-class>
 </listener>
 <listener>
  <listener-class>com.easybiz.chea.web.listener.BaseDataContextListener</listener-class>
 </listener>
 <listener>
  <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
 </listener>
 <listener>
  <listener-class>com.easybiz.chea.web.listener.TaskManager</listener-class>
 </listener>

 <!-- servlets -->
 <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  <init-param>
   <param-name>config</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/admin</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-manager.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/channel</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-channel.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/product</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-product.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/individual</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-individual.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/topic</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-topic.xml</param-value>
  </init-param>
  <init-param>
   <param-name>config/dealer</param-name>
   <param-value>/WEB-INF/config/struts/strutsConfig-dealer.xml</param-value>
  </init-param>
  <init-param>
   <param-name>debug</param-name>
   <param-value>2</param-value>
  </init-param>
  <init-param>
   <param-name>detail</param-name>
   <param-value>2</param-value>
  </init-param>
  <load-on-startup>2</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>
 <servlet>
  <servlet-name>Connector</servlet-name>
  <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>Connector</servlet-name>
  <url-pattern>/commons/fckeditor/editor/filemanager/connectors/*</url-pattern>
 </servlet-mapping>
 <servlet>
  <servlet-name>VerificationCode</servlet-name>
  <servlet-class>com.easybiz.ssi.web.servlet.VerificationCodeServlet</servlet-class>
  <init-param>
   <param-name>codeType</param-name>
   <param-value>0</param-value>
  </init-param>
 </servlet>
 <servlet-mapping>
  <servlet-name>VerificationCode</servlet-name>
  <url-pattern>/images/VerificationCode.jpg</url-pattern>
 </servlet-mapping>
 
 <!-- start 程序性能监测,增加Jwebap控制台Servlet -->
 <servlet>
  <servlet-name>detect</servlet-name>
  <servlet-class>org.jwebap.ui.controler.JwebapServlet</servlet-class> 
 </servlet>
 <servlet-mapping>
  <servlet-name>detect</servlet-name>
  <url-pattern>/detect/*</url-pattern>
 </servlet-mapping>
 <!-- end -->
 
 
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>
 <jsp-config>
  <jsp-property-group>
   <url-pattern>*.jsp</url-pattern>
   <scripting-invalid>true</scripting-invalid>
  </jsp-property-group>
 </jsp-config>

</web-app>

 

二:添加bin包以及lib包中的jar到项目,复制jwebap.xml到WEB-INF下。

 

三:启动程序,并配置参数(点击左边plugins-->Tracer)

配置JdbcComponent 时,driver-clazzs最好写数据源,如:org.apache.commons.dbcp.BasicDataSource

四:重启程序即可。。。。。。。
 类似资料: