KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > samples > voipservice > service > SyncVoipBroker


1 /*
2  * $Id: SyncVoipBroker.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.samples.voipservice.service;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.mule.impl.MuleMessage;
16 import org.mule.impl.RequestContext;
17 import org.mule.samples.voipservice.interfaces.AddressValidation;
18 import org.mule.samples.voipservice.to.CreditProfileTO;
19 import org.mule.samples.voipservice.to.ServiceParamTO;
20 import org.mule.umo.UMOEventContext;
21 import org.mule.umo.UMOMessage;
22
23 import java.util.HashMap JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27 /**
28  * @author Binildas Christudas
29  */

30 public class SyncVoipBroker
31 {
32
33     protected static transient Log logger = LogFactory.getLog(SyncVoipBroker.class);
34
35     public UMOMessage validate(ServiceParamTO serviceParamTO) throws Exception JavaDoc
36     {
37
38         logger.info("Inside Method : " + serviceParamTO);
39
40         UMOMessage msg = null;
41         List JavaDoc endPoints = null;
42         UMOEventContext umoEventContext = RequestContext.getEventContext();
43         UMOMessage umoMessage = umoEventContext.sendEvent(serviceParamTO.getCustomer().getAddress());
44         Integer JavaDoc isValidAddress = (Integer JavaDoc)umoMessage.getPayload();
45         if (isValidAddress.intValue() == AddressValidation.SUCCESS)
46         {
47             umoMessage = umoEventContext.sendEvent(serviceParamTO.getCreditCard().getCardType());
48             endPoints = (List JavaDoc)umoMessage.getPayload();
49             logger.info("Inside Method : isValidAddress = " + isValidAddress + "; endPoints = " + endPoints);
50             Map JavaDoc props = new HashMap JavaDoc();
51             props.put("recipients", endPoints);
52             msg = new MuleMessage(new CreditProfileTO(serviceParamTO.getCustomer()), props);
53             umoEventContext.dispatchEvent(msg);
54             umoEventContext.setStopFurtherProcessing(true);
55         }
56         return msg;
57     }
58 }
59
Popular Tags