Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/obs/client/vendor/delegates/VendorManagementDelegate.java


1   /*
2    * Created on Aug 11, 2003
3    */
4   package com.obs.client.vendor.delegates;
5   
6   
7   import java.rmi.RemoteException;
8   
9   import javax.ejb.CreateException;
10  import javax.ejb.Handle;
11  import javax.naming.InitialContext;
12  import javax.naming.NamingException;
13  import javax.rmi.PortableRemoteObject;
14  
15  import com.obs.client.templates.EJBDelegate;
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.exceptions.ServerContactException;
20  import com.obs.common.vendor.views.VendorView;
21  import com.obs.ejb.exceptions.NoSuchObjectException;
22  import com.obs.ejb.vendor.interfaces.VendorManagement;
23  import com.obs.ejb.vendor.interfaces.VendorManagementHome;
24  
25  
26  
27  /**
28   * @author David Durst
29   */
30  public class VendorManagementDelegate implements EJBDelegate {
31  
32      private InitialContext ictx = null;
33      private VendorManagement vendorManagement = null;
34      private Handle handle = null;
35      
36      public VendorView createVendor(VendorView vendorView,
37                                                              AddressView shipToView,
38                                                              AddressView remitToView,
39                                                              AddressView mailToView,
40                                                              PhoneView phoneView,
41                                                              PhoneView faxView,
42                                                              WebSiteView websiteView){
43          try {
44              return vendorManagement.createVendor(vendorView,
45                                                                                   shipToView,
46                                                                                   remitToView,
47                                                                                   mailToView,
48                                                                                   phoneView,
49                                                                                   faxView,
50                                                                                   websiteView);
51          }
52          catch(RemoteException remote_ex){
53              
54          }
55          catch(CreateException create_ex){
56          }
57          return null;
58      }
59  
60      public VendorView updateVendor(VendorView vendorView) {
61          try {
62              return vendorManagement.updateVendor(vendorView);
63          }
64          catch(RemoteException remote_ex){
65          }
66          catch(NoSuchObjectException noso_ex){
67          }
68          return null;
69      }
70      
71      public void updateVendorShipTo(AddressView shipTo, String vendorId){
72          try{
73              vendorManagement.updateVendorShipTo(shipTo,vendorId);
74          }
75          catch(RemoteException remote_ex){
76          }
77          catch(NoSuchObjectException noso_ex){
78          }
79      }
80       
81          
82      public void updateVendorRemitTo(AddressView remitTo, String vendorId){
83          try{
84              vendorManagement.updateVendorRemitTo(remitTo,vendorId);
85          }
86          catch(RemoteException remote_ex){
87          }
88          catch(NoSuchObjectException noso_ex){
89          }        
90      }
91       
92  
93      public void updateVendorMailTo(AddressView mailTo, String vendorId){
94          try{
95              vendorManagement.updateVendorMailTo(mailTo,vendorId);
96          }
97          catch(RemoteException remote_ex){
98          }
99          catch(NoSuchObjectException noso_ex){
100         }        
101     }
102         
103         
104     public void addContactToVendor(String contactId, String vendorId){
105         try{
106             vendorManagement.addContactToVendor(contactId,vendorId);
107         }
108         catch(RemoteException remote_ex){
109         }
110         catch(NoSuchObjectException noso_ex){
111         }        
112     }
113         
114 
115     public void removeContactFromVendor(String contactId, String vendorId){
116         try{
117             vendorManagement.removeContactFromVendor(contactId,vendorId);
118         }
119         catch(RemoteException remote_ex){
120         }
121         catch(NoSuchObjectException noso_ex){
122         }        
123     }
124             
125     
126     public void passivate() throws ServerContactException {
127         try {
128             if(vendorManagement != null) {
129                 handle = vendorManagement.getHandle();
130                 vendorManagement = null;
131             }
132         }
133         catch(RemoteException remote_ex){
134             throw new ServerContactException();
135         }
136     }
137 
138     public void activate() throws ServerContactException {
139         if(handle != null) {
140             try {
141                 vendorManagement = (VendorManagement)handle.getEJBObject();
142             }
143             catch(RemoteException remote_ex) {
144                 throw new ServerContactException();
145             }
146         }
147         else {
148             try {
149                 ictx = new InitialContext();
150                 VendorManagementHome vmHome = (VendorManagementHome)
151                                  PortableRemoteObject.narrow(
152                                    ictx.lookup("com/obs/ejb/vendor/VendorManagementEJB"),
153                                    VendorManagementHome.class);
154                 vendorManagement = vmHome.create();
155             }
156             catch(NamingException naming_ex) {
157                 throw new ServerContactException();
158             }
159             catch(RemoteException remote_ex) {
160                 throw new ServerContactException();
161             }
162             catch(CreateException create_ex) {
163             }           
164         }        
165     }
166 
167     public void destroy() throws ServerContactException {
168         try{
169             vendorManagement.remove();
170         }
171         catch(Exception ex){
172             throw new ServerContactException();
173         }        
174     }
175 
176 }