1 10 11 package org.mule.samples.loanbroker.esb.ca; 12 13 import javax.ejb.EJBException ; 14 import javax.ejb.SessionBean ; 15 import javax.ejb.SessionContext ; 16 import java.text.MessageFormat ; 17 18 24 public class CreditAgencyBean implements SessionBean 25 { 26 private static final long serialVersionUID = 1546168214387311746L; 27 28 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>"; 29 30 public void ejbActivate() throws EJBException 31 { 32 } 34 35 public void ejbPassivate() throws EJBException 36 { 37 } 39 40 public void ejbRemove() throws EJBException 41 { 42 } 44 45 public void ejbCreate() throws EJBException 46 { 47 } 49 50 public void setSessionContext(SessionContext sessionContext) throws EJBException 51 { 52 } 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 80 public String getCreditProfile(String name, Integer ssn) 81 { 82 String msg = MessageFormat.format(MSG, new Object []{name, ssn, 83 new Integer (getCreditScore(ssn.intValue())), new Integer (getCreditHistoryLength(ssn.intValue()))}); 84 return msg; 85 } 86 87 } 88 | Popular Tags |