com.mtgi.analytics
Class JdbcBehaviorEventPersisterImpl

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.jdbc.core.support.JdbcDaoSupport
          extended by com.mtgi.analytics.JdbcBehaviorEventPersisterImpl
All Implemented Interfaces:
BehaviorEventPersister, org.springframework.beans.factory.InitializingBean

public class JdbcBehaviorEventPersisterImpl
extends org.springframework.jdbc.core.support.JdbcDaoSupport
implements BehaviorEventPersister

Basic implementation of BehaviorEventPersister, which uses JDBC batching to persist instances of BehaviorEvent using configurable insert SQL. An instance of EventDataElementSerializer is used to convert event data to XML documents for insertion.


Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
JdbcBehaviorEventPersisterImpl()
           
 
Method Summary
 String getIdSql()
           
protected  void initDao()
           
protected  Long nextId(PreparedStatement idQuery)
           
protected  void nullSafeSet(PreparedStatement stmt, int index, Object value, int sqlType)
           
 int persist(Queue<BehaviorEvent> events)
          Drain the given event queue, persisting all instances to the database.
 void setBatchSize(int batchSize)
          Set the JDBC batch size for executing inserts.
 void setIdSql(String idSql)
          Set the SQL select statement used to retrieve a new primary key value for an event prior to insert.
 void setInsertSql(String insertSql)
          Set the SQL statement used to insert a new behavior event record into the database.
 
Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport
checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcBehaviorEventPersisterImpl

public JdbcBehaviorEventPersisterImpl()
Method Detail

setBatchSize

public void setBatchSize(int batchSize)
Set the JDBC batch size for executing inserts. Only has effect if the JDBC driver supports statement batching. Defaults to 25 if unspecified.


setIdSql

public void setIdSql(String idSql)
Set the SQL select statement used to retrieve a new primary key value for an event prior to insert. Default is
select S_BEHAVIOR_TRACKING_EVENT.nextval from dual
if unspecified.


getIdSql

public String getIdSql()

setInsertSql

public void setInsertSql(String insertSql)
Set the SQL statement used to insert a new behavior event record into the database. The SQL statement must take exactly 11 parameters, which must accept the following event values in order:
  1. EVENT ID
  2. PARENT EVENT ID
  3. APPLICATION
  4. TYPE
  5. NAME
  6. START
  7. DURATION
  8. USER ID
  9. SESSION ID
  10. ERROR
  11. DATA
Default is
insert into BEHAVIOR_TRACKING_EVENT
  (EVENT_ID, PARENT_EVENT_ID, APPLICATION, TYPE, NAME, START, DURATION_MS, USER_ID, SESSION_ID, ERROR, DATA) 
   values 
  (       ?,               ?,           ?,    ?,    ?,     ?,           ?,       ?,          ?,     ?,    ?)
 


initDao

protected void initDao()
                throws Exception
Overrides:
initDao in class org.springframework.dao.support.DaoSupport
Throws:
Exception

persist

public int persist(Queue<BehaviorEvent> events)
Description copied from interface: BehaviorEventPersister
Drain the given event queue, persisting all instances to the database. Persisters must support the persisting of child events before their parents, since this is generally the natural order in which events are completed. This method returns when the queue is empty.

Specified by:
persist in interface BehaviorEventPersister
Returns:
the number of persisted events

nextId

protected Long nextId(PreparedStatement idQuery)
               throws SQLException
Throws:
SQLException

nullSafeSet

protected void nullSafeSet(PreparedStatement stmt,
                           int index,
                           Object value,
                           int sqlType)
                    throws SQLException
Throws:
SQLException