[cvs] expresso commit by yves: Yves Amaizo new changes commit today

JCorporate Ltd jcorp at jcorporate.com
Tue Oct 18 22:57:27 UTC 2005


Log Message:
-----------
Yves Amaizo new changes commit today 2005/10/19 00:55 french time

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc:
        ConfigManager.java
        DateTimeForThread.java
        StringUtil.java
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db:
        DBInitializer.java
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc:
        JDBCUtil.java
        JDBCObjectMetaData.java
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
        DBObjectDef.java

Revision Data
-------------
Index: DBInitializer.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBInitializer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBInitializer.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBInitializer.java -u -r1.7 -r1.8
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBInitializer.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBInitializer.java
@@ -139,7 +139,7 @@
 
             // set up ConfigManager first
             ConfigManager.setWebAppDir(webAppDir);
-            ConfigManager.load(configDir);
+            ConfigManager.configStandAlone(configDir, logDir, "2_3");
 
             //initialize the db pool
             ConfigManager.dbInitialize();
@@ -164,6 +164,31 @@
         }
         return myConnection;
     } /* initialize(String) */
+
+	/**
+	 * Initialize method
+	 *
+	 * @param args Command line arguments to supply the information to
+	 *             connect to the database
+	 */
+	public synchronized static boolean isPoolInitialized(String dataContext) {
+	    try {
+	
+	        //initialize the db pool
+	
+			DBConnectionPool myDb = DBConnectionPool.getInstance(dataContext);
+	        if (myDb != null) {
+//	            myConnection = myDb.getConnection("DBInitialize");
+	        } else {
+	            return false;
+	        }
+	
+	    } catch (Exception de) {
+	        System.out.println("DBInitialze Error:" + de.getMessage());
+	        de.printStackTrace();
+	    }
+	    return true;
+	} /* initialize(String) */
 
     public synchronized void close(DBConnection myConnection) throws DBException {
         myConnection.clear();
Index: JDBCUtil.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCUtil.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCUtil.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCUtil.java -u -r1.35 -r1.36
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCUtil.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCUtil.java
@@ -340,7 +340,7 @@
 
                 if (StringUtil.notNull(convertFormat).length() == 0 &&
                         StringUtil.notNull(convertFunction).length() == 0) {
-                    convertFormat = "yyyy-MM-dd";
+                    convertFormat = DATE_FORMAT;
                 }
             } else if (oneField.getTypeString().equalsIgnoreCase("datetime")
                     || oneField.getTypeString().equalsIgnoreCase(DBField.TIMESTAMP_TYPE)) {
@@ -348,14 +348,14 @@
                 convertFunction = myConfig.getDateTimeUpdateFunction();
                 if (StringUtil.notNull(convertFormat).length() == 0 &&
                         StringUtil.notNull(convertFunction).length() == 0) {
-                    convertFormat = "yyyy-MM-dd HH:mm:ss";
+                    convertFormat = DATETIME_FORMAT;
                 }
             } else if (oneField.getTypeString().equalsIgnoreCase("time")) {
                 convertFormat = myConfig.getTimeUpdateFormat();
                 convertFunction = myConfig.getTimeUpdateFunction();
                 if (StringUtil.notNull(convertFormat).length() == 0 &&
                         StringUtil.notNull(convertFunction).length() == 0) {
-                    convertFormat = "HH:mm:ss";
+                    convertFormat = TIME_FORMAT;
                 }
             } else {
                 throw new DataException("Field '" + fieldName +
Index: JDBCObjectMetaData.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCObjectMetaData.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCObjectMetaData.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCObjectMetaData.java -u -r1.9 -r1.10
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCObjectMetaData.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCObjectMetaData.java
@@ -114,10 +114,23 @@
     public String getTargetSQLTable(String dataContext)
             throws DataException;
 
+	/**
+	 * Retrieve the full store procedure name associated with this data object
+	 *
+	 * @param dataContext The target data context.
+	 * @return the className of the schema associated with this DBObject
+	 * @throws DataException upon error
+	 *                       <p/>
+	 *                       author Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+	 */
+	public String getTargetSQLStoreProcedure(String dataContext)
+	        throws DataException;
+
     /**
      * Retrieve the database schema name associated with this data object
      *
      * @return the className of the schema associated with this DBObject
      */
     public String getTargetDbSchema();
+
 }
Index: DateTimeForThread.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/DateTimeForThread.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/DateTimeForThread.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/DateTimeForThread.java -u -r1.1 -r1.2
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/DateTimeForThread.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/DateTimeForThread.java
@@ -110,7 +110,7 @@
 					throw new DataException(ce);
 				}
 				if (!StringUtil.notNull(myConfig.getDateTimeSelectFormat()).equals("")) {
-					convertFormat = myConfig.getDateSelectFormat();
+					convertFormat = myConfig.getDateTimeSelectFormat();
 				} 
 				return buildNewDateFormatter(convertFormat);
 			} catch (DBException e) {
Index: StringUtil.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/StringUtil.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/StringUtil.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/StringUtil.java -u -r1.28 -r1.29
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/StringUtil.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/StringUtil.java
@@ -1541,5 +1541,72 @@
 
         return false;
     }
