Java Code Examples for org.springframework.jndi.JndiTemplate#lookup()

The following examples show how to use org.springframework.jndi.JndiTemplate#lookup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringBootWebApplication.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Bean(destroyMethod = "")
public MongoClient mongoClient(@Value("${mongo.host:}") String host, @Value("${mongo.jndiName:}") String jndiName) throws NamingException
{
	if (!Strings.isNullOrEmpty(jndiName))
	{
		JndiTemplate jndiTemplate = new JndiTemplate();
		return jndiTemplate.lookup(jndiName, MongoClient.class);
	}
	else if (!Strings.isNullOrEmpty(host))
	{
		return MongoClients.create(host);
	}
	else
	{
		throw new RuntimeException("Either mongo.host or mongo.jndiName must be set");
	}
}
 
Example 2
Source File: SpringWebSphereUowTransactionManager.java    From jadira with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance
 * @param template The JndiTemplate
 */
private TransactionAdapter(JndiTemplate template) {
    try {
        extendedJTATransaction = template.lookup("java:comp/websphere/ExtendedJTATransaction");

    } catch (NamingException e) {
        throw new IllegalStateException("Could not find ExtendedJTATransaction in JNDI: " + e.getMessage(),
                e);
    }
}