Example usage for org.springframework.jndi JndiTemplate JndiTemplate

List of usage examples for org.springframework.jndi JndiTemplate JndiTemplate

Introduction

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

Prototype

public JndiTemplate() 

Source Link

Document

Create a new JndiTemplate instance.

Usage

From source file:com.apress.prospringintegration.messaging.qpid.jms.adapter.QpidConfiguration.java

@Bean
public JndiTemplate jndiTemplate() {
    JndiTemplate jndiTemplate = new JndiTemplate();
    Properties properties = new Properties();
    properties.setProperty("java.naming.factory.initial",
            "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
    jndiTemplate.setEnvironment(properties);

    return jndiTemplate;
}

From source file:org.devproof.mubble.server.jndi.JndiConfiguration.java

private String getJndiValue(String jndiContext) {
    JndiTemplate jndi = new JndiTemplate();
    try {//from  ww w. j  a  va 2s  .  co  m
        return (String) jndi.lookup(jndiContext);
    } catch (NamingException e) {
        return "empty";
    }
}

From source file:com.github.djabry.platform.service.data.config.JndiDataConfig.java

@Bean
@Override/*from   w  w w. ja va 2 s  . c  o  m*/
public DataSource dataSource() {
    DataSource dataSource = null;
    JndiTemplate jndi = new JndiTemplate();

    try {
        dataSource = (DataSource) jndi.lookup("java:comp/env/jdbc/yourname");
    } catch (NamingException e) {
        log.severe("NamingException for java:comp/env/jdbc/yourname " + e);
    }
    return dataSource;

}

From source file:org.dms.sys.web.app.ContextLoaderListener.java

/**
 * Instantiates a new context loader listener.
 *//*www  . j av  a 2 s . c  o  m*/
public ContextLoaderListener() {
    try {
        this.enableStartup = (Boolean) new JndiTemplate().lookup(ContextLoaderListener.PROPERTY_ENABLE_STARTUP,
                Boolean.class);
    } catch (Exception e) {
        this.enableStartup = true;
    }
}

From source file:org.devproof.mubble.server.jndi.JndiConfiguration.java

private Integer getJndiIntValue(String jndiContext) {
    JndiTemplate jndi = new JndiTemplate();
    try {/*from ww w  .  j  av a  2  s  .  com*/
        return (Integer) jndi.lookup(jndiContext);
    } catch (NamingException e) {
        return -1;
    }
}

From source file:org.drugis.trialverse.config.MainConfig.java

@Bean
public DataSource dataSource() {
    DataSource ds;//from  w  w  w  .ja va  2 s .  co m
    JndiTemplate jndi = new JndiTemplate();
    try {
        ds = (DataSource) jndi.lookup("java:/comp/env/jdbc/trialverse");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ds;
}

From source file:org.apache.cxf.transport.jms.JMSOldConfigHolder.java

public JMSConfiguration createJMSConfigurationFromEndpointInfo(Bus bus, EndpointInfo endpointInfo,
        boolean isConduit) {

    // Retrieve configuration information that was extracted from the WSDL
    address = endpointInfo.getTraversedExtensor(new AddressType(), AddressType.class);
    clientConfig = endpointInfo.getTraversedExtensor(new ClientConfig(), ClientConfig.class);
    runtimePolicy = endpointInfo.getTraversedExtensor(new ClientBehaviorPolicyType(),
            ClientBehaviorPolicyType.class);
    serverConfig = endpointInfo.getTraversedExtensor(new ServerConfig(), ServerConfig.class);
    sessionPool = endpointInfo.getTraversedExtensor(new SessionPoolType(), SessionPoolType.class);
    serverBehavior = endpointInfo.getTraversedExtensor(new ServerBehaviorPolicyType(),
            ServerBehaviorPolicyType.class);
    String name = endpointInfo.getName().toString() + (isConduit ? ".jms-conduit" : ".jms-destination");

    // Try to retrieve configuration information from the spring
    // config. Search for a conduit or destination with name=endpoint name + ".jms-conduit"
    // or ".jms-destination"

    Configurer configurer = bus.getExtension(Configurer.class);
    if (null != configurer) {
        configurer.configureBean(name, this);
    }// w ww. j av a  2  s.  c o  m

    if (jmsConfig == null) {
        jmsConfig = new JMSConfiguration();
    }

    if (jmsConfig.isUsingEndpointInfo()) {
        JndiTemplate jt = new JndiTemplate();
        jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(address));
        boolean pubSubDomain = false;
        if (address.isSetDestinationStyle()) {
            pubSubDomain = DestinationStyleType.TOPIC == address.getDestinationStyle();
        }
        JNDIConfiguration jndiConfig = new JNDIConfiguration();
        jndiConfig.setJndiConnectionFactoryName(address.getJndiConnectionFactoryName());
        jmsConfig.setJndiTemplate(jt);
        jndiConfig.setConnectionUserName(address.getConnectionUserName());
        jndiConfig.setConnectionPassword(address.getConnectionPassword());
        jmsConfig.setJndiConfig(jndiConfig);
        if (address.isSetReconnectOnException()) {
            jmsConfig.setReconnectOnException(address.isReconnectOnException());
        }
        jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
        jmsConfig.setExplicitQosEnabled(true);
        jmsConfig.setMessageSelector(serverBehavior.getMessageSelector());
        if (isConduit && runtimePolicy.isSetMessageType()) {
            jmsConfig.setMessageType(runtimePolicy.getMessageType().value());
        }
        jmsConfig.setPubSubDomain(pubSubDomain);
        jmsConfig.setPubSubNoLocal(true);
        //if (clientConfig.isSetClientReceiveTimeout()) {
        jmsConfig.setReceiveTimeout(clientConfig.getClientReceiveTimeout());
        //}
        jmsConfig.setUseConduitIdSelector(clientConfig.isUseConduitIdSelector());
        if (clientConfig.isSetConduitSelectorPrefix()) {
            jmsConfig.setConduitSelectorPrefix(clientConfig.getConduitSelectorPrefix());
        }
        jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
        jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
        if (sessionPool.isSetHighWaterMark()) {
            jmsConfig.setMaxConcurrentTasks(sessionPool.getHighWaterMark());
        }
        long timeToLive = isConduit ? clientConfig.getMessageTimeToLive() : serverConfig.getMessageTimeToLive();
        jmsConfig.setTimeToLive(timeToLive);
        if (address.isSetUseJms11()) {
            jmsConfig.setUseJms11(address.isUseJms11());
        }
        if (serverBehavior.isSetTransactional()) {
            jmsConfig.setSessionTransacted(serverBehavior.isTransactional());
        }
        boolean useJndi = address.isSetJndiDestinationName();
        jmsConfig.setUseJndi(useJndi);
        if (useJndi) {
            // Setup Destination jndi destination resolver
            final JndiDestinationResolver jndiDestinationResolver = new JndiDestinationResolver();
            jndiDestinationResolver.setJndiTemplate(jt);
            jmsConfig.setDestinationResolver(jndiDestinationResolver);
            jmsConfig.setTargetDestination(address.getJndiDestinationName());
            jmsConfig.setReplyDestination(address.getJndiReplyDestinationName());
        } else {
            // Use the default dynamic destination resolver
            jmsConfig.setTargetDestination(address.getJmsDestinationName());
            jmsConfig.setReplyDestination(address.getJmsReplyDestinationName());
        }
    }
    return jmsConfig;
}

From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORJpaConfiguration.java

public DataSource JNDIDataSource() {
    DataSource dataSource = null;
    JndiTemplate jndi = new JndiTemplate();
    try {//from  www  .j a  v  a  2 s. c o  m
        logger.info("          jdbc.jndi: " + environment.getProperty("jdbc.jndi"));
        dataSource = (DataSource) jndi.lookup(environment.getRequiredProperty("jdbc.jndi"));
    } catch (NamingException e) {
        logger.error("No se ha podido establecer la conexion a base de datos: " + e.toString());
    }
    return dataSource;
}

From source file:com.dominion.salud.mpr.configuration.MPRJpaConfiguration.java

public DataSource JNDIDataSource() {
    DataSource dataSource = null;
    JndiTemplate jndi = new JndiTemplate();
    try {// w ww  .  j  a  va2s .  c o  m
        dataSource = (DataSource) jndi.lookup(environment.getRequiredProperty("jdbc.jndi"));
    } catch (NamingException e) {

    }
    return dataSource;
}

From source file:com.jmstoolkit.queuebrowser.QueueBrowserView.java

private void _init() {
    try {//from  ww w  .  j a v  a2s .c om
        Settings.loadSystemSettings(System.getProperty(D_JNDI_PROPERTIES, D_JNDI_PROPERTIES));
        // load settings from default file: app.properties
        // which contains previously used connection
        // factories and destinations
        Settings.loadSettings(appProperties);
        connectionFactoryList = Settings.getSettings(appProperties, P_CONNECTION_FACTORIES);
        destinationList = Settings.getSettings(appProperties, P_DESTINATIONS);
    } catch (JTKException se) {
        // this happens BEFORE initComponents, so can't put the error in the
        // status area or any other part of the GUI
        System.out.println(se.toStringWithStackTrace());
    }
    // FIXME: Not using the applicationContext at all... ho hum
    this.jmsTemplate = new JmsTemplate();

    this.connectionFactory = new CachingConnectionFactory();
    this.connectionFactory.setCacheProducers(true);
    this.jmsTemplate.setConnectionFactory(connectionFactory);
    this.jndiTemplate = new JndiTemplate();
}