From 3fb1fb61ed20b849fbb83bfecf30bc31f581d9b3 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 27 Jan 2014 14:13:10 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1288 :    Migrate I18n and logging support to i18n framework and SLF4J

---
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMarkerBinder.java  |   64 ++++
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/package-info.java        |   30 ++
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerFactory.java |   62 ++++
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticLoggerBinder.java  |   80 +++++
 opendj-slf4j-adapter/pom.xml                                               |   89 +++++
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMDCBinder.java     |   65 ++++
 opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerAdapter.java |  465 +++++++++++++++++++++++++++++++
 7 files changed, 855 insertions(+), 0 deletions(-)

diff --git a/opendj-slf4j-adapter/pom.xml b/opendj-slf4j-adapter/pom.xml
new file mode 100644
index 0000000..51554b4
--- /dev/null
+++ b/opendj-slf4j-adapter/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ! CDDL HEADER START
+  !
+  ! The contents of this file are subject to the terms of the
+  ! Common Development and Distribution License, Version 1.0 only
+  ! (the "License").  You may not use this file except in compliance
+  ! with the License.
+  !
+  ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+  ! or http://forgerock.org/license/CDDLv1.0.html.
+  ! See the License for the specific language governing permissions
+  ! and limitations under the License.
+  !
+  ! When distributing Covered Code, include this CDDL HEADER in each
+  ! file and include the License file at legal-notices/CDDLv1_0.txt.
+  ! If applicable, add the following below this CDDL HEADER, with the
+  ! fields enclosed by brackets "[]" replaced with your own identifying
+  ! information:
+  !      Portions Copyright [yyyy] [name of copyright owner]
+  !
+  ! CDDL HEADER END
+  !
+  !      Copyright 2014 ForgeRock AS
+  !
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>opendj-project</artifactId>
+    <groupId>org.forgerock.opendj</groupId>
+    <version>3.0.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>opendj-slf4j-adapter</artifactId>
+  <name>OpenDJ SLF4J Adapter</name>
+  <description>
+    This module  includes an adapter to SLF4J library which maps SLF4J API
+    to OpenDJ logging classes.
+  </description>
+  <packaging>jar</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.forgerock.commons</groupId>
+      <artifactId>i18n-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.forgerock.commons</groupId>
+      <artifactId>i18n-slf4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.forgerock.opendj</groupId>
+      <artifactId>opendj3-server-dev</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>mailing-list</report>
+              <report>issue-tracking</report>
+              <report>license</report>
+              <report>cim</report>
+              <report>distribution-management</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <links>
+            <link>http://commons.forgerock.org/i18n-framework/i18n-core/apidocs</link>
+          </links>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
\ No newline at end of file
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerAdapter.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerAdapter.java
new file mode 100644
index 0000000..5508f94
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerAdapter.java
@@ -0,0 +1,465 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.slf4j.impl;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedMarker;
+import org.opends.messages.Severity;
+import org.opends.server.loggers.ErrorLogger;
+import org.opends.server.loggers.debug.DebugLogger;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.DebugLogLevel;
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+
+/**
+ * OpenDJ implementation of a SLF4J Logger.
+ * <p>
+ * Log calls at trace level are redirected to {@code DebugLogger}, while calls
+ * at other levels are redirected to {@code ErrorLogger}.
+ * <p>
+ * Trace level calls are accepted with no Marker argument, while calls at other
+ * level must be done with a Marker expected to be an instance of
+ * {@code LocalizedMarker}.
+ */
+final class OpenDJLoggerAdapter implements Logger {
+    /** Name of logger, used as the category. */
+    private final String name;
+
+    /** The tracer associated to this logger. */
+    private final DebugTracer tracer;
+
+    /**
+     * Creates a new logger with the provided name.
+     *
+     * @param name
+     *            The name of logger.
+     */
+    public OpenDJLoggerAdapter(final String name) {
+        this.name = name;
+        this.tracer = DebugLogger.getTracer(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    /** Trace with message only. */
+    private void logTraceMessage(String msg) {
+        tracer.debugMessage(DebugLogLevel.VERBOSE, msg);
+
+    }
+
+    /** Trace with message and exception. */
+    private void logTraceException(@SuppressWarnings("unused") String message, Throwable t) {
+        tracer.debugCaught(DebugLogLevel.VERBOSE, t);
+    }
+
+    /**
+     * Log a message to {@code ErrorLogger} with the provided severity,
+     * extracting {@code LocalizableMessage} from the provided
+     * {@code Marker marker} argument.
+     *
+     * @param marker
+     *            The marker, expected to be an instance of
+     *            {@code LocalizedMarker} class, from which message to log is
+     *            extracted.
+     * @param severity
+     *            The severity to use when logging message.
+     * @param throwable
+     *            Exception to log. May be {@code null}.
+     */
+    private void logError(Marker marker, Severity severity, Throwable throwable) {
+        if (marker instanceof LocalizedMarker) {
+            LocalizableMessage message = ((LocalizedMarker) marker).getMessage();
+            ErrorLogger.log(name, severity, message, throwable);
+        } else {
+            throw new IllegalStateException("Expecting the marker to be an instance of LocalizedMarker");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isTraceEnabled() {
+        return DebugLogger.debugEnabled() && tracer.enabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(String msg) {
+        logTraceMessage(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(Marker marker, String msg) {
+        logTraceMessage(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(String msg, Throwable t) {
+        logTraceException(msg, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(Marker marker, String msg, Throwable t) {
+        logTraceException(msg, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isDebugEnabled() {
+        return ErrorLogger.isEnabledFor(name, Severity.INFORMATION);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(Marker marker, String msg) {
+        logError(marker, Severity.INFORMATION, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(Marker marker, String msg, Throwable t) {
+        logError(marker, Severity.INFORMATION, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isInfoEnabled() {
+        return ErrorLogger.isEnabledFor(name, Severity.NOTICE);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(Marker marker, String msg) {
+        logError(marker, Severity.NOTICE, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(Marker marker, String msg, Throwable t) {
+        logError(marker, Severity.NOTICE, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isWarnEnabled() {
+        return ErrorLogger.isEnabledFor(name, Severity.SEVERE_WARNING);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(Marker marker, String msg) {
+        logError(marker, Severity.SEVERE_WARNING, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(Marker marker, String msg, Throwable t) {
+        logError(marker, Severity.SEVERE_WARNING, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isErrorEnabled() {
+        return ErrorLogger.isEnabledFor(name, Severity.FATAL_ERROR);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(Marker marker, String msg) {
+        logError(marker, Severity.FATAL_ERROR, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(Marker marker, String msg, Throwable t) {
+        logError(marker, Severity.FATAL_ERROR, t);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isTraceEnabled(Marker marker) {
+        return isTraceEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isDebugEnabled(Marker marker) {
+        return isDebugEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isInfoEnabled(Marker marker) {
+        return isInfoEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isWarnEnabled(Marker marker) {
+        return isWarnEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isErrorEnabled(Marker marker) {
+        return isErrorEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(String format, Object arg) {
+        throw new UnsupportedOperationException("Use #trace(String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #trace(String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(String format, Object... argArray) {
+        throw new UnsupportedOperationException("Use #trace(String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(Marker marker, String format, Object arg) {
+        throw new UnsupportedOperationException("Use #trace(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(Marker marker, String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #trace(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(Marker marker, String format, Object... argArray) {
+        throw new UnsupportedOperationException("Use #trace(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(String msg) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(String format, Object arg) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(String format, Object... argArray) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(String msg, Throwable t) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String, Throwable) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(Marker marker, String format, Object arg) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(Marker marker, String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(Marker marker, String format, Object... arguments) {
+        throw new UnsupportedOperationException("Use #debug(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(String msg) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(String format, Object arg) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(String format, Object... argArray) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(String msg, Throwable t) {
+        throw new UnsupportedOperationException("Use #info(Marker, String, Throwable) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(Marker marker, String format, Object arg) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(Marker marker, String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(Marker marker, String format, Object... arguments) {
+        throw new UnsupportedOperationException("Use #info(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(String msg) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(String format, Object arg) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(String format, Object... argArray) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(String msg, Throwable t) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String, Throwable) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(Marker marker, String format, Object arg) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(Marker marker, String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(Marker marker, String format, Object... arguments) {
+        throw new UnsupportedOperationException("Use #warn(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(String msg) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(String format, Object arg) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(String format, Object... arguments) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(String msg, Throwable t) {
+        throw new UnsupportedOperationException("Use #error(Marker, String, Throwable) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(Marker marker, String format, Object arg) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(Marker marker, String format, Object arg1, Object arg2) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(Marker marker, String format, Object... arguments) {
+        throw new UnsupportedOperationException("Use #error(Marker, String) instead.");
+    }
+}
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerFactory.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerFactory.java
new file mode 100644
index 0000000..a1c9e97
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/OpenDJLoggerFactory.java
@@ -0,0 +1,62 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.slf4j.impl;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * Factory to retrieve an openDJ implementation of SLF4J Logger.
+ */
+final class OpenDJLoggerFactory implements ILoggerFactory {
+
+    private final ConcurrentMap<String, Logger> loggerMap;
+
+    /**
+     * Create the factory.
+     */
+    public OpenDJLoggerFactory() {
+        loggerMap = new ConcurrentHashMap<String, Logger>();
+    }
+
+    /** {@inheritDoc} */
+    public Logger getLogger(String name) {
+        if (name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME)) {
+            name = "org.forgerock";
+        }
+
+        Logger slf4jLogger = loggerMap.get(name);
+        if (slf4jLogger != null) {
+            return slf4jLogger;
+        }
+        Logger newInstance = new OpenDJLoggerAdapter(name);
+        Logger oldInstance = loggerMap.putIfAbsent(name, newInstance);
+        return oldInstance == null ? newInstance : oldInstance;
+    }
+}
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
new file mode 100644
index 0000000..ab249ab
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -0,0 +1,80 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * Binds {@link LoggerFactory} class with an instance of {@link ILoggerFactory}.
+ */
+//@Checkstyle:off
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+    private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+    /**
+     * Declare the version of the SLF4J API this implementation is compiled
+     * against.
+     */
+    // to avoid constant folding by the compiler, this field must *not* be final
+
+    public static String REQUESTED_API_VERSION = "1.7.5";
+
+    private static final String FACTORY_CLASSNAME = OpenDJLoggerFactory.class.getName();
+
+    /**
+     * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
+     * method should always be the same object.
+     */
+    private final ILoggerFactory loggerFactory;
+
+    private StaticLoggerBinder() {
+        loggerFactory = new OpenDJLoggerFactory();
+    }
+
+    /**
+     * Return the singleton of this class.
+     *
+     * @return the StaticLoggerBinder singleton
+     */
+    public static final StaticLoggerBinder getSingleton() {
+        return SINGLETON;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public ILoggerFactory getLoggerFactory() {
+        return loggerFactory;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getLoggerFactoryClassStr() {
+        return FACTORY_CLASSNAME;
+    }
+}
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMDCBinder.java
new file mode 100644
index 0000000..ea3f532
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMDCBinder.java
@@ -0,0 +1,65 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.helpers.BasicMDCAdapter;
+import org.slf4j.spi.MDCAdapter;
+
+/**
+ * Binds {@link MarkerFactory} class with an instance of {@link IMarkerFactory}.
+ */
+//@Checkstyle:off
+public class StaticMDCBinder {
+
+    /**
+     * The unique instance of this class.
+     */
+    public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
+
+    private StaticMDCBinder() {
+        // no implementation
+    }
+
+    /**
+     * Returns an instance of MDC.
+     *
+     * @return a MDC
+     */
+    public MDCAdapter getMDCA() {
+        return new BasicMDCAdapter();
+    }
+
+    /**
+     * Returns the class name of MDC.
+     *
+     * @return the class name
+     */
+    public String getMDCAdapterClassStr() {
+        return BasicMDCAdapter.class.getName();
+    }
+}
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
new file mode 100644
index 0000000..7447760
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
@@ -0,0 +1,64 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.helpers.BasicMarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ * Binds {@link MarkerFactory} class with an instance of {@link IMarkerFactory}.
+ */
+//@Checkstyle:off
+public class StaticMarkerBinder implements MarkerFactoryBinder {
+
+    private static final String FACTORY_CLASSNAME = BasicMarkerFactory.class.getName();
+
+    /**
+     * The unique instance of this class.
+     */
+    public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+
+    final IMarkerFactory markerFactory = new BasicMarkerFactory();
+
+    private StaticMarkerBinder() {
+        // no implementation
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public IMarkerFactory getMarkerFactory() {
+        return markerFactory;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getMarkerFactoryClassStr() {
+        return FACTORY_CLASSNAME;
+    }
+
+}
diff --git a/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/package-info.java b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/package-info.java
new file mode 100644
index 0000000..38ee4e3
--- /dev/null
+++ b/opendj-slf4j-adapter/src/main/java/org/slf4j/impl/package-info.java
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+
+/**
+ * Classes implementing a SLF4J Logging Adapter for OpenDJ server.
+ */
+package org.slf4j.impl;

--
Gitblit v1.10.0