portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r331613 - in /portals/jetspeed-2/trunk: components/statistics/src/java/org/apache/jetspeed/statistics/impl/ components/statistics/src/test/org/apache/jetspeed/statistics/ jetspeed-api/src/java/org/apache/jetspeed/statistics/
Date Mon, 07 Nov 2005 22:03:38 GMT
Author: taylor
Date: Mon Nov  7 14:03:29 2005
New Revision: 331613

URL: http://svn.apache.org/viewcvs?rev=331613&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-362
statistics portlet query and user support

Added:
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/UserStatsImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/UserStats.java
Modified:
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/AggregateStatisticsImpl.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPageStatistics.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPortletStatistics.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedUserStatistics.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/PortalStatisticsImpl.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/StatisticsQueryCriteriaImpl.java
    portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/statistics/TestStatistics.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/AggregateStatistics.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/InvalidCriteriaException.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/PortalStatistics.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/StatisticsQueryCriteria.java

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/AggregateStatisticsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/AggregateStatisticsImpl.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/AggregateStatisticsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/AggregateStatisticsImpl.java Mon Nov  7 14:03:29 2005
@@ -1,17 +1,17 @@
 /* Copyright 2005 Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jetspeed.statistics.impl;
 
 import java.util.ArrayList;
@@ -20,112 +20,162 @@
 
 import org.apache.jetspeed.statistics.AggregateStatistics;
 
-
-
 /**
  * AggregateStatisticsImpl
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: $
  */
 public class AggregateStatisticsImpl implements AggregateStatistics
 {
 
-    float avgProcessingTime;
-    float maxProcessingTime;
-    float minProcessingTime;
-    float stddevProcessingTime;
-    int hitcount;
-    
-    List statlist;
-    
-    public AggregateStatisticsImpl() {
+    private float avgProcessingTime;
+
+    private float maxProcessingTime;
+
+    private float minProcessingTime;
+
+    private float stddevProcessingTime;
+
+    private int hitcount;
+
+    private List statlist;
+
+    public AggregateStatisticsImpl()
+    {
         statlist = new ArrayList();
     }
-    
-    public void addRow(Map row) {
+
+    public void addRow(Map row)
+    {
         statlist.add(row);
     }
-    
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#getAvgProcessingTime()
      */
     public float getAvgProcessingTime()
     {
         return this.avgProcessingTime;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#getHitCount()
      */
     public int getHitCount()
     {
-         return this.hitcount;
+        return this.hitcount;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#getMaxProcessingTime()
      */
     public float getMaxProcessingTime()
     {
         return this.maxProcessingTime;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#getMinProcessingTime()
      */
     public float getMinProcessingTime()
     {
         return this.minProcessingTime;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#getStdDevProcessingTime()
      */
     public float getStdDevProcessingTime()
     {
         return this.stddevProcessingTime;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#setAvgProcessingTime(float)
      */
     public void setAvgProcessingTime(float time)
     {
         this.avgProcessingTime = time;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#setHitCount(int)
      */
     public void setHitCount(int hitCount)
     {
         this.hitcount = hitCount;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#setMaxProcessingTime(float)
      */
     public void setMaxProcessingTime(float time)
     {
         this.maxProcessingTime = time;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#setMinProcessingTime(float)
      */
     public void setMinProcessingTime(float time)
     {
         this.minProcessingTime = time;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.AggregateStatistics#setStdDevProcessingTime(float)
      */
     public void setStdDevProcessingTime(float time)
     {
         this.stddevProcessingTime = time;
     }
-    
-    
-    public String toString() {
-        String s = "hit count = "+this.hitcount+"\n";
-        s = s + "max time = "+this.maxProcessingTime+"\n";
-        s = s + "min time = "+this.minProcessingTime+"\n";
-        s = s + "avg time = "+this.avgProcessingTime+"\n";
-        s = s + "stddev   = "+this.stddevProcessingTime+"\n";
+
+    public String toString()
+    {
+        String s = "hit count = " + this.hitcount + "\n";
+        s = s + "max time = " + this.maxProcessingTime + "\n";
+        s = s + "min time = " + this.minProcessingTime + "\n";
+        s = s + "avg time = " + this.avgProcessingTime + "\n";
+        s = s + "stddev   = " + this.stddevProcessingTime + "\n";
         return s;
+    }
+
+    /**
+     * @return Returns the statlist.
+     */
+    public List getStatlist()
+    {
+        return statlist;
+    }
+
+    /**
+     * @param statlist
+     *            The statlist to set.
+     */
+    public void setStatlist(List statlist)
+    {
+        this.statlist = statlist;
     }
 }

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPageStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPageStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPageStatistics.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPageStatistics.java Mon Nov  7 14:03:29 2005
@@ -26,8 +26,8 @@
  * BatchedPageStatistics
  * </p>
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
  */
 public class BatchedPageStatistics extends BatchedStatistics

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPortletStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPortletStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPortletStatistics.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedPortletStatistics.java Mon Nov  7 14:03:29 2005
@@ -30,8 +30,8 @@
  * instances added to a BatchedStatistics instance are all of the same type
  * (Portlet Access, Page Access, or User Logout).
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
  */
 public class BatchedPortletStatistics extends BatchedStatistics

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedStatistics.java Mon Nov  7 14:03:29 2005
@@ -29,8 +29,8 @@
  * BatchedStatistics
  * </p>
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
  */
 public abstract class BatchedStatistics implements Runnable
@@ -114,11 +114,11 @@
         {
             try
             {
-                synchronized(this.thread) {
+                synchronized (this.thread)
+                {
                     this.thread.wait(msElapsedTimeThreshold / 4);
                 }
-            } 
-            catch (InterruptedException ie)
+            } catch (InterruptedException ie)
             {
                 keepRunning = false;
             }

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedUserStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedUserStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedUserStatistics.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/BatchedUserStatistics.java Mon Nov  7 14:03:29 2005
@@ -26,8 +26,8 @@
  * BatchedUserStatistics
  * </p>
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
  */
 public class BatchedUserStatistics extends BatchedStatistics

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/PortalStatisticsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/PortalStatisticsImpl.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/PortalStatisticsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/PortalStatisticsImpl.java Mon Nov  7 14:03:29 2005
@@ -24,11 +24,14 @@
 import java.sql.Timestamp;
 import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -45,6 +48,7 @@
 import org.apache.jetspeed.statistics.InvalidCriteriaException;
 import org.apache.jetspeed.statistics.PortalStatistics;
 import org.apache.jetspeed.statistics.StatisticsQueryCriteria;
+import org.apache.jetspeed.statistics.UserStats;
 import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
 
 /**
@@ -52,15 +56,15 @@
  * PortalStatisticsImpl
  * </p>
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
  */
 public class PortalStatisticsImpl extends PersistenceBrokerDaoSupport implements
         PortalStatistics
 {
 
-    /** 
+    /**
      * @see org.apache.jetspeed.statistics.PortalStatistics#forceFlush()
      */
     public void forceFlush()
@@ -123,38 +127,25 @@
     private long maxTimeMsToFlush_Page = 10 * 1000;
 
     ConnectionRepositoryEntry jetspeedDSEntry;
-    
+
     /* after this is NOT for injection */
 
     DataSource ds;
 
-    private int currentUsers = 0;
+    private int currentUserCount = 0;
+
+    private Map currentUsers;
 
     /* date formatter */
     protected SimpleDateFormat formatter = null;
 
-    /**
-     * <p>
-     * Default Constructor.
-     * </p>
-     */
-    public PortalStatisticsImpl()
+    public PortalStatisticsImpl(boolean logToCLF, boolean logToDatabase,
+            int maxRecordToFlush_Portal, int maxRecordToFlush_User,
+            int maxRecordToFlush_Page, long maxTimeMsToFlush_Portal,
+            long maxTimeMsToFlush_User, long maxTimeMsToFlush_Page,
+            ConnectionRepositoryEntry jetspeedDSEntry)
     {
-    }
-    
-    public PortalStatisticsImpl(
-             boolean logToCLF,
-             boolean logToDatabase,
-             int maxRecordToFlush_Portal,
-             int maxRecordToFlush_User,
-             int maxRecordToFlush_Page,
-             long maxTimeMsToFlush_Portal,
-             long maxTimeMsToFlush_User,
-             long maxTimeMsToFlush_Page,
-            ConnectionRepositoryEntry jetspeedDSEntry
-            )
-    {
-        
+
         this.logToCLF = logToCLF;
         this.logToDatabase = logToDatabase;
         this.maxRecordToFlush_Portlet = maxRecordToFlush_Portal;
@@ -164,27 +155,28 @@
         this.maxTimeMsToFlush_User = maxTimeMsToFlush_User;
         this.maxTimeMsToFlush_Page = maxTimeMsToFlush_Page;
         this.jetspeedDSEntry = jetspeedDSEntry;
-        
+        currentUsers = new TreeMap();
     }
 
     public void springInit() throws NamingException
     {
         formatter = new SimpleDateFormat("dd/MM/yyyy:hh:mm:ss z");
 
-        if (jetspeedDSEntry != null )
+        if (jetspeedDSEntry != null)
         {
-            if (jetspeedDSEntry.getJndiName() != null) {
+            if (jetspeedDSEntry.getJndiName() != null)
+            {
                 try
                 {
                     Context initialContext = new InitialContext();
-                    ds = (DataSource) initialContext.lookup(jetspeedDSEntry.getJndiName());
+                    ds = (DataSource) initialContext.lookup(jetspeedDSEntry
+                            .getJndiName());
                 } catch (NamingException e)
                 {
                     e.printStackTrace();
                     throw e;
                 }
-            }
-            else
+            } else
             {
                 BasicDataSource bds = new BasicDataSource();
                 bds.setDriverClassName(jetspeedDSEntry.getDriverClassName());
@@ -193,11 +185,8 @@
                 bds.setPassword(jetspeedDSEntry.getPassword());
                 ds = (DataSource) bds;
             }
-        } 
-        
-        
-        currentUsers = 0;
-
+        }
+        currentUserCount = 0;
     }
 
     public DataSource getDataSource()
@@ -247,8 +236,9 @@
         {
             if (portletBatch == null)
             {
-                portletBatch = new BatchedPortletStatistics(ds, this.maxRecordToFlush_Portlet, this.maxTimeMsToFlush_Portlet,
-                        "portletLogBatcher");
+                portletBatch = new BatchedPortletStatistics(ds,
+                        this.maxRecordToFlush_Portlet,
+                        this.maxTimeMsToFlush_Portlet, "portletLogBatcher");
             }
             portletBatch.addStatistic(record);
 
@@ -257,7 +247,8 @@
         {
             if (pageBatch == null)
             {
-                pageBatch = new BatchedPageStatistics(ds, this.maxRecordToFlush_Page, this.maxTimeMsToFlush_Page,
+                pageBatch = new BatchedPageStatistics(ds,
+                        this.maxRecordToFlush_Page, this.maxTimeMsToFlush_Page,
                         "pageLogBatcher");
             }
             pageBatch.addStatistic(record);
@@ -267,7 +258,8 @@
         {
             if (userBatch == null)
             {
-                userBatch = new BatchedUserStatistics(ds, this.maxRecordToFlush_User, this.maxTimeMsToFlush_User,
+                userBatch = new BatchedUserStatistics(ds,
+                        this.maxRecordToFlush_User, this.maxTimeMsToFlush_User,
                         "userLogBatcher");
             }
             userBatch.addStatistic(record);
@@ -352,24 +344,46 @@
         }
     }
 
-    public void logUserLogout(RequestContext request, long msElapsedTime)
+    public void logUserLogout(String ipAddress, String userName,
+            long msSessionLength)
     {
         try
         {
-            currentUsers = currentUsers - 1;
+            currentUserCount = currentUserCount - 1;
+
+            if (userName == null)
+            {
+                userName = "guest";
+            }
+
+            synchronized (currentUsers)
+            {
+                UserStats userStats = (UserStats) currentUsers.get(userName);
+                if (userStats == null)
+                {
+                    //log.warn("Trying to log out a user that was never logged
+                    // in!");
+                    userStats = new UserStatsImpl();
+                    userStats.setNumberOfSession(0);
+                    userStats.setUsername(userName);
+                    currentUsers.put(userName, userStats);
+                }
+                userStats
+                        .setNumberOfSession(userStats.getNumberOfSessions() - 1);
+                if (userStats.getNumberOfSessions() <= 0)
+                {
+                    currentUsers.remove(userName);
+                }
+            }
 
-            HttpServletRequest req = request.getRequest();
-            Principal principal = req.getUserPrincipal();
-            String userName = (principal != null) ? principal.getName()
-                    : "guest";
             Timestamp timestamp = new Timestamp(System.currentTimeMillis());
             UserLogRecord record = new UserLogRecord();
 
             record.setUserName(userName);
-            record.setIpAddress(req.getRemoteAddr());
+            record.setIpAddress(ipAddress);
             record.setStatus(STATUS_LOGGED_OUT);
             record.setTimeStamp(timestamp);
-            record.setMsElapsedTime(msElapsedTime);
+            record.setMsElapsedTime(msSessionLength);
 
             if (logToCLF)
             {
@@ -396,7 +410,7 @@
     {
         try
         {
-            currentUsers = currentUsers + 1;
+            currentUserCount = currentUserCount + 1;
 
             HttpServletRequest req = request.getRequest();
             Principal principal = req.getUserPrincipal();
@@ -405,6 +419,23 @@
             Timestamp timestamp = new Timestamp(System.currentTimeMillis());
             UserLogRecord record = new UserLogRecord();
 
+            synchronized (currentUsers)
+            {
+                UserStats userStats = (UserStats) currentUsers.get(userName);
+                if (userStats == null)
+                {
+                    //log.warn("Trying to log out a user that was never logged
+                    // in!");
+                    userStats = new UserStatsImpl();
+                    userStats.setNumberOfSession(0);
+                    userStats.setUsername(userName);
+                    currentUsers.put(userName, userStats);
+
+                }
+                userStats
+                        .setNumberOfSession(userStats.getNumberOfSessions() + 1);
+            }
+
             record.setUserName(userName);
             record.setIpAddress(req.getRemoteAddr());
             record.setStatus(STATUS_LOGGED_IN);
@@ -427,7 +458,7 @@
 
     }
 
-    /** 
+    /**
      * @see org.springframework.beans.factory.DisposableBean#destroy()
      */
     public void springDestroy()
@@ -435,16 +466,16 @@
         if (portletBatch != null)
         {
             portletBatch.tellThreadToStop();
-            synchronized(portletBatch.thread) 
+            synchronized (portletBatch.thread)
             {
                 portletBatch.thread.notify();
             }
-            
+
         }
         if (userBatch != null)
         {
             userBatch.tellThreadToStop();
-            synchronized(userBatch.thread) 
+            synchronized (userBatch.thread)
             {
                 userBatch.thread.notify();
             }
@@ -452,13 +483,13 @@
         if (pageBatch != null)
         {
             pageBatch.tellThreadToStop();
-            synchronized(pageBatch.thread) 
+            synchronized (pageBatch.thread)
             {
                 pageBatch.thread.notify();
             }
         }
 
-        if ((this.currentUsers != 0) && logger.isDebugEnabled())
+        if ((this.currentUserCount != 0) && logger.isDebugEnabled())
         {
             logger.debug("destroying while users are logged in");
         }
@@ -491,120 +522,131 @@
             try
             {
                 Thread.sleep(2);
-            } 
-            catch (InterruptedException ie)
+            } catch (InterruptedException ie)
             {
             }
         }
         long end = System.currentTimeMillis();
         // new we're done
-        
+
     }
 
-    /** 
+    /**
      * @see org.apache.jetspeed.statistics.PortalStatistics#getNumberOfCurrentUsers()
      */
     public int getNumberOfCurrentUsers()
     {
-        return currentUsers;
+        return currentUserCount;
     }
 
-    private Date getStartDateFromPeriod(String period,Date end) 
+    private Date getStartDateFromPeriod(String period, Date end)
     {
         GregorianCalendar gcEnd = new GregorianCalendar();
         gcEnd.setTime(end);
-        if(period != null) 
+        if (period != null)
         {
-            if(period.endsWith("m")) 
+            if (period.endsWith("m"))
             {
                 // months
-                String p = period.substring(0,period.length()-1);                
+                String p = period.substring(0, period.length() - 1);
                 int ret = Integer.parseInt(p);
-                gcEnd.add(Calendar.MONTH,(ret * -1));
-            } 
-            else if(period.endsWith("h")) 
+                gcEnd.add(Calendar.MONTH, (ret * -1));
+            } else if (period.endsWith("h"))
             {
                 // hours
-                String p = period.substring(0,period.length()-1);
+                String p = period.substring(0, period.length() - 1);
                 int ret = Integer.parseInt(p);
-                gcEnd.add(Calendar.HOUR,(ret * -1));
-            } 
-            else if(period.equals("all"))
+                gcEnd.add(Calendar.HOUR, (ret * -1));
+            } else if (period.equals("all"))
             {
                 gcEnd = new GregorianCalendar();
-                gcEnd.set(1968,07,15);
-            } 
-            else 
+                gcEnd.set(1968, 07, 15);
+            } else
             {
                 // minutes
                 int ret = Integer.parseInt(period);
-                gcEnd.add(Calendar.MINUTE,(ret * -1));
+                gcEnd.add(Calendar.MINUTE, (ret * -1));
             }
-        } 
-        else 
+        } else
         {
             gcEnd = new GregorianCalendar();
-            gcEnd.set(1968,07,15);
-        
+            gcEnd.set(1968, 07, 15);
+
         }
         return gcEnd.getTime();
     }
-    
+
     /**
      * @see org.apache.jetspeed.statistics.PortalStatistics#queryStatistics(org.apache.jetspeed.statistics.StatisticsQueryCriteria)
      */
-    public AggregateStatistics queryStatistics(StatisticsQueryCriteria criteria) throws InvalidCriteriaException
+    public AggregateStatistics queryStatistics(StatisticsQueryCriteria criteria)
+            throws InvalidCriteriaException
     {
         AggregateStatistics as = new AggregateStatisticsImpl();
         String query;
         String query2;
-        
+
         String tableName;
         String groupColumn;
-        
+
         Date end = new Date();
-        Date start = getStartDateFromPeriod(criteria.getTimePeriod(),end);
-        
-        
+        Date start = getStartDateFromPeriod(criteria.getTimePeriod(), end);
+
         String queryType = criteria.getQueryType();
         if ("user".equals(queryType))
         {
             tableName = "USER_STATISTICS";
             groupColumn = "USER_NAME";
-        }
-        else if ("portlet".equals(queryType))
+        } else if ("portlet".equals(queryType))
         {
             tableName = "PORTLET_STATISTICS";
             groupColumn = "PORTLET";
-        }
-        else if ("page".equals(queryType))
+        } else if ("page".equals(queryType))
         {
             tableName = "PAGE_STATISTICS";
             groupColumn = "PAGE";
-        }
-        else 
+        } else
         {
-            throw new InvalidCriteriaException(" invalid queryType passed to queryStatistics");
+            throw new InvalidCriteriaException(
+                    " invalid queryType passed to queryStatistics");
         }
         String orderColumn = "count";
-        
-        //String orderColumn = "MAX(ELAPSSE_TIME)";
-        //String orderColumn = "AVG(ELAPSED_TIME)";
-        //String orderColumn = "MIN(ELAPSED_TIME)";
-        
+
         String ascDesc = "DESC";
-        
-        query= "select count(*) as count , STDDEV(ELAPSED_TIME),MIN(ELAPSED_TIME),AVG(ELAPSED_TIME),MAX(ELAPSED_TIME) from "+tableName+" where time_stamp > ? and time_stamp < ?";
-        query2= "select count(*) as count ,"+groupColumn+", MIN(ELAPSED_TIME) as min ,AVG(ELAPSED_TIME) as avg ,MAX(ELAPSED_TIME) as max "
-                    +"from "+tableName+" where time_stamp > ? and time_stamp < ? group by "+groupColumn+"  order by "+orderColumn+" "+ascDesc+" limit 5";
+
+        if (!"user".equals(queryType))
+        {
+            query = "select count(*) as count , STDDEV(ELAPSED_TIME),MIN(ELAPSED_TIME),AVG(ELAPSED_TIME),MAX(ELAPSED_TIME) from "
+                    + tableName + " where time_stamp > ? and time_stamp < ?";
+            query2 = "select count(*) as count ,"
+                    + groupColumn
+                    + ", MIN(ELAPSED_TIME) as min ,AVG(ELAPSED_TIME) as avg ,MAX(ELAPSED_TIME) as max "
+                    + "from " + tableName
+                    + " where time_stamp > ? and time_stamp < ? group by "
+                    + groupColumn + "  order by " + orderColumn + " " + ascDesc
+                    + " limit 5";
+        } else
+        {
+            query = "select count(*) as count , STDDEV(ELAPSED_TIME),MIN(ELAPSED_TIME),AVG(ELAPSED_TIME),MAX(ELAPSED_TIME) from "
+                    + tableName
+                    + " where time_stamp > ? and time_stamp < ? and status = 2";
+            query2 = "select count(*) as count ,"
+                    + groupColumn
+                    + ", MIN(ELAPSED_TIME) as min ,AVG(ELAPSED_TIME) as avg ,MAX(ELAPSED_TIME) as max "
+                    + "from "
+                    + tableName
+                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
+                    + groupColumn + "  order by " + orderColumn + " " + ascDesc
+                    + " limit 5";
+        }
         try
         {
             Connection con = ds.getConnection();
             PreparedStatement pstmt = con.prepareStatement(query);
-            pstmt.setTimestamp(1,new Timestamp(start.getTime()));
-            pstmt.setTimestamp(2,new Timestamp(end.getTime()));
+            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
+            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
             ResultSet rs = pstmt.executeQuery();
-            if(rs.next()) 
+            if (rs.next())
             {
                 as.setHitCount(rs.getInt("count"));
                 as.setStdDevProcessingTime(rs.getFloat("STDDEV(ELAPSED_TIME)"));
@@ -613,31 +655,52 @@
                 as.setMaxProcessingTime(rs.getFloat("MAX(ELAPSED_TIME)"));
             }
             PreparedStatement pstmt2 = con.prepareStatement(query2);
-            pstmt2.setTimestamp(1,new Timestamp(start.getTime()));
-            pstmt2.setTimestamp(2,new Timestamp(end.getTime()));
+            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
+            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
             ResultSet rs2 = pstmt2.executeQuery();
-            while(rs2.next()) 
+
+            while (rs2.next())
             {
                 Map row = new HashMap();
-                row.put("count",""+rs2.getInt("count"));
-                row.put("groupColumn",rs2.getString(groupColumn));
-                row.put("min",""+rs2.getFloat("min"));
-                row.put("avg",""+rs2.getFloat("avg"));
-                row.put("max",""+rs2.getFloat("max"));
+                row.put("count", "" + rs2.getInt("count"));
+                row.put("groupColumn", rs2.getString(groupColumn));
+                row.put("min", "" + rs2.getFloat("min"));
+                row.put("avg", "" + rs2.getFloat("avg"));
+                row.put("max", "" + rs2.getFloat("max"));
                 as.addRow(row);
-                //as.setHitCount(rs.getInt("count"));
-                //as.setStdDevProcessingTime(rs.getFloat("STDDEV(ELAPSED_TIME)"));
-                //as.setMinProcessingTime(rs.getFloat("MIN(ELAPSED_TIME)"));
-                //as.setAvgProcessingTime(rs.getFloat("AVG(ELAPSED_TIME)"));
-                //as.setMaxProcessingTime(rs.getFloat("MAX(ELAPSED_TIME)"));
-            }
-        
-        } 
-        catch (SQLException e)
+            }
+
+        } catch (SQLException e)
         {
             throw new InvalidCriteriaException(e.toString());
         }
-        
+
         return as;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.PortalStatistics#getListOfLoggedInUsers()
+     */
+    public List getListOfLoggedInUsers()
+    {
+        List list = new ArrayList();
+
+        synchronized (currentUsers)
+        {
+            list.addAll(currentUsers.values());
+        }
+        return list;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.PortalStatistics#getNumberOfLoggedInUsers()
+     */
+    public int getNumberOfLoggedInUsers()
+    {
+        return this.currentUserCount;
     }
 }

Modified: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/StatisticsQueryCriteriaImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/StatisticsQueryCriteriaImpl.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/StatisticsQueryCriteriaImpl.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/StatisticsQueryCriteriaImpl.java Mon Nov  7 14:03:29 2005
@@ -1,16 +1,16 @@
-
 package org.apache.jetspeed.statistics.impl;
 
 import org.apache.jetspeed.statistics.StatisticsQueryCriteria;
 
-
 public class StatisticsQueryCriteriaImpl implements StatisticsQueryCriteria
 {
 
     String user;
+
     String timePeriod;
+
     String queryType;
-    
+
     /**
      * @return Returns the ipAddress.
      */
@@ -18,13 +18,16 @@
     {
         return timePeriod;
     }
+
     /**
-     * @param ipAddress The ipAddress to set.
+     * @param ipAddress
+     *            The ipAddress to set.
      */
     public void setTimePeriod(String ipAddress)
     {
         this.timePeriod = ipAddress;
     }
+
     /**
      * @return Returns the user.
      */
@@ -32,24 +35,30 @@
     {
         return user;
     }
+
     /**
-     * @param user The user to set.
+     * @param user
+     *            The user to set.
      */
     public void setUser(String user)
     {
         this.user = user;
     }
-    
-    
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.StatisticsQueryCriteria#getQueryType()
      */
     public String getQueryType()
     {
-        
+
         return queryType;
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.jetspeed.statistics.StatisticsQueryCriteria#setQueryType(java.lang.String)
      */
     public void setQueryType(String queryType)

Added: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/UserStatsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/UserStatsImpl.java?rev=331613&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/UserStatsImpl.java (added)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/statistics/impl/UserStatsImpl.java Mon Nov  7 14:03:29 2005
@@ -0,0 +1,75 @@
+/* Copyright 2005 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.statistics.impl;
+
+import org.apache.jetspeed.statistics.UserStats;
+
+/**
+ * UserStatsImpl
+ * 
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class UserStatsImpl implements UserStats
+{
+
+    private String username;
+
+    private int numberOfSessions;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.UserStats#getNumberOfSessions()
+     */
+    public int getNumberOfSessions()
+    {
+        return numberOfSessions;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.UserStats#getUsername()
+     */
+    public String getUsername()
+    {
+
+        return username;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.UserStats#setNumberOfSession(int)
+     */
+    public void setNumberOfSession(int number)
+    {
+        numberOfSessions = number;
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.statistics.UserStats#setUsername(java.lang.String)
+     */
+    public void setUsername(String username)
+    {
+        this.username = username;
+
+    }
+}

Modified: portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/statistics/TestStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/statistics/TestStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/statistics/TestStatistics.java (original)
+++ portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/statistics/TestStatistics.java Mon Nov  7 14:03:29 2005
@@ -19,6 +19,7 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -37,14 +38,15 @@
 /**
  * TestStatistics
  * 
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
  * @version $Id: $
  */
 public class TestStatistics extends AbstractSpringTestCase
 {
+
     private PortalStatistics statistics = null;
-    
+
     /*
      * (non-Javadoc)
      * 
@@ -65,21 +67,20 @@
     public static void main(String args[])
     {
         junit.awtui.TestRunner.main(new String[]
-        { TestStatistics.class.getName() });
-        
-        
+        { TestStatistics.class.getName()});
+
     }
 
-    
     protected void setUp() throws Exception
     {
         super.setUp();
         this.statistics = (PortalStatistics) ctx.getBean("PortalStatistics");
         assertNotNull("statistics not found ", statistics);
     }
-    
-    public void clearDBs() {
-        
+
+    public void clearDBs()
+    {
+
         try
         {
             Connection con = statistics.getDataSource().getConnection();
@@ -100,18 +101,19 @@
             fail("problem with database connection:" + e.toString());
         }
     }
-    
-    public int count(String query) {
+
+    public int count(String query)
+    {
         int val = -1;
         try
         {
             Connection con = statistics.getDataSource().getConnection();
 
-            PreparedStatement psmt = con
-                    .prepareStatement(query);
+            PreparedStatement psmt = con.prepareStatement(query);
             ResultSet rs = psmt.executeQuery();
-            
-            if(rs.next()) {
+
+            if (rs.next())
+            {
                 val = rs.getInt(1);
             }
             psmt.close();
@@ -122,33 +124,36 @@
         }
         return val;
     }
-    public int countPages() {
+
+    public int countPages()
+    {
         return count("SELECT count(*) from PAGE_STATISTICS");
     }
-        
-    public int countPortlets() {
+
+    public int countPortlets()
+    {
         return count("SELECT count(*) from PORTLET_STATISTICS");
     }
-    public int countUsers() {
+
+    public int countUsers()
+    {
         return count("SELECT count(*) from USER_STATISTICS");
     }
-    
+
     public static Test suite()
     {
         // All methods starting with "test" will be executed in the test suite.
         return new TestSuite(TestStatistics.class);
     }
-    
-    
-    public void testPortletStatistics() 
-    throws Exception
+
+    public void testPortletStatistics() throws Exception
     {
         System.out.println("testing one of each ");
         statistics.forceFlush();
         clearDBs();
-        
+
         assertNotNull("statistics service is null", statistics);
-        
+
         RequestContext request = initRequestContext();
         PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
         app.setName("MyApp");
@@ -157,32 +162,46 @@
         portlet.setName("TestPortlet");
         portlet.setPortletApplicationDefinition(app);
         long elapsedTime = 123;
-        statistics.logPortletAccess(request, portlet.getUniqueName(), "401",elapsedTime);
-        statistics.logPageAccess(request, "401",elapsedTime);
-        statistics.logUserLogin(request,elapsedTime);
-        statistics.logUserLogout(request,elapsedTime);
-        
+        statistics.logPortletAccess(request, portlet.getUniqueName(), "401",
+                elapsedTime);
+        statistics.logPageAccess(request, "401", elapsedTime);
+        statistics.logUserLogin(request, elapsedTime);
+
+        assertEquals("number of users incorrect", 1, statistics
+                .getNumberOfCurrentUsers());
+
+        List l = statistics.getListOfLoggedInUsers();
+        assertNotNull("list returned is null", l);
+        assertEquals("wrong number of users in list", 1, l.size());
+
+        statistics.logUserLogout("123.234.145.156", "SuperFakeyUser",
+                elapsedTime);
+
         statistics.forceFlush();
+
+        assertEquals("number of users incorrect", statistics
+                .getNumberOfCurrentUsers(), 0);
+
         int x = 1;
         int pages = this.countPages();
         int users = this.countUsers();
         int portlets = this.countPortlets();
-        assertEquals("User Log count incorrect ",2*x,users);
-        assertEquals("Portlet Log count incorrect ",x,portlets);
-        assertEquals("Page Log count incorrect ",x,pages);
-        
-    }
-    
-    public void testLotsOfPortletStatistics() 
-    throws Exception
+        assertEquals("User Log count incorrect ", 2 * x, users);
+        assertEquals("Portlet Log count incorrect ", x, portlets);
+        assertEquals("Page Log count incorrect ", x, pages);
+
+    }
+
+    public void testLotsOfPortletStatistics() throws Exception
     {
         System.out.println("testing Multiple portlet stats");
         statistics.forceFlush();
         clearDBs();
-        
+
         int x = 37;
         assertNotNull("statistics service is null", statistics);
-        for(int i = 0; i < x ; i++) {
+        for (int i = 0; i < x; i++)
+        {
             RequestContext request = initRequestContext();
             PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
             app.setName("MyApp");
@@ -190,51 +209,64 @@
             portlet.setPortletApplicationDefinition(app);
             portlet.setName("TestPortlet");
             portlet.setPortletApplicationDefinition(app);
-            long elapsedTime = 123+i;
+            long elapsedTime = 123 + i;
             //System.out.println("logging something, number "+i);
-            statistics.logPortletAccess(request, portlet.getUniqueName(), "401",elapsedTime);
-            statistics.logPageAccess(request, "401",elapsedTime);
-            statistics.logUserLogin(request,elapsedTime);
-            statistics.logUserLogout(request,elapsedTime);
-            try { Thread.sleep(200);} catch(InterruptedException ie) {}
+            statistics.logPortletAccess(request, portlet.getUniqueName(),
+                    "401", elapsedTime);
+            statistics.logPageAccess(request, "401", elapsedTime);
+            statistics.logUserLogin(request, elapsedTime);
+            assertEquals("number of users incorrect", 1, statistics
+                    .getNumberOfCurrentUsers());
+            List l = statistics.getListOfLoggedInUsers();
+            assertNotNull("list returned is null", l);
+            assertEquals("wrong number of users in list", 1, l.size());
+
+            statistics.logUserLogout("123.234.145.156", "SuperFakeyUser",
+                    elapsedTime);
+            try
+            {
+                Thread.sleep(200);
+            } catch (InterruptedException ie)
+            {
+            }
         }
-        
+
         statistics.forceFlush();
+
+        assertEquals("number of users incorrect", statistics
+                .getNumberOfCurrentUsers(), 0);
+
         int pages = this.countPages();
         int users = this.countUsers();
         int portlets = this.countPortlets();
-        assertEquals("User Log count incorrect ",2*x,users);
-        assertEquals("Portlet Log count incorrect ",x,portlets);
-        assertEquals("Page Log count incorrect ",x,pages);
-        
-        
+        assertEquals("User Log count incorrect ", 2 * x, users);
+        assertEquals("Portlet Log count incorrect ", x, portlets);
+        assertEquals("Page Log count incorrect ", x, pages);
+
     }
 
-    
-    public void testQuerySystem() 
-    throws Exception
+    public void testQuerySystem() throws Exception
     {
         System.out.println("testing Query System");
         StatisticsQueryCriteria sqc = new StatisticsQueryCriteriaImpl();
         sqc.setQueryType("user");
-        AggregateStatistics as = statistics.queryStatistics( sqc    );
-        System.out.println("user = "+as);
+        AggregateStatistics as = statistics.queryStatistics(sqc);
+        System.out.println("user = " + as);
         sqc.setQueryType("portlet");
-        as = statistics.queryStatistics( sqc );
-        System.out.println("user = "+as);
+        as = statistics.queryStatistics(sqc);
+        System.out.println("user = " + as);
         sqc.setQueryType("page");
-        as = statistics.queryStatistics( sqc );
-        System.out.println("user = "+as);
-        
+        as = statistics.queryStatistics(sqc);
+        System.out.println("user = " + as);
+
     }
-    
+
     private RequestContext initRequestContext()
     {
         MockHttpServletRequest request = new MockHttpServletRequest();
         MockHttpServletResponse response = new MockHttpServletResponse();
         MockHttpSession session = new MockHttpSession();
 
-        
         request.setRemoteAddr("192.168.2.3");
         request.setSession(session);
         request.setServerName("www.sporteportal.com");
@@ -243,19 +275,21 @@
         request.setServletPath("/portal");
         request.setPathInfo("/news/default-page.psml");
         request.setRequestURI("/jetspeed/portal/news/default-page.psml");
-        request.setMethod("GET");    
+        request.setMethod("GET");
         RequestContext rc = new MockRequestContext(request, response);
         return rc;
     }
-    
+
     protected String[] getConfigurations()
     {
-        return new String[]{"statistics.xml"};
+        return new String[]
+        { "statistics.xml"};
     }
-    
+
     protected String[] getBootConfigurations()
     {
-        return new String[]{"test-repository-datasource-spring.xml"};
+        return new String[]
+        { "test-repository-datasource-spring.xml"};
     }
 
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/AggregateStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/AggregateStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/AggregateStatistics.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/AggregateStatistics.java Mon Nov  7 14:03:29 2005
@@ -1,41 +1,57 @@
 /* Copyright 2005 Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jetspeed.statistics;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
  * AggregateStatistics
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: $
  */
 public interface AggregateStatistics extends Serializable
 {
+
     public void addRow(Map row);
+
     public int getHitCount();
+
     public float getAvgProcessingTime();
+
     public float getMinProcessingTime();
+
     public float getMaxProcessingTime();
+
     public float getStdDevProcessingTime();
+
     public void setHitCount(int hitCount);
+
     public void setAvgProcessingTime(float time);
+
     public void setMinProcessingTime(float time);
+
     public void setMaxProcessingTime(float time);
+
     public void setStdDevProcessingTime(float time);
-    
+
+    public List getStatlist();
+
+    public void setStatlist(List statlist);
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/InvalidCriteriaException.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/InvalidCriteriaException.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/InvalidCriteriaException.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/InvalidCriteriaException.java Mon Nov  7 14:03:29 2005
@@ -1,31 +1,31 @@
 /* Copyright 2005 Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jetspeed.statistics;
 
-
-
 /**
  * InvalidCriteriaException
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: $
  */
 public class InvalidCriteriaException extends Exception
 {
-    public InvalidCriteriaException(String mesg) {
+
+    public InvalidCriteriaException(String mesg)
+    {
         super(mesg);
     }
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/PortalStatistics.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/PortalStatistics.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/PortalStatistics.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/PortalStatistics.java Mon Nov  7 14:03:29 2005
@@ -1,129 +1,153 @@
 /* Copyright 2005 Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jetspeed.statistics;
 
+import java.util.List;
+
 import javax.sql.DataSource;
 
 import org.apache.jetspeed.request.RequestContext;
 
 /**
- * The PortletStatistics interface provides an API for logging portlet statistics.
- * Each log entry is formatted in the <A HREF="http://httpd.apache.org/docs/logs.html">
- * Apache Common Log Format (CLF)</A>.  Each CLF log entry has the following form:
+ * The PortletStatistics interface provides an API for logging portlet
+ * statistics. Each log entry is formatted in the <A
+ * HREF="http://httpd.apache.org/docs/logs.html"> Apache Common Log Format (CLF)
+ * </A>. Each CLF log entry has the following form:
  * <P>
  * "%h %l %u %t \"%r\" %>s %b"
  * <P>
  * where:
  * <UL>
- * <LI><B>%h</B> - remote host</LI>
- * <LI><B>%l</B> - remote log name</LI>
- * <LI><B>%u</B> - remote user</LI>
- * <LI><B>%t</B> - time in common log time format</LI>
- * <LI><B>%r</B> - first line of HTTP request</LI>
- * <LI><B>%s</B> - HTTP status code</LI>
- * <LI><B>%b</B> - number of bytes sent ("-" if no bytes sent).
+ * <LI><B>%h </B>- remote host</LI>
+ * <LI><B>%l </B>- remote log name</LI>
+ * <LI><B>%u </B>- remote user</LI>
+ * <LI><B>%t </B>- time in common log time format</LI>
+ * <LI><B>%r </B>- first line of HTTP request</LI>
+ * <LI><B>%s </B>- HTTP status code</LI>
+ * <LI><B>%b </B>- number of bytes sent ("-" if no bytes sent).
  * </UL>
  * <P>
  * Here's an example of a CLF log entry:
  * <P>
+ * 
  * <PRE>
- * 192.168.2.3 - johndoe [25/Oct/2005:11:44:40 PDT] "GET /jetspeed/DatabaseBrowserTest HTTP/1.1" 200 -
+ * 
+ * 192.168.2.3 - johndoe [25/Oct/2005:11:44:40 PDT] "GET
+ * /jetspeed/DatabaseBrowserTest HTTP/1.1" 200 -
+ * 
  * </PRE>
+ * 
  * <P>
  * The PortletStatistics interface overloads the %r field of the CLF format,
  * depending on the type of information being logged:
  * <P>
+ * 
  * <PRE>
- * LOG TYPE             FORMAT OF %r FIELD
- * --------------       ----------------------------
- * Portlet access       "PORTLET <page-path> <portlet-name>"
- * Page access          "PAGE <page-path>"
- * User logout          "LOGOUT"
+ * 
+ * LOG TYPE FORMAT OF %r FIELD -------------- ----------------------------
+ * Portlet access "PORTLET <page-path><portlet-name>" Page access "PAGE
+ * <page-path>" User logout "LOGOUT"
+ * 
  * </PRE>
  * 
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
- * @author <a href="mailto:rklein@bluesunrise.com">Richard Klein</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @author <a href="mailto:morciuch@apache.org">Mark Orciuch </a>
+ * @author <a href="mailto:rklein@bluesunrise.com">Richard Klein </a>
  * @version $Id: $
  */
 public interface PortalStatistics
 {
+
     public static final String HTTP_OK = "200";
+
     public static final String HTTP_UNAUTHORIZED = "401";
+
     public static final String HTTP_NOT_FOUND = "404";
+
     public static final String HTTP_INTERNAL_ERROR = "500";
-    
+
     /**
      * Logs an access to a portlet.
      * 
-     * @param request           current request info object
-     * @param portlet           portlet being logged
-     * @param statusCode        HTTP status code.
-     * @param msElapsedTime     elapsed time the portlet took to render
-     */
-    public void logPortletAccess(RequestContext request,
-                                String portlet, 
-                                String statusCode,
-                                long msElapsedTime);
- 
+     * @param request
+     *            current request info object
+     * @param portlet
+     *            portlet being logged
+     * @param statusCode
+     *            HTTP status code.
+     * @param msElapsedTime
+     *            elapsed time the portlet took to render
+     */
+    public void logPortletAccess(RequestContext request, String portlet,
+            String statusCode, long msElapsedTime);
+
     /**
      * Logs an access to a page.
      * 
-     * @param request           current request info object
-     * @param statusCode        HTTP status code
-     * @param msElapsedTime     elapsed time the page took to render
+     * @param request
+     *            current request info object
+     * @param statusCode
+     *            HTTP status code
+     * @param msElapsedTime
+     *            elapsed time the page took to render
      */
-    public void logPageAccess(RequestContext request, 
-            String statusCode, 
+    public void logPageAccess(RequestContext request, String statusCode,
             long msElapsedTime);
-    
-    
+
     /**
-     * Logs a user logout event.  The %s (HTTP status code)
-     * field of the log entry will be set to 200 (OK).
+     * Logs a user logout event. The %s (HTTP status code) field of the log
+     * entry will be set to 200 (OK).
      * 
-     * @param request           current request info object
-     * @param msElapsedTime     elapsed time that the user was logged in
+     * @param request
+     *            current request info object
+     * @param msElapsedTime
+     *            elapsed time that the user was logged in
      */
-    public void logUserLogout(RequestContext request, 
-            long msElapsedTime);
+    public void logUserLogout(String ipAddress, String userName,
+            long msSessionLength);
+
     /**
-     * Logs a user logout event.  The %s (HTTP status code)
-     * field of the log entry will be set to 200 (OK).
+     * Logs a user logout event. The %s (HTTP status code) field of the log
+     * entry will be set to 200 (OK).
      * 
-     * @param request           current request info object
-     * @param msElapsedLoginTime     time it took the user to login
+     * @param request
+     *            current request info object
+     * @param msElapsedLoginTime
+     *            time it took the user to login
      */
     public void logUserLogin(RequestContext request, long msElapsedLoginTime);
-    
+
     /**
-     * @return   returns the current number of logged in users
+     * @return returns the current number of logged in users
      */
     public int getNumberOfCurrentUsers();
-    
+
     /**
      * force the database loggers to flush out
      */
     public void forceFlush();
-    
+
     /**
-     * @return  DataSource in use by the logger
-     *   useful for writing decent tests
+     * @return DataSource in use by the logger useful for writing decent tests
      */
     public DataSource getDataSource();
 
-    public AggregateStatistics queryStatistics(StatisticsQueryCriteria criteria) throws InvalidCriteriaException;
-    
+    public AggregateStatistics queryStatistics(StatisticsQueryCriteria criteria)
+            throws InvalidCriteriaException;
+
+    public int getNumberOfLoggedInUsers();
+
+    public List getListOfLoggedInUsers();
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/StatisticsQueryCriteria.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/StatisticsQueryCriteria.java?rev=331613&r1=331612&r2=331613&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/StatisticsQueryCriteria.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/StatisticsQueryCriteria.java Mon Nov  7 14:03:29 2005
@@ -1,36 +1,40 @@
 /* Copyright 2005 Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.jetspeed.statistics;
 
 import java.io.Serializable;
 
-
 /**
  * StatisticsQueryCriteria
  * 
- * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id: $
  */
 public interface StatisticsQueryCriteria extends Serializable
 {
 
     public String getTimePeriod();
-    public void setTimePeriod(String ipAddress);
+
+    public void setTimePeriod(String timePeriod);
+
     public String getUser();
+
     public void setUser(String user);
+
     public void setQueryType(String queryType);
+
     public String getQueryType();
 }

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/UserStats.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/UserStats.java?rev=331613&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/UserStats.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/statistics/UserStats.java Mon Nov  7 14:03:29 2005
@@ -0,0 +1,36 @@
+/* Copyright 2005 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.statistics;
+
+import java.io.Serializable;
+
+/**
+ * UserStats
+ * 
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public interface UserStats extends Serializable
+{
+
+    public String getUsername();
+
+    public int getNumberOfSessions();
+
+    public void setNumberOfSession(int number);
+
+    public void setUsername(String username);
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message