You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2010/02/18 18:23:07 UTC
svn commit: r911496 - in /openjpa/trunk/openjpa-jdbc/src/main:
java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
resources/org/apache/openjpa/jdbc/kernel/localizer.properties
Author: ppoddar
Date: Thu Feb 18 17:23:06 2010
New Revision: 911496
URL: http://svn.apache.org/viewvc?rev=911496&view=rev
Log:
OPENJPA-924: Remove logging from FinderCache -- such low-level details seem to confuse rather to inform the user.
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java?rev=911496&r1=911495&r2=911496&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java Thu Feb 18 17:23:06 2010
@@ -29,7 +29,6 @@
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang.StringUtils;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
import org.apache.openjpa.jdbc.meta.ClassMapping;
import org.apache.openjpa.jdbc.sql.Result;
import org.apache.openjpa.jdbc.sql.SelectExecutor;
@@ -39,8 +38,6 @@
import org.apache.openjpa.kernel.QueryHints;
import org.apache.openjpa.kernel.QueryStatistics;
import org.apache.openjpa.lib.conf.Configuration;
-import org.apache.openjpa.lib.log.Log;
-import org.apache.openjpa.lib.util.Localizer;
/**
* Implementation of FinderCache for JDBC.
@@ -55,20 +52,15 @@
private static final String PATTERN_SEPARATOR = "\\;";
private static final String EXLUDED_BY_USER = "Excluded by user";
- private final Map<ClassMapping,
- FinderQuery<ClassMapping, SelectExecutor, Result>> _delegate;
+ private final Map<ClassMapping, FinderQuery<ClassMapping, SelectExecutor, Result>> _delegate;
// Key: class name Value: Reason why excluded
private final Map<String, String> _uncachables;
private List<String> _exclusionPatterns;
private QueryStatistics<ClassMapping> _stats;
private ReentrantLock _lock = new ReentrantLock();
- private Log _log;
- private Localizer _loc = Localizer.forPackage(FinderCacheImpl.class);
-
public FinderCacheImpl() {
- _delegate = new HashMap<ClassMapping,
- FinderQuery<ClassMapping, SelectExecutor, Result>>();
+ _delegate = new HashMap<ClassMapping, FinderQuery<ClassMapping, SelectExecutor, Result>>();
_uncachables = new HashMap<String, String>();
_stats = new QueryStatistics.Default<ClassMapping>();
}
@@ -82,9 +74,10 @@
lock();
try {
Map<String, String> view = new TreeMap<String, String>();
- for (ClassMapping mapping : _delegate.keySet())
+ for (ClassMapping mapping : _delegate.keySet()) {
view.put(mapping.getDescribedType().getName(),
_delegate.get(mapping).getQueryString());
+ }
return view;
} finally {
unlock();
@@ -110,16 +103,18 @@
*/
public FinderQuery<ClassMapping,SelectExecutor,Result>
get(ClassMapping mapping, FetchConfiguration fetch) {
- if (fetch.getReadLockLevel() != 0)
+ if (fetch.getReadLockLevel() != 0) {
return null;
+ }
boolean ignore = isHinted(fetch, QueryHints.HINT_IGNORE_FINDER);
boolean invalidate = isHinted(fetch, QueryHints.HINT_INVALIDATE_FINDER);
- if (invalidate)
+ if (invalidate) {
invalidate(mapping);
- if (ignore)
+ }
+ if (ignore) {
return null;
- FinderQuery<ClassMapping, SelectExecutor, Result> result =
- _delegate.get(mapping);
+ }
+ FinderQuery<ClassMapping, SelectExecutor, Result> result = _delegate.get(mapping);
_stats.recordExecution(mapping);
return result;
}
@@ -145,8 +140,9 @@
(ClassMapping mapping, SelectExecutor select, FetchConfiguration fetch) {
lock();
try {
- if (fetch.getReadLockLevel() != 0)
+ if (fetch.getReadLockLevel() != 0) {
return null;
+ }
boolean recache = isHinted(fetch, QueryHints.HINT_RECACHE_FINDER);
if (isExcluded(mapping)) {
return recache ? put(mapping, select) : null;
@@ -167,18 +163,11 @@
* some Select are not cached), then the mapping is marked invalid.
*
*/
- private FinderQuery<ClassMapping, SelectExecutor, Result> put
- (ClassMapping mapping, SelectExecutor select) {
- FinderQuery<ClassMapping, SelectExecutor, Result> finder =
- FinderQueryImpl.newFinder(mapping, select);
+ private FinderQuery<ClassMapping, SelectExecutor, Result> put(ClassMapping mapping, SelectExecutor select) {
+ FinderQuery<ClassMapping, SelectExecutor, Result> finder = FinderQueryImpl.newFinder(mapping, select);
if (finder != null) {
_delegate.put(mapping, finder);
- if (_log != null && _log.isTraceEnabled())
- _log.trace(_loc.get("finder-cached", mapping,
- finder.getQueryString()));
} else {
- if (_log != null && _log.isWarnEnabled())
- _log.warn(_loc.get("finder-not-cachable", mapping));
invalidate(mapping);
}
return finder;
@@ -188,8 +177,7 @@
* Affirms if the given mapping is excluded from being cached.
*/
public boolean isExcluded(ClassMapping mapping) {
- return mapping != null &&
- isExcluded(mapping.getDescribedType().getName());
+ return mapping != null && isExcluded(mapping.getDescribedType().getName());
}
/**
@@ -214,10 +202,6 @@
_exclusionPatterns.add(pattern);
Collection<ClassMapping> invalidMappings = getMatchedKeys(pattern,
_delegate.keySet());
- if (!invalidMappings.isEmpty()
- && _log != null && _log.isInfoEnabled())
- _log.info(_loc.get("finder-add-pattern", pattern,
- invalidMappings.size(), invalidMappings));
for (ClassMapping invalidMapping : invalidMappings)
markUncachable(invalidMapping, pattern);
} finally {
@@ -237,9 +221,6 @@
_exclusionPatterns.remove(pattern);
Collection<String> reborns = getMatchedKeys(pattern,
_uncachables.keySet());
- if (!reborns.isEmpty() && _log != null && _log.isInfoEnabled())
- _log.info(_loc.get("finder-remove-pattern", pattern,
- reborns.size(), reborns));
for (String rebornKey : reborns)
_uncachables.remove(rebornKey);
} finally {
@@ -262,8 +243,7 @@
/**
* Gets the elements of the given set that match the given pattern.
*/
- private Collection<ClassMapping> getMatchedKeys(String pattern,
- Set<ClassMapping> set) {
+ private Collection<ClassMapping> getMatchedKeys(String pattern, Set<ClassMapping> set) {
List<ClassMapping> result = new ArrayList<ClassMapping>();
for (ClassMapping entry : set) {
if (matches(pattern, entry)) {
@@ -276,8 +256,7 @@
/**
* Gets the elements of the given list which match the given pattern.
*/
- private Collection<String> getMatchedKeys(String pattern,
- Collection<String> coll) {
+ private Collection<String> getMatchedKeys(String pattern, Collection<String> coll) {
List<String> result = new ArrayList<String>();
for (String key : coll) {
if (matches(pattern, key)) {
@@ -299,58 +278,39 @@
public boolean invalidate(ClassMapping mapping) {
lock();
try {
- if (_log.isTraceEnabled())
- _log.trace(_loc.get("finder-invalidate", mapping));
return _delegate.remove(mapping) != null;
} finally {
unlock();
}
}
- public FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(
- ClassMapping mapping) {
+ public FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(ClassMapping mapping) {
return markUncachable(mapping.getDescribedType().getName());
}
- public FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(
- String id) {
+ public FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(String id) {
return markUncachable(id, EXLUDED_BY_USER);
}
- private FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(
- String cls, String reason) {
+ private FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(String cls, String reason) {
lock();
try {
boolean excludedByUser = _uncachables.get(cls) == EXLUDED_BY_USER;
if (!excludedByUser)
_uncachables.put(cls, reason);
- if (_log != null && _log.isInfoEnabled()) {
- if (excludedByUser)
- _log.info(_loc.get("finder-uncache-strong", cls));
- else
- _log.info(_loc.get("finder-uncache-weak", cls,
- reason));
- }
return _delegate.remove(searchMappingByName(cls));
} finally {
unlock();
}
}
- private FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(
- ClassMapping mapping, String reason) {
+ private FinderQuery<ClassMapping, SelectExecutor, Result> markUncachable(ClassMapping mapping, String reason) {
lock();
try {
String cls = mapping.getDescribedType().getName();
boolean excludedByUser = _uncachables.get(cls) == EXLUDED_BY_USER;
if (!excludedByUser)
_uncachables.put(cls, reason);
- if (_log != null && _log.isInfoEnabled()) {
- if (excludedByUser)
- _log.info(_loc.get("finder-uncache-strong", cls));
- else
- _log.info(_loc.get("finder-uncache-weak", cls, reason));
- }
return _delegate.remove(mapping);
} finally {
unlock();
@@ -411,10 +371,8 @@
}
public void setConfiguration(Configuration conf) {
- _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
}
public void endConfiguration() {
}
-
}
Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties?rev=911496&r1=911495&r2=911496&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties Thu Feb 18 17:23:06 2010
@@ -135,10 +135,6 @@
positions {2} in the parameter list of the prepared query is not compatible.
uparam-missing: Parameter {0} in SQL Query "{1}" is not given a value. The \
parameters given is "{2}".
-finder-cached: Cached finder for "{0}" SQL: "{1}"
-finder-not-cachable: Finder for "{0}" is not cachable.
-finder-add-pattern: Exclusion pattern "{0}" for finder query has invalidated \
- {1} existing entries "{2}"
optimistic-violation-lock: An optimistic lock violation was detected when \
locking object instance.
sql-warning: The statement resulted in SQL warning: {0}