Author: julien_viet
Date: 2011-04-27 17:23:28 -0400 (Wed, 27 Apr 2011)
New Revision: 6384
Added:
portal/branches/global-portlet-metadata/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationMonitoringFilter.java
Removed:
portal/branches/global-portlet-metadata/component/pc/src/main/java/org/exoplatform/portal/pc/filter/
Modified:
portal/branches/global-portlet-metadata/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/portlet.xml
portal/branches/global-portlet-metadata/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/portlet.xml
Log:
wire portlet application monitoring with ApplicationStatisticService
Modified:
portal/branches/global-portlet-metadata/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/portlet.xml
===================================================================
---
portal/branches/global-portlet-metadata/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/portlet.xml 2011-04-27
19:37:42 UTC (rev 6383)
+++
portal/branches/global-portlet-metadata/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/portlet.xml 2011-04-27
21:23:28 UTC (rev 6384)
@@ -23,10 +23,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
+ <!-- This filter collects runtime request statistics -->
<filter>
- <filter-name>RenderPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.RenderPerformanceFilter</filter-class>
+
<filter-name>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-name>
+
<filter-class>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-class>
+ <lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
+ <lifecycle>EVENT_PHASE</lifecycle>
+ <lifecycle>RESOURCE_PHASE</lifecycle>
<init-params>
<init-param>
<name>org.gatein.portlet.global.exclude</name>
@@ -35,22 +39,4 @@
</init-params>
</filter>
- <filter>
- <filter-name>ActionProcessingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.ActionProcessingPerformanceFilter</filter-class>
- <lifecycle>ACTION_PHASE</lifecycle>
- </filter>
-
- <filter>
- <filter-name>EventHandlingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.EventHandlingPerformanceFilter</filter-class>
- <lifecycle>EVENT_PHASE</lifecycle>
- </filter>
-
- <filter>
- <filter-name>ResourceServingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.ResourceServingPerformanceFilter</filter-class>
- <lifecycle>RESOURCE_PHASE</lifecycle>
- </filter>
-
</portlet-app>
Modified:
portal/branches/global-portlet-metadata/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/portlet.xml
===================================================================
---
portal/branches/global-portlet-metadata/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/portlet.xml 2011-04-27
19:37:42 UTC (rev 6383)
+++
portal/branches/global-portlet-metadata/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/portlet.xml 2011-04-27
21:23:28 UTC (rev 6384)
@@ -23,10 +23,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
+ <!-- This filter collects runtime request statistics -->
<filter>
- <filter-name>RenderPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.RenderPerformanceFilter</filter-class>
+
<filter-name>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-name>
+
<filter-class>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-class>
+ <lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
+ <lifecycle>EVENT_PHASE</lifecycle>
+ <lifecycle>RESOURCE_PHASE</lifecycle>
<init-params>
<init-param>
<name>org.gatein.portlet.global.exclude</name>
@@ -35,22 +39,4 @@
</init-params>
</filter>
- <filter>
- <filter-name>ActionProcessingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.ActionProcessingPerformanceFilter</filter-class>
- <lifecycle>ACTION_PHASE</lifecycle>
- </filter>
-
- <filter>
- <filter-name>EventHandlingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.EventHandlingPerformanceFilter</filter-class>
- <lifecycle>EVENT_PHASE</lifecycle>
- </filter>
-
- <filter>
- <filter-name>ResourceServingPerformanceFilter</filter-name>
-
<filter-class>org.exoplatform.portal.pc.filter.ResourceServingPerformanceFilter</filter-class>
- <lifecycle>RESOURCE_PHASE</lifecycle>
- </filter>
-
</portlet-app>
Added:
portal/branches/global-portlet-metadata/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationMonitoringFilter.java
===================================================================
---
portal/branches/global-portlet-metadata/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationMonitoringFilter.java
(rev 0)
+++
portal/branches/global-portlet-metadata/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationMonitoringFilter.java 2011-04-27
21:23:28 UTC (rev 6384)
@@ -0,0 +1,120 @@
+package org.exoplatform.portal.application;
+
+import org.exoplatform.container.PortalContainer;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.filter.FilterConfig;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.ResourceFilter;
+import java.io.IOException;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 4/5/11
+ */
+public class ApplicationMonitoringFilter implements ActionFilter, RenderFilter,
EventFilter, ResourceFilter
+{
+
+ public void init(FilterConfig cfg) throws PortletException
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void doFilter(ActionRequest req, ActionResponse resp, FilterChain chain) throws
IOException, PortletException
+ {
+ ApplicationStatistic stat = get(req);
+ if (stat != null)
+ {
+ long t = -System.currentTimeMillis();
+ chain.doFilter(req, resp);
+ t += System.currentTimeMillis();
+ stat.logTime(t);
+ }
+ else
+ {
+ chain.doFilter(req, resp);
+ }
+ }
+
+ public void doFilter(EventRequest req, EventResponse resp, FilterChain chain) throws
IOException, PortletException
+ {
+ ApplicationStatistic stat = get(req);
+ if (stat != null)
+ {
+ long t = -System.currentTimeMillis();
+ chain.doFilter(req, resp);
+ t += System.currentTimeMillis();
+ stat.logTime(t);
+ }
+ else
+ {
+ chain.doFilter(req, resp);
+ }
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws
IOException, PortletException
+ {
+ ApplicationStatistic stat = get(req);
+ if (stat != null)
+ {
+ long t = -System.currentTimeMillis();
+ chain.doFilter(req, resp);
+ t += System.currentTimeMillis();
+ stat.logTime(t);
+ }
+ else
+ {
+ chain.doFilter(req, resp);
+ }
+ }
+
+ public void doFilter(ResourceRequest req, ResourceResponse resp, FilterChain chain)
throws IOException, PortletException
+ {
+ ApplicationStatistic stat = get(req);
+ if (stat != null)
+ {
+ long t = -System.currentTimeMillis();
+ chain.doFilter(req, resp);
+ t += System.currentTimeMillis();
+ stat.logTime(t);
+ }
+ else
+ {
+ chain.doFilter(req, resp);
+ }
+ }
+
+ private ApplicationStatistic get(PortletRequest req) throws IOException,
PortletException
+ {
+ PortalContainer container = PortalContainer.getInstance();
+ ApplicationStatisticService service =
(ApplicationStatisticService)container.getComponentInstance(ApplicationStatisticService.class);
+ if (service != null)
+ {
+ PortletConfig portletConfig =
(PortletConfig)req.getAttribute("javax.portlet.config");
+ String portletName = portletConfig.getPortletName();
+ String phase = (String)req.getAttribute(PortletRequest.LIFECYCLE_PHASE);
+ String applicationId = portletName + "/" + phase;
+ return service.getApplicationStatistic(applicationId);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}