Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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:
Add two members to the MyAction class:
public String SYMBOL = "&"; public int COUNT = 48;
Modify the constructor as follows:
_config = config;
String symbol = _config.getAttribute("symbol");
if (symbol != null) {
SYMBOL = symbol;
}
String count = _config.getAttribute("count");
if (count != null) {
COUNT = Integer.parseInt(count);
}
Add a printLine() method:
private void printLine() {
StringBuffer line = new StringBuffer(COUNT);
for (int i = 0; i < COUNT; i++) {
line.append(SYMBOL);
}
System.out.println(line);
}
Modify the printMessage() method as shown in the following snippet:
printLine();
System.out.println("Body: " + message.getBody().get());
printLine();
return message;
Click on Save or press Ctrl + S.
Deploy the application using the Run menu and select Run As | Run on Server.
Run SendJMSMessage.java by clicking Run, select Run As and Java Application.
The following message will be printed in the console: