[jboss-svn-commits] JBL Code SVN: r15926 - in labs/jbossesb/trunk/product: samples/quickstarts/helloworld_file_notifier and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 18 12:41:27 EDT 2007
Author: tfennelly
Date: 2007-10-18 12:41:27 -0400 (Thu, 18 Oct 2007)
New Revision: 15926
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/FileListenerAction.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/MyJMSListenerAction.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/test/SendEsbMessage.java
Log:
File notifier quickstart + a more useful error message in the NotifyFiles class.
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java 2007-10-18 16:38:45 UTC (rev 15925)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java 2007-10-18 16:41:27 UTC (rev 15926)
@@ -22,20 +22,21 @@
package org.jboss.soa.esb.notification;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.URI;
-
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.message.format.MessageType;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+
/**
* Write the notification contents into a list of files specified in the
* constructor time parameters.
@@ -112,25 +113,32 @@
for (int i = 0; i < p_oaP.length; i++)
{
- String fileURI = p_oaP[i].getAttribute(ATT_URI);
+ String fileURIString = p_oaP[i].getAttribute(ATT_URI);
String append = p_oaP[i].getAttribute(ATT_APPEND);
- if (null == fileURI)
+ if (null == fileURIString)
{
throw new IllegalArgumentException(
"Bad File Notification Configuration: Missing file URI attribute.");
}
- try
- {
- m_oaOutF[i] = new NotificationFile(new URI(fileURI), Boolean
- .valueOf(append));
- }
- catch (Exception e)
- {
- m_oaOutF[i] = new NotificationFile(fileURI, Boolean
- .valueOf(append));
- }
+ fileURIString = fileURIString.replace('\\', '/');
+ try {
+ URI fileURI = new URI(fileURIString);
+
+ if("file".equalsIgnoreCase(fileURI.getScheme())) {
+ if(fileURI.getHost() != null) {
+ // Remote dir ref... not supported...
+ throw new IllegalArgumentException("Sorry, the NotifyFiles notifier doesn't support remote directories: '" + fileURIString + "'. To reference a local dir, add a forward slash character before '" + fileURI.getAuthority() + "'.");
+ }
+ m_oaOutF[i] = new NotificationFile(fileURI, Boolean.valueOf(append));
+ } else {
+ // Not a file based URI... don't use the URI object...
+ m_oaOutF[i] = new NotificationFile(fileURIString, Boolean.valueOf(append));
+ }
+ } catch (URISyntaxException e) {
+ m_oaOutF[i] = new NotificationFile(fileURIString, Boolean.valueOf(append));
+ }
// Make sure the parent folder exists...
File parent = m_oaOutF[i].getAbsoluteFile().getParentFile();
@@ -242,7 +250,7 @@
/**
* @param file
- * @param append2
+ * @param append
*/
public NotificationFile (String file, boolean append)
{
Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/build.xml 2007-10-18 16:38:45 UTC (rev 15925)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/build.xml 2007-10-18 16:41:27 UTC (rev 15926)
@@ -11,9 +11,9 @@
<target name="config">
<property name="results.dir" location="."/>
<copy file="jboss-esb-unfiltered.xml"
- tofile="jboss-esb.xml">
+ tofile="jboss-esb.xml" overwrite="true">
<filterset>
- <filter token="results.dir" value="file://${results.dir}"/>
+ <filter token="results.dir" value="file:///${results.dir}"/>
</filterset>
</copy>
</target>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/FileListenerAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/FileListenerAction.java 2007-10-18 16:38:45 UTC (rev 15925)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/FileListenerAction.java 2007-10-18 16:41:27 UTC (rev 15926)
@@ -36,7 +36,7 @@
public Message displayMessage(Message message) throws Exception{
BufferedWriter out = new BufferedWriter(new FileWriter("results.txt"));
- out.write(new String(message.getBody().getByteArray()));
+ out.write(new String((byte[])message.getBody().get()));
out.close();
return message;
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/MyJMSListenerAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/MyJMSListenerAction.java 2007-10-18 16:38:45 UTC (rev 15925)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/MyJMSListenerAction.java 2007-10-18 16:41:27 UTC (rev 15926)
@@ -35,7 +35,7 @@
public Message displayMessage(Message message) throws Exception{
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
- System.out.println("Body: " + new String(message.getBody().getByteArray()));
+ System.out.println("Body: " + message.getBody().get());
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
return message;
Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/test/SendEsbMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/test/SendEsbMessage.java 2007-10-18 16:38:45 UTC (rev 15925)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_notifier/src/org/jboss/soa/esb/samples/quickstart/helloworldfilenotifier/test/SendEsbMessage.java 2007-10-18 16:41:27 UTC (rev 15926)
@@ -58,7 +58,7 @@
esbMessage.getHeader().setCall(call);
// set body contents with args[2], and send
- esbMessage.getBody().setByteArray(args[2].getBytes());
+ esbMessage.getBody().add(args[2].getBytes());
new ServiceInvoker(args[0], args[1]).deliverAsync(esbMessage);
More information about the jboss-svn-commits
mailing list