⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customerdelegate.java

📁 A J2EE & Jsp Example
💻 JAVA
字号:
/* * CustomerDelegate.java * * Created on April 11, 2003, 4:12 PM */import javax.ejb.EJBObject;import javax.rmi.PortableRemoteObject;import java.rmi.RemoteException;import customerejb.CustomerTO;import customerejb.ICustomerTO;import customerejb.CustomerException;import customerejb.*;/** * * @author  cm88860 */public class CustomerDelegate {    // the current customer facade customerFacade bean remote interface    private CustomerFacade customerFacade = null;    String jndiCustomerName  = "java:comp/env/ejb/CustomerFacade";    /**     * Initializes the delegate and retrieves a new Remote Interface of the     * CustomerFacade customerFacade bean.     *     * @throws CustomerException Thrown if an error occurs while retrieving     *         CustomerFacade.     */    public CustomerDelegate() throws CustomerException {        try {            CustomerFacadeHome home = (CustomerFacadeHome)                    ServiceLocator.getInstance().getRemoteHome(jndiCustomerName, CustomerFacadeHome.class);            System.out.println( "CustomerDelegate: customerFacade = home.create");            customerFacade = home.create();        } catch (Exception e) {            throw new CustomerException("Cannot locate CustomerFacadeHome", e);        }    }    /**      * Retrieves the customer data associated with the specified customer id.      *      * @param customerId The customer id for which customer data is to be      *        retrieved.      * @return A transfer object object containing the customer data associated      *         with the specified customer id.      * @throws CustomerException Thrown if an error occurs during data retrieval.      * @throws AuthorizationException Thrown if the current user does not have      *         the authorization to view customer data.      */    public CustomerTO getCustomer(String customerId) throws CustomerException {        CustomerTO customer=null;        try {            customer=  (CustomerTO)customerFacade.getCustomer(customerId);            return customer;        } catch (Exception e) {           throw new CustomerException(e);        }            }    /**     * Modifies the customer data specified by the specified TO object.     * The TO object <b>MUST</b> contain a customer id value in order for     * an update to be correctly processed.     *     * @param customer The TO containing the data which will be used to     *        update a customer.     * @throws CustomerException Thrown if an error occurs during data modification.     * @throws AuthorizationException Thrown if the current user does not have     *         the authorization to modify customers.     */    public void updateCustomer(CustomerTO customer) throws CustomerException {        try {            customerFacade.updateCustomer(customer);        } catch (Exception e) {           throw new CustomerException(e);        }    }    /**     * Creates a customer using the data provided by the specified     * TO.     *     * @param customer The TO containing the data which is used to     *        create a customer.     * @return A transfer object containing the newly created customer.     * @throws CustomerException Thrown if an error occurs during data creation.     * @throws AuthorizationException Thrown if the current user does not have     *         the authorization to create customers.     */    public CustomerTO createCustomer(CustomerTO customer) throws CustomerException{        CustomerTO customerTO=null;        try {           customerTO= customerFacade.createCustomer(customer);           return customerTO;        } catch (RemoteException e) {            throw new CustomerException(e);        }    }    /**     * Removes the customer data associated with the specified customer id.     *     * @param customerId The customer id of the customer data to be removed.     * @throws CustomerException Thrown if an error occurs during data removal.     * @throws AuthorizationException Thrown if the current user does not have     *         the authorization to remove customers.     */    public void removeCustomer(String customerId)throws CustomerException{        try {            customerFacade.removeCustomer(customerId);      } catch (RemoteException e) {            throw new CustomerException(e);        }    } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -