01: /*
02: * ConverterClient.java
03: *
04: * Created on May 3, 2005, 4:37 PM
05: *
06: * To change this template, choose Tools | Options and locate the template under
07: * the Source Creation and Management node. Right-click the template and choose
08: * Open. You can then make changes to the template in the Source Editor.
09: */
10:
11: package converterclient;
12:
13: import converter.ConverterRemote;
14: import converter.ConverterRemoteHome;
15: import javax.naming.Context;
16: import javax.naming.InitialContext;
17: import javax.rmi.PortableRemoteObject;
18: import java.math.BigDecimal;
19:
20: public class ConverterClient {
21: public static void main(String[] args) {
22: try {
23: Context initial = new InitialContext();
24: Object objref = initial.lookup("ejb/SimpleConverter");
25:
26: ConverterRemoteHome home = (ConverterRemoteHome) PortableRemoteObject
27: .narrow(objref, ConverterRemoteHome.class);
28:
29: ConverterRemote currencyConverter = home.create();
30:
31: BigDecimal param = new BigDecimal("100.00");
32: BigDecimal amount = currencyConverter.dollarToYen(param);
33:
34: System.out.println(amount);
35: amount = currencyConverter.yenToEuro(param);
36: System.out.println(amount);
37:
38: System.exit(0);
39: } catch (Exception ex) {
40: System.err.println("Caught an unexpected exception!");
41: ex.printStackTrace();
42: }
43: }
44: }
|