org.mule.example.loanbroker.esn.LoanBrokerApp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-example-loanbroker-esn
Show all versions of mule-example-loanbroker-esn
The Loan Broker example application is based on the example presented in the Enterprise Integration Patterns book. This chapter of the book is available online so you can see a detailed description of the application here (http://www.eaipatterns.com/ComposedMessagingWS.html).
/*
* $Id$
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.example.loanbroker.esn;
import org.mule.example.loanbroker.AbstractLoanBrokerApp;
import org.mule.example.loanbroker.LocaleMessage;
import org.mule.example.loanbroker.messages.LoanQuote;
import org.mule.util.DateUtils;
import org.mule.util.StringMessageUtils;
import org.mule.util.StringUtils;
import org.mule.util.SystemUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Runs the LoanBroker ESN example application.
*/
public class LoanBrokerApp extends AbstractLoanBrokerApp
{
public static final String CLI_OPTIONS[][] = {
{ "config", "true", "Configuration File(s)" },
{ "main", "true", "LoanBrokerApp Class"},
{ "req", "true", "Number of loan requests to use"},
{ "sync", "true", "Whether to run in synchronous mode or not"}
};
private static boolean synchronous = false;
// Needed for webapp version!
// TODO Travis ... sadly, it doesn't quite work
public LoanBrokerApp() throws Exception
{
super();
}
public LoanBrokerApp(String config) throws Exception
{
super(config);
}
public static void main(String[] args) throws Exception
{
LoanBrokerApp loanBrokerApp = null;
/////////////////////////////////////////
// Command-line config
/////////////////////////////////////////
Map options = SystemUtils.getCommandLineOptions(args, CLI_OPTIONS);
String config = (String)options.get("config");
if (StringUtils.isNotBlank(config))
{
loanBrokerApp = new LoanBrokerApp(config);
int i = 100;
String requests = (String)options.get("req");
if (requests != null)
{
i = Integer.parseInt(requests);
}
String sync = (String)options.get("sync");
if (sync != null)
{
synchronous = Boolean.valueOf(sync).booleanValue();
}
if (synchronous)
{
long start = System.currentTimeMillis();
List