private void readConfig ( ) throws CacheReloadException { Connection con = null ; try { boolean closeContext = false ; if ( ! Context . isThreadActive ( ) ) { Context . begin ( ) ; closeContext = true ; } final List < Object [ ] > dbValues = new ArrayList <> ( ) ; con = Context . getConnection ( ) ; PreparedStatement stmt = null ; try { stmt = con . prepareStatement ( SystemConfiguration . SQL_CONFIG ) ; stmt . setObject ( 1 , getId ( ) ) ; final ResultSet rs = stmt . executeQuery ( ) ; while ( rs . next ( ) ) { dbValues . add ( new Object [ ] { rs . getLong ( 1 ) , rs . getString ( 2 ) , rs . getString ( 3 ) , rs . getLong ( 4 ) , rs . getString ( 5 ) } ) ; } rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; if ( closeContext ) { Context . rollback ( ) ; } for ( final Object [ ] row : dbValues ) { final Long typeId = ( Long ) row [ 0 ] ; final String key = ( String ) row [ 1 ] ; final String value = ( String ) row [ 2 ] ; final Long companyId = ( Long ) row [ 3 ] ; final String appkey = ( String ) row [ 4 ] ; final Type type = Type . get ( typeId ) ; final ConfType confType ; if ( type . equals ( CIAdminCommon . SystemConfigurationLink . getType ( ) ) ) { confType = ConfType . LINK ; } else if ( type . equals ( CIAdminCommon . SystemConfigurationObjectAttribute . getType ( ) ) ) { confType = ConfType . OBJATTR ; } else { confType = ConfType . ATTRIBUTE ; } values . add ( new Value ( confType , key , value , companyId , appkey ) ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read SystemConfiguration attributes" , e ) ; } catch ( final EFapsException e ) { throw new CacheReloadException ( "could not read SystemConfiguration attributes" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } }
Read the config .