xmlBlaster 2.2.0 contributions API

org.xmlBlaster.contrib.dbwatcher.convert
Interface I_DataConverter

All Known Implementing Classes:
ReplicationConverter, ResultSetToXmlConverter

public interface I_DataConverter

Interface which hides specific JDBC ResultSet to XML converters.

Principally the output can be, depending on the plugin, any string like XML, HTML, CSV etc. For the generated format consult the implementing plugin.

Instances of classes implementing this interface can be reused by calling these tuples:

  1. setOutputStream(out)
  2. addInfo() - zero to n times
  3. done() to flush the output stream

Plugins are not expected to be thread save, please use separate instances if used by multiple threads.

Author:
Marcel Ruff

Field Summary
static int ALL
          Possible settings for what argument of #addInfo(ResultSet, int).
static java.lang.String BASE64
          The Base64 encoding marker string
static java.lang.String IGNORE_MESSAGE
          Used to pass the information from the converter to the publisher that this message shall not be sent (i.e.
static int META_ONLY
          Possible settings for what argument of #addInfo(ResultSet, int).
static int ROW_ONLY
          Possible settings for what argument of #addInfo(ResultSet, int).
 
Method Summary
 void addInfo(java.sql.Connection conn, java.sql.ResultSet rs, int what)
          Add another result set to the XML string.
 void addInfo(java.util.Map attributeMap)
          Add a map with attributes to the XML string.
 int done()
          After the last addInfo() call this method to complete the XML dump.
 long getCurrentMessageSize()
          Returns the size of the message as it is at the current moment
 java.lang.String getPostStatement()
          Gets the statement (if any) to be executed after processing one message.In case of the DbWatcher to be used to send/publish messages on detected changes, this can be used to delete entries in a queue.
 void init(I_Info info)
          Needs to be called after construction.
 void setOutputStream(java.io.OutputStream out, java.lang.String command, java.lang.String ident, ChangeEvent event)
          This has to be called before the first addInfo(Map) or #addInfo(ResultSet, int) call.
 void shutdown()
          Cleanup resources.
 

Field Detail

ALL

static final int ALL
Possible settings for what argument of #addInfo(ResultSet, int). Deliver meta info and data itself

See Also:
Constant Field Values

META_ONLY

static final int META_ONLY
Possible settings for what argument of #addInfo(ResultSet, int). Deliver meta info only

See Also:
Constant Field Values

ROW_ONLY

static final int ROW_ONLY
Possible settings for what argument of #addInfo(ResultSet, int). Deliver data only

See Also:
Constant Field Values

BASE64

static final java.lang.String BASE64
The Base64 encoding marker string

See Also:
Constant Field Values

IGNORE_MESSAGE

static final java.lang.String IGNORE_MESSAGE
Used to pass the information from the converter to the publisher that this message shall not be sent (i.e. published).

See Also:
Constant Field Values
Method Detail

init

void init(I_Info info)
          throws java.lang.Exception
Needs to be called after construction.

Parameters:
info - The configuration environment
Throws:
java.lang.Exception

setOutputStream

void setOutputStream(java.io.OutputStream out,
                     java.lang.String command,
                     java.lang.String ident,
                     ChangeEvent event)
                     throws java.lang.Exception
This has to be called before the first addInfo(Map) or #addInfo(ResultSet, int) call.

Parameters:
out - The stream to dump the converted data to
command - An optional command string or null
ident - the identity or optionally null.
event - The ChangeEvent associated to this invocation. Is never null.
Throws:
java.lang.Exception - of any type

addInfo

void addInfo(java.util.Map attributeMap)
             throws java.lang.Exception
Add a map with attributes to the XML string. This is usually called by the I_AttributeTransformer class.

Parameters:
attributeMap - A map containing key/values to dump
Throws:
java.lang.Exception - of any type

addInfo

void addInfo(java.sql.Connection conn,
             java.sql.ResultSet rs,
             int what)
             throws java.lang.Exception
Add another result set to the XML string.

Parameters:
rs - The JDBC result set
what - One of ALL, META_ONLY or ROW_ONLY. META_ONLY is useful for an empty table where rs access fails.
Throws:
java.lang.Exception - of any type

done

int done()
         throws java.lang.Exception
After the last addInfo() call this method to complete the XML dump. The user needs to call setOutputStream(java.io.OutputStream, java.lang.String, java.lang.String, org.xmlBlaster.contrib.dbwatcher.ChangeEvent) again to reuse this instance.

Returns:
Number of processed ResultSets
Throws:
java.lang.Exception - typically java.io.UnsupportedEncodingException, java.io.IOException

shutdown

void shutdown()
              throws java.lang.Exception
Cleanup resources.

Throws:
java.lang.Exception - of any type

getPostStatement

java.lang.String getPostStatement()
Gets the statement (if any) to be executed after processing one message.In case of the DbWatcher to be used to send/publish messages on detected changes, this can be used to delete entries in a queue. In such cases, after having sent the message, this post statement is executed by the DbWatcher. If the message could not be sent, this post statement is not invoked.

Returns:
the String containing an sql statement to be executed shortly after the processed message has been finished. In normal cases this means after having published the change message.

getCurrentMessageSize

long getCurrentMessageSize()
Returns the size of the message as it is at the current moment

Returns:

xmlBlaster 2.2.0 contributions API

Copyright © 1999-2014 The xmlBlaster.org contributers.