KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ebank > web > TransferBean


1 /*
2  * Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved. U.S.
3  * Government Rights - Commercial software. Government users are subject
4  * to the Sun Microsystems, Inc. standard license agreement and
5  * applicable provisions of the FAR and its supplements. Use is subject
6  * to license terms.
7  *
8  * This distribution may include materials developed by third parties.
9  * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
10  * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
11  * other countries.
12  *
13  * Copyright (c) 2004 Sun Microsystems, Inc. Tous droits reserves.
14  *
15  * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
16  * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
17  * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
18  * en vigueur de la FAR (Federal Acquisition Regulations) et des
19  * supplements a celles-ci. Distribue par des licences qui en
20  * restreignent l'utilisation.
21  *
22  * Cette distribution peut comprendre des composants developpes par des
23  * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
24  * sont des marques de fabrique ou des marques deposees de Sun
25  * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
26  */

27
28
29 package com.sun.ebank.web;
30
31 import com.sun.ebank.web.BeanManager;
32 import com.sun.ebank.util.*;
33 import com.sun.ebank.ejb.tx.TxController;
34 import com.sun.ebank.ejb.exception.*;
35 import java.util.*;
36 import java.rmi.RemoteException JavaDoc;
37 import java.math.BigDecimal JavaDoc;
38
39
40 public class TransferBean {
41     private BigDecimal JavaDoc transferAmount;
42     private String JavaDoc fromAccountId;
43     private String JavaDoc toAccountId;
44     private ResourceBundle messages;
45     private BeanManager beanManager;
46
47     public TransferBean() {
48         beanManager = null;
49         transferAmount = null;
50         fromAccountId = null;
51         toAccountId = null;
52         messages = null;
53     }
54
55     public String JavaDoc doTx() {
56         String JavaDoc message = null;
57         TxController txCtl = beanManager.getTxController();
58
59         try {
60             txCtl.transferFunds(transferAmount, "Transfer", fromAccountId,
61                 toAccountId);
62         } catch (RemoteException JavaDoc e) {
63             message = e.getMessage();
64             Debug.print(message);
65         } catch (InvalidParameterException e) {
66             // Not possible
67
} catch (AccountNotFoundException e) {
68             // Not possible
69
} catch (InsufficientFundsException e) {
70             message = messages.getString("InsufficientFundsError");
71             Debug.print(message);
72         } catch (InsufficientCreditException e) {
73             message = messages.getString("InsufficientCreditError");
74             Debug.print(message);
75         }
76
77         return message;
78     }
79
80     public BigDecimal JavaDoc getTransferAmount() {
81         return transferAmount;
82     }
83
84     public String JavaDoc getFromAccountId() {
85         return fromAccountId;
86     }
87
88     public String JavaDoc getToAccountId() {
89         return toAccountId;
90     }
91
92     public void setBeanManager(BeanManager beanManager) {
93         this.beanManager = beanManager;
94     }
95
96     public void setTransferAmount(BigDecimal JavaDoc transferAmount) {
97         this.transferAmount = transferAmount;
98         Debug.print("Setting transfer amount to: " + transferAmount);
99     }
100
101     public void setFromAccountId(String JavaDoc fromAccountId) {
102         this.fromAccountId = fromAccountId;
103         Debug.print("Setting from account id to: " + fromAccountId);
104     }
105
106     public void setToAccountId(String JavaDoc toAccountId) {
107         this.toAccountId = toAccountId;
108         Debug.print("Setting to account id to: " + toAccountId);
109     }
110
111     public void setMessages(ResourceBundle messages) {
112         this.messages = messages;
113     }
114 }
115
Popular Tags