xmlBlaster 2.2.0 contributions API

org.xmlBlaster.contrib.dbwatcher.detector
Class MD5ChangeDetector

java.lang.Object
  extended by org.xmlBlaster.contrib.dbwatcher.detector.MD5ChangeDetector
All Implemented Interfaces:
I_ChangeDetector

public class MD5ChangeDetector
extends java.lang.Object
implements I_ChangeDetector

Check the database and compare the MD5 of the result set to the previous one.

Configuration:

If the table does not exist in the DB no event is triggered, if an empty table comes to existence an empty event with untouched topic name is triggered:

 topic='db.change.event.${ICAO_ID}'
 
 <?xml version='1.0' encoding='UTF-8' ?>
 <sql>
 </sql>
 

Note that the previous MD5 values are hold in RAM only, after plugin restart they are lost and a complete set of data is send again.

DB statement Reported change Comment
CREATE CREATE -
INSERT INSERT On multiple table entries for a changeDetector.groupColName the change is reported as UPDATE
UPDATE UPDATE -
DELETE DELETE -
DROP DROP see mom.eraseOnDrop configuration

Author:
Marcel Ruff

Field Summary
protected  int changeCount
           
protected  java.lang.String changeDetectStatement
           
protected  I_ChangeListener changeListener
           
protected  I_DataConverter dataConverter
           
protected  I_DbPool dbPool
           
protected  java.security.MessageDigest digest
           
protected  java.lang.String groupColName
           
protected  I_Info info
           
protected  java.util.Map md5Map
           
protected  boolean poolOwner
           
protected  java.lang.String queryMeatStatement
           
protected  boolean tableExists
           
protected  java.util.Set touchSet
           
protected  boolean useGroupCol
           
 
Constructor Summary
MD5ChangeDetector()
          Default constructor, you need to call init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter) thereafter.
MD5ChangeDetector(I_Info info, I_ChangeListener changeListener, I_DataConverter dataConverter)
          Convenience constructor which calls init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter).
 
Method Summary
 int checkAgain(java.util.Map attrMap)
          Check the observed data for changes.
 void init(I_Info info, I_ChangeListener changeListener, I_DataConverter dataConverter)
          Needs to be called after construction.
 void shutdown()
          Cleanup resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

info

protected I_Info info

changeListener

protected I_ChangeListener changeListener

dataConverter

protected I_DataConverter dataConverter

dbPool

protected I_DbPool dbPool

poolOwner

protected boolean poolOwner

tableExists

protected boolean tableExists

digest

protected java.security.MessageDigest digest

md5Map

protected final java.util.Map md5Map

touchSet

protected final java.util.Set touchSet

changeDetectStatement

protected java.lang.String changeDetectStatement

groupColName

protected java.lang.String groupColName

useGroupCol

protected boolean useGroupCol

changeCount

protected int changeCount

queryMeatStatement

protected java.lang.String queryMeatStatement
Constructor Detail

MD5ChangeDetector

public MD5ChangeDetector()
Default constructor, you need to call init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter) thereafter.


MD5ChangeDetector

public MD5ChangeDetector(I_Info info,
                         I_ChangeListener changeListener,
                         I_DataConverter dataConverter)
                  throws java.lang.Exception
Convenience constructor which calls init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter).

Parameters:
info - The configuration environment
changeListener - The listener to notify if something has changed
dataConverter - A converter or null
Throws:
java.lang.Exception
Method Detail

init

public void init(I_Info info,
                 I_ChangeListener changeListener,
                 I_DataConverter dataConverter)
          throws java.lang.Exception
Needs to be called after construction.

Specified by:
init in interface I_ChangeDetector
Parameters:
info - The configuration
changeListener - The listener to notify if something has changed
dataConverter - If not null the data will be transformed immediately during change detection
Throws:
java.lang.Exception

checkAgain

public int checkAgain(java.util.Map attrMap)
               throws java.lang.Exception
Check the observed data for changes.

The method is synchronized so you can call it from the AlertScheduler or manually from outside simultaneously.

Specified by:
checkAgain in interface I_ChangeDetector
Parameters:
attrMap - This map can be null. The event source can transport some specific information to help the changeDetector doing its work efficiently.
Returns:
> 0 if the observed data has changed. If supported by the plugin the the number of changed rows,
Throws:
java.lang.Exception - Can be of any type
See Also:
I_ChangeDetector.checkAgain(Map)

shutdown

public void shutdown()
              throws java.lang.Exception
Description copied from interface: I_ChangeDetector
Cleanup resources.

Specified by:
shutdown in interface I_ChangeDetector
Throws:
java.lang.Exception - Typicall XmlBlasterException
See Also:
org.xmlBlaster.contrib.dbwatcher.db.I_DbPool#shutdown

xmlBlaster 2.2.0 contributions API

Copyright © 1999-2014 The xmlBlaster.org contributers.