private DBService createTenantDBService ( Tenant tenant ) { m_logger . info ( "Creating DBService for tenant: {}" , tenant . getName ( ) ) ; Map < String , Object > dbServiceParams = tenant . getDefinition ( ) . getOptionMap ( "DBService" ) ; String dbServiceName = null ; if ( dbServiceParams == null || ! dbServiceParams . containsKey ( "dbservice" ) ) { dbServiceName = ServerParams . instance ( ) . getModuleParamString ( "DBService" , "dbservice" ) ; Utils . require ( ! Utils . isEmpty ( dbServiceName ) , "DBService.dbservice parameter is not defined" ) ; } else { dbServiceName = dbServiceParams . get ( "dbservice" ) . toString ( ) ; } DBService dbservice = null ; try { @ SuppressWarnings ( "unchecked" ) Class < DBService > serviceClass = ( Class < DBService > ) Class . forName ( dbServiceName ) ; Constructor < DBService > constructor = serviceClass . getConstructor ( Tenant . class ) ; dbservice = constructor . newInstance ( tenant ) ; dbservice . initialize ( ) ; dbservice . start ( ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "Cannot load specified 'dbservice': " + dbServiceName , e ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( "Could not load dbservice class '" + dbServiceName + "'" , e ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( "Required constructor missing for dbservice class: " + dbServiceName , e ) ; } catch ( SecurityException | InstantiationException | IllegalAccessException | InvocationTargetException e ) { throw new RuntimeException ( "Could not invoke constructor for dbservice class: " + dbServiceName , e ) ; } catch ( Throwable e ) { throw new RuntimeException ( "Failed to initialize DBService '" + dbServiceName + "' for tenant: " + tenant . getName ( ) , e ) ; } return dbservice ; }
Create a new DBService for the given tenant .