java/nekurak.net-lib/src/cz/frantovo/nekurak/web/HledacSluzby.java
author František Kučera <franta-hg@frantovo.cz>
Sun Jul 10 20:17:56 2011 +0200 (2011-07-10)
changeset 185 60658773f604
parent 145 0efefbf5f8b6
child 188 74d06a8a4948
permissions -rw-r--r--
Odkaz na OpenStreetMap
franta-hg@28
     1
package cz.frantovo.nekurak.web;
franta-hg@28
     2
franta-hg@149
     3
import cz.frantovo.nekurak.ejb.ChatRemote;
franta-hg@92
     4
import cz.frantovo.nekurak.ejb.ClanekRemote;
franta-hg@39
     5
import cz.frantovo.nekurak.ejb.PodnikRemote;
franta-hg@51
     6
import cz.frantovo.nekurak.ejb.UzivatelRemote;
franta-hg@28
     7
import java.io.Serializable;
franta-hg@28
     8
import java.util.logging.Level;
franta-hg@28
     9
import java.util.logging.Logger;
franta-hg@28
    10
import javax.naming.Context;
franta-hg@28
    11
import javax.naming.InitialContext;
franta-hg@28
    12
import javax.naming.NamingException;
franta-hg@28
    13
franta-hg@28
    14
/**
franta-hg@28
    15
 *
franta-hg@28
    16
 * @author fiki
franta-hg@28
    17
 */
franta-hg@39
    18
public class HledacSluzby implements Serializable {
franta-hg@28
    19
franta-hg@145
    20
	private PodnikRemote podnikEJB;
franta-hg@145
    21
	private UzivatelRemote uzivatelEJB;
franta-hg@145
    22
	private ClanekRemote clanekEJB;
franta-hg@149
    23
	private ChatRemote chatEJB;
franta-hg@145
    24
	private static final Logger log = Logger.getLogger(HledacSluzby.class.getSimpleName());
franta-hg@145
    25
franta-hg@145
    26
	public PodnikRemote getPodnikEJB() {
franta-hg@145
    27
		if (podnikEJB == null) {
franta-hg@145
    28
			try {
franta-hg@145
    29
				Context c = new InitialContext();
franta-hg@145
    30
				podnikEJB = (PodnikRemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikRemote");
franta-hg@145
    31
			} catch (NamingException e) {
franta-hg@145
    32
				log.log(Level.SEVERE, "Chyba při hledání PodnikRemote", e);
franta-hg@145
    33
				throw new RuntimeException(e);
franta-hg@145
    34
			}
franta-hg@145
    35
		}
franta-hg@145
    36
		return podnikEJB;
franta-hg@28
    37
	}
franta-hg@51
    38
franta-hg@145
    39
	public UzivatelRemote getUzivatelEJB() {
franta-hg@145
    40
		if (uzivatelEJB == null) {
franta-hg@145
    41
			try {
franta-hg@145
    42
				Context c = new InitialContext();
franta-hg@145
    43
				uzivatelEJB = (UzivatelRemote) c.lookup("cz.frantovo.nekurak.ejb.UzivatelRemote");
franta-hg@145
    44
			} catch (NamingException e) {
franta-hg@145
    45
				log.log(Level.SEVERE, "Chyba při hledání UzivatelRemote", e);
franta-hg@145
    46
				throw new RuntimeException(e);
franta-hg@145
    47
			}
franta-hg@145
    48
		}
franta-hg@145
    49
		return uzivatelEJB;
franta-hg@51
    50
	}
franta-hg@92
    51
franta-hg@145
    52
	public ClanekRemote getClanekEJB() {
franta-hg@145
    53
		if (clanekEJB == null) {
franta-hg@145
    54
			try {
franta-hg@145
    55
				Context c = new InitialContext();
franta-hg@145
    56
				clanekEJB = (ClanekRemote) c.lookup("cz.frantovo.nekurak.ejb.ClanekRemote");
franta-hg@145
    57
			} catch (NamingException e) {
franta-hg@145
    58
				log.log(Level.SEVERE, "Chyba při hledání ClanekRemote", e);
franta-hg@145
    59
				throw new RuntimeException(e);
franta-hg@145
    60
			}
franta-hg@145
    61
		}
franta-hg@145
    62
		return clanekEJB;
franta-hg@92
    63
	}
franta-hg@149
    64
franta-hg@149
    65
	public ChatRemote getChatEJB() {
franta-hg@149
    66
		if (chatEJB == null) {
franta-hg@149
    67
			try {
franta-hg@149
    68
				Context c = new InitialContext();
franta-hg@149
    69
				chatEJB = (ChatRemote) c.lookup("cz.frantovo.nekurak.ejb.ChatRemote");
franta-hg@149
    70
			} catch (NamingException e) {
franta-hg@149
    71
				log.log(Level.SEVERE, "Chyba při hledání ChatRemote", e);
franta-hg@149
    72
				throw new RuntimeException(e);
franta-hg@149
    73
			}
franta-hg@149
    74
		}
franta-hg@149
    75
		return chatEJB;
franta-hg@149
    76
	}
franta-hg@28
    77
}