LOG4J2-1010 added method ContextDataInjector::rawContextData()

 This method is intended to give fast access to the underlying context data, 
for use in filters and lookups.
 The idea is that this method does *not* need to guarantee that the returned 
object can safely be passed off to another thread, and this looser guarantee 
allows us to avoid making a copy of the data.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d057eb20
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d057eb20
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d057eb20

Branch: 
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: d057eb204aac88bc4a58c6aa694dfac6063d228a
Parents: 07162be
Author: rpopma <rpo...@apache.org>
Authored: Sun Aug 28 23:57:12 2016 +0900
Committer: rpopma <rpo...@apache.org>
Committed: Sun Aug 28 23:57:12 2016 +0900

----------------------------------------------------------------------
 .../log4j/core/impl/ContextDataInjector.java        | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d057eb20/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjector.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjector.java
index c1bd4b4..7fe4c53 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjector.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjector.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.impl;
 
 import java.util.List;
 
+import org.apache.logging.log4j.core.ContextData;
 import org.apache.logging.log4j.core.config.Property;
 
 /**
@@ -47,6 +48,10 @@ public interface ContextDataInjector {
     /**
      * Returns a {@code MutableContextData} object initialized with the 
specified properties and the appropriate
      * context data. The returned value may be the specified parameter or a 
different object.
+     * <p>
+     * Thread-safety note: The returned object can safely be passed off to 
another thread: future changes in the
+     * underlying context data will not be reflected in the returned object.
+     * </p>
      *
      * @param properties Properties from the log4j configuration to be added 
to the resulting ContextData. May be
      *          {@code null} or empty
@@ -55,4 +60,15 @@ public interface ContextDataInjector {
      *          context data. The returned value may be the specified 
parameter or a different object.
      */
     MutableContextData injectContextData(final List<Property> properties, 
final MutableContextData reusable);
+
+    /**
+     * Returns a {@code ContextData} object reflecting the current state of 
the context.
+     * <p>
+     * Thread-safety note: The returned object can only be safely used <em>in 
the current thread</em>. Changes in the
+     * underlying context may or may not be reflected in the returned object, 
depending on the context data source and
+     * the implementation of this method. It is not safe to pass the returned 
object to another thread.
+     * </p>
+     * @return a {@code ContextData} object reflecting the current state of 
the context
+     */
+    ContextData rawContextData();
 }

Reply via email to