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