1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.statistics.impl;
19
20 import java.sql.Connection;
21 import java.sql.PreparedStatement;
22 import java.sql.SQLException;
23
24 import javax.sql.DataSource;
25
26 /***
27 * Batches up LogRecord statistics, and flushes them periodically to the
28 * appropriate table in the database.
29 * <P>
30 * IMPORTANT: It is the caller's responsibility to insure that the LogRecord
31 * instances added to a BatchedStatistics instance are all of the same type
32 * (Portlet Access, Page Access, or User Logout).
33 *
34 * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
35 * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
36 * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $
37 */
38 public class BatchedPortletStatistics extends BatchedStatistics
39 {
40
41 public BatchedPortletStatistics(DataSource ds, int batchSize,
42 long msElapsedTimeThreshold, String name)
43 {
44 super(ds, batchSize, msElapsedTimeThreshold, name);
45 }
46
47
48
49
50
51
52 public boolean canDoRecordType(LogRecord rec)
53 {
54 return (rec instanceof PortletLogRecord);
55 }
56
57 /***
58 * @param stm
59 * @param recordIterator
60 * @throws SQLException
61 */
62 protected void loadOneRecordToStatement(PreparedStatement stm, LogRecord rec)
63 throws SQLException
64 {
65 PortletLogRecord record = (PortletLogRecord) rec;
66
67 stm.setString(1, record.getIpAddress());
68 stm.setString(2, record.getUserName());
69 stm.setTimestamp(3, record.getTimeStamp());
70 stm.setString(4, record.getPagePath());
71 stm.setString(5, record.getPortletName());
72 stm.setInt(6, record.getStatus());
73 stm.setLong(7, record.getMsElapsedTime());
74
75 }
76
77 /***
78 * @param con
79 * @return
80 * @throws SQLException
81 */
82 protected PreparedStatement getPreparedStatement(Connection con)
83 throws SQLException
84 {
85 PreparedStatement stm;
86 stm = con
87 .prepareStatement("INSERT INTO PORTLET_STATISTICS VALUES(?,?,?,?,?,?,?)");
88 return stm;
89 }
90
91 }