Source code: com/obs/client/customer/delegates/CustomerMgmtDelegate.java
1 /*
2 * Created on Aug 11, 2003
3 */
4 package com.obs.client.customer.delegates;
5
6
7 import java.rmi.RemoteException;
8 import java.util.Properties;
9
10 import javax.ejb.CreateException;
11 import javax.naming.NamingException;
12 import javax.rmi.PortableRemoteObject;
13
14 import com.obs.client.templates.EJBDelegateHelper;
15 import com.obs.client.templates.IEJBDelegate;
16 import com.obs.common.contact.views.AddressView;
17 import com.obs.common.contact.views.PhoneView;
18 import com.obs.common.contact.views.WebSiteView;
19 import com.obs.common.customer.views.CustomerView;
20 import com.obs.common.shared.exceptions.NoSuchObjectException;
21 import com.obs.common.shared.exceptions.ServerContactException;
22 import com.obs.ejb.customer.interfaces.CustomerMgmt;
23 import com.obs.ejb.customer.interfaces.CustomerMgmtHome;
24
25
26
27 /**
28 * @author David Durst
29 */
30 public class CustomerMgmtDelegate extends EJBDelegateHelper implements IEJBDelegate {
31
32
33 private CustomerMgmt remote = null;
34 private String jndiREF = "com/obs/ejb/customer/CustomerMgmtEJB";
35
36 public CustomerMgmtDelegate() throws ServerContactException {
37 super();
38 }
39
40 public CustomerMgmtDelegate(Properties props) throws ServerContactException {
41 super(props);
42 }
43
44 public CustomerView createCustomer(CustomerView customerView,
45 AddressView shipToView,
46 AddressView remitToView,
47 AddressView mailToView,
48 PhoneView phoneView,
49 PhoneView faxView,
50 WebSiteView websiteView){
51 try {
52 return remote.createCustomer(customerView,
53 shipToView,
54 remitToView,
55 mailToView,
56 phoneView,
57 faxView,
58 websiteView);
59 }
60 catch(RemoteException remote_ex){
61
62 }
63 catch(CreateException create_ex){
64 }
65 return null;
66 }
67
68 public CustomerView updateCustomer(CustomerView customerView) {
69 try {
70 return remote.updateCustomer(customerView);
71 }
72 catch(RemoteException remote_ex){
73 }
74 catch(NoSuchObjectException noso_ex){
75 }
76 return null;
77 }
78
79 public void updateCustomerShipTo(AddressView shipTo, String vendorId){
80 try{
81 remote.updateCustomerShipTo(shipTo,vendorId);
82 }
83 catch(RemoteException remote_ex){
84 }
85 catch(NoSuchObjectException noso_ex){
86 }
87 }
88
89
90 public void updateCustomerRemitTo(AddressView remitTo, String vendorId){
91 try{
92 remote.updateCustomerRemitTo(remitTo,vendorId);
93 }
94 catch(RemoteException remote_ex){
95 }
96 catch(NoSuchObjectException noso_ex){
97 }
98 }
99
100
101 public void updateCustomerMailTo(AddressView mailTo, String vendorId){
102 try{
103 remote.updateCustomerMailTo(mailTo,vendorId);
104 }
105 catch(RemoteException remote_ex){
106 }
107 catch(NoSuchObjectException noso_ex){
108 }
109 }
110
111
112 public void addContactToCustomer(String contactId, String vendorId){
113 try{
114 remote.addContactToCustomer(contactId,vendorId);
115 }
116 catch(RemoteException remote_ex){
117 }
118 catch(NoSuchObjectException noso_ex){
119 }
120 }
121
122
123 public void removeContactFromCustomer(String contactId, String vendorId){
124 try{
125 remote.removeContactFromCustomer(contactId,vendorId);
126 }
127 catch(RemoteException remote_ex){
128 }
129 catch(NoSuchObjectException noso_ex){
130 }
131 }
132
133 private void init() throws ServerContactException {
134 try {
135 CustomerMgmtHome cmHome = (CustomerMgmtHome)
136 PortableRemoteObject.narrow(ictx.lookup(jndiREF),
137 CustomerMgmtHome.class);
138 remote = cmHome.create();
139 }
140 catch(NamingException naming_ex) {
141 naming_ex.printStackTrace();
142 throw new ServerContactException(naming_ex.getMessage());
143 }
144 catch(RemoteException remote_ex) {
145 remote_ex.printStackTrace();
146 throw new ServerContactException(remote_ex.getMessage());
147 }
148 catch(CreateException create_ex) {
149 create_ex.printStackTrace();
150 throw new ServerContactException(create_ex.getMessage());
151 }
152 inited = true;
153 }
154 public void passivate() throws ServerContactException {
155 gPassivate(remote);
156 }
157
158 public void activate() throws ServerContactException {
159 remote = (CustomerMgmt)gActivate();
160 }
161
162 public void destroy() throws ServerContactException {
163 gDestroy(remote);
164 }
165 }