author | František Kučera <franta-hg@frantovo.cz> |
Thu, 11 Feb 2010 10:06:39 +0100 | |
changeset 28 | 0f037986bb6b |
permissions | -rw-r--r-- |
franta-hg@28 | 1 |
package cz.frantovo.nekurak.web; |
franta-hg@28 | 2 |
|
franta-hg@28 | 3 |
import cz.frantovo.nekurak.dto.Podnik; |
franta-hg@28 | 4 |
import cz.frantovo.nekurak.ejb.PodnikHibernateDAORemote; |
franta-hg@28 | 5 |
import java.io.Serializable; |
franta-hg@28 | 6 |
import java.util.Collection; |
franta-hg@28 | 7 |
import java.util.logging.Level; |
franta-hg@28 | 8 |
import java.util.logging.Logger; |
franta-hg@28 | 9 |
import javax.naming.Context; |
franta-hg@28 | 10 |
import javax.naming.InitialContext; |
franta-hg@28 | 11 |
import javax.naming.NamingException; |
franta-hg@28 | 12 |
|
franta-hg@28 | 13 |
/** |
franta-hg@28 | 14 |
* |
franta-hg@28 | 15 |
* @author fiki |
franta-hg@28 | 16 |
*/ |
franta-hg@28 | 17 |
public class PodnikyHibernateWeb implements Serializable { |
franta-hg@28 | 18 |
|
franta-hg@28 | 19 |
private PodnikHibernateDAORemote podnikDAO; |
franta-hg@28 | 20 |
private static final Logger log = Logger.getLogger(PodnikyHibernateWeb.class.getSimpleName()); |
franta-hg@28 | 21 |
|
franta-hg@28 | 22 |
public Collection<Podnik> getPodniky() { |
franta-hg@28 | 23 |
return lookupCilDAO().getPodniky(); |
franta-hg@28 | 24 |
} |
franta-hg@28 | 25 |
|
franta-hg@28 | 26 |
private PodnikHibernateDAORemote lookupCilDAO() { |
franta-hg@28 | 27 |
if (podnikDAO == null) { |
franta-hg@28 | 28 |
try { |
franta-hg@28 | 29 |
Context c = new InitialContext(); |
franta-hg@28 | 30 |
podnikDAO = (PodnikHibernateDAORemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikHibernateDAORemote"); |
franta-hg@28 | 31 |
} catch (NamingException e) { |
franta-hg@28 | 32 |
log.log(Level.SEVERE, "Chyba při hledání PodnikHibernateDAO", e); |
franta-hg@28 | 33 |
throw new RuntimeException(e); |
franta-hg@28 | 34 |
} |
franta-hg@28 | 35 |
} |
franta-hg@28 | 36 |
return podnikDAO; |
franta-hg@28 | 37 |
} |
franta-hg@28 | 38 |
} |