RentalServiceBase.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.rental;

import java.util.List;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.SessionContext;
import javax.jms.Destination;
import javax.jms.QueueConnectionFactory;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Autogenerated EJB3 session bean base class RentalServiceBean 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 RentalService
 * </p>
 */
public abstract class RentalServiceBase
    implements RentalService
{
    // ------ 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 RentalCarDao
     */
    @EJB
    private RentalCarDao rentalCarDao;

    /**
     * Inject DAO PersonDao
     */
    @EJB
    private PersonDao personDao;

    // ------ Message Driven EJB Injection Definitions --------

    @Resource(mappedName = "java:/JmsXA")
    protected QueueConnectionFactory queueFactory;

    /**
     * Inject javax.jms.Queue
     */
    @Resource(mappedName = "queue/ejb3demo2/payment")
    protected Destination paymentProcessor;

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

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

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

    /**
     * Get the injected DAO RentalCarDao
     * @return RentalCarDao
     */
    protected RentalCarDao getRentalCarDao()
    {
        return this.rentalCarDao;
    }

    /**
     * Get the injected DAO PersonDao
     * @return PersonDao
     */
    protected PersonDao getPersonDao()
    {
        return this.personDao;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for addCar
     * </p>
     * @param car
     */
    public void addCar(RentalCar car)
    {
        if (car == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.rental.RentalServiceBean.addCar(RentalCar car) - 'car' can not be null");
        }
        try
        {
            this.handleAddCar(car);
        }
        catch (Throwable th)
        {
            throw new RentalServiceException(
                "Error performing 'RentalService.addCar(RentalCar car)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addCar(RentalCar)}
     * @param car
     * @throws Exception
     */
    protected abstract void handleAddCar(RentalCar car)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for getAllCars
     * </p>
     * @return List
     */
    public List getAllCars()
    {
        try
        {
            return this.handleGetAllCars();
        }
        catch (Throwable th)
        {
            throw new RentalServiceException(
                "Error performing 'RentalService.getAllCars()' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getAllCars()}
     * @return List
     * @throws Exception
     */
    protected abstract List handleGetAllCars()
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for getCustomersByName
     * </p>
     * @param name
     * @return List
     */
    public List getCustomersByName(String name)
    {
        if (name == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.rental.RentalServiceBean.getCustomersByName(String name) - 'name' can not be null");
        }
        try
        {
            return this.handleGetCustomersByName(name);
        }
        catch (Throwable th)
        {
            throw new RentalServiceException(
                "Error performing 'RentalService.getCustomersByName(String name)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getCustomersByName(String)}
     * @param name
     * @return List
     * @throws Exception
     */
    protected abstract List handleGetCustomersByName(String name)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for processRental
     * </p>
     * @param car
     * @param leasePeriod
     */
    public void processRental(RentalCar car, int leasePeriod)
    {
        if (car == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.rental.RentalServiceBean.processRental(RentalCar car, int leasePeriod) - 'car' can not be null");
        }
        try
        {
            this.handleProcessRental(car, leasePeriod);
        }
        catch (Throwable th)
        {
            throw new RentalServiceException(
                "Error performing 'RentalService.processRental(RentalCar car, int leasePeriod)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #processRental(RentalCar, int)}
     * @param car
     * @param leasePeriod
     * @throws Exception
     */
    protected abstract void handleProcessRental(RentalCar car, int leasePeriod)
        throws Exception;


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

}