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