[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-dev
Subject:    svn commit: r533406 [1/2] - in /logging/sandbox/experimental/pattern-layout:
From:       carnold () apache ! org
Date:       2007-04-28 18:43:40
Message-ID: 20070428184342.91A611A9838 () eris ! apache ! org
[Download RAW message or body]

Author: carnold
Date: Sat Apr 28 11:43:37 2007
New Revision: 533406

URL: http://svn.apache.org/viewvc?view=rev&rev=533406
Log:
Initial commit on experimental layout framework

Added:
    logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/
    logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Extractor.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Immutable.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Layout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Level.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Localizable.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LogRecord.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LoggingException.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/PropertyContext.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ThreadSafe.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ValueContext.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/CompositeLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/LocalizedMessageFormat.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/SynchronizedLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/ThreadSafeLayoutFactory.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLevel.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLogRecord.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKMessage.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Context.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Level.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1LogRecord.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1PropertyMap.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/handler/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/handler/impl/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/log4j/
    logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/AbbreviatorLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/DateLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/DatePatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/DecoratorLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/FieldLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LevelLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/LevelPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LineSeparatorLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/LineSeparatorPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LiteralLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/LiteralPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LocalizableLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LogRecordDateLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/LoggerNameLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/LoggerPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/MessageLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/MessagePatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/PatternLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/EnhancedPatternLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/PatternSpecifier.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/PropertiesContextLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PropertiesPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/SourceClassNameLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/SourceFileNameLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/SourceLineNumberLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/SourceMethodNameLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/StringLayout.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/ThreadNameLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/ThreadPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/ThrownLayout.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/ThrowableInformationPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/ValueContextLayout.java \
                (contents, props changed)
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/NDCPatternConverter.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/impl/
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/impl/CachedDateFormat.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/CachedDateFormat.java
  logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/impl/PatternParser.java
                
      - copied, changed from r533235, \
logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PatternParser.java
 Removed:
    logging/sandbox/experimental/pattern-layout/src/java/
Modified:
    logging/sandbox/experimental/pattern-layout/build.xml
    logging/sandbox/experimental/pattern-layout/pom.xml
    logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PropertiesPatternConverter.java


Modified: logging/sandbox/experimental/pattern-layout/build.xml
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/build.xml?view=diff&rev=533406&r1=533405&r2=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/build.xml (original)
+++ logging/sandbox/experimental/pattern-layout/build.xml Sat Apr 28 11:43:37 2007
@@ -27,8 +27,8 @@
     <property file="build.properties"/>
 	
 	<!--  project details  -->
-    <property name="project.name" value="apache-log4j-pattern-layout"/>
-    <property name="project.title" value="Enhanced Pattern Layout Component for \
log4j 1.2"/> +    <property name="project.name" \
value="apache-log4j-experimental-pattern-layout"/> +    <property \
name="project.title" value="Enhanced Pattern Layout Component for log4j X"/>  \
                <property name="project.version" value="0.1-SNAPSHOT"/>
     <property name="project.jar" value="${project.name}-${project.version}.jar"/>
     
@@ -37,7 +37,7 @@
 
 	<!--  Versions for dependencies   -->
     <property name="log4j.version" value="1.2.14"/>
-    <property name="junit.version" value="3.8.1"/>
+    <property name="junit.version" value="4.3.1"/>
     <property name="oro.version" value="2.0.8"/>
 	
 	<!--  Dependency locations - assumed to be in Maven 2 repository   -->
@@ -50,8 +50,8 @@
        
 
     <!--   Java compiler settings   -->
-    <property name="javac.source" value="1.3"/>
-    <property name="javac.target" value="1.2"/>   
+    <property name="javac.source" value="1.5"/>
+    <property name="javac.target" value="1.5"/>
     <property name="javac.deprecation" value="true"/>
     <property name="javac.debug" value="true"/>
        

Modified: logging/sandbox/experimental/pattern-layout/pom.xml
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/pom.xml?view=diff&rev=533406&r1=533405&r2=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/pom.xml (original)
+++ logging/sandbox/experimental/pattern-layout/pom.xml Sat Apr 28 11:43:37 2007
@@ -19,20 +19,20 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
http://maven.apache.org/maven-v4_0_0.xsd">  <modelVersion>4.0.0</modelVersion>
   <groupId>log4j</groupId>
-  <artifactId>apache-log4j-pattern-layout</artifactId>
+  <artifactId>apache-log4j-experimental-pattern-layout</artifactId>
   <packaging>jar</packaging>
   <version>0.1-SNAPSHOT</version>
-  <name>Enhanced Pattern Layout Companion for log4j 1.2.</name>
-  <description>This companion provides the enhanced pattern layout from the log4j \
                1.3 project to users of log4j 1.2.</description>
-  <url>http://logging.apache.org/log4j/companions/pattern-layout</url>
+  <name>Enhanced Pattern Layout Experiments</name>
+  <description>Experiments on Pattern Layout.</description>
+  <url>http://logging.apache.org/log4j/experimental</url>
   <issueManagement>
-    <system>Bugzilla</system>
-    <url>http://issues.apache.org/bugzilla</url>
+    <system>Jira</system>
+    <url>http://issues.apache.org/jira</url>
   </issueManagement>
-  <ciManagement>
+  <!-- ciManagement>
   		<system>Gump</system>
   		 <url>http://vmgump.apache.org/gump/public/logging-log4j-pattern-layout/logging-log4j-pattern-layout/index.html</url>
                
-  </ciManagement>
+  </ciManagement -->
 <mailingLists>
 	<mailingList>
 		<name>log4j-user</name>
@@ -73,9 +73,9 @@
 	</license>
 </licenses>
 <scm>
-	<connection>scm:svn:http://svn.apache.org/repos/asf/logging/sandbox/log4j/pattern-layout</connection>
                
-	<developerConnection>scm:svn:https://svn.apache.org/repos/asf/logging/sandbox/log4j/pattern-layout</developerConnection>
                
-	<url>http://svn.apache.org/viewcvs.cgi/logging/sandbox/log4j/pattern-layout</url>
+	<connection>scm:svn:http://svn.apache.org/repos/asf/logging/sandbox/experimental/pattern-layout</connection>
 +	<developerConnection>scm:svn:https://svn.apache.org/repos/asf/logging/sandbox/experimental/pattern-layout</developerConnection>
 +	<url>http://svn.apache.org/viewcvs.cgi/logging/sandbox/experimental/pattern-layout</url>
  </scm>
 <organization>
     <name>Apache Software Foundation</name>
@@ -96,8 +96,8 @@
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-            <source>1.3</source>
-            <target>1.3</target>
+            <source>1.5</source>
+            <target>1.5</target>
         </configuration>
       </plugin>
   <plugin> 
@@ -118,7 +118,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.1</version>
+      <version>4.3.1</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PropertiesPatternConverter.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/log4j/pattern/PropertiesPatternConverter.java?view=diff&rev=533406&r1=533405&r2=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PropertiesPatternConverter.java \
                (original)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/PropertiesPatternConverter.java \
Sat Apr 28 11:43:37 2007 @@ -70,7 +70,7 @@
       option = null;
       try {
          getMethod = LoggingEvent.class.getMethod(
-                    "getPropertyKeySet", null);
+                    "getPropertyKeySet");
       } catch(Exception ex) {
           getMethod = null;
       }
