Jedis getConnection ( ) { if ( logger . isDebugEnabled ( ) ) logger . info ( "borrowing connection from pool" ) ; Object poolOrConnection = getConnectionPoolOrConnection ( ) ; if ( poolOrConnection != null && poolOrConnection instanceof JedisPool ) { Jedis connection = ( ( JedisPool ) getConnectionPoolOrConnection ( ) ) . getResource ( ) ; connection . getClient ( ) . setTimeoutInfinite ( ) ; Map props = RedisPropertyReader . rsmd . getProperties ( ) ; // set external xml properties. if ( props != null ) { // props. for ( Object key : props . keySet ( ) ) { connection . configSet ( key . toString ( ) , props . get ( key ) . toString ( ) ) ; } } return connection ; } else { PersistenceUnitMetadata puMetadata = kunderaMetadata . getApplicationMetadata ( ) . getPersistenceUnitMetadata ( getPersistenceUnit ( ) ) ; Properties props = puMetadata . getProperties ( ) ; String contactNode = null ; String defaultPort = null ; String password = null ; if ( externalProperties != null ) { contactNode = ( String ) externalProperties . get ( PersistenceProperties . KUNDERA_NODES ) ; defaultPort = ( String ) externalProperties . get ( PersistenceProperties . KUNDERA_PORT ) ; password = ( String ) externalProperties . get ( PersistenceProperties . KUNDERA_PASSWORD ) ; } if ( contactNode == null ) { contactNode = RedisPropertyReader . rsmd . getHost ( ) != null ? RedisPropertyReader . rsmd . getHost ( ) : ( String ) props . get ( PersistenceProperties . KUNDERA_NODES ) ; } if ( defaultPort == null ) { defaultPort = RedisPropertyReader . rsmd . getPort ( ) != null ? RedisPropertyReader . rsmd . getPort ( ) : ( String ) props . get ( PersistenceProperties . KUNDERA_PORT ) ; } if ( password == null ) { password = RedisPropertyReader . rsmd . getPassword ( ) != null ? RedisPropertyReader . rsmd . getPassword ( ) : ( String ) props . get ( PersistenceProperties . KUNDERA_PASSWORD ) ; } if ( defaultPort == null || ! StringUtils . isNumeric ( defaultPort ) ) { throw new RuntimeException ( "Invalid port provided: " + defaultPort ) ; } Jedis connection = new Jedis ( contactNode , Integer . parseInt ( defaultPort ) ) ; if ( password != null ) { connection . auth ( password ) ; } connection . connect ( ) ; return connection ; } }
Retrieving connection from connection pool .