xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.dbwriter
Class SqlInfoStreamPublisher

java.lang.Object
  extended by org.xmlBlaster.contrib.dbwriter.SqlInfoStreamPublisher
All Implemented Interfaces:
java.util.EventListener, I_ChangePublisher, I_ContribPlugin, I_Timeout

public class SqlInfoStreamPublisher
extends java.lang.Object
implements I_ChangePublisher, I_Timeout


Field Summary
private  java.io.BufferedReader br
           
private  boolean continuous
           
private  int count
           
private static java.lang.String DATE
           
private static java.lang.String DATE_ALL
           
private static java.lang.String DATE_HR
           
private static java.lang.String DATE_MILLI
           
private static java.lang.String DATE_MIN
           
private static java.lang.String DATE_SEC
           
protected  I_Update eventHandler
           
private  java.lang.String filename
           
private  Global glob
           
private  boolean immediate
           
private static java.lang.String IMMEDIATE_TXT
           
private  I_Info info
           
private static java.lang.String INPUT_FILENAME_TXT
           
private  boolean isInitialized
           
private static java.util.logging.Logger log
           
private static java.lang.String MIN_DELAY_TXT
           
private  long minDelay
           
private  long nextTime
           
private  long offsetTime
           
private  long referenceMidnite
           
private  SqlInfoParser sqlInfoParser
           
private  java.lang.String startTime
           
private  boolean stopped
           
private  java.lang.String TAG
           
private  long thisMidnite
           
private  Timeout timeout
           
 
Constructor Summary
SqlInfoStreamPublisher()
           
 
Method Summary
private  long calculateMidnite(long time)
           
private  long calculateNewTime(long time)
           
private  java.io.BufferedReader getBufferedReader(java.io.BufferedReader br, java.lang.String filename)
           
private  java.lang.String getContent(int pos, java.lang.String origLine, java.lang.String endTag)
           
 XBSession getJmsSession()
          Only used in replication, can return null if not used.
private static long getStartTime(java.lang.String txt)
           
 java.util.Set getUsedPropertyKeys()
          Gets all property keys which may be used by this object.
 void init(I_Info info_)
          After creation this method is called.
static void main(java.lang.String[] args)
           
 void parse()
           
private  void processComment(int pos, java.lang.String line, java.lang.String endTag)
           
 java.lang.String publish(java.lang.String changeKey, byte[] message, java.util.Map attrMap)
          Send the message to the MoM.
 boolean registerAlertListener(I_Update update, java.util.Map attrs)
          Register for alerts when the data source has changed.
 void shutdown()
          Cleanup resources.
private  void startTimeout()
           
 void timeout(java.lang.Object userData)
          You will be notified about the timeout through this method.
