java/nekurak.net-lib/src/cz/frantovo/nekurak/web/HledacSluzby.java
author František Kučera <franta-hg@frantovo.cz>
Sun Jun 20 14:46:47 2010 +0200 (2010-06-20)
changeset 145 0efefbf5f8b6
parent 92 12268fc31114
child 149 8238cdb4113a
permissions -rw-r--r--
Formátování kódu, důsledné používání tabulátorů, drobné úpravy, StringBuilder
     1 package cz.frantovo.nekurak.web;
     2 
     3 import cz.frantovo.nekurak.ejb.ClanekRemote;
     4 import cz.frantovo.nekurak.ejb.PodnikRemote;
     5 import cz.frantovo.nekurak.ejb.UzivatelRemote;
     6 import java.io.Serializable;
     7 import java.util.logging.Level;
     8 import java.util.logging.Logger;
     9 import javax.naming.Context;
    10 import javax.naming.InitialContext;
    11 import javax.naming.NamingException;
    12 
    13 /**
    14  *
    15  * @author fiki
    16  */
    17 public class HledacSluzby implements Serializable {
    18 
    19 	private PodnikRemote podnikEJB;
    20 	private UzivatelRemote uzivatelEJB;
    21 	private ClanekRemote clanekEJB;
    22 	private static final Logger log = Logger.getLogger(HledacSluzby.class.getSimpleName());
    23 
    24 	public PodnikRemote getPodnikEJB() {
    25 		if (podnikEJB == null) {
    26 			try {
    27 				Context c = new InitialContext();
    28 				podnikEJB = (PodnikRemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikRemote");
    29 			} catch (NamingException e) {
    30 				log.log(Level.SEVERE, "Chyba při hledání PodnikRemote", e);
    31 				throw new RuntimeException(e);
    32 			}
    33 		}
    34 		return podnikEJB;
    35 	}
    36 
    37 	public UzivatelRemote getUzivatelEJB() {
    38 		if (uzivatelEJB == null) {
    39 			try {
    40 				Context c = new InitialContext();
    41 				uzivatelEJB = (UzivatelRemote) c.lookup("cz.frantovo.nekurak.ejb.UzivatelRemote");
    42 			} catch (NamingException e) {
    43 				log.log(Level.SEVERE, "Chyba při hledání UzivatelRemote", e);
    44 				throw new RuntimeException(e);
    45 			}
    46 		}
    47 		return uzivatelEJB;
    48 	}
    49 
    50 	public ClanekRemote getClanekEJB() {
    51 		if (clanekEJB == null) {
    52 			try {
    53 				Context c = new InitialContext();
    54 				clanekEJB = (ClanekRemote) c.lookup("cz.frantovo.nekurak.ejb.ClanekRemote");
    55 			} catch (NamingException e) {
    56 				log.log(Level.SEVERE, "Chyba při hledání ClanekRemote", e);
    57 				throw new RuntimeException(e);
    58 			}
    59 		}
    60 		return clanekEJB;
    61 	}
    62 }