01: package converter;
02:
03: import javax.ejb.*;
04:
05: /**
06: * This is the bean class for the ConverterBean enterprise bean.
07: * Created 04-May-2005 18:27:05
08: * @author Administrator
09: */
10: public class ConverterBean implements javax.ejb.SessionBean,
11: converter.ConverterRemoteBusiness {
12: private javax.ejb.SessionContext context;
13: java.math.BigDecimal yenRate = new java.math.BigDecimal("121.6000");
14: java.math.BigDecimal euroRate = new java.math.BigDecimal("0.0077");
15:
16: // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
17: // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
18: // TODO Add business methods or web service operations
19: /**
20: * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
21: */
22: public void setSessionContext(javax.ejb.SessionContext aContext) {
23: context = aContext;
24: }
25:
26: /**
27: * @see javax.ejb.SessionBean#ejbActivate()
28: */
29: public void ejbActivate() {
30:
31: }
32:
33: /**
34: * @see javax.ejb.SessionBean#ejbPassivate()
35: */
36: public void ejbPassivate() {
37:
38: }
39:
40: /**
41: * @see javax.ejb.SessionBean#ejbRemove()
42: */
43: public void ejbRemove() {
44:
45: }
46:
47: // </editor-fold>
48:
49: /**
50: * See section 7.10.3 of the EJB 2.0 specification
51: * See section 7.11.3 of the EJB 2.1 specification
52: */
53: public void ejbCreate() {
54: // TODO implement ejbCreate if necessary, acquire resources
55: // This method has access to the JNDI context so resource aquisition
56: // spanning all methods can be performed here such as home interfaces
57: // and data sources.
58: }
59:
60: // Add business logic below. (Right-click in editor and choose
61: // "EJB Methods > Add Business Method" or "Web Service > Add Operation")
62:
63: public java.math.BigDecimal dollarToYen(java.math.BigDecimal dollars) {
64: java.math.BigDecimal result = dollars.multiply(yenRate);
65: return result.setScale(2, java.math.BigDecimal.ROUND_UP);
66: }
67:
68: public java.math.BigDecimal yenToEuro(java.math.BigDecimal yen) {
69: java.math.BigDecimal result = yen.multiply(euroRate);
70: return result.setScale(2, java.math.BigDecimal.ROUND_UP);
71: }
72:
73: }
|