Example usage for org.hibernate.engine.jndi.internal JndiServiceImpl extractJndiProperties

List of usage examples for org.hibernate.engine.jndi.internal JndiServiceImpl extractJndiProperties

Introduction

In this page you can find the example usage for org.hibernate.engine.jndi.internal JndiServiceImpl extractJndiProperties.

Prototype

@SuppressWarnings({ "unchecked" })
public static Properties extractJndiProperties(Map configurationValues) 

Source Link

Document

Given a hodgepodge of properties, extract out the ones relevant for JNDI interaction.

Usage

From source file:org.redisson.hibernate.JndiRedissonRegionFactory.java

License:Apache License

@Override
protected RedissonClient createRedissonClient(Map properties) {
    String jndiName = ConfigurationHelper.getString(JNDI_NAME, properties);
    if (jndiName == null) {
        throw new CacheException(JNDI_NAME + " property not set");
    }/*  w w  w  .  j  av  a2 s . co m*/

    Properties jndiProperties = JndiServiceImpl.extractJndiProperties(properties);
    InitialContext context = null;
    try {
        context = new InitialContext(jndiProperties);
        return (RedissonClient) context.lookup(jndiName);
    } catch (NamingException e) {
        throw new CacheException("Unable to locate Redisson instance by name: " + jndiName, e);
    } finally {
        if (context != null) {
            try {
                context.close();
            } catch (NamingException e) {
                throw new CacheException("Unable to close JNDI context", e);
            }
        }
    }
}