@@ -103,7 +103,7 @@
       Set keySet = null;
       if (getKeySetMethod != null) {
           try {
-            keySet = (Set) getKeySetMethod.invoke(event, null);
+            keySet = (Set) getKeySetMethod.invoke(event);
           } catch(InvocationTargetException ex) {
               LogLog.error("Exception while calling LoggingEvent.getKeySetMethod",
                       ex.getTargetException());

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Extractor.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Extractor.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Extractor.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Extractor.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.logging.core;
+
+/**
+ * An Extractor extracts a value object from a LogRecord
+ * for subsequent rendering by other methods on the
+ * same object.  If a extractor is immutable or thread-safe
+ * it should declare so with an appropriate attribute.
+ * Extractors not declared thread-safe will externally synchronized.
+ *
+ */
+public interface Extractor {
+    /**
+     * Extracts an object with value semantics from LogRecord.
+     * @param record logging record, may not be null.
+     * @return a value object.
+     */
+    Object extract(LogRecord record);
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Immutable.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Immutable.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Immutable.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Immutable.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,30 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * This annotation is applied to objects that are immutable.
+ * Implies ThreadSafe.
+ * This may be replaced or augmented by more widely used equivalents.
+ * @Documented
+ * @Target(ElementType.TYPE)
+ * @Retention(RetentionPolicy.RUNTIME)
+ */
+
+public @interface Immutable {
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Layout.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Layout.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Layout.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Layout.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,71 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.logging.core;
+
+import java.util.Locale;
+import java.io.*;
+
+/**
+ * A Layout extracts information from a LogRecord and
+ * renders it into the parameterized type.  Layouts
+ * support a two stage process of value extraction and rendering.
+ * Value extraction occurs on the same thread as the log request
+ * and extracts an object with value semantics like String,
+ * Date, Integer, or collection of such objects.  Rendering
+ * of the may occur on the same or different thread.
+ * If a layout is immutable or thread-safe it should declare
+ * so with an appropriate attribute.  Layouts not declared
+ * as thread-safe will externally synchronized.  Layouts may
+ * be combined to composite layout.
+ *
+ * Types used to parameterize Layout include
+ * StringBuilder (patterns),
+ * org.xml.sax.ContentHandler (XML),
+ * ObjectOutputStream (serialization).
+ *
+ *
+ */
+public interface Layout<T> extends Extractor {
+
+    /**
+     * Renders the value object obtained from an earlier call
+     * to extract on the same instance.
+     * @param extract An extracted value from a previous call
+     * to extract.
+     * @param locale locale.
+     * @param destination destination, may not be null.
+     * @throws IOException if error writing to destination.
+     * @throws LoggingException any other error.
+     */
+    void render(Object extract, Locale locale, T destination)
+            throws IOException, LoggingException;
+
+    /**
+     * Formats some aspect of the LogRecord.
+     * This function is functionally equivalent to calling render with
+     * the value returned from extract, but may be slightly more
+     * efficient.
+     *
+     * @param record logging record, may not be null.
+     * @param locale locale.
+     * @param destination destination, may not be null.
+     * @throws IOException if error writing to destination.
+     * @throws LoggingException any other error.
+     */
+    void format(LogRecord record, Locale locale, T destination)
+            throws IOException, LoggingException;
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Level.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Level.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Level.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Level.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,26 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+public interface Level extends Localizable {
+    /**
+     * Get integer value for this level.
+     * @return integer value.
+     */
+    int intValue();
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Localizable.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Localizable.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Localizable.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/Localizable.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,33 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import java.util.Locale;
+/**
+ * Implemented by objects that support locale-sensitive
+ * text representations.
+ *
+ */
+public interface Localizable {
+    /**
+     * Get string representation of object for specified locale.
+     * @param locale locale, may not be null.
+     * @return localized text representation, may not be null.
+     */
+    String getLocalizedName(Locale locale);
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LogRecord.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LogRecord.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LogRecord.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LogRecord.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,96 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+/**
+ * This interface is an abstraction of a record of a logging event.
+ * The current field names are patterned after java.util.logging.LogRecord.
+ * Enhanced behavior beyond what java.util.LogRecord can support
+ * should go in a distinct interface.  Behavior that is java.util.logging
+ * specific should go in a distinct interface.
+ *
+ */
+public interface LogRecord {
+
+    /**
+     * Get level.
+     * @return level.
+     */
+    Level getLevel();
+
+    /**
+     * Get logger name.
+     * @return logger name, may be null.
+     */
+    String getLoggerName();
+
+    /**
+     * Get source of logging request.
+     * @return source of logging request, may be null.
+     */
+    StackTraceElement getSource();
+
+    /**
+     * Get the message string or an object with value
+     * semantics that can produce the message string.
+     *
+     * @return message.
+     */
+    Object getMessage();
+
+    /**
+     * Get thread id.
+     * @return thread id, a negative number indicates
+     * that thread id is unavailable.
+     */
+    long getThreadID();
+
+    /**
+     * Get thread name.
+     * @return thread name, may be null.
+     */
+    String getThreadName();
+
+
+    /**
+     * Get event time in milliseconds since 1970.
+     * @return milliseconds since 1970.
+     */
+    long getMillis();
+
+
+    /**
+     * Get throwable associated with logging request.
+     * @return throwable, may be null.
+     */
+    Throwable getThrown();
+
+
+    /**
+     * Get information about the context of the logging request. 
+     *
+     * @return context, may be null.
+     */
+    Object getContext();
+
+    
+
+
+    
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LoggingException.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LoggingException.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LoggingException.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/LoggingException.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core;
+
+import java.util.logging.*;
+
+import org.apache.log4j.*;
+
+/**
+ * 
+ *
+ *
+ *
+ */
+public class LoggingException extends Exception {
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/PropertyContext.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/PropertyContext.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/PropertyContext.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/PropertyContext.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,32 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import java.util.Map;
+
+/**
+ * Supported by objects returned by LogRecord.getContext() that
+ * provide properties keyed by a string.
+ *
+ */
+public interface PropertyContext {
+    /**
+     * Get properties associated with the context.
+     * @return read-only map of properties, may not be null.
+     */
+    Map<String, Object> getProperties();
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ThreadSafe.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ThreadSafe.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ThreadSafe.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ThreadSafe.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,28 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * This annotation is applied to objects that are thread-safe.
+ * This may be replaced or augmented by more widely used equivalents.
+ * @Documented
+ * @Target(ElementType.TYPE)
+ * @Retention(RetentionPolicy.RUNTIME)
+ */
+public @interface ThreadSafe {
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ValueContext.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ValueContext.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ValueContext.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/ValueContext.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,31 @@
+package org.apache.logging.core;
+
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * Supported by objects returned by LogRecord.getContext() that
+ * provide a context value, for example, the NDC value from log4j 1.2.
+ *
+ */
+public interface ValueContext {
+    /**
+     * Get value associated with the context.
+     * @return value associated with context, may be null.
+     */
+    Object getValue();
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/CompositeLayout.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/CompositeLayout.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/CompositeLayout.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/CompositeLayout.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl;
+
+import org.apache.logging.core.Layout;
+import org.apache.logging.core.LogRecord;
+import org.apache.logging.core.LoggingException;
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Creates a composite layout.
+ *
+ */
+public final class CompositeLayout<T>
+        implements Layout<T>, Serializable {
+    /**
+     * List of layouts.
+     */
+    private final List< Layout<T> > layouts;
+
+    /**
+     * Creates a new thread-safe Layout by
+     * externally synchronizing an existing layout.
+     * @param originals original layouts, may not be null.
+     */
+    public CompositeLayout(final List< Layout<T> > originals) {
+        if (originals != null) {
+            layouts = new ArrayList < Layout<T> >(originals);
+        } else {
+            layouts = new ArrayList < Layout<T> >();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Object extract(final LogRecord record) {
+        ArrayList<Object> values = new ArrayList<Object>(layouts.size());
+        int i = 0;
+        for( Layout<T> layout : layouts) {
+            values.set(i++, layout.extract(record));
+        }
+        return values;
+    }
+
+
+    /** {@inheritDoc} */
+    public void render(final Object extract,
+                       final Locale locale,
+                       final T destination)
+            throws IOException, LoggingException {
+        for( Layout<T> layout : layouts) {
+            layout.render(extract, locale, destination);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void format(final LogRecord record,
+                       final Locale locale,
+                       final T destination)
+            throws IOException, LoggingException {
+        for( Layout<T> layout : layouts) {
+            layout.format(record, locale, destination);
+        }
+    }
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/LocalizedMessageFormat.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/core/impl/LocalizedMessageFormat.java?view=auto&rev=533406 \
                ==============================================================================
                
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/LocalizedMessageFormat.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/LocalizedMessageFormat.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public final class LocalizedMessageFormat {
+    private LocalizedMessageFormat() {
+
+    }
+    private static String getPattern(final String key,
+                              final ResourceBundle bundle) {
+        if (bundle != null) {
+            try {
+                return bundle.getString(key);
+            } catch(Exception ex) {
+                return key;
+            }
+        }
+        return key;
+    }
+
+    private static String getPattern(final ResourceBundle bundle,
+                              final String bundleName,
+                              final Locale locale,
+                              final String key) {
+        if (bundle != null) {
+            return getPattern(key, bundle);
+        }
+        try {
+            return getPattern(key,
+                    ResourceBundle.getBundle(bundleName,
+                        locale,
+                        Thread.currentThread().getContextClassLoader()));
+        } catch (Exception ex) {
+            try {
+                return getPattern(key,
+                    ResourceBundle.getBundle(bundleName,
+                        locale,
+                        ClassLoader.getSystemClassLoader()));
+            } catch(Exception ex2) {
+                return key;
+            }
+        }
+    }
+
+    public static String format(final ResourceBundle bundle,
+                          final String bundleName,
+                          final String key,
+                          final Locale locale,
+                          final Object[] parameters) {
+        if (bundle == null &&
+                (bundleName == null || bundleName.length() == 0) &&
+                (parameters == null || parameters.length == 0) ) {
+            return key;
+        }
+        String pattern = getPattern(bundle, bundleName, locale, key);
+        try {
+            return (new MessageFormat(pattern, locale)).format(parameters,
+                    new StringBuffer(), null).toString();
+        } catch(Exception ex) {
+            return pattern;
+        }
+    }
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/SynchronizedLayout.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/SynchronizedLayout.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/SynchronizedLayout.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/SynchronizedLayout.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl;
+
+import org.apache.logging.core.Layout;
+import org.apache.logging.core.LogRecord;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * Class externally synchronizes a Layout.
+ * After creation of the SynchronizedLayout
+ * the original layout should not be directly
+ * used.
+ *
+ * @ThreadSafe
+ */
+public final class SynchronizedLayout<T>
+        implements Layout<T>, Serializable {
+    /**
+     * Base extractor.
+     */
+    private final Layout<T> base;
+
+    /**
+     * Creates a new thread-safe Layout by
+     * externally synchronizing an existing layout.
+     * @param original layout, may not be null.
+     */
+    public SynchronizedLayout(final Layout<T> original) {
+        if (original == null) {
+            throw new NullPointerException("original");
+        }
+        base = original;
+    }
+
+    /** {@inheritDoc} */
+    public Object extract(final LogRecord record) {
+        synchronized(base) {
+            return base.extract(record);
+        }
+    }
+
+
+    /** {@inheritDoc} */
+    public void render(final Object extract,
+                       final Locale locale,
+                       final T destination) {
+        synchronized(base) {
+            render(extract, locale, destination);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void format(final LogRecord record,
+                       final Locale locale,
+                       final T destination) {
+        synchronized(base) {
+            format(record, locale, destination);
+        }
+    }
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/ThreadSafeLayoutFactory.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/core/impl/ThreadSafeLayoutFactory.java?view=auto&rev=533406 \
                ==============================================================================
                
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/ThreadSafeLayoutFactory.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/ThreadSafeLayoutFactory.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl;
+
+import org.apache.logging.core.Immutable;
+import org.apache.logging.core.Layout;
+import org.apache.logging.core.ThreadSafe;
+
+import java.util.List;
+
+/**
+ * Creates thread-safe layouts.
+ *
+ * @Immutable
+ *
+ */
+public final class ThreadSafeLayoutFactory<T> {
+
+    /**
+     * Creates an instance.
+     */
+    public ThreadSafeLayoutFactory() {
+    }
+
+    /**
+     * Determines if layout is thread-safe based on class annotations.
+     * @param layout layout, may not be null.
+     * @return true if thread-safe based on annotations.
+     */
+    public boolean isThreadSafe(final Layout<T> layout) {
+        return layout.getClass().isAnnotationPresent(Immutable.class) ||
+               layout.getClass().isAnnotationPresent(ThreadSafe.class);
+    }
+
+    /**
+     * Get a thread-safe layout given a base layout.
+     * Base layout should not be directly used after this call.
+     *
+     * @param layout base layout, may be null.
+     * @return thread-safe layout, may be same instance.
+     */
+    public Layout<T> get(final Layout<T> layout) {
+        if (isThreadSafe(layout)) {
+            return layout;
+        }
+        return new SynchronizedLayout<T>(layout);
+    }
+
+    /** Get a thread-safe composite layout given a list of layouts.
+    * Base layouts should not be directly used after this call.
+    *
+    * @param layouts base layouts, may be null.
+    * @return thread-safe layout, may be same instance.
+    */
+   public Layout<T> get(final List< Layout<T> > layouts) {
+       for (Layout<T> layout : layouts) {
+           if (!isThreadSafe(layout)) {
+               return new SynchronizedLayout<T>(new CompositeLayout<T>(layouts));
+           }
+       }
+       return new CompositeLayout<T>(layouts);
+   }
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLevel.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLevel.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLevel.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLevel.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.jdk;
+
+import org.apache.logging.core.Level;
+import org.apache.logging.core.impl.LocalizedMessageFormat;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * This class wraps an instance of java.util.Level
+ * to support the org.apache.logging.core.Level interface.
+ *
+ *
+ */
+public class JDKLevel implements Level, Serializable {
+    /**
+     * Underlying instance of java.util.logging.Level.
+     */
+    private final java.util.logging.Level base;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     */
+    private JDKLevel(final java.util.logging.Level source) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+    }
+
+
+    /**
+     * Create new instance.
+     * @param source underlying instance.
+     * @return new instance or null if source is null.
+     */
+    public static JDKLevel getInstance(final java.util.logging.Level source) {
+        if (source == null) {
+            return null;
+        }
+        return new JDKLevel(source);
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return base.toString();
+    }
+    
+    /** {@inheritDoc} */
+    public int intValue() {
+        return base.intValue();
+    }
+
+    /** {@inheritDoc} */
+    public String getLocalizedName(final Locale locale) {
+        return LocalizedMessageFormat.format(
+                null,
+                base.getResourceBundleName(),
+                base.getName(),
+                locale,
+                null);
+    }
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLogRecord.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLogRecord.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLogRecord.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKLogRecord.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.jdk;
+
+import org.apache.logging.core.Level;
+import org.apache.logging.core.impl.log4j1.Log4j1Context;
+
+import java.io.Serializable;
+
+/**
+ *  This class wraps an instance of java.util.logging.LogRecord
+ * to implement the org.apache.logging.core.LogRecord interface.
+ */
+public final class JDKLogRecord
+        implements org.apache.logging.core.LogRecord, Serializable {
+    /**
+     * Underlying instance.
+     */
+    private final java.util.logging.LogRecord base;
+
+    /**
+     * Thread name.
+     */
+    private final String threadName;
+
+    /**
+     * Thread name.
+     */
+    private final Object context;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     */
+    private JDKLogRecord(final java.util.logging.LogRecord source,
+                         final String threadName,
+                         final Object context) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+        this.threadName = threadName;
+        this.context = context;
+    }
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may be null.
+     */
+    public static JDKLogRecord getInstance(
+            final java.util.logging.LogRecord source,
+            final String threadName,
+            final Object context) {
+        if (source == null) {
+            return null;
+        }
+        return new JDKLogRecord(source, threadName, context);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Level getLevel() {
+        return JDKLevel.getInstance(base.getLevel());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getLoggerName() {
+        return base.getLoggerName();
+    }
+
+    /** {@inheritDoc} */
+    public StackTraceElement getSource() {
+        return new StackTraceElement(base.getSourceClassName(),
+                base.getSourceMethodName(),
+                null, -1);
+                
+    }
+
+    /**{@inheritDoc} */
+    public Object getMessage() {
+        return JDKMessage.getInstance(base.getMessage(),
+                base.getParameters(),
+                base.getResourceBundle(),
+                base.getResourceBundleName());
+
+    }
+
+
+    /** {@inheritDoc} */
+    public long getThreadID() {
+        return base.getThreadID();
+    }
+
+    /** {@inheritDoc} */
+    public String getThreadName() {
+        return threadName;
+    }
+
+
+
+    /** {@inheritDoc} */
+    public long getMillis() {
+        return base.getMillis();
+    }
+
+
+    /** {@inheritDoc} */
+    public Throwable getThrown() {
+        return base.getThrown();
+    }
+
+    /** {@inheritDoc} */
+    public Object getContext() {
+        return context;
+    }
+
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKMessage.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKMessage.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKMessage.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/jdk/JDKMessage.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.jdk;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.text.MessageFormat;
+import java.io.Serializable;
+import org.apache.logging.core.Localizable;
+import org.apache.logging.core.impl.*;
+
+/**
+ * This object encapsulates all aspects of a JDKLogRecord
+ * that participate in the evaluation of the
+ * message text.
+ *
+ */
+public final class JDKMessage implements Localizable, Serializable {
+    /**
+     * Pattern or key.
+     */
+    private final String message;
+    /**
+     * Parameters.
+     */
+    private final Object[] parameters;
+    /**
+     * Resource bundle.
+     */
+    private final transient ResourceBundle bundle;
+    /**
+     * Resource bundle name.
+     */
+    private final String bundleName;
+
+    /**
+     * Create new instance.
+     * @param message pattern or key.
+     * @param parameters parameters.
+     * @param bundle resource bundle, may be null.
+     * @param bundleName resource bundle name, may be null.
+     */
+    private JDKMessage(final String message,
+                       final Object[] parameters,
+                       final ResourceBundle bundle,
+                       final String bundleName
+                       ) {
+        this.message = message;
+        if (parameters == null) {
+            this.parameters = null;
+        } else {
+            this.parameters = parameters.clone();
+        }
+        this.bundle = bundle;
+        this.bundleName = bundleName;
+    }
+
+
+    /**
+     * Create new instance.
+     * @param message pattern or key.
+     * @param parameters parameters.
+     * @param bundle resource bundle, may be null.
+     * @param bundleName resource bundle name, may be null.
+     * @return new instance.
+     */
+    public static JDKMessage getInstance(final String message,
+                       final Object[] parameters,
+                       final ResourceBundle bundle,
+                       final String bundleName
+                       ) {
+        return new JDKMessage(message, parameters, bundle, bundleName);
+    }
+    /**
+     * Evaluated message for specified locale.
+     * @param locale locale.
+     * @return evaluated message.
+     */
+    public String getLocalizedName(final Locale locale) {
+        return LocalizedMessageFormat.format(bundle,
+                bundleName, message, locale, parameters);
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return message;
+    }
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Context.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/core/impl/log4j1/Log4j1Context.java?view=auto&rev=533406 \
                ==============================================================================
                
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Context.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Context.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.log4j1;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.logging.core.PropertyContext;
+import org.apache.logging.core.ValueContext;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ *  This class wraps an instance of org.apache.log4j.spi.LoggingEvent
+ * to implement the org.apache.logging.core.LogRecord interface.
+ */
+public final class Log4j1Context
+        implements ValueContext, PropertyContext,
+            Serializable {
+    private static final Method getPropertiesMethod;
+    static {
+        Method getProps;
+            try {
+               getProps = LoggingEvent.class.getMethod(
+                          "getProperties");
+            } catch(Exception ex) {
+               getProps = null;
+            }
+        getPropertiesMethod = getProps;
+    }
+
+    /**
+     * Underlying instance.
+     */
+    private final LoggingEvent base;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     */
+    private Log4j1Context(final LoggingEvent source) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+    }
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may be null.
+     * @return new instance.
+     */
+    public static Log4j1Context getInstance(
+            final LoggingEvent source) {
+        if (source == null) {
+            return null;
+        }
+        return new Log4j1Context(source);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getValue() {
+        return base.getNDC();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     */
+    public Map<String,Object> getProperties() {
+        return new HashMap<String, Object>();
+    }
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Level.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Level.java?view=auto&rev=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Level.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1Level.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.log4j1;
+
+import java.util.Locale;
+
+/**
+ * This class wraps an instance of org.apache.log4j.Priority
+ * to support the org.apache.logging.core.Level interface.
+ *
+ *
+ */
+public class Log4j1Level implements org.apache.logging.core.Level {
+    /**
+     * Underlying instance of org.apache.log4j.Priority.
+     */
+    private final org.apache.log4j.Priority base;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     */
+    private Log4j1Level(final org.apache.log4j.Priority source) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+    }
+
+
+    /**
+     * Create new instance.
+     * @param source underlying instance.
+     * @return new instance or null if source is null.
+     */
+    public static Log4j1Level getInstance(final org.apache.log4j.Priority source) {
+        if (source == null) {
+            return null;
+        }
+        return new Log4j1Level(source);
+    }
+
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return base.toString();
+    }
+
+    /** {@inheritDoc} */
+    public int intValue() {
+        return base.toInt();
+    }
+
+    /** {@inheritDoc} */
+    public String getLocalizedName(final Locale locale) {
+        return base.toString();
+    }
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1LogRecord.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/core/impl/log4j1/Log4j1LogRecord.java?view=auto&rev=533406 \
                ==============================================================================
                
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1LogRecord.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1LogRecord.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.log4j1;
+
+import org.apache.logging.core.Level;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.LocationInfo;
+import org.apache.log4j.spi.ThrowableInformation;
+import java.io.Serializable;
+
+
+/**
+ *  This class wraps an instance of org.apache.log4j.spi.LoggingEvent
+ * to implement the org.apache.logging.core.LogRecord interface.
+ */
+public final class Log4j1LogRecord
+        implements org.apache.logging.core.LogRecord,
+            Serializable {
+    /**
+     * Underlying instance.
+     */
+    private final LoggingEvent base;
+
+    /**
+     * Thread id.
+     */
+    private final long threadId;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     * @param threadId thread id, use -1 for unavailable.
+     */
+    private Log4j1LogRecord(final LoggingEvent source,
+                            long threadId) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+        this.threadId = threadId;
+    }
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may be null.
+     * @param threadId thread id, use -1 for unavailable.
+     * @return new instance of null if source is null.
+     */
+    public static Log4j1LogRecord getInstance(
+            final LoggingEvent source,
+            long threadId) {
+        if (source == null) {
+            return null;
+        }
+        return new Log4j1LogRecord(source, threadId);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Level getLevel() {
+        return Log4j1Level.getInstance(base.getLevel());
+    }
+
+    /** {@inheritDoc} */
+    public String getLoggerName() {
+        return base.getLoggerName();
+    }
+
+    /** {@inheritDoc} */
+    public StackTraceElement getSource() {
+        LocationInfo li = base.getLocationInformation();
+        if (li != null) {
+            int lineNumber = -1;
+            String lineStr = li.getLineNumber();
+            if (lineStr != null && lineStr.length() > 0) {
+                try {
+                    lineNumber = Integer.parseInt(lineStr);
+                } catch(Exception ex) {
+                }
+            }
+            return new StackTraceElement(li.getClassName(),
+                    li.getMethodName(),
+                    li.getFileName(),
+                    lineNumber);
+        }
+        return null;
+    }
+
+    /**{@inheritDoc} */
+    public Object getMessage() {
+        return base.toString();
+    }
+
+
+    /** {@inheritDoc} */
+    public long getThreadID() {
+        return threadId;
+    }
+
+    /** {@inheritDoc} */
+    public String getThreadName() {
+        return base.getThreadName();
+    }
+
+    /** {@inheritDoc} */
+    public long getMillis() {
+        return base.timeStamp;
+    }
+
+
+    /** {@inheritDoc} */
+    public Throwable getThrown() {
+        ThrowableInformation ti = base.getThrowableInformation();
+        if (ti != null) {
+            return ti.getThrowable();
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Object getContext() {
+        return Log4j1Context.getInstance(base);
+    }
+
+}

Added: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1PropertyMap.java
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/core/impl/log4j1/Log4j1PropertyMap.java?view=auto&rev=533406 \
                ==============================================================================
                
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1PropertyMap.java \
                (added)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/core/impl/log4j1/Log4j1PropertyMap.java \
Sat Apr 28 11:43:37 2007 @@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.core.impl.log4j1;
+
+import org.apache.log4j.pattern.LogEvent;
+import org.apache.log4j.spi.LoggingEvent;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * This class implements a Map<String, Object> backed by
+ * the MDC contents of a LoggingEvent.  log4j 1.2 versions
+ * prior to log4j 1.2.15 did not provide a mechanism to
+ * get all MDC values.  This class implements a brute-force
+ * mechanism to extract those values when an operation that
+ * requires access to the whole set.  Single value retrievals
+ * are done by a direct call to LoggingEvent.getMDC().
+ */
+public final class Log4j1PropertyMap
+        implements Map<String, Object>, Serializable {
+
+    /**
+     * Reflective method to call MDC contents added in log4j 1.2.15.
+     */
+    private static final Method getPropertiesMethod;
+    static {
+        Method getProps;
+            try {
+               getProps = LoggingEvent.class.getMethod(
+                          "getProperties");
+            } catch(Exception ex) {
+               getProps = null;
+            }
+        getPropertiesMethod = getProps;
+    }
+
+    /**
+     * Underlying instance.
+     */
+    private final LoggingEvent base;
+
+    private transient Map mdc;
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may not be null.
+     */
+    private Log4j1PropertyMap(final LoggingEvent source) {
+        if (source == null) {
+            throw new NullPointerException("source");
+        }
+        base = source;
+    }
+
+    /**
+     * Create new instance.
+     * @param source underlying instance, may be null.
+     * @return new instance.
+     */
+    public static Log4j1PropertyMap getInstance(
+            final LoggingEvent source) {
+        if (source == null) {
+            return null;
+        }
+        return new Log4j1PropertyMap(source);
+    }
+
+    /**
+     * If access to all the MDC properties are required
+     * we have to go to pretty extreme lengths to
+     * get them.
+     *
+     * @return
+     */
+    private synchronized Map<String, Object> getMDC() {
+        if (mdc == null) {
+            mdc = new HashMap<String, Object>();
+            if (getPropertiesMethod != null) {
+                try {
+                    mdc.putAll((Map) getPropertiesMethod.invoke(base));
+                } catch(Exception ex) {
+                    assert false;
+                }
+            } else {
+                //
+                //  for 1.2.14 and earlier could serialize and
+                //    extract MDC content
+                try {
+                  ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
+                  ObjectOutputStream os = new ObjectOutputStream(outBytes);
+                  os.writeObject(base);
+                  os.close();
+
+                  byte[] raw = outBytes.toByteArray();
+                  //
+                  //   bytes 6 and 7 should be the length of the original classname
+                  //     should be the same as our substitute class name
+                  final String subClassName = LogEvent.class.getName();
+                  if (raw[6] == 0 || raw[7] == subClassName.length()) {
+                      //
+                      //  manipulate stream to use our class name
+                      //
+                      for (int i = 0; i < subClassName.length(); i++) {
+                          raw[8 + i] = (byte) subClassName.charAt(i);
+                      }
+                      ByteArrayInputStream inBytes = new ByteArrayInputStream(raw);
+                      ObjectInputStream is = new ObjectInputStream(inBytes);
+                      Object cracked = is.readObject();
+                      assert cracked instanceof LogEvent;
+                      if (cracked instanceof LogEvent) {
+                          mdc.putAll(((LogEvent) cracked).getProperties());
+                      }
+                      is.close();
+                  } else {
+                      assert false;
+                  }
+                } catch(Exception ex) {
+                    assert false;
+                }
+            }
+        }
+        return mdc;
+
+    }
+
+    /** {@inheritDoc} */
+    public int size() {
+        return getMDC().size();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isEmpty() {
+        return getMDC().isEmpty();
+    }
+
+    /** {@inheritDoc} */
+    public boolean containsKey(final Object key) {
+        return base.getMDC((String) key) != null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean containsValue(final Object value) {
+        return getMDC().containsValue(value);
+    }
+
+    /** {@inheritDoc} */
+    public Object get(final Object key) {
+        return base.getMDC((String) key);
+    }
+
+    /** {@inheritDoc} */
+    public Object put(final String key, final Object value) {
+        throw new UnsupportedOperationException();
+    }
+    
+    /** {@inheritDoc} */
+    public Object remove(final Object key) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void putAll(Map<? extends String,? extends Object> t) {
+        throw new UnsupportedOperationException();
+        
+    }
+
+    /** {@inheritDoc} */
+    public void clear() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Set<String> keySet() {
+        return getMDC().keySet();
+    }
+
+    /** {@inheritDoc} */
+    public Collection<Object> values() {
+        return getMDC().values();
+    }
+
+    /** {@inheritDoc} */
+    public Set<Map.Entry<String,Object>> entrySet() {
+        return getMDC().entrySet();
+    }
+    
+}

Copied: logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/AbbreviatorLayout.java \
(from r533235, logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java)
                
URL: http://svn.apache.org/viewvc/logging/sandbox/experimental/pattern-layout/src/main \
/java/org/apache/logging/pattern/AbbreviatorLayout.java?view=diff&rev=533406&p1=loggin \
g/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/NameAbbre \
viator.java&r1=533235&p2=logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/AbbreviatorLayout.java&r2=533406
 ==============================================================================
--- logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java \
                (original)
+++ logging/sandbox/experimental/pattern-layout/src/main/java/org/apache/logging/pattern/AbbreviatorLayout.java \
Sat Apr 28 11:43:37 2007 @@ -14,293 +14,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.logging.pattern;
 
-package org.apache.log4j.pattern;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.logging.core.Layout;
 
+import java.util.Locale;
 
 /**
- * NameAbbreviator generates abbreviated logger and class names.
+ * Class handles abbreviation of fields.
+ *
  *
- * @author Curt Arnold
- * @since 1.3
  */
-public abstract class NameAbbreviator {
-  /**
-   * Default (no abbreviation) abbreviator.
-   */
-  private static final NameAbbreviator DEFAULT = new NOPAbbreviator();
-
-  /**
-   * Gets an abbreviator.
-   *
-   * For example, "%logger{2}" will output only 2 elements of the logger name,
-   * "%logger{1.}" will output only the first character of the non-final elements in \
                the name,
-   * "%logger(1~.2~} will output the first character of the first element, two \
                characters of
-   * the second and subsequent elements and will use a tilde to indicate abbreviated \
                characters.
-   *
-   * @param pattern abbreviation pattern.
-   * @return abbreviator, will not be null.
-   */
-  public static NameAbbreviator getAbbreviator(final String pattern) {
-    if (pattern.length() > 0) {
-      //  if pattern is just spaces and numbers then
-      //     use MaxElementAbbreviator
-      String trimmed = pattern.trim();
-
-      if (trimmed.length() == 0) {
-        return DEFAULT;
-      }
-
-      int i = 0;
-
-      while (
-        (i < trimmed.length()) && (trimmed.charAt(i) >= '0')
-          && (trimmed.charAt(i) <= '9')) {
-        i++;
-      }
-
-      //
-      //  if all blanks and digits
-      //
-      if (i == trimmed.length()) {
-        return new MaxElementAbbreviator(Integer.parseInt(trimmed));
-      }
-
-      ArrayList fragments = new ArrayList(5);
-      char ellipsis;
-      int charCount;
-      int pos = 0;
-
-      while ((pos < trimmed.length()) && (pos >= 0)) {
-        int ellipsisPos = pos;
-
-        if (trimmed.charAt(pos) == '*') {
-          charCount = Integer.MAX_VALUE;
-          ellipsisPos++;
-        } else {
-          if ((trimmed.charAt(pos) >= '0') && (trimmed.charAt(pos) <= '9')) {
-            charCount = trimmed.charAt(pos) - '0';
-            ellipsisPos++;
-          } else {
-            charCount = 0;
-          }
-        }
-
-        ellipsis = '\0';
-
-        if (ellipsisPos < trimmed.length()) {
-          ellipsis = trimmed.charAt(ellipsisPos);
+public final class AbbreviatorLayout extends DecoratorLayout {
 
-          if (ellipsis == '.') {
-            ellipsis = '\0';
-          }
-        }
+    public AbbreviatorLayout(final Layout<StringBuilder> nested,
+                       final int width,
+                       final boolean leftJustify) {
+        super(nested);
 
-        fragments.add(new PatternAbbreviatorFragment(charCount, ellipsis));
-        pos = trimmed.indexOf(".", pos);
-
-        if (pos == -1) {
-          break;
-        }
-
-        pos++;
-      }
-
-      return new PatternAbbreviator(fragments);
     }
 
-    //
-    //  no matching abbreviation, return defaultAbbreviator
-    //
-    return DEFAULT;
-  }
+    /**  {@inheritDoc} */
+    protected void decorate(final Object extract,
+                            final Locale locale,
+                            final StringBuilder destination,
+                            final int initialPos) {
 
-  /**
-   * Gets default abbreviator.
-   *
-   * @return default abbreviator.
-   */
-  public static NameAbbreviator getDefaultAbbreviator() {
-    return DEFAULT;
-  }
-
-  /**
-   * Abbreviates a name in a StringBuffer.
-   *
-   * @param nameStart starting position of name in buf.
-   * @param buf buffer, may not be null.
-   */
-  public abstract void abbreviate(final int nameStart, final StringBuffer buf);
-
-  /**
-   * Abbreviator that simply appends full name to buffer.
-   */
-  private static class NOPAbbreviator extends NameAbbreviator {
-    /**
-     * Constructor.
-     */
-    public NOPAbbreviator() {
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void abbreviate(final int nameStart, final StringBuffer buf) {
-    }
-  }
-
-  /**
-   * Abbreviator that drops starting path elements.
-   */
-  private static class MaxElementAbbreviator extends NameAbbreviator {
-    /**
-     * Maximum number of path elements to output.
-     */
-    private final int count;
-
-    /**
-     * Create new instance.
-     * @param count maximum number of path elements to output.
-     */
-    public MaxElementAbbreviator(final int count) {
-      this.count = count;
-    }
-
-    /**
-     * Abbreviate name.
-     * @param buf buffer to append abbreviation.
-     * @param nameStart start of name to abbreviate.
-     */
-    public void abbreviate(final int nameStart, final StringBuffer buf) {
-      int len = buf.length() - nameStart;
-
-      // We substract 1 from 'len' when assigning to 'end' to avoid out of
-      // bounds exception in return r.substring(end+1, len). This can happen if
-      // precision is 1 and the category name ends with a dot.
-      int end = buf.length() - 1;
 
-      String bufString = buf.toString();
-      for (int i = count; i > 0; i--) {
-        end = bufString.lastIndexOf(".", end - 1);
-
-        if ((end == -1) || (end < nameStart)) {
-          return;
-        }
-      }
-
-      buf.delete(nameStart, end + 1);
-    }
-  }
-
-  /**
-   * Fragment of an pattern abbreviator.
-   *
-   */
-  private static class PatternAbbreviatorFragment {
-    /**
-     * Count of initial characters of element to output.
-     */
-    private final int charCount;
-
-    /**
-     *  Character used to represent dropped characters.
-     * '\0' indicates no representation of dropped characters.
-     */
-    private final char ellipsis;
-
-    /**
-     * Creates a PatternAbbreviatorFragment.
-     * @param charCount number of initial characters to preserve.
-     * @param ellipsis character to represent elimination of characters,
-     *    '\0' if no ellipsis is desired.
-     */
-    public PatternAbbreviatorFragment(
-      final int charCount, final char ellipsis) {
-      this.charCount = charCount;
-      this.ellipsis = ellipsis;
-    }
-
-    /**
-     * Abbreviate element of name.
-     * @param buf buffer to receive element.
-     * @param startPos starting index of name element.
-     * @return starting index of next element.
-     */
-    public int abbreviate(final StringBuffer buf, final int startPos) {
-      int nextDot = buf.toString().indexOf(".", startPos);
-
-      if (nextDot != -1) {
-        if ((nextDot - startPos) > charCount) {
-          buf.delete(startPos + charCount, nextDot);
-          nextDot = startPos + charCount;
-
-          if (ellipsis != '\0') {
-            buf.insert(nextDot, ellipsis);
-            nextDot++;
-          }
-        }
-
-        nextDot++;
-      }
-
-      return nextDot;
-    }
-  }
-
-  /**
-   * Pattern abbreviator.
-   *
-   *
-   */
-  private static class PatternAbbreviator extends NameAbbreviator {
-    /**
-     * Element abbreviation patterns.
-     */
-    private final PatternAbbreviatorFragment[] fragments;
-
-    /**
-     * Create PatternAbbreviator.
-     *
-     * @param fragments element abbreviation patterns.
-     */
-    public PatternAbbreviator(List fragments) {
-      if (fragments.size() == 0) {
-        throw new IllegalArgumentException(
-          "fragments must have at least one element");
-      }
-
-      this.fragments = new PatternAbbreviatorFragment[fragments.size()];
-      fragments.toArray(this.fragments);
-    }
-
-    /**
-     * Abbreviate name.
-     * @param buf buffer that abbreviated name is appended.
-     * @param nameStart start of name.
-     */
-    public void abbreviate(final int nameStart, final StringBuffer buf) {
-      //
-      //  all non-terminal patterns are executed once
-      //
-      int pos = nameStart;
-
-      for (int i = 0; (i < (fragments.length - 1)) && (pos < buf.length());
-          i++) {
-        pos = fragments[i].abbreviate(buf, pos);
-      }
-
-      //
-      //   last pattern in executed repeatedly
-      //
-      PatternAbbreviatorFragment terminalFragment =
-        fragments[fragments.length - 1];
-
-      while ((pos < buf.length()) && (pos >= 0)) {
-        pos = terminalFragment.abbreviate(buf, pos);
-      }
-    }
-  }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic