diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab66e4e9..3ff2b791 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+
+- fj-daogen-version set to 1.2.1 in module fj-core-jvfs
+
## [8.3.1] - 2023-09-15
### Changed
diff --git a/fj-core-jvfs/pom.xml b/fj-core-jvfs/pom.xml
index e930288e..724a7fd5 100644
--- a/fj-core-jvfs/pom.xml
+++ b/fj-core-jvfs/pom.xml
@@ -30,7 +30,7 @@
- 1.1.9
+ 1.2.1
${project.basedir}
target/generated-sources/daogen
diff --git a/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java b/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java
index 0941f675..ce68b94e 100644
--- a/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java
+++ b/fj-core/src/main/java/org/fugerit/java/core/db/connect/ConnectionFactoryImpl.java
@@ -34,8 +34,10 @@
import org.fugerit.java.core.db.dao.DAOException;
import org.fugerit.java.core.db.metadata.DataBaseInfo;
import org.fugerit.java.core.function.UnsafeSupplier;
+import org.fugerit.java.core.lang.helpers.BooleanUtils;
import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.core.log.BasicLogObject;
+import org.fugerit.java.core.util.PropsIO;
import org.fugerit.java.core.xml.dom.DOMUtils;
import org.fugerit.java.core.xml.dom.SearchDOM;
import org.w3c.dom.Element;
@@ -175,11 +177,11 @@ public Connection getConnection() throws DAOException {
/**
* Parse a configuration Element looking for ConnectionFactory configuration
*
- * @param cfConfig the Element
- * @return the CfConfig
- * @throws Exception in case of issues
+ * @param cfConfig the Element
+ * @return the CfConfig
+ * @throws DAOException in case of issues
*/
- public static CfConfig parseCfConfig( Element cfConfig ) throws Exception {
+ public static CfConfig parseCfConfig( Element cfConfig ) throws DAOException {
CfConfig config = new CfConfig();
SearchDOM searchDOM = SearchDOM.newInstance( true , true );
List cfConfigEntryList = searchDOM.findAllTags( cfConfig , "cf-config-entry" );
@@ -215,21 +217,6 @@ public static String getDriverInfo( ConnectionFactory cf ) throws DAOException {
});
}
- /**
- * Helper method to create a property with prefix
- *
- * @param prefix the prefix
- * @param name the property base name
- * @return the property full name ( prefix-name, or name if prefix == null)
- */
- private static String getParamName( String prefix, String name ) {
- String res = name;
- if ( StringUtils.isNotEmpty( prefix ) ) {
- res = prefix+"-"+name;
- }
- return res;
- }
-
/**
* Creates a ConnectionFactory from a property object
*
@@ -256,25 +243,24 @@ public static ConnectionFactory newInstance( Properties props, String propsPrefi
}
ConnectionFactory cf = null;
String prefix = props.getProperty( PROP_CF_MODE_DC_PREFIX, propsPrefix );
- String mode = props.getProperty( getParamName( prefix, PROP_CF_MODE ) );
+ Properties prefixProps = props;
+ if ( StringUtils.isNotEmpty( prefix ) ) {
+ prefixProps = PropsIO.subProps( props , prefix+"-" );
+ log.info( "subProps : {} -> {}", prefix, prefixProps );
+ }
+ String mode = prefixProps.getProperty( PROP_CF_MODE );
log.info( "ConnectionFactory.newInstance() mode : {}", mode );
if ( PROP_CF_MODE_DC.equalsIgnoreCase( mode ) ) {
- if ( "true".equalsIgnoreCase( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED ) ) ) ) {
- int sc = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_SC ), "3" ) );
- int ic = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_IC ), "10" ) );
- int mc = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_MC ), "30" ) );
- cf = new DbcpConnectionFactory( props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_DRV ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_URL ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_USR ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_PWD ) ), sc, ic, mc, cl );
+ if ( BooleanUtils.isTrue( prefixProps.getProperty(PROP_CF_EXT_POOLED ) ) ) {
+ cf = new DbcpConnectionFactory(prefixProps, cl);
} else {
- cf = newInstance( props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_DRV ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_URL ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_USR ) ),
- props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_PWD ) ), cl );
+ cf = newInstance( prefixProps.getProperty( PROP_CF_MODE_DC_DRV ),
+ prefixProps.getProperty(PROP_CF_MODE_DC_URL ),
+ prefixProps.getProperty(PROP_CF_MODE_DC_USR ),
+ prefixProps.getProperty(PROP_CF_MODE_DC_PWD ), cl );
}
} else if ( PROP_CF_MODE_DS.equalsIgnoreCase( mode ) || PROP_CF_MODE_DS2.equalsIgnoreCase( mode ) ) {
- String dsName = props.getProperty( PROP_CF_MODE_DS_NAME );
+ String dsName = prefixProps.getProperty( PROP_CF_MODE_DS_NAME );
log.info( "dsName -> {}", dsName );
cf = newInstance( dsName );
} else {
diff --git a/fj-core/src/main/java/org/fugerit/java/core/db/connect/DbcpConnectionFactory.java b/fj-core/src/main/java/org/fugerit/java/core/db/connect/DbcpConnectionFactory.java
index 6e11b75b..9f91c2a6 100644
--- a/fj-core/src/main/java/org/fugerit/java/core/db/connect/DbcpConnectionFactory.java
+++ b/fj-core/src/main/java/org/fugerit/java/core/db/connect/DbcpConnectionFactory.java
@@ -21,6 +21,7 @@
package org.fugerit.java.core.db.connect;
import java.sql.Connection;
+import java.util.Properties;
import org.apache.commons.dbcp2.BasicDataSource;
import org.fugerit.java.core.db.dao.DAOException;
@@ -36,41 +37,30 @@ public class DbcpConnectionFactory extends ConnectionFactoryImpl {
private BasicDataSource dataSource;
/**
- * Constructor
*
- * @param drv driver type
- * @param url jdbc url
- * @param usr user
- * @param pwd password
- * @param init initial connection
- * @param min minimum connection
- * @param max maximum connection
- * @throws DAOException in case of issues
+ * @param cfProps connections parameters
+ * @throws DAOException in case of issues
*/
- public DbcpConnectionFactory( String drv, String url, String usr, String pwd, int init, int min, int max ) throws DAOException {
- this(drv, url, usr, pwd, init, min, max, null);
+ public DbcpConnectionFactory( Properties cfProps ) throws DAOException {
+ this(cfProps, null);
}
/**
- * Constructor
*
- * @param drv driver type
- * @param url jdbc url
- * @param usr user
- * @param pwd password
- * @param init initial connection
- * @param min minimum connection
- * @param max maximum connection
- * @param cl the class loader
- * @throws DAOException in case of issues
+ * @param cfProps connections parameters
+ * @param cl to use for driver class loading
+ * @throws DAOException in case of issues
*/
- public DbcpConnectionFactory( String drv, String url, String usr, String pwd, int init, int min, int max, ClassLoader cl ) throws DAOException {
+ public DbcpConnectionFactory( Properties cfProps, ClassLoader cl ) throws DAOException {
DAOException.apply( () -> {
+ int init = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_SC , "3" ) );
+ int min = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_IC , "10" ) );
+ int max = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_MC , "30" ) );
this.dataSource = new BasicDataSource();
- this.dataSource.setDriverClassName( drv );
- this.dataSource.setUrl( url );
- this.dataSource.setUsername( usr );
- this.dataSource.setPassword( pwd );
+ this.dataSource.setDriverClassName( cfProps.getProperty( PROP_CF_MODE_DC_DRV ) );
+ this.dataSource.setUrl( cfProps.getProperty( PROP_CF_MODE_DC_URL ) );
+ this.dataSource.setUsername( cfProps.getProperty( PROP_CF_MODE_DC_USR ) );
+ this.dataSource.setPassword( cfProps.getProperty( PROP_CF_MODE_DC_PWD ) );
this.dataSource.setMaxTotal( max );
this.dataSource.setMaxIdle( min );
this.dataSource.setInitialSize( init );
diff --git a/fj-core/src/main/java/org/fugerit/java/core/db/helpers/DbUtils.java b/fj-core/src/main/java/org/fugerit/java/core/db/helpers/DbUtils.java
index 541a6a4d..aa0ab331 100644
--- a/fj-core/src/main/java/org/fugerit/java/core/db/helpers/DbUtils.java
+++ b/fj-core/src/main/java/org/fugerit/java/core/db/helpers/DbUtils.java
@@ -60,7 +60,6 @@ public static int indentifyDB( String productName ) {
dbType = DB_POSTGRESQL;
log.info( "IdGenerator configured for : POSTGRESQL ({}) was ({})", dbType, name );
} else {
- dbType = DB_UNKNOWN;
log.info( "Unknown db type ({})", dbType );
}
return dbType;
diff --git a/fj-core/src/main/java/org/fugerit/java/core/fixed/parser/FixedFieldFileConfig.java b/fj-core/src/main/java/org/fugerit/java/core/fixed/parser/FixedFieldFileConfig.java
index 3469ef4d..37a48e88 100644
--- a/fj-core/src/main/java/org/fugerit/java/core/fixed/parser/FixedFieldFileConfig.java
+++ b/fj-core/src/main/java/org/fugerit/java/core/fixed/parser/FixedFieldFileConfig.java
@@ -8,6 +8,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.fugerit.java.core.cfg.ConfigException;
+import org.fugerit.java.core.cfg.ConfigRuntimeException;
+import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.core.xml.dom.DOMIO;
@@ -22,20 +25,22 @@
*/
public class FixedFieldFileConfig {
- private static void handleValidatorList( FixedFieldFileDescriptor fileDescriptor, Element currentFileTag ) throws Exception {
- NodeList validatorListTagList = currentFileTag.getElementsByTagName( "validator-list" );
- for ( int k=0; k {
+ NodeList validatorListTagList = currentFileTag.getElementsByTagName( "validator-list" );
+ for ( int k=0; kParse fixed filed file configuration.
+ *
+ * NOTE: starting from version 8.4.X java.lang.Exception removed in favor of org.fugerit.java.core.cfg.ConfigRuntimeException.
+ *
+ * @see Define and throw a dedicated exception instead of using a generic one.
+ *
+ * @param is the configuration file to parse
+ * @return the parsed configuration
+ * @throws ConfigRuntimeException in case of issues
+ */
+ public static FixedFieldFileConfig parseConfig( InputStream is ) {
+ return SafeFunction.get( () -> {
+ FixedFieldFileConfig config = new FixedFieldFileConfig();
+ DocumentBuilderFactory dbf = DOMIO.newSafeDocumentBuilderFactory();
+ DocumentBuilder parser = dbf.newDocumentBuilder();
+ Document doc = parser.parse( is );
+ Element root = doc.getDocumentElement();
+ NodeList fileTagList = root.getElementsByTagName( "fixed-field-file" );
+ for ( int i=0; i