KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > samples > loanbroker > esb > ca > CreditAgencyBean


1 /*
2  * $Id: CreditAgencyBean.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.loanbroker.esb.ca;
12
13 import javax.ejb.EJBException JavaDoc;
14 import javax.ejb.SessionBean JavaDoc;
15 import javax.ejb.SessionContext JavaDoc;
16 import java.text.MessageFormat JavaDoc;
17
18 /**
19  * <code>CreditAgencyBean</code> obtains a credit historey record for a customer.
20  *
21  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
22  * @version $Revision: 3798 $
23  */

24 public class CreditAgencyBean implements SessionBean JavaDoc
25 {
26     private static final long serialVersionUID = 1546168214387311746L;
27
28     private static final String JavaDoc MSG = "<credit-profile><customer-name>{0}</customer-name><customer-ssn>{1}</customer-ssn><credit-score>{2}</credit-score><customer-history>{3}</customer-history></credit-profile>";
29
30     public void ejbActivate() throws EJBException JavaDoc
31     {
32         // nothing to do
33
}
34
35     public void ejbPassivate() throws EJBException JavaDoc
36     {
37         // nothing to do
38
}
39
40     public void ejbRemove() throws EJBException JavaDoc
41     {
42         // nothing to do
43
}
44
45     public void ejbCreate() throws EJBException JavaDoc
46     {
47         // nothing to do
48
}
49
50     public void setSessionContext(SessionContext JavaDoc sessionContext) throws EJBException JavaDoc
51     {
52         // SessionContext can be ignored
53
}
54
55     protected int getCreditScore(int ssn)
56     {
57         int credit_score;
58
59         credit_score = (int)(Math.random() * 600 + 300);
60
61         return credit_score;
62     }
63
64     protected int getCreditHistoryLength(int ssn)
65     {
66         int credit_history_length;
67
68         credit_history_length = (int)(Math.random() * 19 + 1);
69
70         return credit_history_length;
71     }
72
73     /**
74      * Used by Ejb Call
75      *
76      * @param name
77      * @param ssn
78      * @return
79      */

80     public String JavaDoc getCreditProfile(String JavaDoc name, Integer JavaDoc ssn)
81     {
82         String JavaDoc msg = MessageFormat.format(MSG, new Object JavaDoc[]{name, ssn,
83             new Integer JavaDoc(getCreditScore(ssn.intValue())), new Integer JavaDoc(getCreditHistoryLength(ssn.intValue()))});
84         return msg;
85     }
86
87 }
88
Popular Tags