+    
+	/**
+	 *  Converts a delimited string into an array of string tokens.
+     * <p/>
+     * author        Henri Yves AMAIZO
+	 * @param String[] The 'separator' separated string.
+	 * @param String The string separator.
+	 * @return String A string array of the original tokens.
+	*/
+	public static final String[] stringToArray(String str, String separators) {
+		StringTokenizer tokenizer;
+		String[] array = null;
+		int count = 0;
+
+		if (str == null)
+			return array;
+
+		if (separators == null)
+			separators = ",";
+
+		tokenizer = new StringTokenizer(str, separators);
+		if ((count = tokenizer.countTokens()) <= 0) {
+			return array;
+		}
+        
+		array = new String[count];
+        
+		int ix = 0;
+		while (tokenizer.hasMoreTokens()) {
+			array[ix] = tokenizer.nextToken();
+			ix++;
+		}
+
+		return array;
+	}
+
+	/**
+	  *  Takes an array of tokens and converts into separator-separated string.
+      * <p/>
+      * author        Henri Yves AMAIZO
+      *
+	  * @param String[] The array of strings input.
+	  * @param String The string separator.
+	  * @return String A string containing tokens separated by seperator.
+	  */
+	 public static final String arrayToString(String[] array, String separators) {
+		 StringBuffer sb = new StringBuffer("");
+		 String empty = "";
+        
+		 if (array == null)
+			 return empty;
+
+		 if (separators == null)
+			 separators = ",";
+
+		 for (int ix=0; ix < array.length; ix++) {
+			 if (array[ix] != null && !array[ix].equals("")) {
+				 sb.append(array[ix] + separators);
+			 }
+		 }
+		 String str = sb.toString();
+		 if (!str.equals("")) {
+			 str = str.substring(0, (str.length() - separators.length()));
+		 }
+		 return str;
+	 }
+
 
 } /* StringUtil */
Index: ConfigManager.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -u -r1.86 -r1.87
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
@@ -1074,6 +1074,94 @@
         }
     }
 
