Skip to content

Commit

Permalink
app startup early fail
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Mar 10, 2024
1 parent ad520fd commit fc77b21
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- app startup early fail
- fj-daogen-version set to 1.7.7
- fj-version set to 8.5.3
- dao-finder-ng-mode 'enabled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import jakarta.enterprise.event.Observes;
import org.fugerit.java.core.db.daogen.BasicDaoResult;
import org.fugerit.java.core.db.daogen.CloseableDAOContextSC;
import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.io.StreamIO;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.daogen.quickstart.def.facade.EntityPersonFacade;
import org.fugerit.java.daogen.quickstart.def.facade.QuickstartLogicFacade;
import org.fugerit.java.daogen.quickstart.def.model.ModelPerson;
Expand All @@ -13,6 +16,7 @@
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DatabaseMetaData;

Expand All @@ -31,25 +35,28 @@ public class AppConfig {

void onStart(@Observes StartupEvent ev) {
logger.info( "onStart BEGIN" );
logger.info( "********************************************************************" );
try ( Connection conn = this.dataSource.getConnection();
CloseableDAOContextSC context = new CloseableDAOContextSC( conn ) ) {
DatabaseMetaData dbmd = conn.getMetaData();
logger.info( "database : {} - {}", dbmd.getDatabaseProductName(), dbmd.getDatabaseProductVersion() );
logger.info( "url : {}", dbmd.getURL() );
logger.info( ">>>>>>>>>>>>>>>>>>> daogen test 1: " );
EntityPersonFacade personFacade = facade.getEntityPersonFacade();
BasicDaoResult<ModelPerson> result = personFacade.loadAll( context );
logger.info( "result : {}", result );
if (result.isResultOk() ) {
for (ModelPerson model : result.getList()) {
logger.info( "model : {}", model );
SafeFunction.apply( () -> {
try (Connection conn = this.dataSource.getConnection();
CloseableDAOContextSC context = new CloseableDAOContextSC( conn );
InputStream is = ClassHelper.loadFromDefaultClassLoader("startup_fugerit_mars_demo.txt") ) {
logger.info( "********************************************************************\n{}", StreamIO.readString( is ) );
logger.info( "********************************************************************" );
DatabaseMetaData dbmd = conn.getMetaData();
logger.info( "database : {} - {}", dbmd.getDatabaseProductName(), dbmd.getDatabaseProductVersion() );
logger.info( "url : {}", dbmd.getURL() );
logger.info( ">>>>>>>>>>>>>>>>>>> daogen test 1: " );
EntityPersonFacade personFacade = facade.getEntityPersonFacade();
BasicDaoResult<ModelPerson> result = personFacade.loadAll( context );
logger.info( "result : {}", result );
if (result.isResultOk() ) {
for (ModelPerson model : result.getList()) {
logger.info( "model : {}", model );
}
}
logger.info( "********************************************************************" );
}
} catch (Exception e) {
logger.info( "onStart ERROR : "+e, e );
}
logger.info( "********************************************************************" );

} );
logger.info( "onStart END" );
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/startup_fugerit_mars_demo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_____ .__ __ .___
_/ ____\_ __ ____ ___________|__|/ |_ _____ _____ _______ ______ __| _/____ _____ ____
\ __\ | \/ ___\_/ __ \_ __ \ \ __\ / \\__ \\_ __ \/ ___/ / __ |/ __ \ / \ / _ \
| | | | / /_/ > ___/| | \/ || | | Y Y \/ __ \| | \/\___ \ / /_/ \ ___/| Y Y ( <_> )
|__| |____/\___ / \___ >__| |__||__| |__|_| (____ /__| /____ > \____ |\___ >__|_| /\____/
/_____/ \/ \/ \/ \/ \/ \/ \/

0 comments on commit fc77b21

Please sign in to comment.