java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/PodnikyHibernateWeb.java
changeset 28 0f037986bb6b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/PodnikyHibernateWeb.java	Thu Feb 11 10:06:39 2010 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +package cz.frantovo.nekurak.web;
     1.5 +
     1.6 +import cz.frantovo.nekurak.dto.Podnik;
     1.7 +import cz.frantovo.nekurak.ejb.PodnikHibernateDAORemote;
     1.8 +import java.io.Serializable;
     1.9 +import java.util.Collection;
    1.10 +import java.util.logging.Level;
    1.11 +import java.util.logging.Logger;
    1.12 +import javax.naming.Context;
    1.13 +import javax.naming.InitialContext;
    1.14 +import javax.naming.NamingException;
    1.15 +
    1.16 +/**
    1.17 + *
    1.18 + * @author fiki
    1.19 + */
    1.20 +public class PodnikyHibernateWeb implements Serializable {
    1.21 +
    1.22 +    private PodnikHibernateDAORemote podnikDAO;
    1.23 +    private static final Logger log = Logger.getLogger(PodnikyHibernateWeb.class.getSimpleName());
    1.24 +
    1.25 +    public Collection<Podnik> getPodniky() {
    1.26 +	return lookupCilDAO().getPodniky();
    1.27 +    }
    1.28 +
    1.29 +    private PodnikHibernateDAORemote lookupCilDAO() {
    1.30 +	if (podnikDAO == null) {
    1.31 +	    try {
    1.32 +		Context c = new InitialContext();
    1.33 +		podnikDAO = (PodnikHibernateDAORemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikHibernateDAORemote");
    1.34 +	    } catch (NamingException e) {
    1.35 +		log.log(Level.SEVERE, "Chyba při hledání PodnikHibernateDAO", e);
    1.36 +		throw new RuntimeException(e);
    1.37 +	    }
    1.38 +	}
    1.39 +	return podnikDAO;
    1.40 +    }
    1.41 +}