All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.samples.loanbroker.AsyncLoanBroker Maven / Gradle / Ivy

Go to download

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).

There is a newer version: 1.3.3
Show newest version
/*
 * $Id: AsyncLoanBroker.java 3982 2006-11-22 14:28:01Z lajos $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 *
 * The software in this package is published under the terms of the MuleSource MPL
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.samples.loanbroker;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mule.samples.loanbroker.service.LoanBroker;

import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;

/**
 * LoanBroker is the Service that starts the loan request process. The
 * broker also receives the final quote.
 */
public class AsyncLoanBroker implements LoanBroker
{
    /**
     * logger used by this class
     */
    protected static Log logger = LogFactory.getLog(AsyncLoanBroker.class);

    private final AtomicInteger quotes = new AtomicInteger(0);
    private final AtomicInteger requests = new AtomicInteger(0);

    public AsyncLoanBroker()
    {
        super();
    }

    public BankQuoteRequest getLoanQuote(LoanRequest request)
    {
        logger.info("\nClient " + request.getCustomer().getName() + " with ssn= "
                        + request.getCustomer().getSsn() + " requests a loan of amount= "
                        + request.getLoanAmount() + " for " + request.getLoanDuration() + " months");
        BankQuoteRequest bqr = new BankQuoteRequest();
        bqr.setLoanRequest(request);
        return bqr;
    }

    public Object receiveQuote(LoanQuote quote)
    {
        System.out.println("Quote " + incQuotes() + " received: " + quote);
        return null;
    }

    public int incQuotes()
    {
        return quotes.incrementAndGet();
    }

    public int incRequests()
    {
        return requests.incrementAndGet();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy