java/nekurak.net-lib/src/cz/frantovo/nekurak/web/HledacSluzby.java
author František Kučera <franta-hg@frantovo.cz>
Tue Jul 19 15:22:15 2011 +0200 (2011-07-19)
changeset 188 74d06a8a4948
parent 149 8238cdb4113a
permissions -rw-r--r--
Velká čistka – zjednodušení – odstraněno: REST, WS, Chat
(části, které sloužily jako ilustrace k článku / výukové účely)
franta-hg@28
     1
package cz.frantovo.nekurak.web;
franta-hg@28
     2
franta-hg@92
     3
import cz.frantovo.nekurak.ejb.ClanekRemote;
franta-hg@39
     4
import cz.frantovo.nekurak.ejb.PodnikRemote;
franta-hg@51
     5
import cz.frantovo.nekurak.ejb.UzivatelRemote;
franta-hg@28
     6
import java.io.Serializable;
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@39
    17
public class HledacSluzby implements Serializable {
franta-hg@28
    18
franta-hg@145
    19
	private PodnikRemote podnikEJB;
franta-hg@145
    20
	private UzivatelRemote uzivatelEJB;
franta-hg@145
    21
	private ClanekRemote clanekEJB;
franta-hg@145
    22
	private static final Logger log = Logger.getLogger(HledacSluzby.class.getSimpleName());
franta-hg@145
    23
franta-hg@145
    24
	public PodnikRemote getPodnikEJB() {
franta-hg@145
    25
		if (podnikEJB == null) {
franta-hg@145
    26
			try {
franta-hg@145
    27
				Context c = new InitialContext();
franta-hg@145
    28
				podnikEJB = (PodnikRemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikRemote");
franta-hg@145
    29
			} catch (NamingException e) {
franta-hg@145
    30
				log.log(Level.SEVERE, "Chyba při hledání PodnikRemote", e);
franta-hg@145
    31
				throw new RuntimeException(e);
franta-hg@145
    32
			}
franta-hg@145
    33
		}
franta-hg@145
    34
		return podnikEJB;
franta-hg@28
    35
	}
franta-hg@51
    36
franta-hg@145
    37
	public UzivatelRemote getUzivatelEJB() {
franta-hg@145
    38
		if (uzivatelEJB == null) {
franta-hg@145
    39
			try {
franta-hg@145
    40
				Context c = new InitialContext();
franta-hg@145
    41
				uzivatelEJB = (UzivatelRemote) c.lookup("cz.frantovo.nekurak.ejb.UzivatelRemote");
franta-hg@145
    42
			} catch (NamingException e) {
franta-hg@145
    43
				log.log(Level.SEVERE, "Chyba při hledání UzivatelRemote", e);
franta-hg@145
    44
				throw new RuntimeException(e);
franta-hg@145
    45
			}
franta-hg@145
    46
		}
franta-hg@145
    47
		return uzivatelEJB;
franta-hg@51
    48
	}
franta-hg@92
    49
franta-hg@145
    50
	public ClanekRemote getClanekEJB() {
franta-hg@145
    51
		if (clanekEJB == null) {
franta-hg@145
    52
			try {
franta-hg@145
    53
				Context c = new InitialContext();
franta-hg@145
    54
				clanekEJB = (ClanekRemote) c.lookup("cz.frantovo.nekurak.ejb.ClanekRemote");
franta-hg@145
    55
			} catch (NamingException e) {
franta-hg@145
    56
				log.log(Level.SEVERE, "Chyba při hledání ClanekRemote", e);
franta-hg@145
    57
				throw new RuntimeException(e);
franta-hg@145
    58
			}
franta-hg@145
    59
		}
franta-hg@145
    60
		return clanekEJB;
franta-hg@92
    61
	}
franta-hg@28
    62
}