java/nekurak.net-lib/src/cz/frantovo/nekurak/web/HledacSluzby.java
author František Kučera <franta-hg@frantovo.cz>
Tue Apr 06 00:27:48 2010 +0200 (2010-04-06)
changeset 92 12268fc31114
parent 91 936ad9853a30
child 145 0efefbf5f8b6
permissions -rw-r--r--
REST: načítání seznamu článků z EJB a DB.
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@39
    19
    private PodnikRemote podnikEJB;
franta-hg@51
    20
    private UzivatelRemote uzivatelEJB;
franta-hg@92
    21
    private ClanekRemote clanekEJB;
franta-hg@39
    22
    private static final Logger log = Logger.getLogger(HledacSluzby.class.getSimpleName());
franta-hg@92
    23
    
franta-hg@39
    24
    public PodnikRemote getPodnikEJB() {
franta-hg@39
    25
	if (podnikEJB == null) {
franta-hg@28
    26
	    try {
franta-hg@28
    27
		Context c = new InitialContext();
franta-hg@39
    28
		podnikEJB = (PodnikRemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikRemote");
franta-hg@28
    29
	    } catch (NamingException e) {
franta-hg@39
    30
		log.log(Level.SEVERE, "Chyba při hledání PodnikRemote", e);
franta-hg@28
    31
		throw new RuntimeException(e);
franta-hg@28
    32
	    }
franta-hg@28
    33
	}
franta-hg@39
    34
	return podnikEJB;
franta-hg@28
    35
    }
franta-hg@51
    36
franta-hg@51
    37
    public UzivatelRemote getUzivatelEJB() {
franta-hg@51
    38
	if (uzivatelEJB == null) {
franta-hg@51
    39
	    try {
franta-hg@51
    40
		Context c = new InitialContext();
franta-hg@51
    41
		uzivatelEJB = (UzivatelRemote) c.lookup("cz.frantovo.nekurak.ejb.UzivatelRemote");
franta-hg@51
    42
	    } catch (NamingException e) {
franta-hg@51
    43
		log.log(Level.SEVERE, "Chyba při hledání UzivatelRemote", e);
franta-hg@51
    44
		throw new RuntimeException(e);
franta-hg@51
    45
	    }
franta-hg@51
    46
	}
franta-hg@51
    47
	return uzivatelEJB;
franta-hg@51
    48
    }
franta-hg@92
    49
franta-hg@92
    50
    public ClanekRemote getClanekEJB() {
franta-hg@92
    51
	if (clanekEJB == null) {
franta-hg@92
    52
	    try {
franta-hg@92
    53
		Context c = new InitialContext();
franta-hg@92
    54
		clanekEJB = (ClanekRemote) c.lookup("cz.frantovo.nekurak.ejb.ClanekRemote");
franta-hg@92
    55
	    } catch (NamingException e) {
franta-hg@92
    56
		log.log(Level.SEVERE, "Chyba při hledání ClanekRemote", e);
franta-hg@92
    57
		throw new RuntimeException(e);
franta-hg@92
    58
	    }
franta-hg@92
    59
	}
franta-hg@92
    60
	return clanekEJB;
franta-hg@92
    61
    }
franta-hg@28
    62
}