Let us add some configuration properties to our MyAction
. We will make the &
and the number of times it needs to be printed as configurable properties. Follow these steps:
MyAction
class:public String SYMBOL = "&"; public int COUNT = 48;
_config = config; String symbol = _config.getAttribute("symbol"); if (symbol != null) { SYMBOL = symbol; } String count = _config.getAttribute("count"); if (count != null) { COUNT = Integer.parseInt(count); }
printLine()
method:private void printLine() { StringBuffer line = new StringBuffer(COUNT); for (int i = 0; i < COUNT; i++) { line.append(SYMBOL); } System.out.println(line); }
printMessage()
method as shown in the following snippet:printLine(); System.out.println("Body: " + message.getBody().get()); printLine(); return message;
jboss-esb.xml
file and select the action, BodyPrinter
. Add two properties symbol
as *
and count
as 50
:SendJMSMessage.java
by clicking Run, select Run As and Java Application.The following message will be printed in the console:
INFO [STDOUT] ************************************************** INFO [STDOUT] Body: Chapter 3 says Hello! INFO [STDOUT] **************************************************