Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 3. Understanding Services > Time for action - examining configuration p...

Time for action - examining configuration properties

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:

  1. Add two members to the MyAction class:

    public String SYMBOL = "&";
    public int COUNT = 48;
    
  2. 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);
    }
    
  3. 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);
    }
    
  4. Modify the printMessage() method as shown in the following snippet:

    printLine();
    System.out.println("Body: " + message.getBody().get());
    printLine();
    return message;
    
  5. Edit the jboss-esb.xml file and select the action, BodyPrinter. Add two properties symbol as * and count as 50:

  6. Click on Save or press Ctrl + S.

  7. Deploy the application using the Run menu and select Run As | Run on Server.

  8. Run SendJMSMessage.java by clicking Run, select Run As and Java Application.

    The following message will be printed in the console:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint