📄 cardholderaccessdelegate.java
字号:
package com.ebusiness.ebank.servicedelegate;/** * <p>Title: </p> * <p>Description: Delegate is a bridge class interacting between front-tier and middle tier. * With this class, the back-end business lodic is isolated from * front-end. Front-end developers can focus on the presentation layer. * * Since the Delegate can be used either within eBank application * or by other applications, please do not use struts and Log service * within the delegate classes. * </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author * @version 1.0 */import java.rmi.RemoteException;import javax.ejb.EJBException;import javax.ejb.CreateException;import com.ebusiness.ebank.bean.ClientCardValue;import com.ebusiness.ebank.bean.CardholderValue;import com.ebusiness.ebank.bean.AddressValue;import com.ebusiness.ebank.bean.ValueList;import com.ebusiness.ebank.ejb.sessionbean.CardholderAccessLocalHome;import com.ebusiness.ebank.ejb.sessionbean.CardholderAccessLocal;import com.ebusiness.ebank.ejb.sessionbean.CardholderAccessHome;import com.ebusiness.ebank.ejb.sessionbean.CardholderAccess;import com.ebusiness.ebank.exception.SystemException;import com.ebusiness.ebank.exception.BusinessException;import com.ebusiness.ebank.exception.ErrorMessages;import com.ebusiness.ebank.util.Constants;public class CardholderAccessDelegate{ private static CardholderAccessHome home; private static CardholderAccessLocalHome localHome; private static boolean isLocal; //Indicate if the Delegate can use local call to ejb tier //Instantiate it and initialize CardholderAccess local Home or CardholderAccess remote Home object static { try { localHome = (CardholderAccessLocalHome)ServiceLocator.getInstance().getLocalHome(Constants.CARDHOLDER_ACCESS_LOCALHOME); } catch (ServiceLocatorException sle){} if (localHome != null) isLocal = true; //can use local call else //must use remote call { try { home = (CardholderAccessHome)ServiceLocator.getInstance().getRemoteHome(Constants.CARDHOLDER_ACCESS_HOME, CardholderAccessHome.class); } catch (ServiceLocatorException sle){} } } //The following are the delegated business methods. It has an one-to-one //relationship with CardholderAccess Session Bean /** * @Description: Insert a new cardhoder record and its associated addresses records * to eBank database. This method allows anyone ba able to register online * @param: CardholderValue * @return: */ public static void register(CardholderValue value) throws SystemException, BusinessException { try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); cardholderAccessLocal.register(value); } else { CardholderAccess cardholderAccess = home.create(); cardholderAccess.register(value); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } } /** * @Description: Change password for the cardholder's debit card * @return: */ public static ClientCardValue changePW(ClientCardValue value) throws SystemException, BusinessException { ClientCardValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.changePW(value); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.changePW(value); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: Reset password for the cardholder's web login * @return: */ public static ClientCardValue resetWebPW(ClientCardValue value) throws SystemException, BusinessException { ClientCardValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.resetWebPW(value); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.resetWebPW(value); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: View cardholder data * @return: CardholderValue */ public static ClientCardValue viewClientCardByCardholderOID(long oid) throws SystemException, BusinessException { ClientCardValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.viewClientCardByCardholderOID(oid); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.viewClientCardByCardholderOID(oid); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: Update cardholder data * @param: CardholderValue * @return: CardholderValue */ public static ClientCardValue updateClientCard(ClientCardValue value) throws SystemException, BusinessException { ClientCardValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.updateClientCard(value); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.updateClientCard(value); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: Insert a new record for cardholder table * @param: CardholderValue * @return: CardholderValue */ public static ClientCardValue createClientCard(ClientCardValue value) throws SystemException, BusinessException { ClientCardValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.createClientCard(value); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.createClientCard(value); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: View cardholder data * @return: CardholderValue */ public static CardholderValue viewCardholderByOID(long oid) throws SystemException, BusinessException { CardholderValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.viewCardholderByOID(oid); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.viewCardholderByOID(oid); } } catch(CreateException ce) { throw new SystemException(ce); } catch(EJBException ee) { throw new SystemException(ee); } catch(RemoteException re) { throw new SystemException(re); } return newValue; } /** * @Description: View cardholder data * @return: CardholderValue */ public static CardholderValue viewCardholder(ClientCardValue value) throws SystemException, BusinessException { CardholderValue newValue; try { if(isLocal) { CardholderAccessLocal cardholderAccessLocal = localHome.create(); newValue = cardholderAccessLocal.viewCardholder(value); } else { CardholderAccess cardholderAccess = home.create(); newValue = cardholderAccess.viewCardholder(value); } } catch(CreateException ce) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -