UserManagerBase.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.user;

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 UserManagerBean 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 UserManager
 * </p>
 */
public abstract class UserManagerBase
    implements UserManager
{
    // ------ 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 UserDao
     */
    @EJB
    private UserDao userDao;

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

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

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

    /**
     * Get the injected DAO UserDao
     * @return UserDao
     */
    protected UserDao getUserDao()
    {
        return this.userDao;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for addUser
     * </p>
     * @param user
     * @throws UserException
     */
    public void addUser(User user)
        throws UserException
    {
        if (user == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.user.UserManagerBean.addUser(User user) - 'user' can not be null");
        }
        try
        {
            this.handleAddUser(user);
        }
        catch (UserException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new UserManagerException(
                "Error performing 'UserManager.addUser(User user)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addUser(User)}
     * @param user
     * @throws Exception
     */
    protected abstract void handleAddUser(User user)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for getUser
     * </p>
     * @param principalId
     * @return User
     * @throws UserException
     */
    public User getUser(String principalId)
        throws UserException
    {
        if (principalId == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.user.UserManagerBean.getUser(String principalId) - 'principalId' can not be null");
        }
        try
        {
            return this.handleGetUser(principalId);
        }
        catch (UserException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new UserManagerException(
                "Error performing 'UserManager.getUser(String principalId)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getUser(String)}
     * @param principalId
     * @return User
     * @throws Exception
     */
    protected abstract User handleGetUser(String principalId)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for deleteUser
     * </p>
     * @param principalId
     * @throws UserException
     */
    public void deleteUser(String principalId)
        throws UserException
    {
        if (principalId == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.user.UserManagerBean.deleteUser(String principalId) - 'principalId' can not be null");
        }
        try
        {
            this.handleDeleteUser(principalId);
        }
        catch (UserException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new UserManagerException(
                "Error performing 'UserManager.deleteUser(String principalId)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #deleteUser(String)}
     * @param principalId
     * @throws Exception
     */
    protected abstract void handleDeleteUser(String principalId)
        throws Exception;


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

}