Permalink
Browse files

MODE-1462 - Updated logging:

- moved all logging classes to common.logging instead of common.util
- added logging factory  & logger for pure Log4j support
- changed logging dependencies scope from <compile> to <provided>
- added a logger abstraction in modeshape-jcr-api and an implementation in modeshape-jcr which should be used for extensions
- updated Sequencer and TextExtractor base classes so that upon creation, they are provided with the extension logger
  • Loading branch information...
1 parent fbff7fe commit abac784a829855b4bd008eff0663bcd521707f6b @hchiorean hchiorean committed May 29, 2012
Showing with 781 additions and 473 deletions.
  1. +0 −13 demos/embedded-repo/pom.xml
  2. +2 −0 demos/sequencers/pom.xml
  3. +1 −1 ...ssas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java
  4. +4 −1 deploy/jbossas/modeshape-jbossas-web-rest-war/pom.xml
  5. +4 −4 modeshape-common/src/main/java/org/modeshape/common/collection/AbstractProblems.java
  6. +1 −1 modeshape-common/src/main/java/org/modeshape/common/collection/ImmutableProblems.java
  7. +1 −1 modeshape-common/src/main/java/org/modeshape/common/collection/Problem.java
  8. +1 −1 modeshape-common/src/main/java/org/modeshape/common/collection/Problems.java
  9. +3 −4 modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java
  10. +53 −0 modeshape-common/src/main/java/org/modeshape/common/i18n/I18nResource.java
  11. +38 −12 modeshape-common/src/main/java/org/modeshape/common/{util/log → logging}/LogFactory.java
  12. +27 −50 modeshape-common/src/main/java/org/modeshape/common/{util → logging}/Logger.java
  13. +4 −7 modeshape-common/src/main/java/org/modeshape/common/{util/log → logging/jdk}/JdkLoggerFactory.java
  14. +15 −16 modeshape-common/src/main/java/org/modeshape/common/{util/log → logging/jdk}/JdkLoggerImpl.java
  15. +14 −26 .../util/LogContextTest.java → main/java/org/modeshape/common/logging/log4j/Log4jLoggerFactory.java}
  16. +166 −0 modeshape-common/src/main/java/org/modeshape/common/logging/log4j/Log4jLoggerImpl.java
  17. +4 −8 ...hape-common/src/main/java/org/modeshape/common/{util/log → logging/slf4j}/SLF4JLoggerFactory.java
  18. +22 −21 modeshape-common/src/main/java/org/modeshape/common/{util/log → logging/slf4j}/SLF4JLoggerImpl.java
  19. +0 −116 modeshape-common/src/main/java/org/modeshape/common/util/LogContext.java
  20. +4 −1 modeshape-common/src/main/java/org/modeshape/common/util/MimeTypeUtil.java
  21. +4 −4 modeshape-common/src/test/java/org/modeshape/common/{util → logging}/LoggerTest.java
  22. +1 −2 modeshape-common/src/test/java/org/modeshape/common/statistic/DetailedStatisticsTest.java
  23. +1 −2 modeshape-common/src/test/java/org/modeshape/common/statistic/HistogramTest.java
  24. +1 −1 modeshape-common/src/test/java/org/modeshape/common/util/SecureHashTest.java
  25. 0 modeshape-common/src/test/resources/org/modeshape/common/{util → logging}/LoggerTest.properties
  26. +143 −0 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/Logger.java
  27. +6 −0 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java
  28. +12 −5 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/text/TextExtractor.java
  29. +0 −4 modeshape-jcr-tck/pom.xml
  30. +0 −4 modeshape-jcr/pom.xml
  31. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
  32. +143 −0 modeshape-jcr/src/main/java/org/modeshape/jcr/ExtensionLogger.java
  33. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrEngine.java
  34. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeManager.java
  35. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrObservationManager.java
  36. +2 −2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java
  37. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepositoryFactory.java
  38. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java
  39. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/JndiRepositoryFactory.java
  40. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShape.java
  41. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java
  42. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryLockManager.java
  43. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java
  44. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
  45. +4 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java
  46. +3 −2 modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java
  47. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/SystemContent.java
  48. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/SystemNamespaceRegistry.java
  49. +3 −2 modeshape-jcr/src/main/java/org/modeshape/jcr/TextExtractors.java
  50. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/bus/ClusteredRepositoryChangeBus.java
  51. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java
  52. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WritableSessionCache.java
  53. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/query/lucene/LuceneProcessingContext.java
  54. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/query/lucene/LuceneQueryEngine.java
  55. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/query/lucene/basic/BasicLuceneSchema.java
  56. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RuleBasedOptimizer.java
  57. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/security/AuthenticationProviders.java
  58. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/security/JaasProvider.java
  59. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/security/JaasSecurityContext.java
  60. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/security/JaccSubjectResolver.java
  61. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/text/NoOpTextExtractor.java
  62. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/value/basic/StringValueFactory.java
  63. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/FileSystemBinaryStore.java
  64. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/TransientBinaryStore.java
  65. +1 −1 modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/UnusedBinaryChangeSetListener.java
  66. +1 −1 modeshape-jcr/src/main/java/org/modeshape/sequencer/cnd/CndSequencer.java
  67. +1 −1 modeshape-jcr/src/test/java/org/modeshape/jcr/AbstractSchematicDbTest.java
  68. +1 −1 modeshape-jcr/src/test/java/org/modeshape/jcr/TestingUtil.java
  69. +3 −3 modeshape-jdbc-local/pom.xml
  70. +1 −1 modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/LocalJcrDriver.java
  71. +1 −1 modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/AbstractRepositoryDelegate.java
  72. +12 −17 modeshape-parent/pom.xml
  73. +0 −4 modeshape-schematic/pom.xml
  74. +0 −14 modeshape-unit-test/pom.xml
  75. +1 −1 sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlSequencer.java
  76. +2 −5 ...odeshape-sequencer-images/src/main/java/org/modeshape/sequencer/image/ImageMetadataSequencer.java
  77. +1 −5 ...rs/modeshape-sequencer-java/src/main/java/org/modeshape/sequencer/javafile/JavaFileSequencer.java
  78. +1 −5 ...ncers/modeshape-sequencer-mp3/src/main/java/org/modeshape/sequencer/mp3/Mp3MetadataSequencer.java
  79. +2 −3 ...modeshape-sequencer-msoffice/src/main/java/org/modeshape/sequencer/msoffice/MSOfficeMetadata.java
  80. +1 −5 ...-sequencer-msoffice/src/main/java/org/modeshape/sequencer/msoffice/MSOfficeMetadataSequencer.java
  81. +1 −1 ...pe-sequencer-msoffice/src/main/java/org/modeshape/sequencer/msoffice/word/WordMetadataReader.java
  82. +2 −0 ...odeshape-sequencer-sramp/src/main/java/org/modeshape/sequencer/sramp/AbstractResolvingReader.java
  83. +1 −4 ...rs/modeshape-sequencer-text/src/main/java/org/modeshape/sequencer/text/AbstractTextSequencer.java
  84. +2 −2 sequencers/modeshape-sequencer-wsdl/src/main/java/org/modeshape/sequencer/wsdl/Wsdl11Reader.java
  85. +2 −6 sequencers/modeshape-sequencer-wsdl/src/main/java/org/modeshape/sequencer/wsdl/WsdlReader.java
  86. +4 −8 sequencers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencer.java
  87. +4 −5 ...encers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java
  88. +14 −18 sequencers/modeshape-sequencer-xsd/src/main/java/org/modeshape/sequencer/xsd/XsdReader.java
  89. +1 −5 sequencers/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipSequencer.java
  90. +2 −9 sequencers/pom.xml
  91. +3 −6 web/modeshape-web-jcr-rest-war/pom.xml
