public static ServiceAdapter < DataSource > forDataSource ( ) { return new SimpleServiceAdapter < DataSource > ( true , false ) { @ Override protected void start ( DataSource instance ) throws Exception { Connection connection = instance . getConnection ( ) ; connection . close ( ) ; } @ Override protected void stop ( DataSource instance ) { } } ; }
Returns factory which transforms DataSource object to ConcurrentService . On starting it checks connecting on stopping it close DataSource .