java/nekurak.net-lib/src/cz/frantovo/nekurak/web/HledacSluzby.java
author František Kučera <franta-hg@frantovo.cz>
Tue Apr 06 00:09:59 2010 +0200 (2010-04-06)
changeset 91 936ad9853a30
parent 51 java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/HledacSluzby.java@d01685a7e07d
child 92 12268fc31114
permissions -rw-r--r--
Přesun Hledače do společné knihovny.
     1 package cz.frantovo.nekurak.web;
     2 
     3 import cz.frantovo.nekurak.ejb.PodnikRemote;
     4 import cz.frantovo.nekurak.ejb.UzivatelRemote;
     5 import java.io.Serializable;
     6 import java.util.logging.Level;
     7 import java.util.logging.Logger;
     8 import javax.naming.Context;
     9 import javax.naming.InitialContext;
    10 import javax.naming.NamingException;
    11 
    12 /**
    13  *
    14  * @author fiki
    15  */
    16 public class HledacSluzby implements Serializable {
    17 
    18     private PodnikRemote podnikEJB;
    19     private UzivatelRemote uzivatelEJB;
    20     private static final Logger log = Logger.getLogger(HledacSluzby.class.getSimpleName());
    21 
    22     public PodnikRemote getPodnikEJB() {
    23 	if (podnikEJB == null) {
    24 	    try {
    25 		Context c = new InitialContext();
    26 		podnikEJB = (PodnikRemote) c.lookup("cz.frantovo.nekurak.ejb.PodnikRemote");
    27 	    } catch (NamingException e) {
    28 		log.log(Level.SEVERE, "Chyba při hledání PodnikRemote", e);
    29 		throw new RuntimeException(e);
    30 	    }
    31 	}
    32 	return podnikEJB;
    33     }
    34 
    35     public UzivatelRemote getUzivatelEJB() {
    36 	if (uzivatelEJB == null) {
    37 	    try {
    38 		Context c = new InitialContext();
    39 		uzivatelEJB = (UzivatelRemote) c.lookup("cz.frantovo.nekurak.ejb.UzivatelRemote");
    40 	    } catch (NamingException e) {
    41 		log.log(Level.SEVERE, "Chyba při hledání UzivatelRemote", e);
    42 		throw new RuntimeException(e);
    43 	    }
    44 	}
    45 	return uzivatelEJB;
    46     }
    47 }