Example usage for org.springframework.jndi JndiObjectFactoryBean getObject

List of usage examples for org.springframework.jndi JndiObjectFactoryBean getObject

Introduction

In this page you can find the example usage for org.springframework.jndi JndiObjectFactoryBean getObject.

Prototype

@Override
@Nullable
public Object getObject() 

Source Link

Document

Return the singleton JNDI object.

Usage

From source file:dk.nsi.haiba.epimibaimporter.config.EPIMIBAConfiguration.java

@Bean
@Qualifier("haibaDataSource")
public DataSource haibaDataSource() throws Exception {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(haibaJdbcJNDIName);
    factory.setExpectedType(DataSource.class);
    factory.afterPropertiesSet();// w w  w  .  jav  a 2  s. c  o m
    return (DataSource) factory.getObject();
}

From source file:dk.nsi.haiba.epimibaimporter.config.EPIMIBAConfiguration.java

@Bean
@Qualifier("classificationDataSource")
public DataSource classificationDataSource() throws Exception {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(classificationJdbcJNDIName);
    factory.setExpectedType(DataSource.class);
    factory.afterPropertiesSet();/*ww w .  j  a v  a 2 s. co m*/
    return (DataSource) factory.getObject();
}

From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java

@Bean
public DataSource lprDataSource() throws Exception {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(lprJdbcJNDIName);
    factory.setExpectedType(DataSource.class);
    factory.afterPropertiesSet();// www  . j a v  a2  s  .c  om
    return (DataSource) factory.getObject();
}

From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java

@Bean
public DataSource haibaDataSource() throws Exception {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(haibaJdbcJNDIName);
    factory.setExpectedType(DataSource.class);
    factory.afterPropertiesSet();/*  w  w  w. ja v a2  s. co  m*/
    return (DataSource) factory.getObject();
}

From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java

@Bean
public DataSource lprDataSourceMinipas() throws Exception {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(lprJdbcJNDIName_minipas);
    factory.setExpectedType(DataSource.class);
    factory.afterPropertiesSet();//from www.j a v a 2s. com
    return (DataSource) factory.getObject();
}

From source file:com.mycompany.projetsportmanager.spring.configuration.DefaultProfileConfiguration.java

/**
 * Builds a JNDI datasource./*  ww  w . j  a  v a 2 s .com*/
 * @return the datasource.
 */
@Bean(destroyMethod = "")
public DataSource dataSource() {
    JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
    jndiObjectFactoryBean.setJndiName("jdbc/ProjetSportManager");
    jndiObjectFactoryBean.setResourceRef(true);
    jndiObjectFactoryBean.setExpectedType(DataSource.class);
    try {
        jndiObjectFactoryBean.afterPropertiesSet();
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }
    return (DataSource) jndiObjectFactoryBean.getObject();
}

From source file:info.jtrac.mail.MailSender.java

private void initMailSenderFromJndi(String mailSessionJndiName) {
    logger.info("attempting to initialize mail sender from jndi name = '" + mailSessionJndiName + "'");
    JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean();
    factoryBean.setJndiName(mailSessionJndiName);
    // "java:comp/env/" will be prefixed if the JNDI name doesn't already have it
    factoryBean.setResourceRef(true);/* w w  w.  j a  v a 2  s .c o m*/
    try {
        // this step actually does the JNDI lookup
        factoryBean.afterPropertiesSet();
    } catch (Exception e) {
        logger.warn("failed to locate mail session : " + e);
        return;
    }
    Session session = (Session) factoryBean.getObject();
    sender = new JavaMailSenderImpl();
    sender.setSession(session);
    logger.info("email sender initialized from jndi name = '" + mailSessionJndiName + "'");
}

From source file:MailSender.java

private void initMailSenderFromJndi(String mailSessionJndiName) {
    logger.info("attempting to initialize mail sender from jndi name = '" + mailSessionJndiName + "'");
    JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean();
    factoryBean.setJndiName(mailSessionJndiName);
    // "java:comp/env/" will be prefixed if the JNDI name doesn't already
    // have it//from   w ww.ja v a2 s .co m

    // major: the above behavoiur is already documented
    // in the class JndiObjectFactoryBean. Remove it.

    factoryBean.setResourceRef(true);
    try {
        // this step actually does the JNDI lookup
        factoryBean.afterPropertiesSet();
    } catch (Exception e) {
        logger.warn("failed to locate mail session : " + e);
        return;
    }
    Session session = (Session) factoryBean.getObject();
    sender = new JavaMailSenderImpl();
    sender.setSession(session);
    logger.info("email sender initialized from jndi name = '" + mailSessionJndiName + "'");
}