protected void init ( Class < T > cls , Key ... keys ) { readDataSource = Execution . getDataSourceName ( cls . getName ( ) , true ) ; writeDataSource = Execution . getDataSourceName ( cls . getName ( ) , false ) ; if ( readDataSource == null ) { readDataSource = writeDataSource ; } if ( writeDataSource == null ) { writeDataSource = readDataSource ; } Properties props = new Properties ( ) ; try { InputStream is = DaseinSequencer . class . getResourceAsStream ( DaseinSequencer . PROPERTIES ) ; if ( is != null ) { props . load ( is ) ; } } catch ( Exception e ) { logger . error ( "Problem reading " + DaseinSequencer . PROPERTIES + ": " + e . getMessage ( ) , e ) ; } database = props . getProperty ( "dasein.persist.handlersocket.database" ) ; handlerSocketHost = props . getProperty ( "dasein.persist.handlersocket.host" ) ; port = Integer . valueOf ( props . getProperty ( "dasein.persist.handlersocket.port" ) ) ; poolSize = Integer . valueOf ( props . getProperty ( "dasein.persist.handlersocket.poolSize" ) ) ; // get the columns List < String > targetColumns = new ArrayList < String > ( ) ; Class < ? > clazz = cls ; while ( clazz != null && ! clazz . equals ( Object . class ) ) { Field [ ] fields = clazz . getDeclaredFields ( ) ; for ( Field f : fields ) { int m = f . getModifiers ( ) ; if ( Modifier . isTransient ( m ) || Modifier . isStatic ( m ) ) { continue ; } if ( f . getType ( ) . getName ( ) . equals ( Collection . class . getName ( ) ) ) { continue ; // this is handled by dependency manager } if ( ! f . getType ( ) . getName ( ) . equals ( Translator . class . getName ( ) ) ) { targetColumns . add ( f . getName ( ) ) ; types . put ( f . getName ( ) , f . getType ( ) ) ; } } clazz = clazz . getSuperclass ( ) ; } columns = new String [ targetColumns . size ( ) ] ; databaseColumns = new String [ targetColumns . size ( ) ] ; for ( int i = 0 ; i < targetColumns . size ( ) ; i ++ ) { columns [ i ] = targetColumns . get ( i ) ; databaseColumns [ i ] = getSqlName ( targetColumns . get ( i ) ) ; } }
Constructs a new persistent factory for objects of the specified class with the named unique identifier attributes as well as with reading the persistence properties file to find out the HandlerSocket host database port and pool size .