From: <jbo...@li...> - 2006-06-28 19:55:20
|
Author: estebanschifman Date: 2006-06-28 15:55:16 -0400 (Wed, 28 Jun 2006) New Revision: 4849 Modified: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java Log: Added NotifySqlTable example Modified: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java =================================================================== --- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-06-28 19:54:21 UTC (rev 4848) +++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-06-28 19:55:16 UTC (rev 4849) @@ -25,6 +25,7 @@ import java.text.SimpleDateFormat; import org.jboss.soa.esb.helpers.*; +import org.jboss.soa.esb.helpers.persist.SimpleDataSource; import org.jboss.soa.esb.notification.*; import org.jboss.soa.esb.services.*; @@ -53,7 +54,8 @@ // oEl.addElemChild(fileListTarget()); // oEl.addElemChild(emailTarget()); // oEl.addElemChild(jmsQueueTarget()); - oEl.addElemChild(jmsTopicTarget()); +// oEl.addElemChild(jmsTopicTarget()); + oEl.addElemChild(sqlTableTarget()); NotificationList oNL = new NotificationList(oEl); @@ -157,4 +159,39 @@ } return oaRet; } //________________________________ + + static DomElement sqlTableTarget() throws Exception + { + DomElement oTgt = new DomElement(NotificationList.CHILD_TGT); + oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifySqlTable"); + + oTgt.setAttr(SimpleDataSource.DRIVER,"org.postgresql.Driver"); + oTgt.setAttr(SimpleDataSource.URL,"jdbc:postgresql://lavasca:5432/rosetta"); + oTgt.setAttr(SimpleDataSource.USER,"postgres"); + oTgt.setAttr(SimpleDataSource.PASSWORD,""); + + // Table name for insert - must exist in database (URL) + oTgt.setAttr(NotifySqlTable.ATT_TABLE,"test_notif_table"); + // Column that will contain the dynamic data generated by the ActionClass + // must exist in table (ATT_TABLE above) + oTgt.setAttr(NotifySqlTable.ATT_DATA,"msg"); + + // constant data that can be also added in the insert + // (perhaps needed for queries) + // Key = column name (it must exist in the table, same as ATT_DATA column) + KeyValuePair[] oaCols = new KeyValuePair[] + {new KeyValuePair("src","TestNotification") + ,new KeyValuePair("ref","any Ref") + ,new KeyValuePair("val1","VVVV 11111") + }; + for (KeyValuePair oCurr : oaCols) + { DomElement oElem = new DomElement(NotifySqlTable.CHILD_COLUMN); + oElem.setAttr(NotifySqlTable.ATT_NAME,oCurr.getKey()); + oElem.setAttr(NotifySqlTable.ATT_VALUE,oCurr.getValue()); + oTgt.addElemChild(oElem); + } + + + return oTgt; + } //________________________________ } //____________________________________________________________________________ |