Package org.glassfish.movieplex7.batch

Source Code of org.glassfish.movieplex7.batch.SalesBean

package org.glassfish.movieplex7.batch;

import java.util.List;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.operations.JobStartException;
import javax.batch.runtime.BatchRuntime;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import org.glassfish.movieplex7.entities.Sales;


@Named
@RequestScoped
public class SalesBean {
   
    @PersistenceUnit EntityManagerFactory em;
   
    public void runJob() {
        try {
            JobOperator jo = BatchRuntime.getJobOperator();
            long jobId = jo.start("eod-sales", new Properties());
            System.out.println("Started job: with id: " + jobId);
        } catch (JobStartException ex) {
            ex.printStackTrace();
        }
    }
   
    public List<Sales> getSalesData() {
        return em.createEntityManager().createNamedQuery("Sales.findAll", Sales.class).getResultList();
    }
}
TOP

Related Classes of org.glassfish.movieplex7.batch.SalesBean

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.