View
13 demos/embedded-repo/pom.xml
@@ -30,19 +30,6 @@
<artifactId>picketbox-bare</artifactId>
<scope>compile</scope>
</dependency>
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
<!-- Testing (note the scope) -->
<dependency>
<groupId>junit</groupId>
View
2 demos/sequencers/pom.xml
@@ -50,10 +50,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
+ <scope>runtime</scope>
</dependency>
<!--
Java Content Repository API
View
2 ...eshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java
@@ -41,7 +41,7 @@
import org.jboss.msc.value.InjectedValue;
import org.jgroups.Channel;
import org.modeshape.common.collection.Problems;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jboss.subsystem.MappedAttributeDefinition;
import org.modeshape.jcr.ConfigurationException;
import org.modeshape.jcr.Environment;
View
5 deploy/jbossas/modeshape-jbossas-web-rest-war/pom.xml
@@ -23,10 +23,13 @@
<artifactId>modeshape-web-jcr-rest</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
View
8 modeshape-common/src/main/java/org/modeshape/common/collection/AbstractProblems.java
@@ -29,8 +29,8 @@
import java.util.List;
import org.modeshape.common.collection.Problem.Status;
import org.modeshape.common.i18n.I18n;
-import org.modeshape.common.util.Logger;
-import org.modeshape.common.util.Logger.Level;
+import org.modeshape.common.logging.Logger;
+import org.modeshape.common.logging.Logger.Level;
/**
* A list of problems for some execution context. The problems will be {@link #iterator() returned} in the order in which they
@@ -321,7 +321,7 @@ public int size() {
/**
* {@inheritDoc}
*
- * @see org.modeshape.common.collection.Problems#writeTo(org.modeshape.common.util.Logger)
+ * @see org.modeshape.common.collection.Problems#writeTo(org.modeshape.common.logging.Logger)
*/
@Override
public void writeTo( Logger logger ) {
@@ -336,7 +336,7 @@ public void writeTo( Logger logger ) {
/**
* {@inheritDoc}
*
- * @see org.modeshape.common.collection.Problems#writeTo(org.modeshape.common.util.Logger,
+ * @see org.modeshape.common.collection.Problems#writeTo(org.modeshape.common.logging.Logger,
* org.modeshape.common.collection.Problem.Status,org.modeshape.common.collection.Problem.Status[])
*/
@Override
View
2 modeshape-common/src/main/java/org/modeshape/common/collection/ImmutableProblems.java
@@ -28,7 +28,7 @@
import org.modeshape.common.collection.Problem.Status;
import org.modeshape.common.i18n.I18n;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
/**
* An immutable wrapper for a mutable {@link Problems}.
View
2 modeshape-common/src/main/java/org/modeshape/common/collection/Problem.java
@@ -27,7 +27,7 @@
import org.modeshape.common.i18n.I18n;
import org.modeshape.common.util.CheckArg;
import org.modeshape.common.util.HashCode;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
/**
* An immutable representation of a problem, with a status, code, internationalized and parameterized message, values for the
View
2 modeshape-common/src/main/java/org/modeshape/common/collection/Problems.java
@@ -27,7 +27,7 @@
import java.util.Iterator;
import org.modeshape.common.collection.Problem.Status;
import org.modeshape.common.i18n.I18n;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
/**
* An interface for a collection of {@link Problem} objects, with multiple overloaded methods for adding errors, warnings, and
View
7 modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java
@@ -43,18 +43,17 @@
import org.modeshape.common.SystemFailureException;
import org.modeshape.common.util.CheckArg;
import org.modeshape.common.util.ClassUtil;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.StringUtil;
-import org.modeshape.common.util.log.LogFactory;
/**
* An internalized string object, which manages the initialization of internationalization (i18n) files, substitution of values
* within i18n message placeholders, and dynamically reading properties from i18n property files.
*/
@ThreadSafe
-public final class I18n {
+public final class I18n implements I18nResource {
- private static final Logger LOGGER = LogFactory.getLogFactory().getLogger(I18n.class);
+ private static final Logger LOGGER = Logger.getLogger(I18n.class);
private static final LocalizationRepository DEFAULT_LOCALIZATION_REPOSITORY = new ClasspathLocalizationRepository();
View
53 modeshape-common/src/main/java/org/modeshape/common/i18n/I18nResource.java
@@ -0,0 +1,53 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.common.i18n;
+
+import java.util.Locale;
+
+/**
+ * Interface which should be implemented by any i18n compliant resource.
+ *
+ * @author Horia Chiorean
+ */
+public interface I18nResource {
+
+ /**
+ * Get the localized text for the {@link Locale#getDefault() current (default) locale}, replacing the parameters in the text
+ * with those supplied.
+ *
+ * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
+ * @return the localized text
+ */
+ public String text(Object...arguments);
+
+ /**
+ * Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.
+ *
+ * @param locale the locale, or <code>null</code> if the {@link Locale#getDefault() current (default) locale} should be used
+ * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
+ * @return the localized text
+ */
+ public String text(Locale locale, Object...arguments);
+}
View
50 ...modeshape/common/util/log/LogFactory.java → .../modeshape/common/logging/LogFactory.java
@@ -22,32 +22,56 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-/**
- * The abstract class for the LogFactory, which is called to create a specific implementation of the @link Logger.
- */
-
-package org.modeshape.common.util.log;
+package org.modeshape.common.logging;
import org.modeshape.common.util.ClassUtil;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.jdk.JdkLoggerFactory;
+import org.modeshape.common.logging.log4j.Log4jLoggerFactory;
+import org.modeshape.common.logging.slf4j.SLF4JLoggerFactory;
+/**
+ * The abstract class for the LogFactory, which is called to create a specific implementation of the {@link Logger}.
+ */
public abstract class LogFactory {
private static LogFactory LOGFACTORY;
static {
+ if (isSLF4JAvailable()) {
+ LOGFACTORY = new SLF4JLoggerFactory();
+ }
+ else if (isLog4jAvailable()) {
+ LOGFACTORY = new Log4jLoggerFactory();
+ }
+ else {
+ LOGFACTORY = new JdkLoggerFactory();
+ }
+ }
+
+ private static boolean isSLF4JAvailable() {
try {
+ //check if the api is in the classpath
ClassUtil.loadClassStrict("org.slf4j.LoggerFactory");
ClassUtil.loadClassStrict("org.slf4j.Logger");
- LOGFACTORY = new SLF4JLoggerFactory();
- } catch (ClassNotFoundException cnfe) {
- LOGFACTORY = new JdkLoggerFactory();
+ //check if there's at least one implementation
+ ClassUtil.loadClassStrict("org.slf4j.impl.StaticLoggerBinder");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
}
+ }
+ private static boolean isLog4jAvailable() {
+ try {
+ ClassUtil.loadClassStrict("org.apache.log4j.Logger");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
}
- public static LogFactory getLogFactory() {
+ static LogFactory getLogFactory() {
return LOGFACTORY;
}
@@ -57,14 +81,16 @@ public static LogFactory getLogFactory() {
* @param clazz the returned logger will be named after clazz
* @return logger
*/
- public abstract Logger getLogger( Class<?> clazz );
+ Logger getLogger( Class<?> clazz ) {
+ return Logger.getLogger(clazz.getName());
+ }
/**
* Return a logger named according to the name parameter.
*
* @param name The name of the logger.
* @return logger
*/
- public abstract Logger getLogger( String name );
+ protected abstract Logger getLogger( String name );
}
View
77 ...ava/org/modeshape/common/util/Logger.java → .../org/modeshape/common/logging/Logger.java
@@ -21,48 +21,40 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util;
+package org.modeshape.common.logging;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
import org.modeshape.common.annotation.ThreadSafe;
-import org.modeshape.common.i18n.I18n;
-import org.modeshape.common.util.log.LogFactory;
+import org.modeshape.common.i18n.I18nResource;
/**
- * A simple logging interface that is fully compatible with multiple logging implementations. If no log4j implementation is found,
- * then its defaulted to the JDK Logger implementation. This interface does take advantage of the variable arguments and
+ * A simple logging interface that is fully compatible with multiple logging implementations. If no specific logging implementation
+ * is found, then its defaulted to the JDK Logger implementation. This interface does take advantage of the variable arguments and
* autoboxing features in Java 5, reducing the number of methods that are necessary and allowing callers to supply primitive
* values as parameters.
*/
@ThreadSafe
public abstract class Logger {
- static final LogFactory LOG_FACTORY;
-
public enum Level {
OFF,
ERROR,
WARNING,
INFO,
DEBUG,
- TRACE;
- }
-
- static {
- LOG_FACTORY = LogFactory.getLogFactory();
-
+ TRACE
}
- protected static final AtomicReference<Locale> LOGGING_LOCALE = new AtomicReference<Locale>(null);
+ private static final AtomicReference<Locale> LOGGING_LOCALE = new AtomicReference<Locale>(null);
/**
* Get the locale used for the logs. If null, the {@link Locale#getDefault() default locale} is used.
*
* @return the current locale used for logging, or null if the system locale is used
* @see #setLoggingLocale(Locale)
*/
- public static Locale getLoggingLocale() {
+ public Locale getLoggingLocale() {
return LOGGING_LOCALE.get();
}
@@ -85,7 +77,7 @@ public static Locale setLoggingLocale( Locale locale ) {
* @return logger
*/
public static Logger getLogger( Class<?> clazz ) {
- return LOG_FACTORY.getLogger(clazz);
+ return LogFactory.getLogFactory().getLogger(clazz);
}
/**
@@ -95,7 +87,7 @@ public static Logger getLogger( Class<?> clazz ) {
* @return logger
*/
public static Logger getLogger( String name ) {
- return LOG_FACTORY.getLogger(name);
+ return LogFactory.getLogFactory().getLogger(name);
}
/**
@@ -106,7 +98,7 @@ public static Logger getLogger( String name ) {
public abstract String getName();
/**
- * Log a message at the suplied level according to the specified format and (optional) parameters. The message should contain
+ * Log a message at the supplied level according to the specified format and (optional) parameters. The message should contain
* a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
* efficient and avoids superfluous object creation when the logger is disabled for the desired level.
*
@@ -115,7 +107,7 @@ public static Logger getLogger( String name ) {
* @param params the parameter values that are to replace the variables in the format string
*/
public void log( Level level,
- I18n message,
+ I18nResource message,
Object... params ) {
if (message == null) return;
switch (level) {
@@ -150,7 +142,7 @@ public void log( Level level,
*/
public void log( Level level,
Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
if (message == null) return;
switch (level) {
@@ -201,46 +193,46 @@ public abstract void debug( Throwable t,
* Log a message at the ERROR level according to the specified format and (optional) parameters. The message should contain a
* pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
* and avoids superfluous object creation when the logger is disabled for the ERROR level.
- *
+ *
* @param message the message string
* @param params the parameter values that are to replace the variables in the format string
*/
- public abstract void error( I18n message,
+ public abstract void error( I18nResource message,
Object... params );
/**
* Log an exception (throwable) at the ERROR level with an accompanying message. If the exception is null, then this method
- * calls {@link #error(I18n, Object...)}.
- *
+ * calls {@link #error(org.modeshape.common.i18n.I18nResource, Object...)}.
+ *
* @param t the exception (throwable) to log
* @param message the message accompanying the exception
* @param params the parameter values that are to replace the variables in the format string
*/
public abstract void error( Throwable t,
- I18n message,
+ I18nResource message,
Object... params );
/**
* Log a message at the INFO level according to the specified format and (optional) parameters. The message should contain a
* pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
* and avoids superfluous object creation when the logger is disabled for the INFO level.
- *
+ *
* @param message the message string
* @param params the parameter values that are to replace the variables in the format string
*/
- public abstract void info( I18n message,
+ public abstract void info( I18nResource message,
Object... params );
/**
* Log an exception (throwable) at the INFO level with an accompanying message. If the exception is null, then this method
- * calls {@link #info(I18n, Object...)}.
- *
+ * calls {@link #info(org.modeshape.common.i18n.I18nResource, Object...)}.
+ *
* @param t the exception (throwable) to log
* @param message the message accompanying the exception
* @param params the parameter values that are to replace the variables in the format string
*/
public abstract void info( Throwable t,
- I18n message,
+ I18nResource message,
Object... params );
/**
@@ -270,23 +262,23 @@ public abstract void trace( Throwable t,
* Log a message at the WARNING level according to the specified format and (optional) parameters. The message should contain
* a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
* efficient and avoids superfluous object creation when the logger is disabled for the WARNING level.
- *
+ *
* @param message the message string
* @param params the parameter values that are to replace the variables in the format string
*/
- public abstract void warn( I18n message,
+ public abstract void warn( I18nResource message,
Object... params );
/**
* Log an exception (throwable) at the WARNING level with an accompanying message. If the exception is null, then this method
- * calls {@link #warn(I18n, Object...)}.
- *
+ * calls {@link #warn(org.modeshape.common.i18n.I18nResource, Object...)}.
+ *
* @param t the exception (throwable) to log
* @param message the message accompanying the exception
* @param params the parameter values that are to replace the variables in the format string
*/
public abstract void warn( Throwable t,
- I18n message,
+ I18nResource message,
Object... params );
/**
@@ -323,19 +315,4 @@ public abstract void warn( Throwable t,
* @return true if TRACE log messages are currently being logged, or false otherwise.
*/
public abstract boolean isTraceEnabled();
-
- /**
- * Get the logging level at which this logger is current set.
- *
- * @return the current logging level
- */
- public Level getLevel() {
- if (this.isTraceEnabled()) return Level.TRACE;
- if (this.isDebugEnabled()) return Level.DEBUG;
- if (this.isInfoEnabled()) return Level.INFO;
- if (this.isWarnEnabled()) return Level.WARNING;
- if (this.isErrorEnabled()) return Level.ERROR;
- return Level.OFF;
- }
-
}
View
11 ...ape/common/util/log/JdkLoggerFactory.java → .../common/logging/jdk/JdkLoggerFactory.java
@@ -21,21 +21,18 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util.log;
+package org.modeshape.common.logging.jdk;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
+import org.modeshape.common.logging.LogFactory;
/**
* Factory used to create the {@link Logger} implementation that uses the JDK logging framework.
*/
public final class JdkLoggerFactory extends LogFactory {
- @Override
- public Logger getLogger( Class<?> clazz ) {
- return getLogger(clazz.getName());
- }
@Override
- public Logger getLogger( String name ) {
+ protected Logger getLogger( String name ) {
return new JdkLoggerImpl(name);
}
}
View
31 ...eshape/common/util/log/JdkLoggerImpl.java → ...ape/common/logging/jdk/JdkLoggerImpl.java
@@ -22,18 +22,18 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util.log;
+package org.modeshape.common.logging.jdk;
import java.util.logging.Logger;
-import org.modeshape.common.i18n.I18n;
+import org.modeshape.common.i18n.I18nResource;
import org.modeshape.common.util.StringUtil;
/**
* Logger that delivers messages to a JDK logger
*
* @since 2.5
*/
-public class JdkLoggerImpl extends org.modeshape.common.util.Logger {
+final class JdkLoggerImpl extends org.modeshape.common.logging.Logger {
private final java.util.logging.Logger logger;
@@ -107,29 +107,29 @@ public void debug( Throwable t,
}
@Override
- public void error( I18n message,
+ public void error( I18nResource message,
Object... params ) {
- log(java.util.logging.Level.SEVERE, message.text(LOGGING_LOCALE.get(), params), null);
+ log(java.util.logging.Level.SEVERE, message.text(getLoggingLocale(), params), null);
}
@Override
public void error( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
- log(java.util.logging.Level.SEVERE, message.text(LOGGING_LOCALE.get(), params), t);
+ log(java.util.logging.Level.SEVERE, message.text(getLoggingLocale(), params), t);
}
@Override
- public void info( I18n message,
+ public void info( I18nResource message,
Object... params ) {
- log(java.util.logging.Level.INFO, message.text(LOGGING_LOCALE.get(), params), null);
+ log(java.util.logging.Level.INFO, message.text(getLoggingLocale(), params), null);
}
@Override
public void info( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
- log(java.util.logging.Level.INFO, message.text(LOGGING_LOCALE.get(), params), t);
+ log(java.util.logging.Level.INFO, message.text(getLoggingLocale(), params), t);
}
@Override
@@ -142,22 +142,21 @@ public void trace( String message,
public void trace( Throwable t,
String message,
Object... params ) {
- // TODO Auto-generated method stub
log(java.util.logging.Level.FINER, StringUtil.createString(message, params), t);
}
@Override
- public void warn( I18n message,
+ public void warn( I18nResource message,
Object... params ) {
- log(java.util.logging.Level.WARNING, message.text(LOGGING_LOCALE.get(), params), null);
+ log(java.util.logging.Level.WARNING, message.text(getLoggingLocale(), params), null);
}
@Override
public void warn( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
- log(java.util.logging.Level.WARNING, message.text(LOGGING_LOCALE.get(), params), t);
+ log(java.util.logging.Level.WARNING, message.text(getLoggingLocale(), params), t);
}
}
View
40 ...modeshape/common/util/LogContextTest.java → ...mon/logging/log4j/Log4jLoggerFactory.java
@@ -3,8 +3,8 @@
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
@@ -22,32 +22,20 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util;
+package org.modeshape.common.logging.log4j;
-import org.modeshape.common.i18n.MockI18n;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.modeshape.common.logging.Logger;
+import org.modeshape.common.logging.LogFactory;
-public class LogContextTest {
-
- private Logger logger;
-
- @Before
- public void beforeEach() {
- logger = Logger.getLogger(LoggerTest.class);
- }
-
- @After
- public void afterEach() {
- LogContext.clear();
- }
+/**
+ * A {@link LogFactory} extension which creates a {@link Log4jLoggerImpl} instance to use for logging
+ *
+ * @author Horia Chiorean
+ */
+public final class Log4jLoggerFactory extends LogFactory {
- @Test
- public void shouldAcceptValidKeys() {
- LogContext.set("username", "jsmith");
- logger.info(MockI18n.passthrough, "tracking activity for username");
- logger.info(MockI18n.passthrough, "A second log message");
+ @Override
+ protected Logger getLogger( String name ) {
+ return new Log4jLoggerImpl(name);
}
-
}
View
166 modeshape-common/src/main/java/org/modeshape/common/logging/log4j/Log4jLoggerImpl.java
@@ -0,0 +1,166 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.common.logging.log4j;
+
+import org.apache.log4j.Logger;
+import org.modeshape.common.i18n.I18nResource;
+import org.modeshape.common.util.StringUtil;
+
+/**
+ * {@link org.modeshape.common.logging.Logger} implementation which uses a Log4j logger to perform the logging operation
+ *
+ * @author Horia Chiorean
+ */
+final class Log4jLoggerImpl extends org.modeshape.common.logging.Logger {
+
+ private final org.apache.log4j.Logger logger;
+
+ public Log4jLoggerImpl( String name ) {
+ logger = Logger.getLogger(name);
+ }
+
+ @Override
+ public void debug( String message,
+ Object... params ) {
+ logger.debug(StringUtil.createString(message, params));
+ }
+
+ @Override
+ public String getName() {
+ return logger.getName();
+ }
+
+ @Override
+ public void debug( Throwable t,
+ String message,
+ Object... params ) {
+ if (StringUtil.isBlank(message)) {
+ return;
+ }
+ logger.debug(StringUtil.createString(message, params), t);
+ }
+
+ @Override
+ public void error( I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.error(message.text(getLoggingLocale(), params));
+ }
+
+ @Override
+ public void error( Throwable t,
+ I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.error(message.text(getLoggingLocale(), params), t);
+
+ }
+
+ @Override
+ public void info( I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.info(message.text(getLoggingLocale(), params));
+ }
+
+ @Override
+ public void info( Throwable t,
+ I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.info(message.text(getLoggingLocale(), params), t);
+ }
+
+ @Override
+ public void trace( String message,
+ Object... params ) {
+ if (StringUtil.isBlank(message)) {
+ return;
+ }
+ logger.trace(StringUtil.createString(message, params));
+ }
+
+ @Override
+ public void trace( Throwable t,
+ String message,
+ Object... params ) {
+ if (StringUtil.isBlank(message)) {
+ return;
+ }
+ logger.trace(StringUtil.createString(message, params), t);
+ }
+
+ @Override
+ public void warn( I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.warn(message.text(getLoggingLocale(), params));
+ }
+
+ @Override
+ public void warn( Throwable t,
+ I18nResource message,
+ Object... params ) {
+ if (message == null) {
+ return;
+ }
+ logger.warn(message.text(getLoggingLocale(), params), t);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return logger.isEnabledFor(org.apache.log4j.Level.INFO);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return logger.isEnabledFor(org.apache.log4j.Level.WARN);
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return logger.isEnabledFor(org.apache.log4j.Level.ERROR);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return logger.isEnabledFor(org.apache.log4j.Level.DEBUG);
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return logger.isEnabledFor(org.apache.log4j.Level.TRACE);
+ }
+}
View
12 ...e/common/util/log/SLF4JLoggerFactory.java → ...mon/logging/slf4j/SLF4JLoggerFactory.java
@@ -21,22 +21,18 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util.log;
+package org.modeshape.common.logging.slf4j;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
+import org.modeshape.common.logging.LogFactory;
/**
* Factory used to create the {@link Logger} implementation that uses the SLF4J logging framework.
*/
public final class SLF4JLoggerFactory extends LogFactory {
@Override
- public Logger getLogger( Class<?> clazz ) {
- return getLogger(clazz.getName());
- }
-
- @Override
- public Logger getLogger( String name ) {
+ protected Logger getLogger( String name ) {
return new SLF4JLoggerImpl(name);
}
View
43 ...hape/common/util/log/SLF4JLoggerImpl.java → ...common/logging/slf4j/SLF4JLoggerImpl.java
@@ -22,18 +22,19 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util.log;
+package org.modeshape.common.logging.slf4j;
-import org.modeshape.common.i18n.I18n;
+import org.modeshape.common.i18n.I18nResource;
import org.modeshape.common.util.StringUtil;
+import org.modeshape.common.logging.Logger;
import org.slf4j.LoggerFactory;
/**
* Logger that delivers messages to a Log4J logger
*
* @since 2.5
*/
-public class SLF4JLoggerImpl extends org.modeshape.common.util.Logger {
+final class SLF4JLoggerImpl extends Logger {
private final org.slf4j.Logger logger;
public SLF4JLoggerImpl( String category ) {
@@ -72,7 +73,7 @@ public boolean isErrorEnabled() {
@Override
public void warn( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
if (!isWarnEnabled()) return;
if (t == null) {
@@ -83,15 +84,15 @@ public void warn( Throwable t,
logger.warn(null, t);
return;
}
- logger.warn(message.text(LOGGING_LOCALE.get(), params), t);
+ logger.warn(message.text(getLoggingLocale(), params), t);
}
@Override
- public void warn( I18n message,
+ public void warn( I18nResource message,
Object... params ) {
if (!isWarnEnabled()) return;
if (message == null) return;
- logger.warn(message.text(LOGGING_LOCALE.get(), params));
+ logger.warn(message.text(getLoggingLocale(), params));
}
/**
@@ -138,29 +139,29 @@ public void debug( Throwable t,
* Log a message at the ERROR level according to the specified format and (optional) parameters. The message should contain a
* pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
* and avoids superfluous object creation when the logger is disabled for the ERROR level.
- *
+ *
* @param message the message string
* @param params the parameter values that are to replace the variables in the format string
*/
@Override
- public void error( I18n message,
+ public void error( I18nResource message,
Object... params ) {
if (!isErrorEnabled()) return;
if (message == null) return;
- logger.error(message.text(LOGGING_LOCALE.get(), params));
+ logger.error(message.text(getLoggingLocale(), params));
}
/**
* Log an exception (throwable) at the ERROR level with an accompanying message. If the exception is null, then this method
- * calls {@link #error(I18n, Object...)}.
- *
+ * calls {@link org.modeshape.common.logging.Logger#error(org.modeshape.common.i18n.I18nResource, Object...)}.
+ *
* @param t the exception (throwable) to log
* @param message the message accompanying the exception
* @param params the parameter values that are to replace the variables in the format string
*/
@Override
public void error( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
if (!isErrorEnabled()) return;
if (t == null) {
@@ -171,36 +172,36 @@ public void error( Throwable t,
logger.error(null, t);
return;
}
- logger.error(message.text(LOGGING_LOCALE.get(), params), t);
+ logger.error(message.text(getLoggingLocale(), params), t);
}
/**
* Log a message at the INFO level according to the specified format and (optional) parameters. The message should contain a
* pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
* and avoids superfluous object creation when the logger is disabled for the INFO level.
- *
+ *
* @param message the message string
* @param params the parameter values that are to replace the variables in the format string
*/
@Override
- public void info( I18n message,
+ public void info( I18nResource message,
Object... params ) {
if (!isInfoEnabled()) return;
if (message == null) return;
- logger.info(message.text(LOGGING_LOCALE.get(), params));
+ logger.info(message.text(getLoggingLocale(), params));
}
/**
* Log an exception (throwable) at the INFO level with an accompanying message. If the exception is null, then this method
- * calls {@link #info(I18n, Object...)}.
- *
+ * calls {@link org.modeshape.common.logging.Logger#info(org.modeshape.common.i18n.I18nResource, Object...)}.
+ *
* @param t the exception (throwable) to log
* @param message the message accompanying the exception
* @param params the parameter values that are to replace the variables in the format string
*/
@Override
public void info( Throwable t,
- I18n message,
+ I18nResource message,
Object... params ) {
if (!isInfoEnabled()) return;
if (t == null) {
@@ -211,7 +212,7 @@ public void info( Throwable t,
logger.info(null, t);
return;
}
- logger.info(message.text(LOGGING_LOCALE.get(), params), t);
+ logger.info(message.text(getLoggingLocale(), params), t);
}
/**
View
116 modeshape-common/src/main/java/org/modeshape/common/util/LogContext.java
@@ -1,116 +0,0 @@
-/*
- * ModeShape (http://www.modeshape.org)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * ModeShape is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.modeshape.common.util;
-
-import org.modeshape.common.annotation.Immutable;
-import org.slf4j.MDC;
-
-/**
- * Provides a "mapped diagnostic context" (MDC) for use in capturing extra context information to be included in logs of
- * multithreaded applications. Not all logging implementations support MDC, although a few do (including <a
- * href="http://logging.apache.org/log4j/1.3/index.html">Log4J</a> and <a href="http://logback.qos.ch/">Logback</a>). Note that if
- * the logging implementation does not support MDC, this information is ignored.
- * <p>
- * It can be difficult to understand what is going on within a multithreaded application. When multiple threads are working
- * simultaneously, their log messages are mixed together. Thus, it's difficult to follow the log messages of a single thread. Log
- * contexts provide a way to associate additional information with "the current context", and log messages can include that
- * additional information in the messages.
- * </p>
- * <p>
- * Log contexts are managed for you, and so using them is very straightforward. Typically, log contexts are used within
- * well-defined activities, and additional information is recorded in the context at the beginning of the activity and cleared at
- * the end of the activity.
- * </p>
- * <p>
- * The following example shows how to set and clear this additional information:
- *
- * <pre>
- * LogContext.set(&quot;username&quot;,&quot;jsmith&quot;);
- * LogContext.set(&quot;operation&quot;,&quot;process&quot;);
- * ...
- * // do work here
- * ...
- * LogContext.clear();
- * </pre>
- *
- * Note that the actually values would not be hardcoded but would be retrieved from other objects available at the time.
- * </p>
- * <p>
- * If the logging system doesn't support MDC, then the additional information provided via LogContext is ignored. However, if the
- * logging system is able to use MDC and it is set up with patterns that reference the keys, then those log messages will contain
- * the values for those keys.
- * </p>
- */
-@Immutable
-public class LogContext {
-
- /**
- * Put a context value (the <code>val</code> parameter) as identified with the <code>key</code> parameter into the current
- * thread's context map. The <code>key</code> parameter cannot be null. The code>val</code> parameter can be null only if the
- * underlying implementation supports it.
- * <p>
- * This method delegates all work to the MDC of the underlying logging system.
- *
- * @param key the key
- * @param value the value
- * @throws IllegalArgumentException in case the "key" parameter is null
- */
- public static void set( String key,
- String value ) {
- MDC.put(key, value);
- }
-
- /**
- * Get the context identified by the <code>key</code> parameter. The <code>key</code> parameter cannot be null.
- * <p>
- * This method delegates all work to the MDC of the underlying logging system.
- *
- * @param key the key
- * @return the string value identified by the <code>key</code> parameter.
- * @throws IllegalArgumentException in case the "key" parameter is null
- */
- public static String get( String key ) {
- return MDC.get(key);
- }
-
- /**
- * Remove the the context identified by the <code>key</code> parameter using the underlying system's MDC implementation. The
- * <code>key</code> parameter cannot be null. This method does nothing if there is no previous value associated with
- * <code>key</code>.
- *
- * @param key the key
- * @throws IllegalArgumentException in case the "key" parameter is null
- */
- public static void remove( String key ) {
- MDC.remove(key);
- }
-
- /**
- * Clear all entries in the MDC of the underlying implementation.
- */
- public static void clear() {
- MDC.clear();
- }
-
-}
View
5 modeshape-common/src/main/java/org/modeshape/common/util/MimeTypeUtil.java
@@ -39,6 +39,7 @@
import org.modeshape.common.CommonI18n;
import org.modeshape.common.annotation.Immutable;
import org.modeshape.common.i18n.I18n;
+import org.modeshape.common.logging.Logger;
/**
* A simple utility that determines an appropriate MIME type by matching the extension of the supplied filename against a set of
@@ -59,6 +60,8 @@
*/
public static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH = "org/modeshape/mime.types";
+ private static final Logger LOGGER = Logger.getLogger(MimeTypeUtil.class);
+
/**
* The mapping of extension (which includes the leading '.') to MIME type.
*/
@@ -169,7 +172,7 @@ public ClassLoader run() {
lines = StringUtil.splitLines(content);
} catch (IOException e) {
I18n msg = CommonI18n.unableToAccessResourceFileFromClassLoader;
- Logger.getLogger(MimeTypeUtil.class).warn(e, msg, MIME_TYPE_EXTENSIONS_RESOURCE_PATH);
+ LOGGER.warn(e, msg, MIME_TYPE_EXTENSIONS_RESOURCE_PATH);
}
Map<String, String> mimeTypesByExtension = new HashMap<String, String>();
if (lines != null) {
View
8 ...org/modeshape/common/util/LoggerTest.java → .../modeshape/common/logging/LoggerTest.java
@@ -22,7 +22,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.modeshape.common.util;
+package org.modeshape.common.logging;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
@@ -47,9 +47,9 @@
import org.junit.Test;
/**
- * Test the {@link Logger} class, ensuring that it uses Log4J appropriately. The {@link Logger} class uses the SLF4J generalized
+ * Test the {@link org.modeshape.common.logging.Logger} class, ensuring that it uses Log4J appropriately. The {@link org.modeshape.common.logging.Logger} class uses the SLF4J generalized
* logging framework, which can sit on top of multiple logging frameworks, including Log4J. Therefore, this test assumes that
- * SLF4J works correctly for all logging frameworks, then the {@link Logger} class can be tested by using it and checking the
+ * SLF4J works correctly for all logging frameworks, then the {@link org.modeshape.common.logging.Logger} class can be tested by using it and checking the
* resulting Log4J output.
* <p>
* To ensure that the Log4J configuration used in the remaining tests (in <code>src/test/resources/log4j.properties</code>)
@@ -394,7 +394,7 @@ public void shouldSupportAskingWhetherLoggingLevelsAreEnabled() {
/**
* A special Log4J Appender that records log messages and whose content can be
- * {@link #removeFirst(org.modeshape.common.util.Logger.Level, String, Class) validated} to ensure that the log contains
+ * {@link #removeFirst(org.modeshape.common.logging.Logger.Level, String, Class) validated} to ensure that the log contains
* messages in the proper order and with the proper content.
*/
public class LogRecorder extends WriterAppender {
View
3 modeshape-common/src/test/java/org/modeshape/common/statistic/DetailedStatisticsTest.java
@@ -29,8 +29,7 @@
import static org.junit.Assert.assertTrue;
import org.modeshape.common.math.FloatOperations;
import org.modeshape.common.math.IntegerOperations;
-import org.modeshape.common.statistic.DetailedStatistics;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.junit.Test;
public class DetailedStatisticsTest {
View
3 modeshape-common/src/test/java/org/modeshape/common/statistic/HistogramTest.java
@@ -34,9 +34,8 @@
import org.modeshape.common.i18n.MockI18n;
import org.modeshape.common.math.FloatOperations;
import org.modeshape.common.math.MathOperations;
-import org.modeshape.common.statistic.Histogram;
import org.modeshape.common.text.Inflector;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.junit.Test;
public class HistogramTest {
View
2 modeshape-common/src/test/java/org/modeshape/common/util/SecureHashTest.java
@@ -66,7 +66,7 @@ protected void assertCorrectlyComputeSecureHashUsing( Algorithm algorithm ) thro
assertSecureHashStreamWorks(algorithm, "/org/modeshape/common/i18n/I18nTest$TestI18n_fr.properties");
assertSecureHashStreamWorks(algorithm, "/org/modeshape/common/i18n/MockI18n.properties");
assertSecureHashStreamWorks(algorithm, "/org/modeshape/common/util/additionalmime.types");
- assertSecureHashStreamWorks(algorithm, "/org/modeshape/common/util/LoggerTest.properties");
+ assertSecureHashStreamWorks(algorithm, "/org/modeshape/common/logging/LoggerTest.properties");
assertSecureHashStreamWorks(algorithm, "/log4j.properties");
assertSecureHashStreamWorks(algorithm, "/maven-metadata-repository.jboss.org.xml");
}
View
0 ...deshape/common/util/LoggerTest.properties → ...hape/common/logging/LoggerTest.properties
File renamed without changes.
View
143 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/Logger.java
@@ -0,0 +1,143 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jcr.api;
+
+/**
+ * A generic logger interface.
+ *
+ * @author Horia Chiorean
+ */
+public interface Logger {
+
+ /**
+ * Log a message at the DEBUG level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void debug( String message,
+ Object... params );
+
+ /**
+ * Log an exception (throwable) at the DEBUG level with an accompanying message. If the exception is null, then this method
+ * calls {@link #debug(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void debug( Throwable t,
+ String message,
+ Object... params );
+
+ /**
+ * Log a message at the ERROR level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void error( String message,
+ Object... params );
+
+ /**
+ * Log an exception (throwable) at the ERROR level with an accompanying message. If the exception is null, then this method
+ * calls {@link #error(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void error( Throwable t,
+ String message,
+ Object... params );
+
+ /**
+ * Log a message at the INFO level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void info( String message,
+ Object... params );
+
+ /**
+ * Log an exception (throwable) at the INFO level with an accompanying message. If the exception is null, then this method
+ * calls {@link #info(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void info( Throwable t,
+ String message,
+ Object... params );
+
+ /**
+ * Log a message at the TRACE level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void trace( String message,
+ Object... params );
+
+ /**
+ * Log an exception (throwable) at the TRACE level with an accompanying message. If the exception is null, then this method
+ * calls {@link #trace(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void trace( Throwable t,
+ String message,
+ Object... params );
+
+ /**
+ * Log a message at the WARNING level according to the specified format and (optional) parameters. The message should contain
+ * a pair of empty curly braces for each of the parameter, which should be passed in the correct order.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void warn( String message,
+ Object... params );
+
+ /**
+ * Log an exception (throwable) at the WARNING level with an accompanying message. If the exception is null, then this method
+ * calls {@link #warn(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public abstract void warn( Throwable t,
+ String message,
+ Object... params );
+}
View
6 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/sequencer/Sequencer.java
@@ -34,6 +34,7 @@
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
+import org.modeshape.jcr.api.Logger;
import org.modeshape.jcr.api.mimetype.MimeTypeDetector;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;
@@ -50,6 +51,11 @@
*/
public abstract class Sequencer {
+ /**
+ * The logger instance, set via reflection
+ */
+ protected Logger logger;
+
private final UUID uuid = UUID.randomUUID();
private String name;
private String repositoryName;
View
17 modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/text/TextExtractor.java
@@ -23,22 +23,25 @@
*/
package org.modeshape.jcr.api.text;
+import org.modeshape.jcr.api.Logger;
import java.io.IOException;
import java.io.InputStream;
/**
* An abstraction for components that are able to extract text content from an input stream.
* //TODO author=Horia Chiorean date=2/9/12 description=Refine this class when porting/implementing extractors
*/
-public interface TextExtractor {
+public abstract class TextExtractor {
+
+ protected Logger logger;
/**
* Determine if this extractor is capable of processing content with the supplied MIME type.
*
* @param mimeType the MIME type; never null
* @return true if this extractor can process content with the supplied MIME type, or false otherwise.
*/
- boolean supportsMimeType( String mimeType );
+ public abstract boolean supportsMimeType( String mimeType );
/**
* Sequence the data found in the supplied stream, placing the output information into the supplied map.
@@ -54,14 +57,18 @@
* @param context the context for the sequencing operation; never <code>null</code>
* @throws IOException if there is a problem reading the stream
*/
- void extractFrom( InputStream stream,
+ public abstract void extractFrom( InputStream stream,
TextExtractorOutput output,
Context context ) throws IOException;
+ protected void setLogger(Logger logger) {
+ if (logger == null) {
+ throw new IllegalArgumentException("Logger cannot be null");
+ }
+ this.logger = logger;
+ }
public interface Context {
- //TODO author=Horia Chiorean date=2/9/12 description=define
-
String getMimeType();
}
View
4 modeshape-jcr-tck/pom.xml
@@ -53,10 +53,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
<!--
Java Content Repository API
View
4 modeshape-jcr/pom.xml
@@ -151,10 +151,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
<!--
Apache JCR API unit tests (for any JCR implementation), which is a subset of the official TCK
-->
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/ExecutionContext.java
@@ -38,7 +38,7 @@
import org.modeshape.common.component.ThreadPoolFactory;
import org.modeshape.common.component.ThreadPools;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.SecureHash;
import org.modeshape.jcr.api.mimetype.MimeTypeDetector;
import org.modeshape.jcr.mimetype.ExtensionBasedMimeTypeDetector;
View
143 modeshape-jcr/src/main/java/org/modeshape/jcr/ExtensionLogger.java
@@ -0,0 +1,143 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.modeshape.jcr;
+
+import org.modeshape.common.i18n.I18nResource;
+import org.modeshape.common.logging.Logger;
+import org.modeshape.common.util.StringUtil;
+import java.util.Locale;
+
+/**
+ * Implementation of the {@link org.modeshape.jcr.api.Logger} interface which delegates the logging operations to an I18n based
+ * {@link org.modeshape.common.logging.Logger} implementation, using pass-through I18n objects. This is implementation should be
+ * normally used by ModeShape extensions, to avoid coupling with the I18n objects and the -common module.
+ *
+ * @author Horia Chiorean
+ */
+public final class ExtensionLogger implements org.modeshape.jcr.api.Logger {
+
+ private final Logger logger;
+
+ private ExtensionLogger( Logger logger ) {
+ this.logger = logger;
+ }
+
+ public static org.modeshape.jcr.api.Logger getLogger(Class<?> clazz) {
+ return new ExtensionLogger(Logger.getLogger(clazz));
+ }
+
+ @Override
+ public void debug( String message,
+ Object... params ) {
+ logger.debug(message, params);
+ }
+
+ @Override
+ public void debug( Throwable t,
+ String message,
+ Object... params ) {
+ logger.debug(t, message, params);
+ }
+
+ @Override
+ public void error( String message,
+ Object... params ) {
+ logger.error(new I18n(message), params);
+ }
+
+ @Override
+ public void error( Throwable t,
+ String message,
+ Object... params ) {
+ logger.error(t, new I18n(message), params);
+ }
+
+ @Override
+ public void info( String message,
+ Object... params ) {
+ logger.info(new I18n(message), params);
+
+ }
+
+ @Override
+ public void info( Throwable t,
+ String message,
+ Object... params ) {
+ logger.info(t, new I18n(message), params);
+
+ }
+
+ @Override
+ public void trace( String message,
+ Object... params ) {
+ logger.trace(message, params);
+ }
+
+ @Override
+ public void trace( Throwable t,
+ String message,
+ Object... params ) {
+ logger.trace(t, message, params);
+ }
+
+ @Override
+ public void warn( String message,
+ Object... params ) {
+ logger.warn(new I18n(message), params);
+
+ }
+
+ @Override
+ public void warn( Throwable t,
+ String message,
+ Object... params ) {
+ logger.warn(t, new I18n(message), params);
+ }
+
+ /**
+ * A pass-through implementation of {@link I18nResource} which uses an underlying text as the real value, ignoring any
+ * kind of internationalization.
+ */
+ private static class I18n implements I18nResource {
+ private final static String BLANK = "";
+
+ private final String text;
+
+ I18n( String text ) {
+ this.text = StringUtil.isBlank(text) ? BLANK : text;
+ }
+
+ @Override
+ public String text( Object... arguments ) {
+ return StringUtil.createString(text, arguments);
+ }
+
+ @Override
+ public String text( Locale locale,
+ Object... arguments ) {
+ return StringUtil.createString(text, arguments);
+ }
+ }
+}
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrEngine.java
@@ -52,7 +52,7 @@
import org.modeshape.common.collection.Problems;
import org.modeshape.common.util.CheckArg;
import org.modeshape.common.util.ImmediateFuture;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.NamedThreadFactory;
import org.modeshape.jcr.api.Repositories;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeManager.java
@@ -58,7 +58,7 @@
import org.modeshape.common.i18n.I18n;
import org.modeshape.common.util.CheckArg;
import org.modeshape.common.util.IoUtil;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.JcrContentHandler.EnclosingSAXException;
import org.modeshape.jcr.RepositoryNodeTypeManager.NodeTypes;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrObservationManager.java
@@ -37,7 +37,7 @@
import org.modeshape.common.annotation.NotThreadSafe;
import org.modeshape.common.annotation.ThreadSafe;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.StringUtil;
import org.modeshape.jcr.api.monitor.ValueMetric;
import org.modeshape.jcr.api.value.DateTime;
View
4 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java
@@ -82,7 +82,7 @@
import org.modeshape.common.collection.Problems;
import org.modeshape.common.collection.SimpleProblems;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.NamedThreadFactory;
import org.modeshape.jcr.JcrEngine.State;
import org.modeshape.jcr.RepositoryConfiguration.AnonymousSecurity;
@@ -1057,7 +1057,7 @@ protected RunningState( JcrRepository.RunningState other,
}
if (other != null && !change.extractorsChanged) {
- List<Component> extractorComponents = config.getQuery().getTextExtractors();
+ List<Component> extractorComponents = other.config.getQuery().getTextExtractors();
this.extractors = new TextExtractors(this, extractorComponents);
} else {
List<Component> extractorComponents = config.getQuery().getTextExtractors();
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepositoryFactory.java
@@ -41,7 +41,7 @@
import javax.naming.NamingException;
import org.infinispan.schematic.document.ParsingException;
import org.modeshape.common.annotation.ThreadSafe;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.api.Repositories;
import org.modeshape.jcr.api.RepositoryFactory;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java
@@ -62,7 +62,7 @@
import org.infinispan.schematic.SchematicEntry;
import org.modeshape.common.i18n.I18n;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.AbstractJcrNode.Type;
import org.modeshape.jcr.JcrContentHandler.EnclosingSAXException;
import org.modeshape.jcr.JcrNamespaceRegistry.Behavior;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/JndiRepositoryFactory.java
@@ -18,7 +18,7 @@
import javax.naming.event.NamingEvent;
import javax.naming.event.NamingExceptionEvent;
import javax.naming.spi.ObjectFactory;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.xml.sax.SAXException;
/**
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShape.java
@@ -27,7 +27,7 @@
import java.io.InputStream;
import java.util.Properties;
import org.modeshape.common.collection.UnmodifiableProperties;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
/**
* Information about ModeShape.
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java
@@ -70,7 +70,7 @@
import org.modeshape.common.annotation.Immutable;
import org.modeshape.common.collection.Problems;
import org.modeshape.common.collection.SimpleProblems;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.common.util.ObjectUtil;
import org.modeshape.jcr.clustering.DefaultChannelProvider;
import org.modeshape.jcr.security.AnonymousProvider;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryLockManager.java
@@ -18,7 +18,7 @@
import javax.jcr.lock.LockException;
import org.modeshape.common.annotation.Immutable;
import org.modeshape.common.annotation.ThreadSafe;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.api.value.DateTime;
import org.modeshape.jcr.cache.CachedNode;
import org.modeshape.jcr.cache.ChildReference;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java
@@ -55,7 +55,7 @@
import org.modeshape.common.collection.Multimap;
import org.modeshape.common.i18n.I18n;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.api.query.qom.QueryCommand;
import org.modeshape.jcr.cache.NodeCache;
import org.modeshape.jcr.cache.NodeKey;
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
@@ -40,7 +40,7 @@
import org.hibernate.search.spi.SearchFactoryBuilder;
import org.modeshape.common.annotation.GuardedBy;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.JcrRepository.RunningState;
import org.modeshape.jcr.RepositoryConfiguration.QuerySystem;
import org.modeshape.jcr.api.query.qom.QueryCommand;
View
5 modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java
@@ -44,7 +44,7 @@
import org.modeshape.common.SystemFailureException;
import org.modeshape.common.annotation.Immutable;
import org.modeshape.common.util.HashCode;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.RepositoryConfiguration.Component;
import org.modeshape.jcr.api.mimetype.MimeTypeDetector;
import org.modeshape.jcr.api.monitor.ValueMetric;
@@ -129,6 +129,9 @@ public Sequencers( JcrRepository.RunningState repository,
Sequencer sequencer = component.createInstance(cl);
// Set the repository name field ...
ReflectionUtil.setValue(sequencer, "repositoryName", repoName);
+
+ //Set the logger instance
+ ReflectionUtil.setValue(sequencer, "logger", ExtensionLogger.getLogger(sequencer.getClass()));
// We'll initialize it later in #intialize() ...
// For each sequencer, figure out which workspaces apply ...
View
5 modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java
@@ -36,7 +36,7 @@
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
-import org.modeshape.common.util.Logger;
+import org.modeshape.common.logging.Logger;
import org.modeshape.jcr.JcrRepository.RunningState;
import org.modeshape.jcr.Sequencers.SequencingContext;
import org.modeshape.jcr.Sequencers.SequencingWorkItem;
@@ -134,7 +134,8 @@ public void run() {
// Execute the sequencer ...
DateTime now = outputSession.dateFactory().create();
- Sequencer.Context context = new SequencingContext(now, outputSession.getValueFactory(),
+ Sequencer.Context context = new SequencingContext(now,
+ outputSession.getValueFactory(),
outputSession.context().getMimeTypeDetector());
if (inputSession.isLive() && (inputSession == outputSession || outputSession.isLive())) {
final long start = System.nanoTime();
View
2 modeshape-jcr/src/main/java/org/modeshape/jcr/SystemContent.java