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