franta-hg@4: package cz.frantovo.hibernateDemo1; franta-hg@4: franta-hg@4: import cz.frantovo.hibernateDemo1.CilDAORemote; franta-hg@4: import cz.frantovo.hibernateDemo1.dto.Cil; franta-hg@4: import java.util.Collection; franta-hg@4: import java.util.logging.Level; franta-hg@4: import java.util.logging.Logger; franta-hg@4: import javax.naming.Context; franta-hg@4: import javax.naming.InitialContext; franta-hg@4: import javax.naming.NamingException; franta-hg@4: franta-hg@4: /** franta-hg@4: * Webová Beana pro zobrazení seznamu cílů. franta-hg@4: * Volá EJB, které tento seznam získá z databáze franta-hg@4: * @author fiki franta-hg@4: */ franta-hg@4: public class SeznamCilu { franta-hg@4: franta-hg@4: private CilDAORemote cilDAO; franta-hg@4: private static final Logger log = Logger.getLogger(SeznamCilu.class.getSimpleName()); franta-hg@4: franta-hg@4: public Collection getCile() { franta-hg@4: return lookupCilDAO().getCile(); franta-hg@4: } franta-hg@4: franta-hg@4: private CilDAORemote lookupCilDAO() { franta-hg@4: if (cilDAO == null) { franta-hg@4: try { franta-hg@4: Context c = new InitialContext(); franta-hg@4: cilDAO = (CilDAORemote) c.lookup("cz.frantovo.hibernateDemo1.CilDAORemote"); franta-hg@4: } catch (NamingException e) { franta-hg@4: log.log(Level.SEVERE, "Chyba při hledání CilDAO", e); franta-hg@4: throw new RuntimeException(e); franta-hg@4: } franta-hg@4: } franta-hg@4: return cilDAO; franta-hg@4: } franta-hg@4: }