AccountManagerBase.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.account;

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 AccountManagerBean 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 AccountManager
 * </p>
 */
public abstract class AccountManagerBase
    implements AccountManager
{
    // ------ 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 AccountDao
     */
    @EJB
    private AccountDao accountDao;

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

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

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

    /**
     * Get the injected DAO AccountDao
     * @return AccountDao
     */
    protected AccountDao getAccountDao()
    {
        return this.accountDao;
    }

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

    /**
     * <p>
     * Adds a new account
     * </p>
     * @param account
     * @return long
     * @throws AccountException
     */
    public long addAccount(Account account)
        throws AccountException
    {
        if (account == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.account.AccountManagerBean.addAccount(Account account) - 'account' can not be null");
        }
        try
        {
            return this.handleAddAccount(account);
        }
        catch (AccountException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new AccountManagerException(
                "Error performing 'AccountManager.addAccount(Account account)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addAccount(Account)}
     * @param account
     * @return long
     * @throws Exception
     */
    protected abstract long handleAddAccount(Account account)
        throws Exception;

    /**
     * <p>
     * Get the account using the account id
     * </p>
     * @param id
     * @return Account
     * @throws AccountException
     */
    public Account getAccount(long id)
        throws AccountException
    {
        try
        {
            return this.handleGetAccount(id);
        }
        catch (AccountException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new AccountManagerException(
                "Error performing 'AccountManager.getAccount(long id)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getAccount(long)}
     * @param id
     * @return Account
     * @throws Exception
     */
    protected abstract Account handleGetAccount(long id)
        throws Exception;

    /**
     * <p>
     * Delete the account using the id
     * </p>
     * @param id
     * @throws AccountException
     */
    public void deleteAccount(long id)
        throws AccountException
    {
        try
        {
            this.handleDeleteAccount(id);
        }
        catch (AccountException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new AccountManagerException(
                "Error performing 'AccountManager.deleteAccount(long id)' --> " + th,
                th);
        }
    }

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


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

}