View Javadoc

1   /*
2    * $Id: LoanBrokerApp.java 11978 2008-06-09 14:27:30Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.example.loanbroker.esb;
12  
13  import org.mule.example.loanbroker.AbstractLoanBrokerApp;
14  import org.mule.example.loanbroker.LocaleMessage;
15  import org.mule.util.StringUtils;
16  
17  import java.io.IOException;
18  
19  /**
20   * Runs the LoanBroker ESB example application.
21   */
22  
23  public class LoanBrokerApp extends AbstractLoanBrokerApp
24  {
25      public LoanBrokerApp(String config) throws Exception
26      {
27          super(config);
28      }
29  
30      public static void main(String[] args) throws Exception
31      {
32          String config = getInteractiveConfig();
33          if (StringUtils.isNotEmpty(config))
34          {
35              LoanBrokerApp loanBrokerApp = new LoanBrokerApp(config);
36              loanBrokerApp.run(false);
37          }
38      }
39  
40      protected static String getInteractiveConfig() throws IOException
41      {
42          int response = 0;
43          
44          System.out.println("******************\n"
45              + LocaleMessage.esbWelcome()
46              + "\n******************");
47          
48          while (response != 'q')
49          {
50              response = readCharacter();
51              if (response == '1')
52              {
53                  System.out.println(LocaleMessage.loadingEndpointEjb());
54                  return "loan-broker-esb-mule-config.xml";
55              }
56              else
57              {
58                  System.out.println(LocaleMessage.loadingManagedEjb());
59                  return "loan-broker-esb-mule-config-with-ejb-container.xml";
60              }
61          }
62          
63          return "";
64      }
65  }