1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.example.loanbroker.credit; |
8 | |
|
9 | |
import java.text.MessageFormat; |
10 | |
|
11 | |
import javax.ejb.EJBException; |
12 | |
import javax.ejb.SessionBean; |
13 | |
import javax.ejb.SessionContext; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | 0 | public class CreditAgencyBean implements SessionBean |
19 | |
{ |
20 | |
private static final long serialVersionUID = 1546168214387311746L; |
21 | |
|
22 | |
private static final String 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>"; |
23 | |
|
24 | |
public void ejbActivate() throws EJBException |
25 | |
{ |
26 | |
|
27 | 0 | } |
28 | |
|
29 | |
public void ejbPassivate() throws EJBException |
30 | |
{ |
31 | |
|
32 | 0 | } |
33 | |
|
34 | |
public void ejbRemove() throws EJBException |
35 | |
{ |
36 | |
|
37 | 0 | } |
38 | |
|
39 | |
public void ejbCreate() throws EJBException |
40 | |
{ |
41 | |
|
42 | 0 | } |
43 | |
|
44 | |
public void setSessionContext(SessionContext sessionContext) throws EJBException |
45 | |
{ |
46 | |
|
47 | 0 | } |
48 | |
|
49 | |
protected int getCreditScore(int ssn) |
50 | |
{ |
51 | |
int credit_score; |
52 | |
|
53 | 0 | credit_score = (int)(Math.random() * 600 + 300); |
54 | |
|
55 | 0 | return credit_score; |
56 | |
} |
57 | |
|
58 | |
protected int getCreditHistoryLength(int ssn) |
59 | |
{ |
60 | |
int credit_history_length; |
61 | |
|
62 | 0 | credit_history_length = (int)(Math.random() * 19 + 1); |
63 | |
|
64 | 0 | return credit_history_length; |
65 | |
} |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
public String getCreditProfile(String name, Integer ssn) |
71 | |
{ |
72 | 0 | String msg = MessageFormat.format(MSG, name, ssn, |
73 | |
getCreditScore(ssn), getCreditHistoryLength(ssn)); |
74 | 0 | return msg; |
75 | |
} |
76 | |
|
77 | |
} |