BookServiceBase.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.book;

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 BookServiceBean 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 BookService
 * </p>
 */
public abstract class BookServiceBase
    implements BookService
{
    // ------ 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 BookDao
     */
    @EJB
    private BookDao bookDao;

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

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

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

    /**
     * Get the injected DAO BookDao
     * @return BookDao
     */
    protected BookDao getBookDao()
    {
        return this.bookDao;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for addBook
     * </p>
     * @param book
     * @throws BookException
     */
    public void addBook(Book book)
        throws BookException
    {
        if (book == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.book.BookServiceBean.addBook(Book book) - 'book' can not be null");
        }
        try
        {
            this.handleAddBook(book);
        }
        catch (BookException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new BookServiceException(
                "Error performing 'BookService.addBook(Book book)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addBook(Book)}
     * @param book
     * @throws Exception
     */
    protected abstract void handleAddBook(Book book)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for deleteBook
     * </p>
     * @param id
     * @throws BookException
     */
    public void deleteBook(long id)
        throws BookException
    {
        try
        {
            this.handleDeleteBook(id);
        }
        catch (BookException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new BookServiceException(
                "Error performing 'BookService.deleteBook(long id)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #deleteBook(long)}
     * @param id
     * @throws Exception
     */
    protected abstract void handleDeleteBook(long id)
        throws Exception;


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

}