KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.ejb.*;
32 import javax.naming.*;
33 import javax.rmi.PortableRemoteObject JavaDoc;
34 import java.rmi.RemoteException JavaDoc;
35 import com.sun.ebank.ejb.exception.*;
36 import com.sun.ebank.util.*;
37 import com.sun.ebank.ejb.account.*;
38 import com.sun.ebank.ejb.customer.*;
39 import com.sun.ebank.ejb.tx.*;
40 import java.util.*;
41
42
43 public class CustomerBean {
44     private BeanManager beanManager;
45     private String JavaDoc customer;
46     private String JavaDoc account;
47
48     public CustomerBean() {
49         beanManager = null;
50         customer = null;
51         account = null;
52     }
53
54     public void setBeanManager(BeanManager beanManager) {
55         this.beanManager = beanManager;
56     }
57
58     public BeanManager getBeanManager() {
59         return this.beanManager;
60     }
61
62     public void setCustomer(String JavaDoc customer) {
63         this.customer = customer;
64     }
65
66     public String JavaDoc getCustomer() {
67         return this.customer;
68     }
69
70     public void setAccount(String JavaDoc account) {
71         this.account = account;
72     }
73
74     public String JavaDoc getAccount() {
75         return this.account;
76     }
77
78     public CustomerDetails getCustomerDetails() {
79         CustomerDetails cd = null;
80
81         try {
82             cd = beanManager.getCustomerController()
83                             .getDetails(this.customer);
84         } catch (InvalidParameterException e) {
85             Debug.print(e.getMessage());
86
87             // Not possible
88
} catch (RemoteException JavaDoc e) {
89             Debug.print(e.getMessage());
90
91             // Not possible
92
} catch (CustomerNotFoundException e) {
93             Debug.print(e.getMessage());
94
95             // Not possible
96
}
97
98         Debug.print(cd.getCustomerId());
99
100         return cd;
101     }
102
103     public AccountDetails getAccountDetails() {
104         AccountDetails ad = null;
105
106         try {
107             ad = beanManager.getAccountController()
108                             .getDetails(this.account);
109         } catch (InvalidParameterException e) {
110             Debug.print(e.getMessage());
111
112             // Not possible
113
} catch (RemoteException JavaDoc e) {
114             Debug.print(e.getMessage());
115
116             // Not possible
117
} catch (AccountNotFoundException e) {
118             Debug.print(e.getMessage());
119
120             // Not possible
121
}
122
123         Debug.print(ad.getAccountId());
124
125         return ad;
126     }
127
128     public ArrayList getAccounts() {
129         ArrayList accounts = null;
130
131         try {
132             accounts =
133                 beanManager.getAccountController()
134                            .getAccountsOfCustomer(this.customer);
135         } catch (InvalidParameterException e) {
136             // Not possible
137
} catch (RemoteException JavaDoc e) {
138             // Not possible
139
} catch (AccountNotFoundException e) {
140             // Not possible
141
}
142
143         return accounts;
144     }
145
146     public void destroy() {
147         beanManager = null;
148         customer = null;
149         account = null;
150     }
151 }
152
Popular Tags