⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbwatcherplugin.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
字号:
/*------------------------------------------------------------------------------Name:      DbWatcherPlugin.javaProject:   xmlBlaster.orgCopyright: xmlBlaster.org, see xmlBlaster-LICENSE fileSwitch on finer logging in xmlBlaster.properties:trace[org.xmlBlaster.contrib.dbwatcher.convert.ResultSetToXmlConverter]=truetrace[org.xmlBlaster.contrib.db.DbPool]=truetrace[org.xmlBlaster.contrib.dbwatcher.detector.MD5ChangeDetector]=truetrace[org.xmlBlaster.contrib.dbwatcher.detector.AlertScheduler]=truetrace[org.xmlBlaster.contrib.dbwatcher.detector.TimestampChangeDetector]=truetrace[org.xmlBlaster.contrib.dbwatcher.plugin.DbWatcherPlugin]=truetrace[org.xmlBlaster.contrib.dbwatcher.mom.XmlBlasterPublisher]=truetrace[org.xmlBlaster.contrib.dbwatcher.DbWatcher]=true------------------------------------------------------------------------------*/package org.xmlBlaster.contrib.dbwatcher.plugin;import org.xmlBlaster.contrib.GlobalInfo;import org.xmlBlaster.contrib.dbwatcher.DbWatcher;import org.xmlBlaster.util.Global;import org.xmlBlaster.util.def.ErrorCode;import org.xmlBlaster.util.XmlBlasterException;import org.xmlBlaster.util.plugin.PluginInfo;import java.util.logging.Logger;/** * DbWatcherPlugin is a plugin wrapper if you want to run DbWatcher inside xmlBlaster.  * <p /> * DbWatcher checks a database for changes and publishes these to the MoM * <p /> * This plugin needs to be registered in <tt>xmlBlasterPlugins.xml</tt> * to be available on xmlBlaster server startup. * <pre>&lt;plugin id='DbWatcherPlugin.TEST_TS' className='org.xmlBlaster.contrib.dbwatcher.plugin.DbWatcherPlugin'>   &lt;attribute id='jdbc.drivers'>oracle.jdbc.driver.OracleDriver&lt;/attribute>   &lt;attribute id='db.url'>${db.url}&lt;/attribute>   &lt;attribute id='db.user'>${db.user}&lt;/attribute>   &lt;attribute id='db.password'>${db.password}&lt;/attribute>   &lt;attribute id='db.queryMeatStatement'>SELECT * FROM TEST_TS WHERE TO_CHAR(ts, 'YYYY-MM-DD HH24:MI:SSXFF') > '${oldTimestamp}' ORDER BY ICAO_ID&lt;/attribute>   &lt;attribute id='mom.topicName'>db.change.event.${groupColValue}&lt;/attribute>   &lt;attribute id='mom.loginName'>dbWatcher/3&lt;/attribute>   &lt;attribute id='mom.password'>secret&lt;/attribute>   &lt;attribute id='mom.alertSubscribeKey'>&lt;key oid=''/>&lt;/attribute>   &lt;attribute id='mom.alertSubscribeQos'>&lt;qos/>&lt;/attribute>   &lt;attribute id='changeDetector.class'>org.xmlBlaster.contrib.dbwatcher.detector.TimestampChangeDetector&lt;/attribute>   &lt;attribute id='alertScheduler.pollInterval'>10000&lt;/attribute>   &lt;attribute id='changeDetector.groupColName'>ICAO_ID&lt;/attribute>   &lt;attribute id='changeDetector.detectStatement'>SELECT MAX(TO_CHAR(ts, 'YYYY-MM-DD HH24:MI:SSXFF')) FROM TEST_TS&lt;/attribute>   &lt;attribute id='converter.class'>org.xmlBlaster.contrib.dbwatcher.convert.ResultSetToXmlConverter&lt;/attribute>   &lt;attribute id='converter.addMeta'>true&lt;/attribute>   &lt;attribute id='transformer.class'>&lt;/attribute>   &lt;action do='LOAD' onStartupRunlevel='9' sequence='6' onFail='resource.configuration.pluginFailed'/>   &lt;action do='STOP' onShutdownRunlevel='6' sequence='5'/>&lt;/plugin> * </pre> * * <p> * This plugin uses <tt>java.util.logging</tt> and redirects the logging to xmlBlasters default * logging framework. You can switch this off by setting the attribute <tt>xmlBlaster/jdk14loggingCapture</tt> to false. * </p> *  * @author <a href="mailto:xmlblast@marcelruff.info">Marcel Ruff</a> */public class DbWatcherPlugin extends GlobalInfo {   private static Logger log = Logger.getLogger(DbWatcherPlugin.class.getName());   private DbWatcher dbWatcher;      /**    * Default constructor, you need to call <tt>init()<tt> thereafter.    */   public DbWatcherPlugin() {      super(new String[] {"mom.topicName", "mom.publishKey", "mom.alertSubscribeKey", "db.queryMeatStatement", "db.typeStatement"});   }      /**    * @see org.xmlBlaster.util.plugin.I_Plugin#init(org.xmlBlaster.util.Global, org.xmlBlaster.util.plugin.PluginInfo)    */   protected void doInit(Global global_, PluginInfo pluginInfo) throws XmlBlasterException {      try {         this.dbWatcher = new DbWatcher(this);         this.dbWatcher.startAlertProducers();      }      catch (Throwable e) {         throw new XmlBlasterException(this.global, ErrorCode.RESOURCE_CONFIGURATION, "DbWatcherPlugin", "init failed", e);       }      log.info("Loaded DbWatcher plugin '" + getType() + "'");   }   /**    * @see org.xmlBlaster.util.plugin.I_Plugin#shutdown()    */   public void shutdown() throws XmlBlasterException {      super.shutdown();      try {         this.dbWatcher.shutdown();      }      catch (Throwable e) {         log.warning("Ignoring shutdown problem: " + e.toString());      }      log.info("Stopped DbWatcher plugin '" + getType() + "'");   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -