[jboss-svn-commits] JBoss Portal SVN: r5478 - trunk/portlet/src/main/org/jboss/portal/portlet/management

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 18 14:06:32 EDT 2006


Author: julien at jboss.com
Date: 2006-10-18 14:06:29 -0400 (Wed, 18 Oct 2006)
New Revision: 5478

Modified:
   trunk/portlet/src/main/org/jboss/portal/portlet/management/PortletContainerManagementInterceptorImpl.java
Log:
- avoid to create date objects when not needed
- use ConcurrentHashMap to preserve thread safery

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/management/PortletContainerManagementInterceptorImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/management/PortletContainerManagementInterceptorImpl.java	2006-10-18 17:57:07 UTC (rev 5477)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/management/PortletContainerManagementInterceptorImpl.java	2006-10-18 18:06:29 UTC (rev 5478)
@@ -34,6 +34,7 @@
 import org.jboss.portal.portlet.invocation.PortletInterceptor;
 import org.jboss.portal.portlet.invocation.PortletInvocation;
 import org.jboss.portal.portlet.invocation.RenderInvocation;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
@@ -47,26 +48,27 @@
     */
    private int sampleSize = 10;
 
-   private Map map = new HashMap();
+   private Map map = new ConcurrentHashMap();
    
    protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
    {
       PortletContext portlet = (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
       String portletName = portlet.getId();
-      Date start = new Date();
+
+      long delta = - System.currentTimeMillis();
       Object object = invocation.invokeNext();
-      Date done = new Date();
-      System.out.println(invocation);
+      delta += System.currentTimeMillis();
+
       if (invocation instanceof RenderInvocation)
       {
          Value value = getValue(portletName);
-         value.renderTimes.put(new Long(done.getTime() - start.getTime()));
+         value.renderTimes.put(new Long(delta));
          value.nbRenderCalls++;
       }
       else if (invocation instanceof ActionInvocation)
       {
          Value value = getValue(portletName);
-         value.actionTimes.put(new Long(done.getTime() - start.getTime()));
+         value.actionTimes.put(new Long(delta));
          value.nbActionCalls++;
       }
       return object;




More information about the jboss-svn-commits mailing list