CustomerServiceBase.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by SessionBeanBase.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04.
//
package org.andromda.demo.ejb3.customer;

import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.SessionContext;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Autogenerated EJB3 session bean base class CustomerServiceBean which contains
 * method level annotations for the session bean.  All method level annotations
 * are inherited by the extending session bean class.
 * <p>
 * TODO: Model Documentation for CustomerService
 * </p>
 */
public abstract class CustomerServiceBase
    implements CustomerService
{
    // ------ Session Context Injection ------

    /**
     * SessionContext Injection
     */
    @Resource
    protected SessionContext context;

    // ------ Persistence Context Definitions --------
    /**
     * Inject persistence context demo-ejb3
     */
    @PersistenceContext(unitName = "demo-ejb3")
    protected EntityManager emanager;

    // ------ DAO Injection Definitions --------

    /**
     * Inject DAO CustomerDao
     */
    @EJB
    private CustomerDao customerDao;

    // --------------- Constructors ---------------

    /**
     * Default constructor method with no arguments.
     */
    public CustomerServiceBase()
    {
        super();
    }

    // ------ DAO Getters --------

    /**
     * Get the injected DAO CustomerDao
     * @return CustomerDao
     */
    protected CustomerDao getCustomerDao()
    {
        return this.customerDao;
    }

    // -------- Business Methods  --------------

    /**
     * <p>
     * TODO: Model Documentation for addCustomer
     * </p>
     * @param customer
     * @throws CustomerException
     */
    public void addCustomer(Customer customer)
        throws CustomerException
    {
        if (customer == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.customer.CustomerServiceBean.addCustomer(Customer customer) - 'customer' can not be null");
        }
        try
        {
            this.handleAddCustomer(customer);
        }
        catch (CustomerException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new CustomerServiceException(
                "Error performing 'CustomerService.addCustomer(Customer customer)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addCustomer(Customer)}
     * @param customer
     * @throws Exception
     */
    protected abstract void handleAddCustomer(Customer customer)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for getAllCustomers
     * </p>
     * @return Customer[]
     * @throws CustomerException
     */
    public Customer[] getAllCustomers()
        throws CustomerException
    {
        try
        {
            return this.handleGetAllCustomers();
        }
        catch (CustomerException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new CustomerServiceException(
                "Error performing 'CustomerService.getAllCustomers()' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getAllCustomers()}
     * @return Customer[]
     * @throws Exception
     */
    protected abstract Customer[] handleGetAllCustomers()
        throws Exception;


    // -------- Lifecycle Callbacks --------------

}