Example usage for javax.naming Context lookup

List of usage examples for javax.naming Context lookup

Introduction

In this page you can find the example usage for javax.naming Context lookup.

Prototype

public Object lookup(String name) throws NamingException;

Source Link

Document

Retrieves the named object.

Usage

From source file:br.ufac.sion.converter.EmpresaConverter.java

private EmpresaFacadeLocal lookupEmpresaFacadeLocal() {
    try {//  w ww .  j av a2 s . co  m
        Context c = new InitialContext();
        return (EmpresaFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/EmpresaFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:br.ufac.sion.converter.ConcursoConverter.java

private ConcursoFacadeLocal lookupConcursoFacadeLocal() {
    try {//from w  w  w.j  av a 2 s .co m
        Context c = new InitialContext();
        return (ConcursoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/ConcursoFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:br.ufac.sion.converter.InscricaoConverter.java

private InscricaoFacadeLocal lookupInscricaoFacadeLocal() {
    try {/*w  w w  .  j  a va  2 s  . c om*/
        Context c = new InitialContext();
        return (InscricaoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/InscricaoFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:br.ufac.sion.inscricao.converter.CandidatoConverter.java

private CandidatoFacadeLocal lookupCidadeFacadeLocal() {
    try {/* w  w w .j av a  2  s  . co m*/
        Context c = new InitialContext();
        return (CandidatoFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/CandidatoFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:br.ufac.sion.converter.FuncionarioConverter.java

private FuncionarioFacadeLocal lookupFuncionarioFacadeLocal() {
    try {//from w  ww.j  a  va 2  s .c  o  m
        Context c = new InitialContext();
        return (FuncionarioFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/FuncionarioFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:fr.gouv.culture.thesaurus.util.MailUtil.java

/**
 * Initialise les proprits statiques pour la gestion des emails.
 *///from   w  w w.  j av a2 s  .c  o  m
public static void init(String mailSessionJndiName, String defaultFrom, String subjectPrefix) {

    if (hostProperty == null) {
        Session mailSession;
        try {
            Context ctx = new InitialContext();
            mailSession = (Session) ctx.lookup(mailSessionJndiName);
            hostProperty = mailSession.getProperty("mail.smtp.host");
        } catch (NamingException e) {
            log.warn("Initialisation de la session email impossible.", e);
        }

    }

    MailUtil.defaultFrom = defaultFrom;
    MailUtil.subjectPrefix = subjectPrefix;
}

From source file:br.ufac.sion.converter.ContaConverter.java

private ContaBancariaFacadeLocal lookupVagaFacadeLocal() {
    try {/*from   w ww  .  j a v  a 2 s .  c  om*/
        Context c = new InitialContext();
        return (ContaBancariaFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/ContaBancariaFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:com.peadargrant.filecheck.web.support.ServerEnvironment.java

public String getPropertyAsString(String propertyName) throws Exception {
    Context env = (Context) new InitialContext().lookup("java:comp/env");

    String property = (String) env.lookup(propertyName);

    return property;
}

From source file:br.ufac.sion.converter.OrgaoExpedidorConverter.java

private OrgaoExpedidorFacadeLocal lookupOrgaoExpedidorFacadeLocal() {
    try {//from   w ww.  jav  a  2s  .  c o  m
        Context c = new InitialContext();
        return (OrgaoExpedidorFacadeLocal) c.lookup("java:global/sion-ear/sion-ejb-2.0/OrgaoExpedidorFacade");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

From source file:org.akhikhl.examples.gretty.hellogretty.MainConfig.java

@Bean
public DataSource dataSource() {
    /* final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);/*from   w ww.  j av  a2  s .  c om*/
    return dsLookup.getDataSource("jdbc/devcore"); */

    DataSource dataSource = null;
    try {
        InitialContext init = new InitialContext();
        Context env = (Context) init.lookup("java:comp/env");
        dataSource = (DataSource) env.lookup("jdbc/devcore");
        Connection con = dataSource.getConnection();
    } catch (Exception e) {
        logger.error("Exception in dataSource", e);
        throw new RuntimeException(e);
    }
    return dataSource;
}