[jboss-svn-commits] JBL Code SVN: r5338 - in labs/jbossesb/trunk/product/core/common: src/org/jboss/soa/esb/helpers src/org/jboss/soa/esb/notification src/org/jboss/soa/esb/services tests/src/org/jboss/soa/esb/common/tests/parameters tests/src/org/jboss/soa/esb/helpers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 28 00:54:21 EDT 2006
Author: estebanschifman
Date: 2006-07-28 00:54:17 -0400 (Fri, 28 Jul 2006)
New Revision: 5338
Modified:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java
Log:
Change sendNotification() argument from Object to Serializable
DomElement.fromURL - piggyback on DomElement.fromInputStream
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -37,7 +37,7 @@
private static final transient String s_sCharset = "ISO-8859-1";
- private static final transient String s_sEncoding = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+// private static final transient String s_sEncoding = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
private transient static DocumentBuilder s_oDocumentBuilder;
@@ -120,6 +120,10 @@
return oRet;
} // __________________________________
+ public static DomElement fromURL(String p_sFname) throws Exception
+ { return fromInputStream(new FileInputStream(p_sFname));
+ } //__________________________________
+
public static DomElement fromXml(String p_xmlString) throws SAXException, IOException {
// TF: Modified this constructor to use the fromInputStream method.
@@ -278,6 +282,18 @@
}
} // __________________________________
+ public void addTextChild (String p_sKey, String p_sVal)
+ { if (null==p_sKey || null==p_sVal) return;
+ DomElement oNew = new DomElement(p_sKey,this);
+ oNew.m_oRootW3CElement.appendChild(m_oRootW3CElement.getOwnerDocument().createTextNode(p_sVal));
+ } //__________________________________
+
+ public void addTextChildren (String p_sKey, String[] p_saVal)
+ { if (null==p_sKey || null==p_saVal) return;
+ for (int i1=0; i1<p_saVal.length;i1++)
+ addTextChild(p_sKey,p_saVal[i1]);
+ } //__________________________________
+
public void addElemChild(DomElement p_oE) {
p_oE.m_oParentDomElement = this;
Document oDoc = m_oRootW3CElement.getOwnerDocument();
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.notification;
import org.jboss.soa.esb.helpers.*;
+import java.io.Serializable;
/**
* Holds lists of NotificationTarget objects so that the
@@ -91,7 +92,7 @@
* @throws Exception -
* use Exception.getMessage() at runtime
*/
- public void sendNotification(Object p_o) throws Exception {
+ public void sendNotification(Serializable p_o) throws Exception {
NotificationTarget[] oaTgt = getTargets();
for (int i1 = 0; i1 < oaTgt.length; i1++) {
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -43,7 +43,7 @@
* @throws Exception - invoke Exception.getMessage() at runtime for this object
* @see DomElement
*/
- public abstract void sendNotification(Object p_o) throws Exception;
+ public abstract void sendNotification(java.io.Serializable p_o) throws Exception;
private static final String NOTIF_PFX = "org.jboss.soa.esb.notification";
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -22,6 +22,8 @@
package org.jboss.soa.esb.notification;
+import java.io.Serializable;
+
import javax.mail.internet.*;
import org.jboss.soa.esb.helpers.*;
@@ -38,21 +40,19 @@
*
* @version 1.0
*/
-public class NotifyEmail extends NotificationTarget {
- /**
- * Instantiate a NotifyEmail object using the information contained in
- * <arg 1>
- *
- * @param p_oP
- * DomElement - See attributes and structure needed for the
- * EsbEmail(DomElement) constructor - The MESSAGE attribute will
- * be filled in at sendNotification(Object) time
- * @throws Exception
- * @see EsbEmail#EsbEmail(DomElement)
- * @see NotifyEmail#sendNotification(Object)
- */
- public NotifyEmail(DomElement p_oP) throws Exception {
- super(p_oP);
+public class NotifyEmail extends NotificationTarget
+{
+ /**
+ * Instantiate a NotifyEmail object using the information contained in <arg 1>
+ * @param p_oP DomElement - See attributes and structure needed for the
+ * EsbEmail(DomElement) constructor - The MESSAGE attribute will be filled
+ * in at sendNotification(Serializable) time
+ * @throws Exception
+ * @see EsbEmail#EsbEmail(DomElement)
+ * @see NotifyEmail#sendNotification(Serializable)
+ */
+ public NotifyEmail(DomElement p_oP) throws Exception
+ { super (p_oP);
String sAtt = (String) m_oParms.getAttr(EsbEmail.FROM);
if (null != sAtt)
@@ -60,35 +60,32 @@
InternetAddress.parse(m_oParms.getAttr(EsbEmail.SENDTO));
- sAtt = (String) m_oParms.getAttr(EsbEmail.COPYTO);
- if (null != sAtt)
- InternetAddress.parse(sAtt);
- } // __________________________________
+ sAtt = (String)m_oParms.getAttr(EsbEmail.COPYTO);
+ if (null != sAtt) InternetAddress.parse(sAtt);
+ } //__________________________________
+ /**
+ * Send an Email using EsbEmail() using p_o.toString() to fill in the
+ * message text
+ * @param p_o Object - This object's toString() method will supply contents
+ * of mail message
+ */
+ public void sendNotification(Serializable p_o)
+ { try
+ { DomElement oP = m_oParms.cloneObj();
+ String sMsg = oP.getAttr(EsbEmail.MESSAGE);
+ sMsg = ((null==sMsg)?p_o.toString():sMsg+"\n")+p_o.toString();
+ // HB added line for debugging
+ //System.out.println("Sending Email Notification ->" +sMsg );
- /**
- * Send an Email using EsbEmail() using p_o.toString() to fill in the
- * message text
- *
- * @param p_o
- * Object - This object's toString() method will supply contents
- * of mail message
- */
- public void sendNotification(Object p_o) {
- try {
- DomElement oP = m_oParms.cloneObj();
- String sMsg = oP.getAttr(EsbEmail.MESSAGE);
- sMsg = ((null == sMsg) ? p_o.toString() : sMsg + "\n")
- + p_o.toString();
- // HB added line for debugging
- // System.out.println("Sending Email Notification ->" +sMsg );
+ oP.setAttr(EsbEmail.MESSAGE, sMsg);
+ EsbEmail esbMail = new EsbEmail(oP);
+ esbMail.sendMessage();
+ }
+ catch (Exception e)
+ {
+ EsbUtil.getDefaultLogger(this.getClass()).error("Send Mail Failed", e);
+ e.printStackTrace();
+ }
+ } // __________________________________
- oP.setAttr(EsbEmail.MESSAGE, sMsg);
- EsbEmail esbMail = new EsbEmail(oP);
- esbMail.sendMessage();
- } catch (Exception e) {
- EsbUtil.getDefaultLogger(this.getClass()).error("Send Mail Failed", e);
- e.printStackTrace();
- }
- } // __________________________________
-
} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -95,27 +95,50 @@
}
} //__________________________________
/**
- * Writes the result of p_o.toString() into each one of the File objects
+ * Writes the result of p_o into each one of the File objects
* contained in the m_oaOutF array
* @param p_o Object - This object's toString() results will be written to
* (appended to) each one of the files in m_oaOutF
* @see NotifyFiles#setFiles(DomElement[])
* @see NotifyFiles#m_oaOutF
*/
- public void sendNotification(Object p_o)
- { FileOutputStream OS = null;
- int iCurr = 0;
+ public void sendNotification(Serializable p_o)
+ {
+ FileOutputStream OS = null;
+ int iCurr = 0;
for (File oCurr : m_oaOutF)
{ try
{
OS = new FileOutputStream(oCurr,m_baAppend[iCurr++]);
- OS.write(p_o.toString().getBytes());
- OS.write("\n".getBytes());
- OS.close();
+ if (p_o instanceof String)
+ stringNotification(OS,(String)p_o);
+ else
+ objectNotification(OS,p_o);
}
- catch (Exception e) { continue; }
- finally { try { OS.close();} catch (Exception eCl) {} }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ finally
+ { try { OS.close(); }
+ catch (Exception eCl) {/* Unable to Close - What could we do */ }
+ }
}
} //__________________________________
+ private void stringNotification(FileOutputStream p_oF,String p_s)
+ { try
+ {
+ p_oF.write(p_s.getBytes());
+ if (!p_s.endsWith("\n"))
+ p_oF.write("\n".getBytes());
+ }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ } //__________________________________
+
+ private void objectNotification(FileOutputStream p_oF,Object p_o)
+ { try
+ { ObjectOutputStream OS = new ObjectOutputStream(p_oF);
+ OS.writeObject(p_o);
+ }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ } //__________________________________
+
} //____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.notification;
+import java.io.Serializable;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
@@ -124,15 +125,19 @@
try { m_oConn.close(); } catch (Exception e2) {}
} //__________________________________
/**
- * Send a JMS message using p_o.toString() to fill in the message text
+ * Send a JMS message using p_o to fill in the message content
* and the list of message properties that will be added to the JMS
* message header fields
- * @param p_o Object - This object's toString() method will supply contents
- * of JMS message
+ * @param p_o Object - This object or thie object's toString() method
+ * will supply contents of JMS message
* @see NotifyJMS#CHILD_MSG_PROP
*/
- public void sendNotification(Object p_o) throws Exception
- { Message oMsg = m_oSess.createTextMessage(p_o.toString());
+ public void sendNotification(Serializable p_o) throws Exception
+ { Message oMsg = null;
+ if (p_o instanceof String)
+ oMsg = m_oSess.createTextMessage(p_o.toString());
+ else
+ oMsg = m_oSess.createObjectMessage((Serializable)p_o);
for (Iterator II=m_oProps.keySet().iterator(); II.hasNext(); )
{ String sKey = (String)II.next();
String sVal = m_oProps.getProperty(sKey);
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -89,7 +89,7 @@
return sbCol.append(")").append(sbPrm).append(")").toString();
} //__________________________________
- public void sendNotification(Object p_o)
+ public void sendNotification(java.io.Serializable p_o)
{ m_oCols.setProperty(m_sDataCol,p_o.toString());
JdbcCleanConn oConn = null;
try
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -31,9 +31,8 @@
public class NotifyUtil {
public static void notifyOK(InotificationHandler p_oNH,
- DomElement p_oParent, Object p_o, Map p_oCtx) {
+ DomElement p_oParent, Serializable p_o, Map p_oCtx) {
try {
- String sMsg = p_o.toString();
DomElement[] oaP = p_oParent
.getElementChildren(NotificationList.ELEMENT);
for (int i1 = 0; i1 < oaP.length; i1++) {
@@ -42,7 +41,7 @@
continue;
DomElement oCpy = oaP[i1].cloneObj();
MacroExpander.replaceMacros(oCpy, p_oCtx);
- p_oNH.sendNotifications(oCpy, sMsg);
+ p_oNH.sendNotifications(oCpy, p_o);
}
} catch (Exception e) {
e.printStackTrace(System.out);
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -25,9 +25,10 @@
package org.jboss.soa.esb.services;
import org.jboss.soa.esb.helpers.*;
+import java.io.Serializable;
public interface InotificationHandler
{
- public void sendNotifications (DomElement p_oP, Object p_o) throws Exception;
- public void sendNotifications (Object p_o) throws Exception;
+ public void sendNotifications (DomElement p_oP, Serializable p_o) throws Exception;
+ public void sendNotifications (Serializable p_o) throws Exception;
} //____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -21,9 +21,9 @@
*/
package org.jboss.soa.esb.common.tests.parameters;
-import javax.naming.*;
+//import javax.naming.*;
-import org.jboss.soa.esb.helpers.*;
+//import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.parameters.*;
import org.jboss.soa.esb.common.tests.BaseTest;
Modified: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java 2006-07-28 04:46:39 UTC (rev 5337)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java 2006-07-28 04:54:17 UTC (rev 5338)
@@ -93,7 +93,7 @@
public void test_Constructor_W3CElement() throws SAXException, IOException {
DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile1.xml"));
- ByteArrayOutputStream output;
+// ByteArrayOutputStream output;
byte[] expected = StreamUtils.readStream(getClass().getResourceAsStream("expected_01.xml"));
// Create a new DomElement from an existing one and compare it with the expected.
More information about the jboss-svn-commits
mailing list