[jboss-svn-commits] JBL Code SVN: r12159 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat May 26 11:47:56 EDT 2007


Author: mark.little at jboss.com
Date: 2007-05-26 11:47:56 -0400 (Sat, 26 May 2007)
New Revision: 12159

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java
Log:
reformatted in preparation for http://jira.jboss.com/jira/browse/JBESB-538

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java	2007-05-26 07:27:44 UTC (rev 12158)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java	2007-05-26 15:47:56 UTC (rev 12159)
@@ -33,65 +33,95 @@
 
 /**
  * Simple action that prints out the message contents using System.println.
+ * 
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
  */
-public class SystemPrintln extends AbstractActionPipelineProcessor {
+public class SystemPrintln extends AbstractActionPipelineProcessor
+{
 
 	private String printlnMessage;
-	
+
 	/**
 	 * Public constructor.
-	 * @param config Configuration.
+	 * 
+	 * @param config
+	 *            Configuration.
 	 */
-	public SystemPrintln(ConfigTree config) {
-		printlnMessage = config.getAttribute("message", "** 'message' attribute not set **");
+	public SystemPrintln(ConfigTree config)
+	{
+		printlnMessage = config.getAttribute("message",
+				"** 'message' attribute not set **");
 	}
-	
-	/* (non-Javadoc)
+
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.jboss.soa.esb.actions.ActionProcessor#process(org.jboss.soa.esb.message.Message)
 	 */
-	public Message process(Message message) throws ActionProcessingException {
+	public Message process(Message message) throws ActionProcessingException
+	{
 		Object messageObject = ActionUtils.getTaskObject(message);
-		
-                System.out.println(printlnMessage + ": ");
-		if(messageObject instanceof byte[]) {
-			System.out.println("[" + format(new String((byte[])messageObject)) + "].");
-		} else {
-			if (messageObject!=null) System.out.println("[" + format(messageObject.toString()) + "].");
-            for (int i=0; i<message.getAttachment().getUnnamedCount(); i++) {
-                Message attachedMessage = (Message) message.getAttachment().itemAt(i);
-                System.out.println("attachment " + i + ": [" + new String(attachedMessage.getBody().getByteArray()) + "].");
-            }
+
+		System.out.println(printlnMessage + ": ");
+		if (messageObject instanceof byte[])
+		{
+			System.out.println("[" + format(new String((byte[]) messageObject))
+					+ "].");
 		}
-		
+		else
+		{
+			if (messageObject != null)
+				System.out.println("[" + format(messageObject.toString())
+						+ "].");
+			for (int i = 0; i < message.getAttachment().getUnnamedCount(); i++)
+			{
+				Message attachedMessage = (Message) message.getAttachment()
+						.itemAt(i);
+				System.out.println("attachment " + i + ": ["
+						+ new String(attachedMessage.getBody().getByteArray())
+						+ "].");
+			}
+		}
+
 		return message;
 	}
-	
-	private static TransformerFactory factory = TransformerFactory.newInstance();
 
+	private static TransformerFactory factory = TransformerFactory
+			.newInstance();
+
 	/**
 	 * Attempt to format the output.
-	 * @param output Output to be formatted.
+	 * 
+	 * @param output
+	 *            Output to be formatted.
 	 * @return Output.
 	 */
-	private String format(String output) {
-		StreamSource source = new StreamSource(new ByteArrayInputStream(output.getBytes()));
+	private String format(String output)
+	{
+		StreamSource source = new StreamSource(new ByteArrayInputStream(output
+				.getBytes()));
 		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-		
-		try {
+
+		try
+		{
 			Transformer transformer;
-			
+
 			// There's a bug in Java 5 re this code (formatting).
-			// See http://forum.java.sun.com/thread.jspa?threadID=562510&start=0 and it explains the
+			// See http://forum.java.sun.com/thread.jspa?threadID=562510&start=0
+			// and it explains the
 			// whys of the following code.
 			transformer = factory.newTransformer();
-			transformer.setOutputProperty(OutputKeys.INDENT, "yes");			
-			transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "4");
-			transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+			transformer.setOutputProperty(
+					"{http://xml.apache.org/xalan}indent-amount", "4");
+			transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
+					"yes");
 			transformer.transform(source, new StreamResult(outStream));
-			
+
 			return outStream.toString();
-		} catch (Exception e) {
+		}
+		catch (Exception e)
+		{
 			return output;
 		}
 	}




More information about the jboss-svn-commits mailing list