LOG4J2-1010 implement the new ContextDataInjector::rawContextData() method as 
good as we can.

Note: at this stage the rawContextData() method implementation does not perform 
better than the inject method.
In LOG4J2-1349 we move the ContextData interface to the log4j-api module and we 
introduce ContextData-based implementations of the ThreadContextMap interface. 
Here we can provide a much more efficiently performing implementation.


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

Branch: 
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 25148ca31ea2ba8f96f03bc36eb3963b802db46b
Parents: 16eca7f
Author: rpopma <rpo...@apache.org>
Authored: Mon Aug 29 00:04:03 2016 +0900
Committer: rpopma <rpo...@apache.org>
Committed: Mon Aug 29 00:04:03 2016 +0900

----------------------------------------------------------------------
 .../core/impl/ThreadContextDataInjector.java    | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/25148ca3/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
index af534fb..1e81f1d 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjector.java
@@ -66,6 +66,14 @@ public class ThreadContextDataInjector  {
             return reusable;
         }
 
+        @Override
+        public ContextData rawContextData() {
+            // TODO LOG4J2-1349: DefaultThreadContextMap itself implements the 
ContextData interface
+            final MutableContextData result = 
ContextDataFactory.createContextData();
+            copyThreadContextMap(ThreadContext.getImmutableContext(), result);
+            return result;
+        }
+
         /**
          * Copies key-value pairs from the specified map into the specified 
{@code MutableContextData}.
          *
@@ -109,6 +117,13 @@ public class ThreadContextDataInjector  {
 //            reusable.putAll(immutableCopy);
             return reusable;
         }
+
+        @Override
+        public ContextData rawContextData() {
+            // TODO LOG4J2-1349
+            //return ((AbstractGarbageFreeMutableThreadContext) 
ThreadContext.getThreadContextMap()).getContextData();
+            return null;
+        }
     }
 
     /**
@@ -146,6 +161,13 @@ public class ThreadContextDataInjector  {
 //            reusable.putAll(immutableCopy);
             return reusable;
         }
+
+        @Override
+        public ContextData rawContextData() {
+            // TODO LOG4J2-1349
+            //return ((AbstractCopyOnWriteMutableThreadContext) 
ThreadContext.getThreadContextMap()).getContextData();
+            return null;
+        }
     }
 
     /**

Reply via email to