Author: rgoers
Date: Thu Dec 29 07:58:34 2011
New Revision: 1225462
URL: http://svn.apache.org/viewvc?rev=1225462&view=rev
Log:
More Javadoc/Checkstyle fixes
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
Thu Dec 29 07:58:34 2011
@@ -61,6 +61,8 @@ public final class BurstFilter extends F
private static final int DEFAULT_RATE_MULTIPLE = 100;
+ private static final int HASH_SHIFT = 32;
+
/**
* Level of messages to be filtered. Anything at or below this level will
be
* filtered out if <code>maxBurst</code> has been exceeded. The default is
@@ -198,7 +200,7 @@ public final class BurstFilter extends F
@Override
public int hashCode() {
- return (int) (expireTime ^ (expireTime >>> 32));
+ return (int) (expireTime ^ (expireTime >>> HASH_SHIFT));
}
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
Thu Dec 29 07:58:34 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.helpers;
import org.apache.logging.log4j.Logger;
@@ -22,7 +21,6 @@ import org.apache.logging.log4j.status.S
import java.io.InputStream;
import java.io.InterruptedIOException;
-import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
@@ -30,13 +28,13 @@ import java.net.URL;
* Load resources (or images) from various sources.
*/
-public class Loader {
+public final class Loader {
- static final String TSTR = "Caught Exception while in Loader.getResource.
This may be innocuous.";
+ private static final String TSTR = "Caught Exception while in
Loader.getResource. This may be innocuous.";
- static private boolean ignoreTCL = false;
+ private static boolean ignoreTCL = false;
- static Logger logger = StatusLogger.getLogger();
+ private static final Logger LOGGER = StatusLogger.getLogger();
static {
String ignoreTCLProp =
OptionConverter.getSystemProperty("log4j.ignoreTCL", null);
@@ -45,6 +43,9 @@ public class Loader {
}
}
+ private Loader() {
+ }
+
/**
* This method will search for <code>resource</code> in different
* places. The search order is as follows:
@@ -73,7 +74,7 @@ public class Loader {
try {
classLoader = getTCL();
if (classLoader != null) {
- logger.trace("Trying to find [" + resource + "] using context
classloader "
+ LOGGER.trace("Trying to find [" + resource + "] using context
classloader "
+ classLoader + ".");
url = classLoader.getResource(resource);
if (url != null) {
@@ -84,32 +85,32 @@ public class Loader {
// We could not find resource. Let us now try with the classloader
that loaded this class.
classLoader = Loader.class.getClassLoader();
if (classLoader != null) {
- logger.trace("Trying to find [" + resource + "] using " +
classLoader + " class loader.");
+ LOGGER.trace("Trying to find [" + resource + "] using " +
classLoader + " class loader.");
url = classLoader.getResource(resource);
if (url != null) {
return url;
}
}
} catch (IllegalAccessException t) {
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
} catch (InvocationTargetException t) {
if (t.getTargetException() instanceof InterruptedException
|| t.getTargetException() instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
} catch (Throwable t) {
//
// can't be InterruptedException or InterruptedIOException
// since not declared, must be error or RuntimeError.
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
}
// Last ditch attempt: get the resource from the class path. It
// may be the case that clazz was loaded by the Extentsion class
// loader which the parent of the system class loader. Hence the
// code below.
- logger.trace("Trying to find [" + resource + "] using
ClassLoader.getSystemResource().");
+ LOGGER.trace("Trying to find [" + resource + "] using
ClassLoader.getSystemResource().");
return ClassLoader.getSystemResource(resource);
}
@@ -142,7 +143,7 @@ public class Loader {
try {
classLoader = getTCL();
if (classLoader != null) {
- logger.trace("Trying to find [" + resource + "] using context
classloader " + classLoader + ".");
+ LOGGER.trace("Trying to find [" + resource + "] using context
classloader " + classLoader + ".");
is = classLoader.getResourceAsStream(resource);
if (is != null) {
return is;
@@ -152,7 +153,7 @@ public class Loader {
// We could not find resource. Let us now try with the classloader
that loaded this class.
classLoader = Loader.class.getClassLoader();
if (classLoader != null) {
- logger.trace("Trying to find [" + resource + "] using " +
classLoader + " class loader.");
+ LOGGER.trace("Trying to find [" + resource + "] using " +
classLoader + " class loader.");
is = classLoader.getResourceAsStream(resource);
if (is != null) {
return is;
@@ -161,35 +162,41 @@ public class Loader {
// We could not find resource. Finally try with the default
ClassLoader.
if (defaultLoader != null) {
- logger.trace("Trying to find [" + resource + "] using " +
defaultLoader + " class loader.");
+ LOGGER.trace("Trying to find [" + resource + "] using " +
defaultLoader + " class loader.");
is = defaultLoader.getResourceAsStream(resource);
if (is != null) {
return is;
}
}
} catch (IllegalAccessException t) {
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
} catch (InvocationTargetException t) {
if (t.getTargetException() instanceof InterruptedException
|| t.getTargetException() instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
} catch (Throwable t) {
//
// can't be InterruptedException or InterruptedIOException
// since not declared, must be error or RuntimeError.
- logger.warn(TSTR, t);
+ LOGGER.warn(TSTR, t);
}
// Last ditch attempt: get the resource from the class path. It
// may be the case that clazz was loaded by the Extentsion class
// loader which the parent of the system class loader. Hence the
// code below.
- logger.trace("Trying to find [" + resource + "] using
ClassLoader.getSystemResource().");
+ LOGGER.trace("Trying to find [" + resource + "] using
ClassLoader.getSystemResource().");
return ClassLoader.getSystemResourceAsStream(resource);
}
+ /**
+ * Load a Class by name.
+ * @param clazz The class name.
+ * @return The Class.
+ * @throws ClassNotFoundException if the Class could not be found.
+ */
public static Class loadClass(String clazz) throws ClassNotFoundException {
// Just call Class.forName(clazz) if we are instructed to ignore the
TCL.
if (ignoreTCL) {
@@ -197,13 +204,16 @@ public class Loader {
} else {
try {
return getTCL().loadClass(clazz);
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
return Class.forName(clazz);
}
}
}
+ /**
+ * Return the ClassLoader to use.
+ * @return the ClassLoader.
+ */
public static ClassLoader getClassLoader() {
ClassLoader cl = null;
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
Thu Dec 29 07:58:34 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.helpers;
import org.apache.logging.log4j.Logger;
@@ -25,14 +24,15 @@ import java.util.Properties;
/**
* A convenience class to convert property values to specific types.
*/
-public class OptionConverter {
+public final class OptionConverter {
- private static Logger logger = StatusLogger.getLogger();
+ private static final Logger LOGGER = StatusLogger.getLogger();
- static String DELIM_START = "${";
- static char DELIM_STOP = '}';
- static int DELIM_START_LEN = 2;
- static int DELIM_STOP_LEN = 1;
+ private static final String DELIM_START = "${";
+ private static final char DELIM_STOP = '}';
+ private static final int DELIM_START_LEN = 2;
+ private static final int DELIM_STOP_LEN = 1;
+ private static final int ONE_K = 1024;
/**
* OptionConverter is a static class.
@@ -97,7 +97,7 @@ public class OptionConverter {
try {
return System.getProperty(key, def);
} catch (Throwable e) { // MS-Java throws
com.ms.security.SecurityExceptionEx
- logger.debug("Was not allowed to read system property \"" + key +
"\".");
+ LOGGER.debug("Was not allowed to read system property \"" + key +
"\".");
return def;
}
}
@@ -109,7 +109,7 @@ public class OptionConverter {
// Get the value of the property in string form
String className = findAndSubst(key, props);
if (className == null) {
- logger.error("Could not find value for key " + key);
+ LOGGER.error("Could not find value for key " + key);
return defaultValue;
}
// Trim className to avoid trailing spaces that cause problems.
@@ -124,6 +124,9 @@ public class OptionConverter {
* returned.
* <p/>
* <p>Case of value is unimportant.
+ * @param value The value to convert.
+ * @param dEfault The default value.
+ * @return true or false, depending on the value and/or default.
*/
public static boolean toBoolean(String value, boolean dEfault) {
if (value == null) {
@@ -150,9 +153,8 @@ public class OptionConverter {
String s = value.trim();
try {
return Integer.valueOf(s);
- }
- catch (NumberFormatException e) {
- logger.error("[" + s + "] is not in proper int form.");
+ } catch (NumberFormatException e) {
+ LOGGER.error("[" + s + "] is not in proper int form.");
e.printStackTrace();
}
}
@@ -175,22 +177,21 @@ public class OptionConverter {
int index;
if ((index = s.indexOf("KB")) != -1) {
- multiplier = 1024;
+ multiplier = ONE_K;
s = s.substring(0, index);
} else if ((index = s.indexOf("MB")) != -1) {
- multiplier = 1024 * 1024;
+ multiplier = ONE_K * ONE_K;
s = s.substring(0, index);
} else if ((index = s.indexOf("GB")) != -1) {
- multiplier = 1024 * 1024 * 1024;
+ multiplier = ONE_K * ONE_K * ONE_K;
s = s.substring(0, index);
}
if (s != null) {
try {
return Long.valueOf(s) * multiplier;
- }
- catch (NumberFormatException e) {
- logger.error("[" + s + "] is not in proper int form.");
- logger.error("[" + value + "] not in expected format.", e);
+ } catch (NumberFormatException e) {
+ LOGGER.error("[" + s + "] is not in proper int form.");
+ LOGGER.error("[" + value + "] not in expected format.", e);
}
}
return dEfault;
@@ -213,7 +214,7 @@ public class OptionConverter {
try {
return substVars(value, props);
} catch (IllegalArgumentException e) {
- logger.error("Bad option value [" + value + "].", e);
+ LOGGER.error("Bad option value [" + value + "].", e);
return value;
}
}
@@ -235,23 +236,23 @@ public class OptionConverter {
try {
Class classObj = Loader.loadClass(className);
if (!superClass.isAssignableFrom(classObj)) {
- logger.error("A \"" + className + "\" object is not
assignable to a \"" +
+ LOGGER.error("A \"" + className + "\" object is not
assignable to a \"" +
superClass.getName() + "\" variable.");
- logger.error("The class \"" + superClass.getName() + "\"
was loaded by ");
- logger.error("[" + superClass.getClassLoader() + "]
whereas object of type ");
- logger.error("\"" + classObj.getName() + "\" was loaded by
["
+ LOGGER.error("The class \"" + superClass.getName() + "\"
was loaded by ");
+ LOGGER.error("[" + superClass.getClassLoader() + "]
whereas object of type ");
+ LOGGER.error("\"" + classObj.getName() + "\" was loaded by
["
+ classObj.getClassLoader() + "].");
return defaultValue;
}
return classObj.newInstance();
} catch (ClassNotFoundException e) {
- logger.error("Could not instantiate class [" + className +
"].", e);
+ LOGGER.error("Could not instantiate class [" + className +
"].", e);
} catch (IllegalAccessException e) {
- logger.error("Could not instantiate class [" + className +
"].", e);
+ LOGGER.error("Could not instantiate class [" + className +
"].", e);
} catch (InstantiationException e) {
- logger.error("Could not instantiate class [" + className +
"].", e);
+ LOGGER.error("Could not instantiate class [" + className +
"].", e);
} catch (RuntimeException e) {
- logger.error("Could not instantiate class [" + className +
"].", e);
+ LOGGER.error("Could not instantiate class [" + className +
"].", e);
}
}
return defaultValue;
@@ -301,7 +302,8 @@ public class OptionConverter {
StringBuilder sbuf = new StringBuilder();
int i = 0;
- int j, k;
+ int j;
+ int k;
while (true) {
j = val.indexOf(DELIM_START, i);
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
Thu Dec 29 07:58:34 2011
@@ -20,7 +20,7 @@ package org.apache.logging.log4j.core.he
/**
* Utility class for transforming strings.
*/
-public class Transform {
+public final class Transform {
private static final String CDATA_START = "<![CDATA[";
private static final String CDATA_END = "]]>";
@@ -28,6 +28,9 @@ public class Transform {
private static final String CDATA_EMBEDED_END = CDATA_END +
CDATA_PSEUDO_END + CDATA_START;
private static final int CDATA_END_LEN = CDATA_END.length();
+ private Transform() {
+ }
+
/**
* This method takes a string which may contain HTML tags (ie,
* <b>, <table>, etc) and replaces any
@@ -37,7 +40,7 @@ public class Transform {
* @param input The text to be converted.
* @return The input string with the special characters replaced.
*/
- static public String escapeTags(final String input) {
+ public static String escapeTags(final String input) {
//Check if the string is null, zero length or devoid of special
characters
// if so, return what was sent in.
@@ -85,8 +88,7 @@ public class Transform {
* section are the responsibility of the calling method.
* @param str The String that is inserted into an existing CDATA Section
within buf.
*/
- static public void appendEscapingCDATA(final StringBuilder buf,
- final String str) {
+ public static void appendEscapingCDATA(final StringBuilder buf, final
String str) {
if (str != null) {
int end = str.indexOf(CDATA_END);
if (end < 0) {
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
Thu Dec 29 07:58:34 2011
@@ -31,8 +31,7 @@ import java.util.concurrent.atomic.Atomi
* Generates a unique id. The generated UUID will be unique for approximately
8,925 years so long as
* less than 4095 ids are generated per millisecond on the same device (as
identified by its MAC adddress).
*/
-public final class UUIDUtil
-{
+public final class UUIDUtil {
/**
* System property that may be used to seed the uuid generation with an
integer value.
*/
@@ -44,22 +43,28 @@ public final class UUIDUtil
private static final long TYPE1 = 0x1000L;
- private static final byte VARIANT = (byte)0x80;
+ private static final byte VARIANT = (byte) 0x80;
private static final int SEQUENCE_MASK = 0x3FFF;
- public static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH =
0x01b21dd213814000L;
+ private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH =
0x01b21dd213814000L;
private static long uuidSequence = Long.getLong(UUID_SEQUENCE, 0);
private static long least;
+ private static final long LOW_MASK = 0xffffffffL;
+ private static final long MID_MASK = 0xffff00000000L;
+ private static final long HIGH_MASK = 0xfff000000000000L;
+ private static final int NODE_SIZE = 8;
+ private static final int SHIFT_2 = 16;
+ private static final int SHIFT_4 = 32;
+ private static final int SHIFT_6 = 48;
+ private static final int HUNDRED_NANOS_PER_MILLI = 10000;
- static
- {
+ static {
byte[] mac = null;
- try
- {
+ try {
InetAddress address = InetAddress.getLocalHost();
try {
@@ -67,8 +72,7 @@ public final class UUIDUtil
if (!ni.isLoopback() && ni.isUp()) {
Method method =
ni.getClass().getMethod("getHardwareAddress");
mac = (byte[]) method.invoke(ni);
- }
- else {
+ } else {
Enumeration<NetworkInterface> enumeration =
NetworkInterface.getNetworkInterfaces();
while (enumeration.hasMoreElements() && mac == null) {
ni = enumeration.nextElement();
@@ -85,8 +89,7 @@ public final class UUIDUtil
if (mac == null || mac.length == 0) {
mac = address.getAddress();
}
- }
- catch (UnknownHostException e) {
+ } catch (UnknownHostException e) {
// Ignore exception
}
Random randomGenerator = new SecureRandom();
@@ -96,10 +99,10 @@ public final class UUIDUtil
}
int length = mac.length >= 6 ? 6 : mac.length;
int index = mac.length >= 6 ? mac.length - 6 : 0;
- byte[] node = new byte[8];
+ byte[] node = new byte[NODE_SIZE];
node[0] = VARIANT;
node[1] = 0;
- for (int i=2; i < 8 ; ++i) {
+ for (int i = 2; i < NODE_SIZE; ++i) {
node[i] = 0;
}
System.arraycopy(mac, index, node, index + 2, length);
@@ -114,7 +117,7 @@ public final class UUIDUtil
} else {
String[] array = assigned.split(",");
sequences = new long[array.length];
- int i=0;
+ int i = 0;
for (String value : array) {
sequences[i] = Long.parseLong(value);
++i;
@@ -140,7 +143,7 @@ public final class UUIDUtil
System.setProperty(ASSIGNED_SEQUENCES, assigned);
}
- least = buf.getLong() | rand << 48;
+ least = buf.getLong() | rand << SHIFT_6;
}
@@ -166,11 +169,11 @@ public final class UUIDUtil
*/
public static UUID getTimeBasedUUID() {
- long time = ((System.currentTimeMillis() * 10000) +
NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) +
- (count.incrementAndGet() % 10000);
- long timeLow = (time & 0xffffffffL) << 32;
- long timeMid = (time & 0xffff00000000L) >> 16;
- long timeHi = (time & 0xfff000000000000L) >> 48;
+ long time = ((System.currentTimeMillis() * HUNDRED_NANOS_PER_MILLI) +
NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) +
+ (count.incrementAndGet() % HUNDRED_NANOS_PER_MILLI);
+ long timeLow = (time & LOW_MASK) << SHIFT_4;
+ long timeMid = (time & MID_MASK) >> SHIFT_2;
+ long timeHi = (time & HIGH_MASK) >> SHIFT_6;
long most = timeLow | timeMid | TYPE1 | timeHi;
return new UUID(most, least);
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Thu Dec 29 07:58:34 2011
@@ -97,18 +97,34 @@ public class Log4jLogEvent implements Lo
}
}
+ /**
+ * Returns the logging Level.
+ * @return the Level associated with this event.
+ */
public Level getLevel() {
return level;
}
+ /**
+ * Return the name of the Logger used to generate the event.
+ * @return The Logger name.
+ */
public String getLoggerName() {
return name;
}
+ /**
+ * Return the Message associated with the event.
+ * @return The Message.
+ */
public Message getMessage() {
return message;
}
+ /**
+ * Return the name of the Thread on which the event was generated.
+ * @return The name of the Thread.
+ */
public String getThreadName() {
if (threadName == null) {
threadName = Thread.currentThread().getName();
@@ -116,18 +132,34 @@ public class Log4jLogEvent implements Lo
return threadName;
}
+ /**
+ * Return the time in milliseconds from the epoch when the event occurred.
+ * @return The time the event occurred.
+ */
public long getMillis() {
return timestamp;
}
+ /**
+ * Return the Throwable associated with the event, or null.
+ * @return The Throwable associated with the event.
+ */
public Throwable getThrown() {
return throwable;
}
+ /**
+ * Return the Marker associated with the event, or null.
+ * @return the Marker associated with the event.
+ */
public Marker getMarker() {
return marker;
}
+ /**
+ * The fully qualified class name of the class that was called by the
caller.
+ * @return the fully qualified class name of the class that is performing
logging.
+ */
public String getFQCN() {
return fqcnOfLogger;
}
@@ -135,6 +167,7 @@ public class Log4jLogEvent implements Lo
/**
* @doubt Allows direct access to the map passed into the constructor,
would allow appender
* or layout to manipulate event as seen by other appenders.
+ * @return The context Map.
*/
public Map<String, String> getContextMap() {
return mdc;
@@ -143,6 +176,7 @@ public class Log4jLogEvent implements Lo
/**
* @doubt Allows direct access to the map passed into the constructor,
would allow appender
* or layout to manipulate event as seen by other appenders.
+ * @return The context Stack.
*/
public Stack<String> getContextStack() {
return ndc;
@@ -151,6 +185,7 @@ public class Log4jLogEvent implements Lo
/**
* Return the StackTraceElement for the caller. This will be the entry
that occurs right
* before the first occurrence of FQCN as a class name.
+ * @return the StackTraceElement for the caller.
*/
public StackTraceElement getSource() {
if (fqcnOfLogger == null) {
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
Thu Dec 29 07:58:34 2011
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.im
import java.io.Serializable;
/**
- * Package data for a StackTraceElement
+ * Package data for a StackTraceElement.
*/
public class StackTracePackageElement implements Serializable {
@@ -31,24 +31,43 @@ public class StackTracePackageElement im
private final boolean isExact;
+ /**
+ * Constructor that takes the location, version, and exact match flag.
+ * @param location The location of the Class.
+ * @param version The version of the component.
+ * @param exact if true this is an exact package element.
+ */
public StackTracePackageElement(String location, String version, boolean
exact) {
this.location = location;
this.version = version;
this.isExact = exact;
}
+ /**
+ * Return the location of the element.
+ * @return The location of the element.
+ */
public String getLocation() {
return location;
}
+ /**
+ * Return the version of the element.
+ * @return the version of the element.
+ */
public String getVersion() {
return version;
}
+ /**
+ * Return the indicator of whether this is an exact match.
+ * @return true if the location was determined exactly.
+ */
public boolean isExact() {
return isExact;
}
+ @Override
public String toString() {
String exact = isExact ? "" : "~";
return exact + "[" + location + ":" + version + "]";
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
Thu Dec 29 07:58:34 2011
@@ -40,7 +40,7 @@ public class ThrowableProxy extends Thro
private static PrivateSecurityManager securityManager;
- private static final org.apache.logging.log4j.Logger logger =
StatusLogger.getLogger();
+ private static final org.apache.logging.log4j.Logger LOGGER =
StatusLogger.getLogger();
private static Method getSuppressed;
@@ -159,6 +159,10 @@ public class ThrowableProxy extends Thro
return throwable.getStackTrace();
}
+ /**
+ * Format the Throwable that is the cause of this Throwable.
+ * @return The formatted Throwable that caused this Throwable.
+ */
public String getRootCauseStackTrace() {
StringBuilder sb = new StringBuilder();
if (cause != null) {
@@ -171,6 +175,11 @@ public class ThrowableProxy extends Thro
return sb.toString();
}
+ /**
+ * Formats the specified Throwable.
+ * @param sb StringBuilder to contain the formatted Throwable.
+ * @param cause The Throwable to format.
+ */
public void formatWrapper(StringBuilder sb, ThrowableProxy cause) {
Throwable caused = cause.getCause();
if (caused != null) {
@@ -181,6 +190,10 @@ public class ThrowableProxy extends Thro
formatElements(sb, cause.commonElementCount, cause.getStackTrace(),
cause.callerPackageData);
}
+ /**
+ * Format the stack trace including packaging information.
+ * @return The formatted stack trace including packaging information.
+ */
public String getExtendedStackTrace() {
StringBuilder sb = new StringBuilder(throwable.toString());
sb.append("\n");
@@ -191,6 +204,21 @@ public class ThrowableProxy extends Thro
return sb.toString();
}
+ /**
+ * Format the suppressed Throwables.
+ * @return The formatted suppressed Throwables.
+ */
+ public String getSuppressedStackTrace() {
+ if (suppressed == null || suppressed.length == 0) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder("Suppressed Stack Trace
Elements:\n");
+ for (ThrowableProxy proxy : suppressed) {
+ sb.append(proxy.getExtendedStackTrace());
+ }
+ return sb.toString();
+ }
+
private void formatCause(StringBuilder sb, ThrowableProxy cause) {
sb.append("Caused by: ").append(cause).append("\n");
formatElements(sb, cause.commonElementCount, cause.getStackTrace(),
cause.callerPackageData);
@@ -201,7 +229,7 @@ public class ThrowableProxy extends Thro
private void formatElements(StringBuilder sb, int commonCount,
StackTraceElement[] causedTrace,
StackTracePackageElement[] packageData) {
- for (int i=0; i < packageData.length; ++i) {
+ for (int i = 0; i < packageData.length; ++i) {
sb.append("\tat ");
sb.append(causedTrace[i]);
sb.append(" ");
@@ -268,7 +296,7 @@ public class ThrowableProxy extends Thro
StackTracePackageElement[] packageArray = new
StackTracePackageElement[stackLength];
Class clazz = stack.peek();
ClassLoader lastLoader = null;
- for (int i = stackLength - 1; i >= 0 ; --i) {
+ for (int i = stackLength - 1; i >= 0; --i) {
String className = stackTrace[i].getClassName();
// The stack returned from getCurrentStack will be missing entries
for java.lang.reflect.Method.invoke()
// and its implementation. The Throwable might also contain stack
entries that are no longer
@@ -419,7 +447,7 @@ public class ThrowableProxy extends Thro
}
}
} catch (ClassNotFoundException cnfe) {
- logger.debug("sun.reflect.Reflection is not installed");
+ LOGGER.debug("sun.reflect.Reflection is not installed");
}
try {
@@ -428,10 +456,10 @@ public class ThrowableProxy extends Thro
securityManager = mgr;
} else {
// This shouldn't happen.
- logger.error("Unable to obtain call stack from security
manager");
+ LOGGER.error("Unable to obtain call stack from security
manager");
}
} catch (Exception ex) {
- logger.debug("Unable to install security manager", ex);
+ LOGGER.debug("Unable to install security manager", ex);
}
}
@@ -453,9 +481,12 @@ public class ThrowableProxy extends Thro
return supp;
}
+ /**
+ * Cached StackTracePackageElement and the ClassLoader.
+ */
private class CacheEntry {
- StackTracePackageElement element;
- ClassLoader loader;
+ private StackTracePackageElement element;
+ private ClassLoader loader;
public CacheEntry(StackTracePackageElement element, ClassLoader
loader) {
this.element = element;
@@ -463,6 +494,9 @@ public class ThrowableProxy extends Thro
}
}
+ /**
+ * Security Manager for accessing the call stack.
+ */
private static class PrivateSecurityManager extends SecurityManager {
public Class[] getClasses() {
return getClassContext();
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
Thu Dec 29 07:58:34 2011
@@ -17,4 +17,4 @@
/**
* Log4j 2.0 private implementation classes.
*/
-package org.apache.logging.log4j.core.impl;
\ No newline at end of file
+package org.apache.logging.log4j.core.impl;
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
Thu Dec 29 07:58:34 2011
@@ -19,9 +19,15 @@ package org.apache.logging.log4j.core.ja
import org.apache.logging.log4j.core.LoggerContext;
/**
- *
+ * Anchor for the ThreadContext.
*/
-public class ContextAnchor {
+public final class ContextAnchor {
- public static final ThreadLocal<LoggerContext> threadContext = new
ThreadLocal<LoggerContext>();
+ /**
+ * Anchor for the LoggerContext for the current Thread.
+ */
+ public static final ThreadLocal<LoggerContext> THREAD_CONTEXT = new
ThreadLocal<LoggerContext>();
+
+ private ContextAnchor() {
+ }
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
Thu Dec 29 07:58:34 2011
@@ -23,14 +23,15 @@ import javax.servlet.ServletContextEvent
import javax.servlet.ServletContextListener;
/**
- *
+ * Saves the LoggerContext into the ServletContext as an attribute.
*/
public class ContextListener implements ServletContextListener {
+ /**
+ * The name of the attribute to use to store the LoggerContext into the
ServletContext.
+ */
public static final String LOG4J_CONTEXT_ATTRIBUTE = "Log4JContext";
- public static ThreadLocal<LoggerContext> threadContext = new
ThreadLocal<LoggerContext>();
-
public void contextInitialized(ServletContextEvent event) {
ServletContext context = event.getServletContext();
LoggerContext ctx = new LoggerContext(context.getServletContextName(),
context);
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
Thu Dec 29 07:58:34 2011
@@ -37,8 +37,13 @@ import java.io.IOException;
* ServletFilter than may be used to set up a LoggerContext for each web
application.
*/
public class JNDIContextFilter implements Filter {
-
+ /**
+ * The Filter init parameter that defines the name of the LoggerContext.
+ */
public static final String CONTEXT_NAME = "context-name";
+ /**
+ * The Filter init parameter that defines the configuration location for
the LoggerContext.
+ */
public static final String CONFIG_LOCATION = "config-location";
private ServletContext context;
private boolean created = false;
@@ -76,11 +81,11 @@ public class JNDIContextFilter implement
throws IOException, ServletException {
LoggerContext ctx = (LoggerContext)
context.getAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE);
if (ctx != null) {
- ContextAnchor.threadContext.set(ctx);
+ ContextAnchor.THREAD_CONTEXT.set(ctx);
try {
filterChain.doFilter(servletRequest, servletResponse);
} finally {
- ContextAnchor.threadContext.remove();
+ ContextAnchor.THREAD_CONTEXT.remove();
}
} else {
filterChain.doFilter(servletRequest, servletResponse);
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
Thu Dec 29 07:58:34 2011
@@ -30,7 +30,7 @@ import java.util.List;
*/
public class Log4jManager {
- public StatusLogger logger = StatusLogger.getLogger();
+ private static final StatusLogger LOGGER = StatusLogger.getLogger();
public List<LoggerContext> getLoggerContexts() {
Log4jContextFactory factory = (Log4jContextFactory)
LogManager.getFactory();
@@ -39,6 +39,6 @@ public class Log4jManager {
}
public List<StatusData> getStatusData() {
- return logger.getStatusData();
+ return LOGGER.getStatusData();
}
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
Thu Dec 29 07:58:34 2011
@@ -26,7 +26,7 @@ import java.util.List;
*/
public interface Log4jManagerMBean {
- public List<LoggerContext> getLoggerContexts();
+ List<LoggerContext> getLoggerContexts();
- public List<StatusData> getStatusData();
+ List<StatusData> getStatusData();
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
Thu Dec 29 07:58:34 2011
@@ -61,6 +61,9 @@ public abstract class AbstractStringLayo
return charset;
}
+ /**
+ * Encoder interface to support Java 5 and Java 6+.
+ */
private interface StringEncoder {
byte[] getBytes(String str);
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
Thu Dec 29 07:58:34 2011
@@ -42,14 +42,7 @@ import java.util.ArrayList;
@Plugin(name = "HTMLLayout", type = "Core", elementType = "layout",
printObject = true)
public final class HTMLLayout extends AbstractStringLayout {
- protected static final int BUF_SIZE = 256;
-
- // Print no location info by default
- protected final boolean locationInfo;
-
- protected final String title;
-
- protected final String contentType;
+ private static final int BUF_SIZE = 256;
private static final String TRACE_PREFIX = "<br> ";
@@ -61,6 +54,13 @@ public final class HTMLLayout extends Ab
private final long jvmStartTime =
ManagementFactory.getRuntimeMXBean().getStartTime();
+ // Print no location info by default
+ private final boolean locationInfo;
+
+ private final String title;
+
+ private final String contentType;
+
private HTMLLayout(boolean locationInfo, String title, String contentType,
Charset charset) {
super(charset);
this.locationInfo = locationInfo;
@@ -148,23 +148,24 @@ public final class HTMLLayout extends Ab
return sbuf.toString();
}
- void appendThrowableAsHTML(Throwable throwable, StringBuilder sbuf) {
+ private void appendThrowableAsHTML(Throwable throwable, StringBuilder
sbuf) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
throwable.printStackTrace(pw);
- } catch(RuntimeException ex) {
+ } catch (RuntimeException ex) {
+ // Ignore the exception.
}
pw.flush();
LineNumberReader reader = new LineNumberReader(new
StringReader(sw.toString()));
ArrayList<String> lines = new ArrayList<String>();
try {
String line = reader.readLine();
- while(line != null) {
+ while (line != null) {
lines.add(line);
line = reader.readLine();
}
- } catch(IOException ex) {
+ } catch (IOException ex) {
if (ex instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
@@ -184,6 +185,7 @@ public final class HTMLLayout extends Ab
/**
* Returns appropriate HTML headers.
+ * @return The header as a byte array.
*/
@Override
public byte[] getHeader() {
@@ -223,6 +225,7 @@ public final class HTMLLayout extends Ab
/**
* Returns the appropriate HTML footers.
+ * @return the footer as a byet array.
*/
@Override
public byte[] getFooter() {
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
Thu Dec 29 07:58:34 2011
@@ -32,7 +32,7 @@ public class BasicContextSelector implem
public LoggerContext getContext(String FQCN, boolean currentContext) {
- LoggerContext ctx = ContextAnchor.threadContext.get();
+ LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
return ctx != null ? ctx : context;
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
Thu Dec 29 07:58:34 2011
@@ -65,7 +65,7 @@ public class ClassLoaderContextSelector
public LoggerContext getContext(String fqcn, boolean currentContext) {
if (currentContext) {
- LoggerContext ctx = ContextAnchor.threadContext.get();
+ LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
if (ctx != null) {
return ctx;
}
@@ -122,7 +122,7 @@ public class ClassLoaderContextSelector
//System.out.println("Could not load class " + name);
}
}
- LoggerContext lc = ContextAnchor.threadContext.get();
+ LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get();
if (lc != null) {
return lc;
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
Thu Dec 29 07:58:34 2011
@@ -95,7 +95,7 @@ public class JNDIContextSelector impleme
public LoggerContext getContext(String FQCN, boolean currentContext) {
- LoggerContext lc = ContextAnchor.threadContext.get();
+ LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get();
if (lc != null) {
return lc;
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml?rev=1225462&r1=1225461&r2=1225462&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/pom.xml Thu Dec 29
07:58:34 2011
@@ -252,7 +252,11 @@
<columnNames>Type,Key,Summary,Assignee,Status,Resolution,Fix
Version</columnNames>
</configuration>
</plugin>
-
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
<!-- Surefire report -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>