KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > converter > ConverterBean


1 package converter;
2 import java.math.BigDecimal JavaDoc;
3
4 /**
5  * This is the bean class for the ConverterBean enterprise bean.
6  * Created May 3, 2005 4:35:52 PM
7  * @author honza
8  */

9 public class ConverterBean implements javax.ejb.SessionBean JavaDoc, converter.ConverterRemoteBusiness {
10     private javax.ejb.SessionContext JavaDoc context;
11     BigDecimal JavaDoc yenRate = new BigDecimal JavaDoc("121.6000");
12     BigDecimal JavaDoc euroRate = new BigDecimal JavaDoc("0.0077");
13
14    
15
16     public BigDecimal JavaDoc dollarToYen(BigDecimal JavaDoc dollars) {
17         BigDecimal JavaDoc result = dollars.multiply(yenRate);
18
19         return result.setScale(2, BigDecimal.ROUND_UP);
20     }
21
22     public BigDecimal JavaDoc yenToEuro(BigDecimal JavaDoc yen) {
23         BigDecimal JavaDoc result = yen.multiply(euroRate);
24
25         return result.setScale(2, BigDecimal.ROUND_UP);
26     }
27     
28     
29     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
30
// TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
31
// TODO Add business methods or web service operations
32
/**
33      * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
34      */

35     public void setSessionContext(javax.ejb.SessionContext JavaDoc aContext) {
36         context = aContext;
37     }
38     
39     /**
40      * @see javax.ejb.SessionBean#ejbActivate()
41      */

42     public void ejbActivate() {
43         
44     }
45     
46     /**
47      * @see javax.ejb.SessionBean#ejbPassivate()
48      */

49     public void ejbPassivate() {
50         
51     }
52     
53     /**
54      * @see javax.ejb.SessionBean#ejbRemove()
55      */

56     public void ejbRemove() {
57         
58     }
59     // </editor-fold>
60

61     /**
62      * See section 7.10.3 of the EJB 2.0 specification
63      * See section 7.11.3 of the EJB 2.1 specification
64      */

65     public void ejbCreate() {
66         // TODO implement ejbCreate if necessary, acquire resources
67
// This method has access to the JNDI context so resource aquisition
68
// spanning all methods can be performed here such as home interfaces
69
// and data sources.
70
}
71     
72     
73     
74     // Add business logic below. (Right-click in editor and choose
75
// "EJB Methods > Add Business Method" or "Web Service > Add Operation")
76

77     
78     
79 }
80
Popular Tags