AnimalServiceBase.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.animal;

import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
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 AnimalServiceBean 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 AnimalService
 * </p>
 */
public abstract class AnimalServiceBase
    implements AnimalService
{
    // ------ 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 AnimalDao
     */
    @EJB
    private AnimalDao animalDao;

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

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

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

    /**
     * Get the injected DAO AnimalDao
     * @return AnimalDao
     */
    protected AnimalDao getAnimalDao()
    {
        return this.animalDao;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for addAnimal
     * </p>
     * @param animal
     * @throws AnimalCreateException
     */
    public void addAnimal(Animal animal)
        throws AnimalCreateException
    {
        if (animal == null)
        {
            throw new IllegalArgumentException(
                "org.andromda.demo.ejb3.animal.AnimalServiceBean.addAnimal(Animal animal) - 'animal' can not be null");
        }
        try
        {
            this.handleAddAnimal(animal);
        }
        catch (AnimalCreateException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new AnimalServiceException(
                "Error performing 'AnimalService.addAnimal(Animal animal)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addAnimal(Animal)}
     * @param animal
     * @throws Exception
     */
    protected abstract void handleAddAnimal(Animal animal)
        throws Exception;

    /**
     * <p>
     * TODO: Model Documentation for getAllAnimals
     * </p>
     * @return Collection
     */
    // Interceptors are defined in ejb-jar.xml
    // @javax.interceptor.Interceptors({org.andromda.demo.ejb3.animal.AnimalInterceptorMetod.class})
    public Collection getAllAnimals()
    {
        try
        {
            return this.handleGetAllAnimals();
        }
        catch (Throwable th)
        {
            throw new AnimalServiceException(
                "Error performing 'AnimalService.getAllAnimals()' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getAllAnimals()}
     * @return Collection
     * @throws Exception
     */
    protected abstract Collection handleGetAllAnimals()
        throws Exception;


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

    /**
     * <p>
     * TODO: Model Documentation for init
     * </p>
     */
    @PostConstruct
    public void init()
    {
        this.handleInit();
    }

    /**
     * Performs the core logic for {@link #init()}
     */
    protected abstract void handleInit();

    /**
     * <p>
     * TODO: Model Documentation for cleanup
     * </p>
     */
    @PreDestroy
    public void cleanup()
    {
        this.handleCleanup();
    }

    /**
     * Performs the core logic for {@link #cleanup()}
     */
    protected abstract void handleCleanup();

}