You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2004/11/14 10:36:44 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/util/sequence SequenceManagerHighLowImpl.java
tomdz 2004/11/14 01:36:44
Modified: src/java/org/apache/ojb/broker/util/logging
PoorMansLoggerImpl.java CommonsLoggerImpl.java
Logger.java LoggingConfiguration.java
LoggerFactoryImpl.java Log4jLoggerImpl.java
src/java/org/apache/ojb/broker/locking
LockMapRemoteImpl.java LockMapInMemoryImpl.java
AbstractLockStrategy.java
src/java/org/apache/ojb/broker/query Criteria.java
src/java/org/apache/ojb/broker/util/dbhandling
DatabaseHandlingTask.java
src/java/org/apache/ojb/broker/accesslayer/batch
BatchStrategyBase.java
BatchStrategyDefaultImpl.java
BatchStrategyLeafImpl.java
src/java/org/apache/ojb/broker/transaction/tm
AbstractTransactionManagerFactory.java
src/java/org/apache/ojb/broker/util/sequence
SequenceManagerHighLowImpl.java
Log:
Reworked the OJB core:
- replaced the factories/configuration concept with the ComponentContainer
- removal of most static calls within OJB
- removed the old "D" collection implementations and renamed the new ones
- moved StatementForClassIF handling to the PersistenceConfiguration
- moved RowReader caching from the ClassDescriptor to the PersistenceConfiguration
and other changes (see mail on the dev list for more details)
Revision Changes Path
1.12 +10 -20 db-ojb/src/java/org/apache/ojb/broker/util/logging/PoorMansLoggerImpl.java
Index: PoorMansLoggerImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/PoorMansLoggerImpl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PoorMansLoggerImpl.java 4 Apr 2004 23:53:38 -0000 1.11
+++ PoorMansLoggerImpl.java 14 Nov 2004 09:36:43 -0000 1.12
@@ -15,9 +15,6 @@
* limitations under the License.
*/
-import org.apache.ojb.broker.util.configuration.Configuration;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
-
/**
* this is a most simple Logger implementation.
* All output is directed to System.out.
@@ -25,17 +22,20 @@
* @author Thomas Mahler
* @version $Id$
*/
-public class PoorMansLoggerImpl
- implements Logger
+public class PoorMansLoggerImpl implements Logger
{
- private String name ;
+ private String name;
- private int level = 0;
+ private int level = WARN;
- public PoorMansLoggerImpl( String name)
+ public PoorMansLoggerImpl(String name, LoggingConfiguration conf)
{
- this.name = name ;
+ this.name = name;
+ if (conf != null)
+ {
+ setLevel(conf.getLogLevel(name));
+ }
}
protected int getLevel()
@@ -308,16 +308,6 @@
/*logging should be failsafe*/
}
}
- }
-
- /*
- * @see org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration config) throws ConfigurationException
- {
- LoggingConfiguration lc = (LoggingConfiguration) config;
- String levelName = lc.getLogLevel(name);
- setLevel(levelName);
}
public void setLevel(String levelName)
1.5 +2 -12 db-ojb/src/java/org/apache/ojb/broker/util/logging/CommonsLoggerImpl.java
Index: CommonsLoggerImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/CommonsLoggerImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CommonsLoggerImpl.java 22 May 2004 10:03:02 -0000 1.4
+++ CommonsLoggerImpl.java 14 Nov 2004 09:36:43 -0000 1.5
@@ -17,8 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ojb.broker.util.configuration.Configuration;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
/**
* This is a Logger implementation based on jakarta commons logging.
@@ -38,7 +36,7 @@
/**
* Constructor for CommonsLoggerImpl.
*/
- public CommonsLoggerImpl(String aName)
+ public CommonsLoggerImpl(String aName, LoggingConfiguration conf)
{
this.name = aName;
this.log = LogFactory.getLog(aName);
@@ -286,14 +284,6 @@
}
}
return toString;
- }
-
- /**
- * @see org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration config) throws ConfigurationException
- {
- // do nothing
}
/**
1.10 +1 -1 db-ojb/src/java/org/apache/ojb/broker/util/logging/Logger.java
Index: Logger.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/Logger.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Logger.java 1 Jun 2004 21:42:21 -0000 1.9
+++ Logger.java 14 Nov 2004 09:36:43 -0000 1.10
@@ -1 +1 @@
-package org.apache.ojb.broker.util.logging;
/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.ojb.broker.util.configuration.Configurable;
import org.apache.ojb.broker.util.configuration.Configuration;
import org.apache.ojb.broker.util.configuration.ConfigurationException;
import java.io.Serializable;
/**
* this interface defines the behaviour of a logging mechanism.
* This API corresponds closely to the LOG4J Category Api.
* By using this interface OJB remains free from Logger-Implementation
* specific code.
*/
public interface Logger extends Serializable, Configurable
{
static final long serialVersionUID = 1177329037874407180L; /*
* OJB loglevel constants. they corespond directly to LOG4J LogLevels.
*/
public final static int DEBUG = 1;
public final static int INFO = 2;
public final static int WARN = 3;
public final static int ERROR = 4;
public final static int FATAL = 5;
/**
* generate a message for loglevel DEBUG
* @param pObject the message Object
*/
public void debug(Object pObject);
/**
* generate a message for loglevel INFO
* @param pObject the message Object
*/
public void info(Object pObject);
/**
* generate a message for loglevel WARN
* @param pObject the message Object
*/
public void warn(Object pObject);
/**
* generate a message for loglevel ERROR
* @param pObject the message Object
*/
public void error(Object pObject);
/**
* generate a message for loglevel FATAL
* @param pObject the message Object
*/
public void fatal(Object pObject);
public void debug(Object message, Throwable obj);
public void info(Object message, Throwable obj);
public void warn(Object message, Throwable obj);
public void error(Object message, Throwable obj);
public void fatal(Object message, Throwable obj);
public boolean isEnabledFor(int priority);
public boolean isDebugEnabled();
/**
* returns the name of the logger isntance
*/
public String getName();
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : DEBUG
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeDebug(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : DEBUG
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeDebug(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : INFO
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeInfo(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : INFO
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeInfo(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : WARN
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeWarn(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : WARN
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeWarn(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : ERROR
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeError(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : ERROR
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeError(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : FATAL
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeFatal(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : FATAL
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeFatal(String message, Object obj, Throwable t);
/**
* Configure this logging. Note that the config object will be an instance
* of {@link LoggingConfiguration}.
*
* @param config The {@link LoggingConfiguration} object
* @throws ConfigurationException
*/
void configure(Configuration config) throws ConfigurationException;
}
+package org.apache.ojb.broker.util.logging;
/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.Serializable;
/**
* this interface defines the behaviour of a logging mechanism.
* This API corresponds closely to the LOG4J Category Api.
* By using this interface OJB remains free from Logger-Implementation
* specific code.
*/
public interface Logger extends Serializable
{
static final long serialVersionUID = 1177329037874407180L; /*
* OJB loglevel constants. they corespond directly to LOG4J LogLevels.
*/
public final static int DEBUG = 1;
public final static int INFO = 2;
public final static int WARN = 3;
public final static int ERROR = 4;
public final static int FATAL = 5;
/**
* generate a message for loglevel DEBUG
* @param pObject the message Object
*/
public void debug(Object pObject);
/**
* generate a message for loglevel INFO
* @param pObject the message Object
*/
public void info(Object pObject);
/**
* generate a message for loglevel WARN
* @param pObject the message Object
*/
public void warn(Object pObject);
/**
* generate a message for loglevel ERROR
* @param pObject the message Object
*/
public void error(Object pObject);
/**
* generate a message for loglevel FATAL
* @param pObject the message Object
*/
public void fatal(Object pObject);
public void debug(Object message, Throwable obj);
public void info(Object message, Throwable obj);
public void warn(Object message, Throwable obj);
public void error(Object message, Throwable obj);
public void fatal(Object message, Throwable obj);
public boolean isEnabledFor(int priority);
public boolean isDebugEnabled();
/**
* returns the name of the logger isntance
*/
public String getName();
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : DEBUG
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeDebug(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : DEBUG
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeDebug(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : INFO
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeInfo(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : INFO
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeInfo(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : WARN
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeWarn(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : WARN
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeWarn(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : ERROR
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeError(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : ERROR
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeError(String message, Object obj, Throwable t);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : FATAL
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeFatal(String message, Object obj);
/**
* Exception safe log method.
* This method can be used to prevent any exception thrown by obj.toString() implementations.
* Log level used : FATAL
* @deprecated The normal logging methods should always be safe with regard to exceptions
* that are thrown while accessing the arguments.
*/
public void safeFatal(String message, Object obj, Throwable t);
}
1.9 +29 -12 db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggingConfiguration.java
Index: LoggingConfiguration.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggingConfiguration.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LoggingConfiguration.java 23 Jun 2004 07:13:51 -0000 1.8
+++ LoggingConfiguration.java 14 Nov 2004 09:36:43 -0000 1.9
@@ -19,7 +19,6 @@
import java.util.Properties;
import org.apache.ojb.broker.util.ClassHelper;
-import org.apache.ojb.broker.util.configuration.impl.ConfigurationAbstractImpl;
/**
* Provides the configuration for the logging. Note that this is separated from the OJB
@@ -27,7 +26,7 @@
*
* @version $Id$
*/
-public class LoggingConfiguration extends ConfigurationAbstractImpl
+public class LoggingConfiguration
{
/** The commons-logging property denoting which log to use. This property
* is repeated here to avoid making this class dependent upon commons-logging */
@@ -48,13 +47,15 @@
private Class _loggerClass;
/** The config file for the logger */
private String _loggerConfigFile;
+ /** The configuration data */
+ protected Properties _properties;
/**
* Creates a new logging configuration object which automatically initializes itself.
*/
public LoggingConfiguration()
{
- super();
+ load();
}
/* (non-Javadoc)
@@ -71,7 +72,7 @@
String loggerClassName = null;
_loggerClass = null;
- properties = new Properties();
+ _properties = new Properties();
loggerClassName = getLoggerClass(System.getProperties());
_loggerConfigFile = getLoggerConfigFile(System.getProperties());
@@ -87,9 +88,9 @@
if (ojbLogPropFile != null)
{
bootLogger.debug("Found logging properties file "+OJB_LOGGING_PROPERTIES_FILE);
- properties.load(ojbLogPropFile);
- loggerClassName = getLoggerClass(properties);
- _loggerConfigFile = getLoggerConfigFile(properties);
+ _properties.load(ojbLogPropFile);
+ loggerClassName = getLoggerClass(_properties);
+ _loggerConfigFile = getLoggerConfigFile(_properties);
}
}
catch (Exception ex)
@@ -107,9 +108,9 @@
if (ojbLogPropFile != null)
{
- properties.load(ojbLogPropFile);
- loggerClassName = getLoggerClass(properties);
- _loggerConfigFile = getLoggerConfigFile(properties);
+ _properties.load(ojbLogPropFile);
+ loggerClassName = getLoggerClass(_properties);
+ _loggerConfigFile = getLoggerConfigFile(_properties);
if (loggerClassName != null)
{
// deprecation warning for after 1.0
@@ -124,7 +125,7 @@
{
try
{
- _loggerClass = Class.forName(loggerClassName);
+ _loggerClass = ClassHelper.getClass(loggerClassName);
}
catch (ClassNotFoundException ex)
{
@@ -198,6 +199,21 @@
return loggerConfigFile;
}
+ /**
+ * Returns the string value for the specified key. If no value for this key
+ * is found in the configuration <code>defaultValue</code> is returned.
+ *
+ * @param key The key
+ * @param defaultValue The default value
+ * @return The value for the key, or the <code>defaultValue</code>
+ */
+ private String getString(String key, String defaultValue)
+ {
+ String ret = _properties.getProperty(key);
+
+ return ret == null ? defaultValue : ret;
+ }
+
public String getLogLevel(String loggerName)
{
/*
@@ -205,6 +221,7 @@
use ROOT.LogLevel property to define global
default log level
*/
+
return getString(loggerName + ".LogLevel", getString("ROOT.LogLevel", OJB_DEFAULT_LOG_LEVEL));
}
1.20 +6 -17 db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java
Index: LoggerFactoryImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- LoggerFactoryImpl.java 8 Nov 2004 18:19:07 -0000 1.19
+++ LoggerFactoryImpl.java 14 Nov 2004 09:36:43 -0000 1.20
@@ -78,7 +78,7 @@
{
if (bootLogger == null)
{
- bootLogger = new PoorMansLoggerImpl("BOOT");
+ bootLogger = new PoorMansLoggerImpl("BOOT", null);
// allow user to set boot log level via system property
String level = System.getProperty("OJB.bootLogLevel", LoggingConfiguration.OJB_DEFAULT_LOG_LEVEL);
((PoorMansLoggerImpl) bootLogger).setLevel(level);
@@ -140,19 +140,9 @@
loggerClass = conf.getLoggerClass();
getBootLogger().debug("Using logger class " + loggerClass + " for " + loggerName);
- logger = (Logger) ClassHelper.newInstance(loggerClass, String.class, loggerName);
-
- // configure the logger
- try
- {
- getBootLogger().debug("Initializing logger instance " + loggerName);
- logger.configure(conf);
- }
- catch (Exception ex)
- {
- logger = getBootLogger();
- logger.error("[" + this.getClass().getName() + "] Could not initialize logger for class " + loggerClass.getName(), ex);
- }
+ logger = (Logger) ClassHelper.newInstance(loggerClass,
+ new Class[] { String.class, LoggingConfiguration.class },
+ new Object[] { loggerName, conf });
//cache it so we can get it faster the next time
cache.put(loggerName, logger);
@@ -160,8 +150,7 @@
catch (Throwable t)
{
logger = getBootLogger();
- logger.error("[" + this.getClass().getName() + "] Could not set logger for class '"
- + (loggerClass != null ? loggerClass.getName() : "null") + "'", t);
+ logger.error("[" + this.getClass().getName() + "] Could not set logger for class " + loggerClass.getName(), t);
}
return logger;
}
1.18 +6 -17 db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java
Index: Log4jLoggerImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Log4jLoggerImpl.java 23 Oct 2004 15:46:22 -0000 1.17
+++ Log4jLoggerImpl.java 14 Nov 2004 09:36:43 -0000 1.18
@@ -23,8 +23,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.PropertyConfigurator;
import org.apache.ojb.broker.util.ClassHelper;
-import org.apache.ojb.broker.util.configuration.Configuration;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
/**
* This is a Logger implementation based on Log4j.
@@ -129,7 +127,7 @@
}
}
- public Log4jLoggerImpl(String name)
+ public Log4jLoggerImpl(String name, LoggingConfiguration conf)
{
this.name = name;
logger = org.apache.log4j.Logger.getLogger(name);
@@ -143,6 +141,10 @@
{
if (logger == null)
{
+ if (!isLog4JConfigured())
+ {
+ initializeLog4JSubSystem(getName());
+ }
logger = org.apache.log4j.Logger.getLogger(name);
}
return logger;
@@ -419,17 +421,4 @@
{
return getLogger().isEnabledFor((Level) priorityMap.get(new Integer(priority)));
}
-
- /**
- * @see org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration config) throws ConfigurationException
- {
- if (!isLog4JConfigured())
- {
- LoggingConfiguration lc = (LoggingConfiguration) config;
- initializeLog4JSubSystem(lc.getLoggerConfigFile());
- }
- }
-
}
1.4 +25 -31 db-ojb/src/java/org/apache/ojb/broker/locking/LockMapRemoteImpl.java
Index: LockMapRemoteImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockMapRemoteImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockMapRemoteImpl.java 11 Nov 2004 23:39:01 -0000 1.3
+++ LockMapRemoteImpl.java 14 Nov 2004 09:36:44 -0000 1.4
@@ -28,9 +28,6 @@
import java.util.Collection;
import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.ojb.broker.util.configuration.Configurable;
-import org.apache.ojb.broker.util.configuration.Configuration;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
@@ -40,11 +37,32 @@
* @author Thomas Mahler
* @version $Id$
*/
-public class LockMapRemoteImpl implements LockMap, Configurable
+public class LockMapRemoteImpl implements LockMap
{
private Logger log = LoggerFactory.getLogger(LockMapRemoteImpl.class);
- private static URL lockservlet = null;
+ /** The URL of the lock servlet */
+ private String lockServletUrl = "http://127.0.0.1:8080/ojb-lockserver";
+
+ /**
+ * Returns the lock servlet url.
+ *
+ * @return The lock servlet url
+ */
+ public String getLockServletUrl()
+ {
+ return lockServletUrl;
+ }
+
+ /**
+ * Sets the lock servlet url.
+ *
+ * @param lockServletUrl The new lock servlet url
+ */
+ public void setLockServletUrl(String lockServletUrl)
+ {
+ this.lockServletUrl = lockServletUrl;
+ }
/**
* @see LockMap#getWriter(Object)
@@ -95,7 +113,7 @@
private HttpURLConnection getHttpUrlConnection()
throws MalformedURLException, IOException, ProtocolException
{
- URL lockserver = getLockserverUrl();
+ URL lockserver = new URL(lockServletUrl);
HttpURLConnection conn = (HttpURLConnection) lockserver.openConnection();
conn.setDoInput(true);
@@ -116,13 +134,6 @@
return requestBarr;
}
-
- private URL getLockserverUrl()
- {
- return lockservlet;
- }
-
-
/**
* @see LockMap#getReaders(Object)
*/
@@ -449,22 +460,5 @@
out.close();
conn.disconnect();
return result.booleanValue();
- }
-
- /**
- * @see org.apache.ojb.broker.util.configuration.Configurable#configure(org.apache.ojb.broker.util.configuration.Configuration)
- */
- public void configure(Configuration pConfig) throws ConfigurationException
- {
- String url = pConfig.getString("LockServletUrl", "http://127.0.0.1:8080/ojb-lockserver");
- try
- {
- lockservlet = new URL(url);
- }
- catch(MalformedURLException e)
- {
- throw new ConfigurationException("Invalid LockServlet Url was specified: " + url, e);
- }
-
}
}
1.4 +31 -6 db-ojb/src/java/org/apache/ojb/broker/locking/LockMapInMemoryImpl.java
Index: LockMapInMemoryImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockMapInMemoryImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockMapInMemoryImpl.java 11 Nov 2004 23:39:01 -0000 1.3
+++ LockMapInMemoryImpl.java 14 Nov 2004 09:36:44 -0000 1.4
@@ -42,12 +42,37 @@
*/
private HashMap locktable = new HashMap();
- private long m_lastCleanupAt = System.currentTimeMillis();
+ private long lastCleanupAt = System.currentTimeMillis();
private static long CLEANUP_FREQUENCY = 500; // 500 milliseconds.
private static int MAX_LOCKS_TO_CLEAN = 50;
+ /** The maximum time in milliseconds that a lock may be hold */
+ private long lockTimeout = 60000;
+
+ /**
+ * Returns the lock timeout, i.e. the maximum time in milliseconds
+ * that a lock may be hold
+ *
+ * @return The lock timeout
+ */
+ public long getLockTimeout()
+ {
+ return lockTimeout;
+ }
+
+ /**
+ * Sets the lock timeout.
+ *
+ * @param lockTimeout The new lock timeout
+ */
+ public void setLockTimeout(long lockTimeout)
+ {
+ this.lockTimeout = lockTimeout;
+ }
+
/**
- * @see LockMap#getWriter(Object)
+ * returns the LockEntry for the Writer of object obj.
+ * If now writer exists, null is returned.
*/
public LockEntry getWriter(Object resourceId)
{
@@ -309,10 +334,10 @@
private void checkTimedOutLocks()
{
- if(System.currentTimeMillis() - m_lastCleanupAt > CLEANUP_FREQUENCY)
+ if (System.currentTimeMillis() - lastCleanupAt > CLEANUP_FREQUENCY)
{
- removeTimedOutLocks(AbstractLockStrategy.DEFAULT_LOCK_TIMEOUT);
- m_lastCleanupAt = System.currentTimeMillis();
+ removeTimedOutLocks(lockTimeout);
+ lastCleanupAt = System.currentTimeMillis();
}
}
1.4 +0 -5 db-ojb/src/java/org/apache/ojb/broker/locking/AbstractLockStrategy.java
Index: AbstractLockStrategy.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/AbstractLockStrategy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractLockStrategy.java 11 Nov 2004 23:39:01 -0000 1.3
+++ AbstractLockStrategy.java 14 Nov 2004 09:36:44 -0000 1.4
@@ -26,11 +26,6 @@
public abstract class AbstractLockStrategy implements LockStrategy
{
/**
- * the timeout for lock entries
- */
- public static long DEFAULT_LOCK_TIMEOUT = 30000;
-
- /**
* the map holding all locks
*/
private LockMap lockMap;
1.54 +10 -8 db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java
Index: Criteria.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Criteria.java 25 Sep 2004 14:54:56 -0000 1.53
+++ Criteria.java 14 Nov 2004 09:36:44 -0000 1.54
@@ -28,9 +28,8 @@
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerFactory;
-import org.apache.ojb.broker.core.PersistenceBrokerConfiguration;
+import org.apache.ojb.broker.core.PersistenceBrokerImpl;
import org.apache.ojb.broker.metadata.FieldHelper;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
/**
* Persistent Criteria can be used to retrieve sets of objects based on their attributes
@@ -1038,13 +1037,16 @@
*/
private static int getSqlInLimit()
{
- try
+ // TODO: This is an ugly hack; the Criteria should not be dependant
+ // upon the OJB instance
+ String limit = (String)PersistenceBrokerFactory.getOjb().getComponentContainer().getProperty(
+ PersistenceBrokerImpl.class, "prefetchInLimit");
+
+ if (limit != null)
{
- PersistenceBrokerConfiguration config = (PersistenceBrokerConfiguration) PersistenceBrokerFactory
- .getConfigurator().getConfigurationFor(null);
- return config.getSqlInLimit();
+ return Integer.parseInt(limit);
}
- catch (ConfigurationException e)
+ else
{
return 200;
}
1.9 +1 -1 db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java
Index: DatabaseHandlingTask.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DatabaseHandlingTask.java 14 Aug 2004 20:09:38 -0000 1.8
+++ DatabaseHandlingTask.java 14 Nov 2004 09:36:44 -0000 1.9
@@ -750,7 +750,7 @@
PersistenceBrokerFactory.setOjb(_ojb);
MetadataManager metadataManager = _ojb.getMetadataManager();
- RepositoryPersistor persistor = new RepositoryPersistor();
+ RepositoryPersistor persistor = metadataManager.getRepositoryPersistor();
if (_repositoryFile != null)
{
1.2 +2 -3 db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyBase.java
Index: BatchStrategyBase.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BatchStrategyBase.java 14 Sep 2004 16:03:31 -0000 1.1
+++ BatchStrategyBase.java 14 Nov 2004 09:36:44 -0000 1.2
@@ -3,7 +3,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.Properties;
import org.apache.ojb.broker.OptimisticLockException;
import org.apache.ojb.broker.metadata.ClassDescriptor;
@@ -22,7 +21,7 @@
private BatchManager batchManager;
private ArrayList batchEntries = new ArrayList();
- public BatchStrategyBase(BatchManager batchManager, Properties configuration)
+ public BatchStrategyBase(BatchManager batchManager)
{
this.batchManager = batchManager;
}
1.2 +3 -4 db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyDefaultImpl.java
Index: BatchStrategyDefaultImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyDefaultImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BatchStrategyDefaultImpl.java 14 Sep 2004 16:03:31 -0000 1.1
+++ BatchStrategyDefaultImpl.java 14 Nov 2004 09:36:44 -0000 1.2
@@ -2,7 +2,6 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.CollectionDescriptor;
@@ -26,9 +25,9 @@
new TheSameTableTranspositionBan(),
};
- public BatchStrategyDefaultImpl(BatchManager batchManager, Properties configuration)
+ public BatchStrategyDefaultImpl(BatchManager batchManager)
{
- super(batchManager, configuration);
+ super(batchManager);
}
/**
1.2 +2 -2 db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyLeafImpl.java
Index: BatchStrategyLeafImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/batch/BatchStrategyLeafImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BatchStrategyLeafImpl.java 14 Sep 2004 16:03:31 -0000 1.1
+++ BatchStrategyLeafImpl.java 14 Nov 2004 09:36:44 -0000 1.2
@@ -21,7 +21,7 @@
private BatchManager batchManager;
private BatchEntry lastUsed;
- public BatchStrategyLeafImpl(BatchManager batchManager, Properties configuration)
+ public BatchStrategyLeafImpl(BatchManager batchManager)
{
this.batchManager = batchManager;
}
1.4 +6 -4 db-ojb/src/java/org/apache/ojb/broker/transaction/tm/AbstractTransactionManagerFactory.java
Index: AbstractTransactionManagerFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/transaction/tm/AbstractTransactionManagerFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractTransactionManagerFactory.java 8 Sep 2004 22:23:50 -0000 1.3
+++ AbstractTransactionManagerFactory.java 14 Nov 2004 09:36:44 -0000 1.4
@@ -33,15 +33,17 @@
public abstract class AbstractTransactionManagerFactory implements TransactionManagerFactory
{
- private static Logger log = LoggerFactory.getLogger(AbstractTransactionManagerFactory.class);
+ private Logger log = LoggerFactory.getLogger(AbstractTransactionManagerFactory.class);
/**
* Returns "getTransactionManager";
*/
public static String TM_DEFAULT_METHOD_NAME = "getTransactionManager";
-
- private static TransactionManager tm = null;
+ // [tomdz] Changed from static to instance because the three possible users
+ // of this factory (PBFSyncImpl, JTATxManager, ManagedTransactionFactory)
+ // all hold an instance of this factory
+ private TransactionManager tm = null;
/**
* Returns an array of possible JNDI lookup / class names for
1.30 +2 -3 db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHighLowImpl.java
Index: SequenceManagerHighLowImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHighLowImpl.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- SequenceManagerHighLowImpl.java 4 Apr 2004 23:53:38 -0000 1.29
+++ SequenceManagerHighLowImpl.java 14 Nov 2004 09:36:44 -0000 1.30
@@ -18,7 +18,6 @@
import org.apache.commons.lang.SystemUtils;
import org.apache.ojb.broker.OptimisticLockException;
import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.broker.PersistenceBrokerFactory;
import org.apache.ojb.broker.metadata.FieldDescriptor;
import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.Query;
@@ -187,7 +186,7 @@
Thus we use a new internBroker instance (with new connection) to
avoid this problem.
*/
- internBroker = PersistenceBrokerFactory.createPersistenceBroker(brokerForSequence.getPBKey());
+ internBroker = brokerForSequence.getConfiguration().createPersistenceBroker();
internBroker.beginTransaction();
newSequence = lookupStoreSequence(internBroker, field, sequenceName);
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org