author | František Kučera <franta-hg@frantovo.cz> |
Sat, 14 Mar 2009 23:15:33 +0100 | |
changeset 4 | 58552ccfe6c8 |
permissions | -rw-r--r-- |
franta-hg@4 | 1 |
package cz.frantovo.hibernateDemo1; |
franta-hg@4 | 2 |
|
franta-hg@4 | 3 |
import cz.frantovo.hibernateDemo1.CilDAORemote; |
franta-hg@4 | 4 |
import cz.frantovo.hibernateDemo1.dto.Cil; |
franta-hg@4 | 5 |
import java.util.Collection; |
franta-hg@4 | 6 |
import java.util.logging.Level; |
franta-hg@4 | 7 |
import java.util.logging.Logger; |
franta-hg@4 | 8 |
import javax.naming.Context; |
franta-hg@4 | 9 |
import javax.naming.InitialContext; |
franta-hg@4 | 10 |
import javax.naming.NamingException; |
franta-hg@4 | 11 |
|
franta-hg@4 | 12 |
/** |
franta-hg@4 | 13 |
* Webová Beana pro zobrazení seznamu cílů. |
franta-hg@4 | 14 |
* Volá EJB, které tento seznam získá z databáze |
franta-hg@4 | 15 |
* @author fiki |
franta-hg@4 | 16 |
*/ |
franta-hg@4 | 17 |
public class SeznamCilu { |
franta-hg@4 | 18 |
|
franta-hg@4 | 19 |
private CilDAORemote cilDAO; |
franta-hg@4 | 20 |
private static final Logger log = Logger.getLogger(SeznamCilu.class.getSimpleName()); |
franta-hg@4 | 21 |
|
franta-hg@4 | 22 |
public Collection<Cil> getCile() { |
franta-hg@4 | 23 |
return lookupCilDAO().getCile(); |
franta-hg@4 | 24 |
} |
franta-hg@4 | 25 |
|
franta-hg@4 | 26 |
private CilDAORemote lookupCilDAO() { |
franta-hg@4 | 27 |
if (cilDAO == null) { |
franta-hg@4 | 28 |
try { |
franta-hg@4 | 29 |
Context c = new InitialContext(); |
franta-hg@4 | 30 |
cilDAO = (CilDAORemote) c.lookup("cz.frantovo.hibernateDemo1.CilDAORemote"); |
franta-hg@4 | 31 |
} catch (NamingException e) { |
franta-hg@4 | 32 |
log.log(Level.SEVERE, "Chyba při hledání CilDAO", e); |
franta-hg@4 | 33 |
throw new RuntimeException(e); |
franta-hg@4 | 34 |
} |
franta-hg@4 | 35 |
} |
franta-hg@4 | 36 |
return cilDAO; |
franta-hg@4 | 37 |
} |
franta-hg@4 | 38 |
} |