+	    /**
+	     * Called by the initial load servlet to initialize the entire system
+	     *
+	     * @param c The servlet engine configuration
+	     * @throws ServletException Servlet exception if an error occurs initializing
+	     *                          the configuration system.
+	     */
+	    public static synchronized void configStandAlone(String dirConfig, String dirLog, String strAPI)
+	            throws ConfigurationException {
+	
+	        /* If we've already failed to configure, don't try again */
+	        if (configurationFailed) {
+	            throw new ConfigurationException(
+	                    "ConfigManager: Configuration has already been attempted and has failed - cannot re-run");
+	        }
+	
+	
+	        /* We initialize the default schema object here specifically in order */
+	        /* for it to do it's "version checking" against dependant packages */
+	
+	        try {
+	            servletAPIVersion = "2_3";
+	            configDir = StringUtil.notNull(dirConfig);
+	
+	            if (configDir.equals("")) {
+	                configDir = StringUtil.notNull(dirConfig);
+	            }
+	            if (configDir.equals("")) {
+	                ServletException se = new ServletException("ConfigManager: No 'configDir' initial " +
+	                        "parameter was read - unable to initialize. " +
+	                        "Check web.xml to ensure the configDir parameter is set " +
+	                        "to a non-blank value");
+	                setConfigurationFailureException(se);
+	                throw se;
+	            }
+	
+	            String rootDir = StringUtil.notNull("/");
+	
+	
+	            if (rootDir.equals("")) {
+	                rootDir = System.getProperty("expresso.home", "");
+	                if (rootDir.length() == 0) {
+	                    log.warn("Deployed inside WAR file and no expresso.home " +
+	                            "directory set.  %WEB-APP% will expand to null");
+	                } else {
+	                    configDir = FileUtil.makeAbsolutePath(rootDir, configDir);
+	
+	                    /* if there isn't a drive specification for windows-type path
+	                        nor a beginning slash, add a slash;
+	                        @todo: what is the use case for needing this test?  doesn't getRealPath() above always give absolute path?
+	                        */
+	                    configDir = addInitialSlashIfNecessary(configDir);
+	
+	                    setWebAppDir(rootDir);
+	                }
+	            } else {
+	                configDir = FileUtil.makeAbsolutePath(rootDir, configDir);
+	
+	                /* if there isn't a drive specification for windows-type path
+	                nor a beginning slash, add a slash;
+	                @todo: what is the use case for needing this test?  doesn't getRealPath() above always give absolute path?
+	                */
+	                configDir = addInitialSlashIfNecessary(configDir);
+	
+	
+	                // protect against installation in "Program Files" directory
+	                if (configDir.indexOf(' ') != -1) {
+	                    System.err.println(
+	                            "Bad name for installation path: Reinstall in directory without a space in name.");
+	                }
+	                setWebAppDir(rootDir);
+	            }
+	
+	            initLogManager(configDir, dirLog);
+	
+	            load(configDir);
+	        } catch (Throwable thrown) {
+	            if (log != null) {
+	                log.error(thrown);
+	            }
+	            setConfigurationFailureException(thrown);
+	            System.err.println("ConfigManager: Expresso configuration encountered an exception:");
+	            thrown.printStackTrace(System.err);
+	            configurationFailed = true;
+	            throw new ConfigurationException(thrown);
+	        }
+	    }
+
     private static String addInitialSlashIfNecessary(String path) {
         if ('/' != path.charAt(0) && path.charAt(1) != ':') {
             path = "/" + path;
@@ -1115,6 +1203,37 @@
         new LogManager(logConfig, logDir);
     }
 
+	/**
+	 * Initialize Log Manager based upon the LogDirectory.
+	 *
+	 * @param sc the servlet configuration.
+	 */
+	private static void initLogManager(String dirConfig, String dirLog) {
+	    String logConfig = null;
+	
+	    if (!('/' == dirConfig.charAt(0))) {
+			dirConfig = getWebAppDir() + dirConfig;
+	    }
+	
+	    if (dirLog != null && dirLog.length() > 0 && !('/' == dirLog.charAt(0))) {
+			dirLog = getWebAppDir() + dirLog;
+	    }
+	    //
+	    //expressoLogging can be initialized with or without a log directory
+	    //or a config dir directory.  If log4j.xml exists in the classpath, the
+	    //system will initialize with that.
+	    //
+	    if (dirConfig != null && dirConfig.length() > 0) {
+	        logConfig = dirConfig + "/expressoLogging.xml";
+	        java.io.File f = new java.io.File(logConfig);
+	        if (f == null || !f.exists()) {
+	            logConfig = null;
+	        }
+	    }
+	
+	    new LogManager(logConfig, dirLog);
+	}
+
     /**
      * "Second stage" configuration. Programs not running in the servlet
      * environment can call this method with a configuration directory
@@ -1944,15 +2063,21 @@
                 "setExpressoDir", 0);
         digester.addCallMethod("expresso-config/context/hasSetupTables",
                 "setHasSetupTables", 0);
+		digester.addCallMethod("expresso-config/context/hasSetupValues",
+				"setHasSetupValues", 0);
+		digester.addCallMethod("expresso-config/context/cacheContext",
+				"setCacheContext", 0);
+		digester.addCallMethod("expresso-config/context/setupContext",
+				"setSetupContext", 0);
         digester.addSetNext("expresso-config/context", "addContext",
                 "com.jcorporate.expresso.core.misc.ConfigContext");
 
         /* Jdbc definition within the context */
         digester.addObjectCreate("expresso-config/context/jdbc",
                 "com.jcorporate.expresso.core.misc.ConfigJdbc");
-        digester.addCallMethod("expresso-config/context/jdbc/dbWildcard",
-                "addWildcard", 0);
         digester.addSetProperties("expresso-config/context/jdbc");
+		digester.addCallMethod("expresso-config/context/jdbc/dbWildcard",
+				"addWildcard", 0);
         digester.addSetNext("expresso-config/context/jdbc", "addJdbc",
                 "com.jcorporate.expresso.core.misc.ConfigJdbc");
 
Index: DBObjectDef.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObjectDef.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObjectDef.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObjectDef.java -u -r1.52 -r1.53
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObjectDef.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObjectDef.java
@@ -1879,6 +1879,33 @@
         return sqlTableName;
     } /* getTargetSQLTable() */
 
+	/**
+	 * Return the Table Name of the current database object. Keep in mind
+	 * that a database object could update or affect other tables as well.
+	 *
+	 * @return String: Table name of the target table of this database object
+	 * @throws DataException upon error
+	 *                       <p/>
+	 *                       author Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+	 */
+	public String getTargetSQLStoreProcedure(String dataContext)
+	        throws DataException {
+	    String sqlSPLName = getTargetTable();
+	    try {
+	        if (getTargetDbSchema() != null && !"".equals(getTargetDbSchema())) {
+				sqlSPLName = getTargetDbSchema() + "." + getTargetStoreProcedure();
+	        } else {
+	            JDBCConfig myConfig = ConfigManager.getJdbcRequired(dataContext);
+	            if (myConfig.getDbSchema() != null && !"".equals(myConfig.getDbSchema())) {
+					sqlSPLName = myConfig.getDbSchema() + "." + getTargetStoreProcedure();
+	            }
+	        }
+	    } catch (ConfigurationException ce) {
+	        throw new DataException(ce);
+	    }
+	    return sqlSPLName;
+	} /* getTargetSQLStoreProcedure(String) */
+
 
     /**
      * Get a list of all of the names of the IN param fields in this object


More information about the cvs mailing list