You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/06/14 17:13:26 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/db/pool ConnectionPool.java DBConnection.java
jvanzyl 01/06/14 08:13:26
Modified: src/java/org/apache/turbine/util Log.java
RunDataFactory.java SecurityCheck.java
ServerData.java TurbineConfig.java
src/java/org/apache/turbine/util/db IDBroker.java
UUIdGenerator.java
src/java/org/apache/turbine/util/db/adapter DBFactory.java
src/java/org/apache/turbine/util/db/pool ConnectionPool.java
DBConnection.java
Log:
- just starting to try and do some decoupling of the
db code from turbine.
Revision Changes Path
1.15 +141 -336 jakarta-turbine/src/java/org/apache/turbine/util/Log.java
Index: Log.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/Log.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Log.java 2001/06/01 17:17:21 1.14
+++ Log.java 2001/06/14 15:13:08 1.15
@@ -54,106 +54,85 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.services.Service;
-import org.apache.turbine.services.ServiceBroker;
-import org.apache.turbine.services.TurbineServices;
-import org.apache.turbine.services.logging.Logger;
-import org.apache.turbine.services.logging.LoggingService;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+import org.apache.log4j.PropertyConfigurator;
/**
- * A facade class for {@link org.apache.turbine.services.logging.LoggingService}.
+ * A facade for logging with log4j in Turbine.
*
- * Use this class to conviniently access the system's configured LoggingSerice.
- * <P>
- * @see org.apache.turbine.services.logging.TurbineLoggingService
- * @author <a href="mailto:Tomasz.Zielinski@e-point.pl">Tomasz Zielinski</a>
+ * @author <a href="jvanzyl@apache.org">Jason van Zyl</a>
*/
public class Log
{
/**
- * This method has been deprecated, attempts to shutdown logger service.
- * @deprecated The service should be shut down by the broker class only.
+ * Properties used to initialized log4j
*/
- public static void destroy()
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.shutdown();
- }
-
+ public static Properties properties;
+
/**
- * This method returns default logger for Turbine System
- *
- * @return The default logger for system.
+ * This is the default logger.
*/
- public static Logger getLogger()
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- return logger.getLogger();
- }
-
+ private static Category defaultLogger;
+
/**
- * This method returns logger with given name if such logger exsists,
- * or the default logger.
+ * This is a collection of log4j categories.
*/
- public static Logger getLogger(String logName)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- return logger.getLogger(logName);
- }
+ private static Hashtable loggers;
/**
- * This method sets the log level in default logger
+ * The name of the category that will be
+ * used for default logging.
*/
- public static void setLogLevel(int level)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.setLogLevel(level);
- }
+ private static final String DEFAULT_CATEGORY = "default";
/**
- * This method sets the log level in the logger of given name
+ * Set the properties so that log4j can do
+ * it's thing.
*/
- public static void setLogLevel(String logName, int level)
+ public static void setProperties(Properties p)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.setLogLevel(logName, level);
- }
-
+ properties = p;
+ }
+
/**
- * This method sets format style of the default logger.
- * Format tokens are described in RunDataFilter implementation.
- *
- * @see org.apache.turbine.services.logging.BaseRunDataFilter
- *
- * @param format String describing what information should be extracted from
- * RunData
+ * Initialize our logging fascade
*/
- public static void setFormat(String format)
+ public static void init()
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.setFormat(format);
+ loggers = new Hashtable();
+ PropertyConfigurator.configure(properties);
+
+ // Get all the configured categories.
+ Enumeration e =
+ Category.getDefaultHierarchy().getCurrentCategories();
+
+ // Create catagories for logging.
+ while (e.hasMoreElements())
+ {
+ Category c = (Category) e.nextElement();
+ loggers.put(c.getName(), c);
+ }
+
+ // Set up our default logger. This will be used
+ // when a specific category is not specified.
+ defaultLogger = Category.getInstance(DEFAULT_CATEGORY);
}
/**
- * This method sets format style of the given logger.
- * Format tokens are described in RunDataFilter implementation.
- *
- * @see org.apache.turbine.services.logging.BaseRunDataFilter
+ * Retrieve a category from our configured set
+ * of Categories.
*
- * @param format String describing what information should be extracted from
- * RunData
+ * @param String logger name
+ * @return Category
*/
- public static void setFormat(String logName, String format)
+ public static Category getLogger(String logger)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.setFormat(logName, format);
+ return (Category) loggers.get(logger);
}
/**
@@ -162,9 +141,7 @@
*/
public static void debug(String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(message);
+ defaultLogger.debug(message);
}
/**
@@ -173,89 +150,52 @@
*/
public static void debug(String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(message, t);
+ defaultLogger.debug(message,t);
}
/**
* This is a log method with logLevel == DEBUG, printing is done by
* the given logger
*/
- public static void debug(String logName ,String message, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(logName, message, t);
- }
-
- /**
- * This is a log method with logLevel == DEBUG, printing is done by
- * the given logger
- */
public static void debug(String logName, String message)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(logName, message);
- }
-
- /**
- * This is a log method with logLevel == DEBUG, printing is done by
- * the default logger
- */
- public static void debug(String message, RunData data)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(message, data);
- }
-
- /**
- * This is a log method with logLevel == DEBUG, printing is done by
- * the default logger
- */
- public static void debug(String message, RunData data, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(message, data, t);
- }
-
- /**
- * This is a log method with logLevel == DEBUG, printing is done by
- * the given logger
- */
- public static void debug(String logName,
- String message,
- RunData data,
- Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(logName, message, data, t);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ debug(message);
+ }
+ else
+ {
+ logger.debug(message);
+ }
}
/**
* This is a log method with logLevel == DEBUG, printing is done by
* the given logger
*/
- public static void debug(String logName, String message, RunData data)
+ public static void debug(String logName ,String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.debug(logName, message, data);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ debug(message,t);
+ }
+ else
+ {
+ logger.debug(message,t);
+ }
}
-
+
/**
* This is a log method with logLevel == INFO, printing is done by
* the default logger
*/
public static void info(String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(message);
+ defaultLogger.info(message);
}
/**
@@ -264,9 +204,7 @@
*/
public static void info(String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(message, t);
+ defaultLogger.info(message,t);
}
/**
@@ -275,9 +213,16 @@
*/
public static void info(String logName, String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(logName, message);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ info(message);
+ }
+ else
+ {
+ logger.info(message);
+ }
}
/**
@@ -285,68 +230,26 @@
* the given logger
*/
public static void info(String logName, String message, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(logName, message, t);
- }
-
- /**
- * This is a log method with logLevel == INFO, printing is done by
- * the default logger
- */
- public static void info(String message, RunData data)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(message, data);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ info(message,t);
+ }
+ else
+ {
+ logger.info(message,t);
+ }
}
/**
- * This is a log method with logLevel == INFO, printing is done by
- * the default logger
- */
- public static void info(String message, RunData data, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(message, data, t);
- }
-
- /**
- * This is a log method with logLevel == INFO, printing is done by
- * the given logger
- */
- public static void info(String logName, String message, RunData data)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(logName, message, data);
- }
-
- /**
- * This is a log method with logLevel == INFO, printing is done by
- * the given logger
- */
- public static void info(String logName,
- String message,
- RunData data,
- Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(logName, message, data, t);
- }
-
- /**
* This is a log method with logLevel == WARN, printing is done by
* the default logger
*/
public static void warn(String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(message);
+ defaultLogger.warn(message);
}
/**
@@ -355,9 +258,7 @@
*/
public static void warn(String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(message, t);
+ defaultLogger.warn(message,t);
}
/**
@@ -366,9 +267,16 @@
*/
public static void warn(String logName, String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(logName, message);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ warn(message);
+ }
+ else
+ {
+ logger.warn(message);
+ }
}
/**
@@ -376,68 +284,26 @@
* the given logger
*/
public static void warn(String logName, String message, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(logName, message, t);
- }
-
- /**
- * This is a log method with logLevel == WARN, printing is done by
- * the default logger
- */
- public static void warn(String message, RunData data)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(message, data);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ warn(message,t);
+ }
+ else
+ {
+ logger.warn(message,t);
+ }
}
/**
- * This is a log method with logLevel == WARN, printing is done by
- * the default logger
- */
- public static void warn(String message, RunData data, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(message, data, t);
- }
-
- /**
- * This is a log method with logLevel == WARN, printing is done by
- * the given logger
- */
- public static void warn(String logName, String message, RunData data)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(logName, message, data);
- }
-
- /**
- * This is a log method with logLevel == WARN, printing is done by
- * the given logger
- */
- public static void warn(String logName,
- String message,
- RunData data,
- Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.warn(logName, message, data, t);
- }
-
- /**
* This is a log method with logLevel == ERROR, printing is done by
* the default logger
*/
public static void error(String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(message);
+ defaultLogger.error(message);
}
/**
@@ -446,9 +312,7 @@
*/
public static void error(String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(message, t);
+ defaultLogger.error(message,t);
}
/**
@@ -457,9 +321,16 @@
*/
public static void error(String logName, String message)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(logName, message);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ error(message);
+ }
+ else
+ {
+ logger.error(message);
+ }
}
/**
@@ -468,90 +339,24 @@
*/
public static void error(String logName, String message, Throwable t)
{
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(logName, message, t);
+ Category logger = getLogger(logName);
+
+ if (logger == null)
+ {
+ error(message,t);
+ }
+ else
+ {
+ logger.error(message,t);
+ }
}
/**
* This is a log method with logLevel == ERROR, printing is done by
* the default logger
*/
- public static void error(String message, RunData data)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(message, data);
- }
-
- /**
- * This is a log method with logLevel == ERROR, printing is done by
- * the default logger
- */
- public static void error(String message, RunData data, Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(message, data, t);
- }
-
- /**
- * This is a log method with logLevel == ERROR, printing is done by
- * the given logger
- */
- public static void error(String logName, String message, RunData data)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(logName, message, data);
- }
-
- /**
- * This is a log method with logLevel == ERROR, printing is done by
- * the given logger
- */
- public static void error(String logName,
- String message,
- RunData data,
- Throwable t)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.error(logName, message, data, t);
- }
-
- /**
- * This is a log method with logLevel == ERROR, printing is done by
- * the default logger
- */
public static void error(Throwable e)
{
error("", e);
- }
-
- /**
- * This method has been deprecated.
- * This is method is kept for historical reason.
- *
- * @deprecated You should use info or debug methods instead.
- */
- public static void note(String message)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(message);
- }
-
- /**
- * This method has been deprecated.
- * This is method is kept for historical reason.
- *
- * @deprecated You should use info or debug methods instead.
- */
- public static void note(String logName, String message)
- {
- LoggingService logger = (LoggingService)TurbineServices.getInstance()
- .getService(LoggingService.SERVICE_NAME);
- logger.info(logName, message);
}
}
1.12 +4 -1 jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java
Index: RunDataFactory.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- RunDataFactory.java 2001/05/06 17:06:40 1.11
+++ RunDataFactory.java 2001/06/14 15:13:08 1.12
@@ -77,7 +77,7 @@
* @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: RunDataFactory.java,v 1.11 2001/05/06 17:06:40 jvanzyl Exp $
+ * @version $Id: RunDataFactory.java,v 1.12 2001/06/14 15:13:08 jvanzyl Exp $
*/
public class RunDataFactory
{
@@ -149,6 +149,9 @@
// Cache some information that will be used elsewhere.
data.setRequest(req);
data.setResponse(res);
+
+ Log.debug("RDF: " + req);
+ Log.debug("RDF: " + res);
// Let the implementation to create messages on demand.
// data.setMessages(new FormMessages());
1.6 +2 -2 jakarta-turbine/src/java/org/apache/turbine/util/SecurityCheck.java
Index: SecurityCheck.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/SecurityCheck.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SecurityCheck.java 2001/05/05 03:19:15 1.5
+++ SecurityCheck.java 2001/06/14 15:13:09 1.6
@@ -68,10 +68,10 @@
* new SecurityCheck(data, "Unauthorized to do this!", "WrongPermission");
* if ( !mycheck.hasPermission("add_user");
* return;
- *</code>
+ * </code>
*
* @author <a href="mailto:mbryson@mindspring.com">Dave Bryson</a>
- * @version $Id: SecurityCheck.java,v 1.5 2001/05/05 03:19:15 jvanzyl Exp $
+ * @version $Id: SecurityCheck.java,v 1.6 2001/06/14 15:13:09 jvanzyl Exp $
*/
public class SecurityCheck
{
1.5 +3 -3 jakarta-turbine/src/java/org/apache/turbine/util/ServerData.java
Index: ServerData.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/ServerData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerData.java 2001/03/06 06:13:29 1.4
+++ ServerData.java 2001/06/14 15:13:11 1.5
@@ -62,7 +62,7 @@
*
* @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Id: ServerData.java,v 1.4 2001/03/06 06:13:29 chrise Exp $
+ * @version $Id: ServerData.java,v 1.5 2001/06/14 15:13:11 jvanzyl Exp $
*/
public class ServerData
{
@@ -93,13 +93,13 @@
int serverPort,
String serverScheme,
String scriptName,
- String contextPath )
+ String contextPath )
{
this.serverName = serverName;
this.serverPort = serverPort;
this.serverScheme = serverScheme;
this.scriptName = scriptName;
- this.contextPath = contextPath;
+ this.contextPath = contextPath;
}
/**
1.21 +2 -2 jakarta-turbine/src/java/org/apache/turbine/util/TurbineConfig.java
Index: TurbineConfig.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/TurbineConfig.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TurbineConfig.java 2001/05/23 22:05:00 1.20
+++ TurbineConfig.java 2001/06/14 15:13:11 1.21
@@ -100,7 +100,7 @@
* @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @version $Id: TurbineConfig.java,v 1.20 2001/05/23 22:05:00 dlr Exp $
+ * @version $Id: TurbineConfig.java,v 1.21 2001/06/14 15:13:11 jvanzyl Exp $
*/
public class TurbineConfig implements ServletConfig, ServletContext
{
@@ -148,7 +148,7 @@
{
root = new File(path);
initParams = new HashMap(1);
- initParams.put(TurbineServices.PROPERTIES_PATH_KEY, properties);
+ initParams.put(Turbine.DEFAULT_TURBINE_RESOURCES, properties);
}
/**
1.29 +27 -5 jakarta-turbine/src/java/org/apache/turbine/util/db/IDBroker.java
Index: IDBroker.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/IDBroker.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- IDBroker.java 2001/05/06 17:06:41 1.28
+++ IDBroker.java 2001/06/14 15:13:17 1.29
@@ -69,13 +69,15 @@
import org.apache.turbine.om.peer.BasePeer;
import org.apache.turbine.services.db.TurbineDB;
-import org.apache.turbine.services.resources.TurbineResources;
+//import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.db.map.DatabaseMap;
import org.apache.turbine.util.db.map.TableMap;
import org.apache.turbine.util.db.pool.DBConnection;
+import org.apache.velocity.runtime.configuration.Configuration;
+
/**
* This method of ID generation is used to ensure that code is
* more database independent. For example, MySQL has an auto-increment
@@ -108,7 +110,7 @@
*
* @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
- * @version $Id: IDBroker.java,v 1.28 2001/05/06 17:06:41 jvanzyl Exp $
+ * @version $Id: IDBroker.java,v 1.29 2001/06/14 15:13:17 jvanzyl Exp $
*/
public class IDBroker
implements Runnable, IdGenerator
@@ -184,6 +186,11 @@
*/
private static final BigDecimal ONE = new BigDecimal("1");
+ private Configuration configuration;
+
+ private static final String DB_IDBROKER_CLEVERQUANTITY =
+ "idbroker.clever.quantity";
+
/**
* Creates an IDBroker for the ID table.
*
@@ -235,6 +242,11 @@
}
}
+ public void setConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ }
+
/**
* Returns an id as a primitive int. Note this method does not
* require a Connection, it just implements the KeyGenerator
@@ -467,10 +479,18 @@
*/
private void checkTiming(String tableName)
{
+ /*
+ * Haven't finished setting up the code to pass
+ * in the configuration object. This evaluates
+ * to false given the current default so I'm
+ * going to comment it out for now. jvz.
+ */
+
// Check if quantity changing is switched on.
- if (!TurbineResources.getBoolean(TurbineResources
- .DB_IDBROKER_CLEVERQUANTITY, true))
- return;
+ //if (!configuration.getBoolean(DB_IDBROKER_CLEVERQUANTITY, true))
+ //{
+ // return;
+ //}
// Get the last id request for this table.
java.util.Date lastTime =
@@ -520,7 +540,9 @@
// synchronized(tMap) see comment in the getNextIds method
// {
if (adjustQuantity)
+ {
checkTiming(tableName);
+ }
DBConnection dbCon = null;
try
1.6 +3 -3 jakarta-turbine/src/java/org/apache/turbine/util/db/UUIdGenerator.java
Index: UUIdGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/UUIdGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UUIdGenerator.java 2001/05/06 17:06:41 1.5
+++ UUIdGenerator.java 2001/06/14 15:13:18 1.6
@@ -90,7 +90,7 @@
* TurbineResources.properties file.</p>
*
* @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
- * @version $Id: UUIdGenerator.java,v 1.5 2001/05/06 17:06:41 jvanzyl Exp $
+ * @version $Id: UUIdGenerator.java,v 1.6 2001/06/14 15:13:18 jvanzyl Exp $
*/
public class UUIdGenerator
{
@@ -106,9 +106,9 @@
/**
* Constructor
*/
- public UUIdGenerator() throws TurbineException
+ public UUIdGenerator(String addr) throws TurbineException
{
- String addr = TurbineResources.getString("uuid.address");
+ //String addr = TurbineResources.getString("uuid.address");
if ( addr == null )
{
Log.info("UUIdGenerator is using a random number as the " +
1.6 +16 -7 jakarta-turbine/src/java/org/apache/turbine/util/db/adapter/DBFactory.java
Index: DBFactory.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/adapter/DBFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DBFactory.java 2001/05/06 17:06:42 1.5
+++ DBFactory.java 2001/06/14 15:13:21 1.6
@@ -58,10 +58,10 @@
import java.util.Hashtable;
import java.util.Vector;
-import org.apache.turbine.services.resources.TurbineResources;
-
import org.apache.turbine.util.Log;
+import org.apache.velocity.runtime.configuration.Configuration;
+
/**
* This class creates different DB objects based on the database
* driver that is provided.
@@ -70,18 +70,25 @@
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
* @author <a href="mailto:ralf@reswi.ruhr.de">Ralf Stranzenbach</a>
- * @version $Id: DBFactory.java,v 1.5 2001/05/06 17:06:42 jvanzyl Exp $
+ * @version $Id: DBFactory.java,v 1.6 2001/06/14 15:13:21 jvanzyl Exp $
*/
public class DBFactory
{
// List of registered drivers.
private static Hashtable drivers = null;
+ private static Configuration configuration;
+
+ public static void setConfiguration(Configuration c)
+ {
+ configuration = c;
+ }
+
// This static code creates the list of possible drivers and adds
// the "NO DATABASE" adaptor to this list. After all the
- // TurbineResources is queried to get a list of JDBC drivers and
+ // configuration is queried to get a list of JDBC drivers and
// their associated adaptors.
- static
+ public static void init()
{
drivers = new Hashtable();
@@ -89,12 +96,12 @@
registerDriver("", DBNone.class);
Enumeration adaptors =
- TurbineResources.getVector("database.adaptor").elements();
+ configuration.getVector("database.adaptor").elements();
while (adaptors.hasMoreElements())
{
String adaptor = (String)adaptors.nextElement();
String driver =
- TurbineResources.getString("database.adaptor." + adaptor);
+ configuration.getString("database.adaptor." + adaptor);
Class c = null;
try
@@ -131,8 +138,10 @@
private static void registerDriver(String driver, Class dc)
{
if (!drivers.containsKey(driver))
+ {
// Add this new driver class to the list of known drivers.
drivers.put(driver, dc);
+ }
}
/**
1.24 +8 -79 jakarta-turbine/src/java/org/apache/turbine/util/db/pool/ConnectionPool.java
Index: ConnectionPool.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/pool/ConnectionPool.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ConnectionPool.java 2001/05/06 17:06:45 1.23
+++ ConnectionPool.java 2001/06/14 15:13:24 1.24
@@ -63,7 +63,6 @@
import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;
-import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.db.adapter.DB;
import org.apache.turbine.util.db.adapter.DBFactory;
@@ -79,7 +78,7 @@
* @author <a href="mailto:paul@evolventtech.com">Paul O'Leary</a>
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Id: ConnectionPool.java,v 1.23 2001/05/06 17:06:45 jvanzyl Exp $
+ * @version $Id: ConnectionPool.java,v 1.24 2001/06/14 15:13:24 jvanzyl Exp $
*/
public class ConnectionPool
{
@@ -164,29 +163,6 @@
/**
* Creates a <code>ConnectionPool</code> with the default
* attributes.
- * @deprecated Use the constructor specifying db parameters.
- */
- public ConnectionPool()
- {
- this(null, null, null, null);
- }
-
- /**
- * Creates a <code>ConnectionPool</code> with the specified
- * attributes.
- *
- * @param maxCons The maximum number of connections for this pool.
- * @param expiryTime The expiration time in milliseconds.
- * @deprecated Use the constructor specifying db parameters.
- */
- public ConnectionPool(int maxCons, long expiryTime)
- {
- this(null, null, null, null, maxCons, expiryTime);
- }
-
- /**
- * Creates a <code>ConnectionPool</code> with the default
- * attributes.
*
* @param driver The driver type for this pool.
* @param url The url for this pool.
@@ -196,53 +172,11 @@
public ConnectionPool(String driver,
String url,
String username,
- String password)
- {
- pool = new Stack();
-
- maxConnections =
- TurbineResources.getInt("database.maxConnections", 10);
- expiryTime =
- TurbineResources.getLong("database.expiryTime", 3600000);
- maxConnectionAttempts =
- TurbineResources.getLong("database.maxConnectionAttempts", 50);
- connectionWaitTimeout =
- TurbineResources.getLong("database.connectionWaitTimeout",
- 10 * 1000);
-
- this.driver = driver;
- this.url = url;
- this.username = username;
- this.password = password;
-
- try
- {
- cpds = getDB().getConnectionPoolDataSource();
- }
- catch(Exception ignore)
- {
- // if the JDBC driver does not support the standard extensions, we
- // will get an exception here. Just ignore it and use the old way.
- }
- }
-
- /**
- * Creates a <code>ConnectionPool</code> with the specified
- * attributes.
- *
- * @param driver The driver type for this pool.
- * @param url The url for this pool.
- * @param usernam The user name for this pool.
- * @param password The password for this pool.
- * @param maxCons The maximum number of connections for this pool.
- * @param expiryTime The expiration time in milliseconds.
- */
- public ConnectionPool(String driver,
- String url,
- String username,
String password,
- int maxCons,
- long expiryTime)
+ int maxConnections,
+ long expiryTime,
+ long maxConnectionAttempts,
+ long connectionWaitTimeout)
{
pool = new Stack();
@@ -250,15 +184,10 @@
this.url = url;
this.username = username;
this.password = password;
-
- this.maxConnections = maxCons;
+ this.maxConnections = maxConnections;
this.expiryTime = expiryTime;
-
- maxConnectionAttempts =
- TurbineResources.getLong("database.maxConnectionAttempts", 50);
- connectionWaitTimeout =
- TurbineResources.getLong("database.connectionWaitTimeout",
- 10 * 1000);
+ this.maxConnectionAttempts = maxConnectionAttempts;
+ this.connectionWaitTimeout = connectionWaitTimeout;
try
{
1.20 +15 -11 jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java
Index: DBConnection.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DBConnection.java 2001/05/06 17:06:45 1.19
+++ DBConnection.java 2001/06/14 15:13:25 1.20
@@ -83,7 +83,7 @@
* @author <a href="mailto:dlr@collab.net">Daniel L. Rall</a>
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Id: DBConnection.java,v 1.19 2001/05/06 17:06:45 jvanzyl Exp $
+ * @version $Id: DBConnection.java,v 1.20 2001/06/14 15:13:25 jvanzyl Exp $
*/
public class DBConnection implements ConnectionEventListener
{
@@ -171,7 +171,9 @@
* @param username The user name we are connecting as
* @param pool The ConnectionPool that this DBConnection belongs to
*/
- protected DBConnection(Connection connection, String url, String username,
+ protected DBConnection(Connection connection,
+ String url,
+ String username,
ConnectionPool pool)
{
this.connection = connection;
@@ -191,7 +193,9 @@
* @param username The user name we are connecting as
* @param pool The ConnectionPool that this DBConnection belongs to
*/
- protected DBConnection(PooledConnection pooledConnection, String url, String username,
+ protected DBConnection(PooledConnection pooledConnection,
+ String url,
+ String username,
ConnectionPool pool)
{
this.pooledConnection = pooledConnection;
@@ -244,10 +248,10 @@
this.pool = pool;
- //If we use a PooledConnection object, then request from it a Connection
- //object. This forces the PooledConnection to create a wrapper for the
- //physical connection it represents and return a Logical Connection object
- //that is currently in control of it.
+ //If we use a PooledConnection object, then request from it a Connection
+ //object. This forces the PooledConnection to create a wrapper for the
+ //physical connection it represents and return a Logical Connection object
+ //that is currently in control of it.
if ( pooledConnection != null )
{
try
@@ -341,11 +345,11 @@
public Connection getConnection()
throws SQLException
{
- //if we manage an actual PooledConnection, just delegate the call
+ //if we manage an actual PooledConnection, just delegate the call
if ( pooledConnection != null )
{
- //if the link method has been called first, then the reference will
- //contain a valid connection object. If not, get it from here.
+ //if the link method has been called first, then the reference will
+ //contain a valid connection object. If not, get it from here.
if ( connection != null )
{
return connection;
@@ -356,7 +360,7 @@
}
}
- //else, we try to mimic the PooledConnection interface
+ //else, we try to mimic the PooledConnection interface
if (connection == null)
{
throw new SQLException ("Connection object is null!");
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org