Package com.example.ejb3.beans

Source Code of com.example.ejb3.beans.WidgetBean

/**
* junit-rules: JUnit Rules Library
*
* Copyright (c) 2009-2011 by Alistair A. Israel.
* This software is made available under the terms of the MIT License.
*
* Created Oct 16, 2009
*/
package com.example.ejb3.beans;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.example.dao.WidgetDao;
import com.example.dao.jpa.JpaWidgetDao;
import com.example.model.Widget;

/**
* @author Alistair A. Israel
*/
public class WidgetBean {

    @PersistenceContext
    private EntityManager em;

    private WidgetDao widgetDao;

    /**
     * We create the {@link JpaWidgetDao}
     */
    @PostConstruct
    @SuppressWarnings("unused")
    private void initialize() {
        widgetDao = new JpaWidgetDao(em);
    }

    /**
     * @return list of all widgets
     */
    public final List<Widget> listAll() {
        return widgetDao.listAll();
    }

    /**
     * @param id
     *        the Widget id
     * @return the found Widget
     */
    public final Widget findById(final int id) {
        return widgetDao.findById(id);
    }
}
TOP

Related Classes of com.example.ejb3.beans.WidgetBean

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.