private static java.util.Date txtToDate(java.lang.String dateTxt, java.lang.String formatTxt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

DATE

private static final java.lang.String DATE
See Also:
Constant Field Values

DATE_HR

private static final java.lang.String DATE_HR
See Also:
Constant Field Values

DATE_MIN

private static final java.lang.String DATE_MIN
See Also:
Constant Field Values

DATE_SEC

private static final java.lang.String DATE_SEC
See Also:
Constant Field Values

DATE_MILLI

private static final java.lang.String DATE_MILLI
See Also:
Constant Field Values

DATE_ALL

private static final java.lang.String DATE_ALL
See Also:
Constant Field Values

TAG

private java.lang.String TAG

INPUT_FILENAME_TXT

private static final java.lang.String INPUT_FILENAME_TXT
See Also:
Constant Field Values

IMMEDIATE_TXT

private static final java.lang.String IMMEDIATE_TXT
See Also:
Constant Field Values

MIN_DELAY_TXT

private static final java.lang.String MIN_DELAY_TXT
See Also:
Constant Field Values

nextTime

private long nextTime

referenceMidnite

private long referenceMidnite

thisMidnite

private long thisMidnite

filename

private java.lang.String filename

immediate

private boolean immediate

eventHandler

protected I_Update eventHandler

info

private I_Info info

stopped

private boolean stopped

glob

private Global glob

br

private java.io.BufferedReader br

sqlInfoParser

private SqlInfoParser sqlInfoParser

timeout

private Timeout timeout

minDelay

private long minDelay

isInitialized

private boolean isInitialized

count

private int count

continuous

private boolean continuous

offsetTime

private long offsetTime

startTime

private java.lang.String startTime
Constructor Detail

SqlInfoStreamPublisher

public SqlInfoStreamPublisher()
Method Detail

txtToDate

private static java.util.Date txtToDate(java.lang.String dateTxt,
                                        java.lang.String formatTxt)

getStartTime

private static long getStartTime(java.lang.String txt)

parse

public void parse()
           throws java.lang.Exception
Throws:
java.lang.Exception

getContent

private java.lang.String getContent(int pos,
                                    java.lang.String origLine,
                                    java.lang.String endTag)
                             throws java.lang.Exception
Throws:
java.lang.Exception

processComment

private void processComment(int pos,
                            java.lang.String line,
                            java.lang.String endTag)
                     throws java.lang.Exception
Throws:
java.lang.Exception

calculateMidnite

private long calculateMidnite(long time)

calculateNewTime

private long calculateNewTime(long time)

getJmsSession

public XBSession getJmsSession()
Description copied from interface: I_ChangePublisher
Only used in replication, can return null if not used.

Specified by:
getJmsSession in interface I_ChangePublisher
Returns:

init

public void init(I_Info info_)
          throws java.lang.Exception
Description copied from interface: I_ChangePublisher
After creation this method is called. The plugin must register itself into global scope with info.setObject("org.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher", this) to be available for others.

Specified by:
init in interface I_ChangePublisher
Specified by:
init in interface I_ContribPlugin
Parameters:
info_ - The configuration environment
Throws:
java.lang.Exception - MoM specific

getBufferedReader

private java.io.BufferedReader getBufferedReader(java.io.BufferedReader br,
                                                 java.lang.String filename)

publish

public java.lang.String publish(java.lang.String changeKey,
                                byte[] message,
                                java.util.Map attrMap)
                         throws java.lang.Exception
Description copied from interface: I_ChangePublisher
Send the message to the MoM.

Specified by:
publish in interface I_ChangePublisher
Parameters:
changeKey - Can be used to create the topic name
message - The message content to send
attrMap - An optional map with attributes or null
Returns:
A unique identifier of the sent message
Throws:
java.lang.Exception - On sending problems

registerAlertListener

public boolean registerAlertListener(I_Update update,
                                     java.util.Map attrs)
                              throws java.lang.Exception
Description copied from interface: I_ChangePublisher
Register for alerts when the data source has changed.

This funtionality is plugin depending, for example the xmlBlaster plugin has a configuration option to subscribe on a alert topic and listens if somebody publishes a message to it. If such a message arrives we trigger a new database poll.

Specified by:
registerAlertListener in interface I_ChangePublisher
Parameters:
update - The callback interface to receive the notification
attrs - extra parameters to pass for the registration. For example if one implementation wants to do a specific extra subscription it would pass the quality of service in the attributes.
Returns:
true if a notification is available (is configured)
Throws:
java.lang.Exception - The MoM specific exception

startTimeout

private void startTimeout()

shutdown

public void shutdown()
Description copied from interface: I_ChangePublisher
Cleanup resources.

Can be called multiple times if instance is reused from different plugins.

Specified by:
shutdown in interface I_ChangePublisher
Specified by:
shutdown in interface I_ContribPlugin
See Also:
I_Plugin

getUsedPropertyKeys

public java.util.Set getUsedPropertyKeys()
Description copied from interface: I_ContribPlugin
Gets all property keys which may be used by this object.

Specified by:
getUsedPropertyKeys in interface I_ContribPlugin
Returns:

timeout

public void timeout(java.lang.Object userData)
Description copied from interface: I_Timeout
You will be notified about the timeout through this method.

Specified by:
timeout in interface I_Timeout
Parameters:
userData - You get bounced back your userData which you passed with Timeout.addTimeoutListener()

main

public static void main(java.lang.String[] args)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.