Author: jfrederic.clere(a)jboss.com
Date: 2011-05-04 04:24:29 -0400 (Wed, 04 May 2011)
New Revision: 2763
Added:
trunk/build/unix/util/jbossweb/cacert.pem
trunk/build/unix/util/jbossweb/newcert.pem
trunk/build/unix/util/jbossweb/newkey.pem
trunk/build/unix/util/jbossweb/org/jboss/logging/
trunk/build/unix/util/jbossweb/org/jboss/logging/Logger.java
trunk/build/unix/util/jbossweb/org/jboss/logging/LoggerPlugin.java
trunk/build/unix/util/jbossweb/org/jboss/logging/MDCProvider.java
trunk/build/unix/util/jbossweb/org/jboss/logging/MDCSupport.java
trunk/build/unix/util/jbossweb/org/jboss/logging/NDCProvider.java
trunk/build/unix/util/jbossweb/org/jboss/logging/NDCSupport.java
trunk/build/unix/util/jbossweb/org/jboss/logging/NullLoggerPlugin.java
trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/
trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDK14LoggerPlugin.java
trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKMDCProvider.java
trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKNDCProvider.java
trunk/build/unix/util/jbossweb/org/jboss/test/ClassLoaderLogManager.java
trunk/build/unix/util/jbossweb/org/jboss/test/FileHandler.java
Modified:
trunk/build/unix/util/jbossweb/build.xml
trunk/build/unix/util/jbossweb/node1/conf/logging.properties
trunk/build/unix/util/jbossweb/org/jboss/test/JBossWeb.java
trunk/build/unix/util/jbossweb/org/jboss/test/StartJBossWeb.java
Log:
Add SSL tests.
Modified: trunk/build/unix/util/jbossweb/build.xml
===================================================================
--- trunk/build/unix/util/jbossweb/build.xml 2011-05-03 09:44:00 UTC (rev 2762)
+++ trunk/build/unix/util/jbossweb/build.xml 2011-05-04 08:24:29 UTC (rev 2763)
@@ -36,7 +36,6 @@
<path id="jbossweb.test.classpath">
<pathelement location="${test.classes}"/>
- <pathelement location="${commons-logging.jar}"/>
<pathelement location="${jbossweb.jar}"/>
<pathelement location="${servlet-api.jar}"/>
@@ -75,7 +74,7 @@
source="${compile.source}"
optimize="${compile.optimize}">
<classpath refid="jbossweb.test.classpath" />
- <include name="org/jboss/test/**" />
+ <include name="org/jboss/**" />
</javac>
</target>
Added: trunk/build/unix/util/jbossweb/cacert.pem
===================================================================
--- trunk/build/unix/util/jbossweb/cacert.pem (rev 0)
+++ trunk/build/unix/util/jbossweb/cacert.pem 2011-05-04 08:24:29 UTC (rev 2763)
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC3TCCAkagAwIBAgIBADANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJDSDES
+MBAGA1UECBMJTmV1Y2hhdGVsMRAwDgYDVQQKEwdSZWQgSGF0MQ4wDAYDVQQLEwVq
+Ym9zczEOMAwGA1UEAxMFamZjcGMxITAfBgkqhkiG9w0BCQEWEmpmY2xlcmVAcmVk
+aGF0LmNvbTAeFw0wODEyMDIxMzU2MzdaFw0xMTEyMDIxMzU2MzdaMHYxCzAJBgNV
+BAYTAkNIMRIwEAYDVQQIEwlOZXVjaGF0ZWwxEDAOBgNVBAoTB1JlZCBIYXQxDjAM
+BgNVBAsTBWpib3NzMQ4wDAYDVQQDEwVqZmNwYzEhMB8GCSqGSIb3DQEJARYSamZj
+bGVyZUByZWRoYXQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBju4V
+GAwObduuScxhPHNvBWRbjU1DAiv00fwHh6nELVxwBsyzWOY4pcUBfrr3bNsJP9dd
+ZpGHqHA7kroLZxfyXTmF/C58a1HIhhzgS4rtijOFHOh5WLD0HZICPdCR1D1IznXx
+oAoMOQ/PeGCfiPVLWzwSqrg/GDW3vhTIRlTrpwIDAQABo3sweTAJBgNVHRMEAjAA
+MCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
+BgNVHQ4EFgQU3P9xfJgsEC/jPhHgr5Wt3J8iCYAwHwYDVR0jBBgwFoAU3P9xfJgs
+EC/jPhHgr5Wt3J8iCYAwDQYJKoZIhvcNAQEFBQADgYEAJoT9AdqxQ/7ezw5sx6Fn
+DSJR7DtiXVHB8zChbev3aS36Dym4qiQBXgQ+hUe+AtnMDq3YNN7LGBP/a/eT76zs
+CWsKLfZq200wkQE/54fSxLGmapy6DQuh2Xtuw+oEjAlZVBruLMv9gOQ4Dg+DteRp
+cSlORuUwHEggjl3PakQc78Q=
+-----END CERTIFICATE-----
Added: trunk/build/unix/util/jbossweb/newcert.pem
===================================================================
--- trunk/build/unix/util/jbossweb/newcert.pem (rev 0)
+++ trunk/build/unix/util/jbossweb/newcert.pem 2011-05-04 08:24:29 UTC (rev 2763)
@@ -0,0 +1,73 @@
+Certificate:
+ Data:
+ Version: 3 (0x2)
+ Serial Number: 8 (0x8)
+ Signature Algorithm: sha1WithRSAEncryption
+ Issuer: C=CH, ST=Neuchatel, O=Red Hat, OU=jboss,
CN=jfcpc/emailAddress=jfclere(a)redhat.com
+ Validity
+ Not Before: May 4 07:42:13 2011 GMT
+ Not After : May 3 07:42:13 2012 GMT
+ Subject: C=CH, ST=Neuchatel, L=Neuchatel, O=Red Hat, OU=jboss,
CN=localhost/emailAddress=jfclere(a)jfclere.org
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ Public-Key: (2048 bit)
+ Modulus:
+ 00:d9:46:dc:a0:e0:b9:b1:2c:c8:83:55:ec:a4:06:
+ 5b:ee:60:0a:c0:6f:28:4b:4d:97:39:06:5c:3d:b0:
+ 32:d4:4e:d6:c7:3f:22:54:e2:a7:d9:e2:c7:9c:b9:
+ b9:bd:1d:66:45:53:7e:3b:25:32:76:79:c9:c1:52:
+ 91:bb:d3:02:b5:1c:70:a1:a3:e8:75:94:ea:ad:61:
+ 36:a7:5e:c8:59:c2:7c:94:f5:17:46:6a:65:cc:c9:
+ 2c:09:49:54:ee:73:60:ec:63:ec:92:56:22:60:fc:
+ b5:46:ba:7c:ca:d3:f9:85:e5:7e:20:44:b1:4d:5e:
+ 71:4b:84:07:11:23:ce:0c:70:55:14:f6:74:c6:ce:
+ 34:18:d0:ae:e9:da:a0:0b:ca:98:0e:19:92:d2:d8:
+ 4a:90:9a:62:da:90:5f:7a:d9:f7:ff:14:7b:41:6e:
+ 8d:37:cc:a5:45:c2:18:b9:d9:99:0b:3d:ae:3d:fe:
+ 9c:6a:25:06:b7:25:41:ad:c3:ac:c7:c7:4f:8c:d1:
+ 81:2c:bd:f9:e4:7f:26:d3:5c:84:f4:da:2a:1d:0a:
+ 6a:15:1b:e1:e2:c1:c8:ef:b4:4d:92:9d:b3:3c:c9:
+ 8f:e0:b3:7e:94:12:c1:24:58:6f:87:38:11:2d:e3:
+ c8:c6:0f:be:50:0c:de:3a:9e:ff:e9:64:51:65:64:
+ 6a:db
+ Exponent: 65537 (0x10001)
+ X509v3 extensions:
+ X509v3 Basic Constraints:
+ CA:FALSE
+ Netscape Comment:
+ OpenSSL Generated Certificate
+ X509v3 Subject Key Identifier:
+ 39:CC:FF:65:7D:6D:F3:2D:6F:88:96:8D:ED:9A:A5:5A:BE:FE:EE:E4
+ X509v3 Authority Key Identifier:
+ keyid:DC:FF:71:7C:98:2C:10:2F:E3:3E:11:E0:AF:95:AD:DC:9F:22:09:80
+
+ Signature Algorithm: sha1WithRSAEncryption
+ ae:f3:48:4c:81:6f:5a:af:76:bb:88:85:f7:a7:5b:2e:14:57:
+ 31:d5:04:cb:4d:97:88:24:bd:87:e4:24:05:10:6a:2b:4d:bd:
+ 05:84:d7:f4:0a:3b:de:c7:ba:31:a8:22:c8:82:80:19:5f:f3:
+ 2b:d5:1e:62:20:c3:87:4b:40:b2:f3:78:b4:ef:b3:7b:00:93:
+ 9e:75:ea:6e:fd:e3:e2:55:6a:23:31:b9:2a:01:71:5f:a1:f2:
+ f3:a5:0c:21:cd:1d:34:e1:b4:a4:47:ac:7b:2f:30:76:a6:85:
+ 9c:0e:2b:e2:64:67:f7:14:e6:44:27:52:17:93:8d:e1:0a:41:
+ 29:1c
+-----BEGIN CERTIFICATE-----
+MIIDezCCAuSgAwIBAgIBCDANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJDSDES
+MBAGA1UECBMJTmV1Y2hhdGVsMRAwDgYDVQQKEwdSZWQgSGF0MQ4wDAYDVQQLEwVq
+Ym9zczEOMAwGA1UEAxMFamZjcGMxITAfBgkqhkiG9w0BCQEWEmpmY2xlcmVAcmVk
+aGF0LmNvbTAeFw0xMTA1MDQwNzQyMTNaFw0xMjA1MDMwNzQyMTNaMIGPMQswCQYD
+VQQGEwJDSDESMBAGA1UECAwJTmV1Y2hhdGVsMRIwEAYDVQQHDAlOZXVjaGF0ZWwx
+EDAOBgNVBAoMB1JlZCBIYXQxDjAMBgNVBAsMBWpib3NzMRIwEAYDVQQDDAlsb2Nh
+bGhvc3QxIjAgBgkqhkiG9w0BCQEWE2pmY2xlcmVAamZjbGVyZS5vcmcwggEiMA0G
+CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZRtyg4LmxLMiDVeykBlvuYArAbyhL
+TZc5Blw9sDLUTtbHPyJU4qfZ4secubm9HWZFU347JTJ2ecnBUpG70wK1HHCho+h1
+lOqtYTanXshZwnyU9RdGamXMySwJSVTuc2DsY+ySViJg/LVGunzK0/mF5X4gRLFN
+XnFLhAcRI84McFUU9nTGzjQY0K7p2qALypgOGZLS2EqQmmLakF962ff/FHtBbo03
+zKVFwhi52ZkLPa49/pxqJQa3JUGtw6zHx0+M0YEsvfnkfybTXIT02iodCmoVG+Hi
+wcjvtE2SnbM8yY/gs36UEsEkWG+HOBEt48jGD75QDN46nv/pZFFlZGrbAgMBAAGj
+ezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVk
+IENlcnRpZmljYXRlMB0GA1UdDgQWBBQ5zP9lfW3zLW+Ilo3tmqVavv7u5DAfBgNV
+HSMEGDAWgBTc/3F8mCwQL+M+EeCvla3cnyIJgDANBgkqhkiG9w0BAQUFAAOBgQCu
+80hMgW9ar3a7iIX3p1suFFcx1QTLTZeIJL2H5CQFEGorTb0FhNf0Cjvex7oxqCLI
+goAZX/Mr1R5iIMOHS0Cy83i077N7AJOedepu/ePiVWojMbkqAXFfofLzpQwhzR00
+4bSkR6x7LzB2poWcDiviZGf3FOZEJ1IXk43hCkEpHA==
+-----END CERTIFICATE-----
Added: trunk/build/unix/util/jbossweb/newkey.pem
===================================================================
--- trunk/build/unix/util/jbossweb/newkey.pem (rev 0)
+++ trunk/build/unix/util/jbossweb/newkey.pem 2011-05-04 08:24:29 UTC (rev 2763)
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIzshu5c2pTHkCAggA
+MBQGCCqGSIb3DQMHBAjDDB7mJUWyjASCBMjP18GxwPuBn52/VW71hEIb6i3/ClZp
+XKk+ru10vrfc0tWLqvJYQu0rvpgi9N+7BcfGW6Jv0Ud6NvbTgb/Si6vOtWuCFKLt
+yjgp7P3uPRO2cRk87UegzM6jz/0nKpvQpomqs8IVk949xgrUEz3ExYKiVOHtFTgX
+eddkxYzqK4I/hoRmdziLA5n5MlGbK/N1ehpxahbV7F0wn+MkMyy59WTteLOiqR8M
+EiIIsSJwNh9lkwI3eo9kXQmlfgX7xX5BAtIyLWrjWltTuVqU4hhaG/bjedHJe89n
+QPYuSkb713lu2lEBHpav2qd41sa/4lqz1F8lg26BpacRAeg9UY3fh+SPnz02WsM+
+akOgi+aAX41B1Bzoty1kzIkC4/pr45Za2MajGzzu6gR7V7++AW40E5QmSyf28Bc7
+BRcxmQIoDoeW5NPn7F2IT4alEbdvhYgHUQfGXSdCfe3WZE9WMn0BWznpxKNCU2sg
+soeRi/+de66ffTpMRaoYStRcEa37iEYplcn+Cj3eBrOAIiO+V3Yx3cM8tnQ/5QsA
+gqpySXR9o87TVYXGCf4Kg7/duYfberj4I9nAoJncIFMlKn7ZcOi0OlRy32uUW2DN
+Pejx7UiP1IhpPHvGH3y8HPIpJmHUcGQnYj2M2fY74YZcijzfhjx/Fo8MTe2pB3ri
+TzcnIU+mQqZOxDOPs5QAcspD7zN8jNyxUQz18PY0NXM9fwt3o1I9L+1/rxny8nC7
+x33htuUpGtVQki6zRlXxyh1xpGdy+rK5iDlLg7a/hoagU1kIPIuVJXHBNSOXtwY4
+L9Dod+9LRVEFX4sHgyiPYb3eljbynD2HoSISWTDipW8k00TtdYob33z06IvV2a3x
+LwFqEOZrg9nBzjRWxqa6qNlLbhjLc7M9ySng0uIPpNHAlQuJd+HtPTfFp6yKn99s
+W9ytEHM3r9cdaaULh40y3fiYz5EJwPYD6ri680OT9Mr7D4X2b5/vEYrRKlkhOq6z
+Hho2KVtawlmhKasojYEbnr/GBsUMS5KN87JHuNh5NGfYFvxo+YDm9dAUuDOSuUg9
+AJlIsXiQqZAGvuPlDFZkB8l7NKnviMgsvSK4DSblaXFs3fjdaT27MNpOo9mPYqJB
+meOwaM3tALD0DI9Zf0rvyNJMc6rz8ybSUhrQ6GVX5txMMTCt8Q2RMsBgXKDBnHJ+
+wtVye2DC6quftdP8KMKV+ZQgrti5ENJ3RsoHZJPUsS+HWF8BmxZKhD0bQ8w0D3fB
+4asM4kQJeXq/zAK775CVMvphx6UaYZI78KOYNFvjkXMApXe+OkXl9t6s+wpdlqAQ
+3HKmeOBFHZwA8DGGNwa3zXooYj41Y68agvbYoraqhU7cMTmZONF2zPB6c9Zgy85x
+F9tW4e3B+qPTZtmLNDmT/qJ1P0PFGnMLS4Bh6AGHS2V6+HZU7avvPA4lCKptp0bk
+QjzOsY9w5kVjnFpMld+/3AA6uLr44Jfy0h0My5nDID8BU6GNmj1karf7sSjD8Ers
+PLp5fBUPrya880XHDswjCabcLRkNB7hipD8W+GC1i9bO2Kg9DogD10xv/LAzi8ef
+bKiU5KhALFs3rTnuQYluiRubMRdEDC0OdYSu2vJxnMrrFX+qvacWGzkeW/mqIuKe
+u2I=
+-----END ENCRYPTED PRIVATE KEY-----
Modified: trunk/build/unix/util/jbossweb/node1/conf/logging.properties
===================================================================
--- trunk/build/unix/util/jbossweb/node1/conf/logging.properties 2011-05-03 09:44:00 UTC
(rev 2762)
+++ trunk/build/unix/util/jbossweb/node1/conf/logging.properties 2011-05-04 08:24:29 UTC
(rev 2763)
@@ -46,4 +46,6 @@
#org.apache.catalina.startup.ContextConfig.level = FINE
#org.apache.catalina.startup.HostConfig.level = FINE
#org.apache.catalina.session.ManagerBase.level = FINE
-org.apache.catalina.core.AprLifecycleListener.level=FINE
+org.apache.catalina.core.AprLifecycleListener.level=ALL
+org.apache.catalina.level=ALL
+org.jboss.test.level=ALL
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/Logger.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/Logger.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/Logger.java 2011-05-04 08:24:29 UTC
(rev 2763)
@@ -0,0 +1,434 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Logger wrapper that tries to dynamically load a log4j class to
+ * determine if log4j is available in the VM. If it is the case,
+ * a log4j delegate is built and used. In the contrary, a null
+ * logger is used. This class cannot directly reference log4j
+ * classes otherwise the JVM will try to load it and make it fail.
+ * To set
+ *
+ * <p>Only exposes the relevent factory and logging methods.
+ *
+ * <p>For JBoss the logging should be done as follows:
+ * <ul>
+ * <li>FATAL - JBoss is likely to/will crash
+ * <li>ERROR - A definite problem
+ * <li>WARN - Likely to be a problem, or it could be JBoss
+ * detected a problem it can recover from
+ * <li>INFO - Lifecycle low volume, e.g. "Bound x into jndi",
+ * things that are of interest to a user
+ * <li>DEBUG - Lifecycle low volume but necessarily of interest
+ * to the user, e.g. "Starting listener thread"
+ * <li>TRACE - High volume detailed logging
+ * </ul>
+ *
+ * @see #isTraceEnabled
+ * @see #trace(Object)
+ * @see #trace(Object,Throwable)
+ *
+ * @version <tt>$Revision: 515 $</tt>
+ * @author Scott.Stark(a)jboss.org
+ * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:sacha.labourey@cogito-info.ch">Sacha
Labourey</a>
+ */
+public class Logger implements Serializable
+{
+ /** Serialization */
+ private static final long serialVersionUID = 4232175575988879434L;
+
+ /** The system property to look for an externalized LoggerPlugin implementation class
*/
+ protected static String PLUGIN_CLASS_PROP =
"org.jboss.logging.Logger.pluginClass";
+
+ /** The default LoggerPlugin implementation is log4j */
+ protected static final String DEFAULT_PLUGIN_CLASS_NAME =
"org.jboss.logging.jdk.JDK14LoggerPlugin";
+
+ /** The LoggerPlugin implementation class to use */
+ protected static Class pluginClass = null;
+
+ /** The class name of the LoggerPlugin implementation class to use */
+ protected static String pluginClassName = null;
+
+ static
+ {
+ init();
+ }
+
+ /** The logger name. */
+ private final String name;
+
+ /** The logger plugin delegate */
+ protected transient LoggerPlugin loggerDelegate = null;
+
+ /** The LoggerPlugin implementation class name in use
+ *
+ * @return LoggerPlugin implementation class name
+ */
+ public static String getPluginClassName()
+ {
+ return Logger.pluginClassName;
+ }
+
+ /**
+ * Set the LoggerPlugin implementation class name in use
+ *
+ * @param pluginClassName the LoggerPlugin implementation class name
+ */
+ public static void setPluginClassName(String pluginClassName)
+ {
+ if (pluginClassName.equals(Logger.pluginClassName) == false)
+ {
+ Logger.pluginClassName = pluginClassName;
+ init();
+ }
+ }
+
+ /**
+ * Creates new Logger the given logger name.
+ *
+ * @param name the logger name.
+ */
+ protected Logger(final String name)
+ {
+ this.name = name;
+ this.loggerDelegate = getDelegatePlugin(name);
+ }
+
+ /**
+ * Return the name of this logger.
+ *
+ * @return The name of this logger.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the logger plugin delegate
+ *
+ * @return the delegate
+ */
+ public LoggerPlugin getLoggerPlugin()
+ {
+ return this.loggerDelegate;
+ }
+
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isTraceEnabled()
+ {
+ return loggerDelegate.isTraceEnabled();
+ }
+
+ /**
+ * Issue a log msg with a level of TRACE.
+ *
+ * @param message the message
+ */
+ public void trace(Object message)
+ {
+ loggerDelegate.trace(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of TRACE.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void trace(Object message, Throwable t)
+ {
+ loggerDelegate.trace(message, t);
+ }
+
+ /**
+ * Check to see if the DEBUG level is enabled for this logger.
+ *
+ * @deprecated DEBUG is for low volume logging, you don't need this
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isDebugEnabled()
+ {
+ return loggerDelegate.isDebugEnabled();
+ }
+
+ /**
+ * Issue a log msg with a level of DEBUG.
+ *
+ * @param message the message
+ */
+ public void debug(Object message)
+ {
+ loggerDelegate.debug(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of DEBUG.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void debug(Object message, Throwable t)
+ {
+ loggerDelegate.debug(message, t);
+ }
+
+ /**
+ * Check to see if the INFO level is enabled for this logger.
+ *
+ * @deprecated INFO is for low volume information, you don't need this
+ * @return true if a {@link #info(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isInfoEnabled()
+ {
+ return loggerDelegate.isInfoEnabled();
+ }
+
+ /**
+ * Issue a log msg with a level of INFO.
+ *
+ * @param message the message
+ */
+ public void info(Object message)
+ {
+ loggerDelegate.info(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of INFO.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void info(Object message, Throwable t)
+ {
+ loggerDelegate.info(message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of WARN.
+ *
+ * @param message the message
+ */
+ public void warn(Object message)
+ {
+ loggerDelegate.warn(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of WARN.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void warn(Object message, Throwable t)
+ {
+ loggerDelegate.warn(message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of ERROR.
+ *
+ * @param message the message
+ */
+ public void error(Object message)
+ {
+ loggerDelegate.error(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of ERROR.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void error(Object message, Throwable t)
+ {
+ loggerDelegate.error(message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of FATAL.
+ *
+ * @param message the message
+ */
+ public void fatal(Object message)
+ {
+ loggerDelegate.fatal(message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of FATAL.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ public void fatal(Object message, Throwable t)
+ {
+ loggerDelegate.fatal(message, t);
+ }
+
+ /**
+ * Custom serialization to reinitalize the delegate
+ *
+ * @param stream the object stream
+ * @throws IOException for any error
+ * @throws ClassNotFoundException if a class is not found during deserialization
+ */
+ private void readObject(ObjectInputStream stream) throws IOException,
ClassNotFoundException
+ {
+ // restore non-transient fields (aka name)
+ stream.defaultReadObject();
+
+ // Restore logging
+ if (pluginClass == null)
+ {
+ init();
+ }
+ this.loggerDelegate = getDelegatePlugin(name);
+ }
+
+ /**
+ * Create a Logger instance given the logger name.
+ *
+ * @param name the logger name
+ * @return the logger
+ */
+ public static Logger getLogger(String name)
+ {
+ return new Logger(name);
+ }
+
+ /**
+ * Create a Logger instance given the logger name with the given suffix.
+ *
+ * <p>This will include a logger seperator between classname and suffix
+ *
+ * @param name the logger name
+ * @param suffix a suffix to append to the classname.
+ * @return the logger
+ */
+ public static Logger getLogger(String name, String suffix)
+ {
+ return new Logger(name + "." + suffix);
+ }
+
+ /**
+ * Create a Logger instance given the logger class. This simply
+ * calls create(clazz.getName()).
+ *
+ * @param clazz the Class whose name will be used as the logger name
+ * @return the logger
+ */
+ public static Logger getLogger(Class clazz)
+ {
+ return new Logger(clazz.getName());
+ }
+
+ /**
+ * Create a Logger instance given the logger class with the given suffix.
+ *
+ * <p>This will include a logger seperator between classname and suffix
+ *
+ * @param clazz the Class whose name will be used as the logger name.
+ * @param suffix a suffix to append to the classname.
+ * @return the logger
+ */
+ public static Logger getLogger(Class clazz, String suffix)
+ {
+ return new Logger(clazz.getName() + "." + suffix);
+ }
+
+ /**
+ * Get the delegate plugin
+ *
+ * @param name the name of the logger
+ * @return the plugin
+ */
+ protected static LoggerPlugin getDelegatePlugin(String name)
+ {
+ LoggerPlugin plugin = null;
+ try
+ {
+ plugin = (LoggerPlugin) pluginClass.newInstance();
+ }
+ catch (Throwable e)
+ {
+ plugin = new NullLoggerPlugin();
+ }
+ try
+ {
+ plugin.init(name);
+ }
+ catch (Throwable e)
+ {
+ String extraInfo = e.getMessage();
+ System.err.println("Failed to initalize plugin: " + plugin
+ + (extraInfo != null ? ", cause: " + extraInfo :
""));
+ plugin = new NullLoggerPlugin();
+ }
+
+ return plugin;
+ }
+
+ /**
+ * Initialize the LoggerPlugin class to use as the delegate to the
+ * logging system. This first checks to see if a pluginClassName has
+ * been specified via the {@link #setPluginClassName(String)} method,
+ * then the PLUGIN_CLASS_PROP system property and finally the
+ * LOG4J_PLUGIN_CLASS_NAME default. If the LoggerPlugin implementation
+ * class cannot be loaded the default NullLoggerPlugin will be used.
+ */
+ protected static void init()
+ {
+ try
+ {
+ // See if there is a PLUGIN_CLASS_PROP specified
+ if (pluginClassName == null)
+ {
+ pluginClassName = System.getProperty(PLUGIN_CLASS_PROP,
DEFAULT_PLUGIN_CLASS_NAME);
+ }
+
+ // Try to load the plugin via the TCL
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ pluginClass = cl.loadClass(pluginClassName);
+ }
+ catch (Throwable e)
+ {
+ // The plugin could not be setup, default to a null logger
+ pluginClass = org.jboss.logging.NullLoggerPlugin.class;
+ }
+ }
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/LoggerPlugin.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/LoggerPlugin.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/LoggerPlugin.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * Defines a "pluggable" login module. In fact, this is only used to split
between
+ * log4j and /dev/null. Choice is made in org.jboss.logging.Logger
+ *
+ * @see org.jboss.logging.Logger
+ * @see org.jboss.logging.NullLoggerPlugin
+ *
+ * @author <a href="mailto:sacha.labourey@cogito-info.ch">Sacha
Labourey</a>.
+ * @version $Revision: 515 $
+ */
+public interface LoggerPlugin
+{
+ /**
+ * Initialise the logger with the given name
+ *
+ * @param name the name
+ */
+ void init(String name);
+
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isTraceEnabled();
+
+ /**
+ * Issue a log msg with a level of TRACE.
+ *
+ * @param message the message
+ */
+ void trace(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of TRACE.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void trace(Object message, Throwable t);
+
+ /**
+ * Check to see if the DEBUG level is enabled for this logger.
+ *
+ * @deprecated DEBUG is for low volume logging, you don't need this
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Issue a log msg with a level of DEBUG.
+ *
+ * @param message the message
+ */
+ void debug(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of DEBUG.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void debug(Object message, Throwable t);
+
+ /**
+ * Check to see if the INFO level is enabled for this logger.
+ *
+ * @deprecated INFO is for low volume information, you don't need this
+ * @return true if a {@link #info(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Issue a log msg with a level of INFO.
+ *
+ * @param message the message
+ */
+ void info(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of INFO.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void info(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of WARN.
+ *
+ * @param message the message
+ */
+ void warn(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of WARN.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void warn(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of ERROR.
+ *
+ * @param message the message
+ */
+ void error(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of ERROR.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void error(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of FATAL.
+ *
+ * @param message the message
+ */
+ void fatal(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of FATAL.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void fatal(Object message, Throwable t);
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/MDCProvider.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/MDCProvider.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/MDCProvider.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.util.Map;
+
+/**
+ * MDC SPI for the backend logging implementation.
+ *
+ * @author Jason T. Greene
+ */
+public interface MDCProvider
+{
+ public void put(String key, Object value);
+
+ public Object get(String key);
+
+ public void remove(String key);
+
+ public Map<String, Object> getMap();
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/MDCSupport.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/MDCSupport.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/MDCSupport.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * Indicates that a Logger plugin supports MDC.
+ *
+ * @author Jason T. Greene
+ */
+public interface MDCSupport
+{
+ public MDCProvider getMDCProvider();
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/NDCProvider.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/NDCProvider.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/NDCProvider.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+
+/**
+ * An NDC SPI for the backend logging implementation.
+ *
+ * @author Jason T. Greene
+ */
+public interface NDCProvider
+{
+ public void clear();
+
+ public String get();
+
+ public int getDepth();
+
+ public String pop();
+
+ public String peek();
+
+ public void push(String message);
+
+ public void setMaxDepth(int maxDepth);
+}
\ No newline at end of file
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/NDCSupport.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/NDCSupport.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/NDCSupport.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * Indicates that a logger plugin supports NDC.
+ *
+ * @author Jason T. Greene
+ */
+public interface NDCSupport
+{
+ public NDCProvider getNDCProvider();
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/NullLoggerPlugin.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/NullLoggerPlugin.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/NullLoggerPlugin.java 2011-05-04
08:24:29 UTC (rev 2763)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * LoggerPlugin implementation producing no output at all. Used for client
+ * side logging when no log4j.jar is available on the classpath.
+ *
+ * @see org.jboss.logging.Logger
+ * @see org.jboss.logging.LoggerPlugin
+ *
+ * @author <a href="mailto:sacha.labourey@cogito-info.ch">Sacha
Labourey</a>.
+ * @version $Revision: 515 $
+ */
+public class NullLoggerPlugin implements LoggerPlugin
+{
+ public void init(String name)
+ {
+ /* don't care */
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return false;
+ }
+
+ public void trace(Object message)
+ {
+ // nothing
+ }
+
+ public void trace(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return false;
+ }
+
+ public void debug(Object message)
+ {
+ // nothing
+ }
+
+ public void debug(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return false;
+ }
+
+ public void info(Object message)
+ {
+ // nothing
+ }
+
+ public void info(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void error(Object message)
+ {
+ // nothing
+ }
+
+ public void error(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void fatal(Object message)
+ {
+ // nothing
+ }
+
+ public void fatal(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void warn(Object message)
+ {
+ // nothing
+ }
+
+ public void warn(Object message, Throwable t)
+ {
+ // nothing
+ }
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDK14LoggerPlugin.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDK14LoggerPlugin.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDK14LoggerPlugin.java 2011-05-04
08:24:29 UTC (rev 2763)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.logging.jdk;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import org.jboss.logging.LoggerPlugin;
+import org.jboss.logging.MDCProvider;
+import org.jboss.logging.MDCSupport;
+import org.jboss.logging.NDCProvider;
+import org.jboss.logging.NDCSupport;
+
+/** An example LoggerPlugin which uses the JDK java.util.logging framework.
+ *
+ * @author Scott.Stark(a)jboss.org
+ * @version $Revison:$
+ */
+public class JDK14LoggerPlugin implements LoggerPlugin, MDCSupport, NDCSupport
+{
+ private Logger log;
+
+ public void init(String name)
+ {
+ log = Logger.getLogger(name);
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return log.isLoggable(Level.FINER);
+ }
+
+ public void trace(Object message)
+ {
+ log(Level.FINER, String.valueOf(message), null);
+ }
+
+ public void trace(Object message, Throwable t)
+ {
+ log(Level.FINER, String.valueOf(message), t);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return log.isLoggable(Level.FINE);
+ }
+
+ public void debug(Object message)
+ {
+ log(Level.FINE, String.valueOf(message), null);
+ }
+
+ public void debug(Object message, Throwable t)
+ {
+ log(Level.FINE, String.valueOf(message), t);
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return log.isLoggable(Level.INFO);
+ }
+
+ public void info(Object message)
+ {
+ log(Level.INFO, String.valueOf(message), null);
+ }
+
+ public void info(Object message, Throwable t)
+ {
+ log(Level.INFO, String.valueOf(message), t);
+ }
+
+ public void warn(Object message)
+ {
+ log(Level.WARNING, String.valueOf(message), null);
+ }
+
+ public void warn(Object message, Throwable t)
+ {
+ log(Level.WARNING, String.valueOf(message), t);
+ }
+
+ public void error(Object message)
+ {
+ log(Level.SEVERE, String.valueOf(message), null);
+ }
+
+ public void error(Object message, Throwable t)
+ {
+ log(Level.SEVERE, String.valueOf(message), t);
+ }
+
+ public void fatal(Object message)
+ {
+ log(Level.SEVERE, String.valueOf(message), null);
+ }
+
+ public void fatal(Object message, Throwable t)
+ {
+ log(Level.SEVERE, String.valueOf(message), t);
+ }
+
+ // From commons-logging
+ private void log(Level level, String msg, Throwable ex) {
+ if (log.isLoggable(level)) {
+ // Get the stack trace.
+ Throwable dummyException = new Throwable();
+ StackTraceElement locations[] = dummyException.getStackTrace();
+ // Caller will be the third element
+ String cname = "unknown";
+ String method = "unknown";
+ if (locations != null && locations.length > 3) {
+ StackTraceElement caller = locations[3];
+ cname = caller.getClassName();
+ method = caller.getMethodName();
+ }
+ if (ex == null) {
+ log.logp(level, cname, method, msg);
+ } else {
+ log.logp(level, cname, method, msg, ex);
+ }
+ }
+ }
+
+ public NDCProvider getNDCProvider()
+ {
+ return new JDKNDCProvider();
+ }
+
+ public MDCProvider getMDCProvider()
+ {
+ return new JDKMDCProvider();
+ }
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKMDCProvider.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKMDCProvider.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKMDCProvider.java 2011-05-04
08:24:29 UTC (rev 2763)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging.jdk;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.MDCProvider;
+
+/**
+ * MDC implementation for JDK logging.
+ *
+ * @author Jason T. Greene
+ */
+public class JDKMDCProvider implements MDCProvider
+{
+ private ThreadLocal<Map<String, Object>> map = new
ThreadLocal<Map<String, Object>>();
+
+ public Object get(String key)
+ {
+ return map.get() == null ? null : map.get().get(key);
+ }
+
+ public Map<String, Object> getMap()
+ {
+ return map.get();
+ }
+
+ public void put(String key, Object value)
+ {
+ Map<String, Object> map = this.map.get();
+ if (map == null)
+ {
+ map = new HashMap<String, Object>();
+ this.map.set(map);
+ }
+
+ map.put(key, value);
+ }
+
+ public void remove(String key)
+ {
+ Map<String, Object> map = this.map.get();
+ if (map == null)
+ return;
+
+ map.remove(key);
+ }
+}
\ No newline at end of file
Added: trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKNDCProvider.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKNDCProvider.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/logging/jdk/JDKNDCProvider.java 2011-05-04
08:24:29 UTC (rev 2763)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.logging.jdk;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+import java.util.Stack;
+
+import org.jboss.logging.NDCProvider;
+
+/**
+ * NDC implementation for JDK logging
+ *
+ * @author Jason T. Greene
+ */
+public class JDKNDCProvider implements NDCProvider
+{
+ private class ArrayStack<E> extends ArrayList<E>
+ {
+ private static final long serialVersionUID = -8520038422243642840L;
+
+ public E pop()
+ {
+ int size = size();
+ if (size == 0)
+ throw new EmptyStackException();
+
+ return remove(size - 1);
+ }
+
+ public E peek()
+ {
+ int size = size();
+ if (size == 0)
+ throw new EmptyStackException();
+
+ return get(size - 1);
+ }
+
+ public void push(E val)
+ {
+ add(val);
+ }
+
+ public void setSize(int newSize)
+ {
+ int size = size();
+ if (newSize >= size || newSize < 0)
+ return;
+
+ removeRange(newSize, size);
+ }
+ }
+
+ private class Entry
+ {
+ private String merged;
+ private String current;
+
+ public Entry(String current)
+ {
+ this.merged = current;
+ this.current = current;
+ }
+
+ public Entry(Entry parent, String current)
+ {
+ this.merged = parent.merged + ' ' + current;
+ this.current = current;
+ }
+ }
+
+ private ThreadLocal<ArrayStack<Entry>> stack = new
ThreadLocal<ArrayStack<Entry>>();
+
+ public void clear()
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+ if (stack != null)
+ stack.clear();
+ }
+
+ public String get()
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ return stack == null || stack.isEmpty() ? null : stack.peek().merged;
+ }
+
+ public int getDepth()
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ return stack == null ? 0 : stack.size();
+ }
+
+ public String peek()
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ return stack == null || stack.isEmpty() ? "" : stack.peek().current;
+ }
+
+ public String pop()
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ return stack == null || stack.isEmpty() ? "" : stack.pop().current;
+ }
+
+ public void push(String message)
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ if (stack == null)
+ {
+ stack = new ArrayStack<Entry>();
+ this.stack.set(stack);
+ }
+
+ stack.push(stack.isEmpty() ? new Entry(message) : new Entry(stack.peek(),
message));
+ }
+
+ public void setMaxDepth(int maxDepth)
+ {
+ ArrayStack<Entry> stack = this.stack.get();
+
+ if (stack != null)
+ stack.setSize(maxDepth);
+ }
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/test/ClassLoaderLogManager.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/test/ClassLoaderLogManager.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/test/ClassLoaderLogManager.java 2011-05-04
08:24:29 UTC (rev 2763)
@@ -0,0 +1,585 @@
+/*
+ * 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.jboss.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLClassLoader;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.WeakHashMap;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+
+/**
+ * Per classloader LogManager implementation.
+ */
+public class ClassLoaderLogManager extends LogManager {
+
+
+ // -------------------------------------------------------------- Variables
+
+
+ /**
+ * Map containing the classloader information, keyed per classloader. A
+ * weak hashmap is used to ensure no classloader reference is leaked from
+ * application redeployment.
+ */
+ protected final Map<ClassLoader, ClassLoaderLogInfo> classLoaderLoggers =
+ new WeakHashMap<ClassLoader, ClassLoaderLogInfo>();
+
+
+ /**
+ * This prefix is used to allow using prefixes for the properties names
+ * of handlers and their subcomponents.
+ */
+ protected ThreadLocal<String> prefix = new ThreadLocal<String>();
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Add the specified logger to the classloader local configuration.
+ *
+ * @param logger The logger to be added
+ */
+ public synchronized boolean addLogger(final Logger logger) {
+
+ final String loggerName = logger.getName();
+
+ ClassLoader classLoader =
+ Thread.currentThread().getContextClassLoader();
+ ClassLoaderLogInfo info = getClassLoaderInfo(classLoader);
+ if (info.loggers.containsKey(loggerName)) {
+ return false;
+ }
+ info.loggers.put(loggerName, logger);
+
+ // Apply initial level for new logger
+ final String levelString = getProperty(loggerName + ".level");
+ if (levelString != null) {
+ try {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ logger.setLevel(Level.parse(levelString.trim()));
+ return null;
+ }
+ });
+ } catch (IllegalArgumentException e) {
+ // Leave level set to null
+ }
+ }
+
+ // If any parent loggers have levels definied, make sure they are
+ // instantiated
+ int dotIndex = loggerName.lastIndexOf('.');
+ while (dotIndex >= 0) {
+ final String parentName = loggerName.substring(0, dotIndex);
+ if (getProperty(parentName + ".level") != null) {
+ Logger.getLogger(parentName);
+ break;
+ }
+ dotIndex = loggerName.lastIndexOf('.', dotIndex - 1);
+ }
+
+ // Find associated node
+ LogNode node = info.rootNode.findNode(loggerName);
+ node.logger = logger;
+
+ // Set parent logger
+ Logger parentLogger = node.findParentLogger();
+ if (parentLogger != null) {
+ doSetParentLogger(logger, parentLogger);
+ }
+
+ // Tell children we are their new parent
+ node.setParentLogger(logger);
+
+ // Add associated handlers, if any are defined using the .handlers property.
+ // In this case, handlers of the parent logger(s) will not be used
+ String handlers = getProperty(loggerName + ".handlers");
+ if (handlers != null) {
+ logger.setUseParentHandlers(false);
+ StringTokenizer tok = new StringTokenizer(handlers, ",");
+ while (tok.hasMoreTokens()) {
+ String handlerName = (tok.nextToken().trim());
+ Handler handler = null;
+ ClassLoader current = classLoader;
+ while (current != null) {
+ info = classLoaderLoggers.get(current);
+ if (info != null) {
+ handler = info.handlers.get(handlerName);
+ if (handler != null) {
+ break;
+ }
+ }
+ current = current.getParent();
+ }
+ if (handler != null) {
+ logger.addHandler(handler);
+ }
+ }
+ }
+
+ // Parse useParentHandlers to set if the logger should delegate to its parent.
+ // Unlike java.util.logging, the default is to not delegate if a list of
handlers
+ // has been specified for the logger.
+ String useParentHandlersString = getProperty(loggerName +
".useParentHandlers");
+ if (Boolean.valueOf(useParentHandlersString).booleanValue()) {
+ logger.setUseParentHandlers(true);
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Get the logger associated with the specified name inside
+ * the classloader local configuration. If this returns null,
+ * and the call originated for Logger.getLogger, a new
+ * logger with the specified name will be instantiated and
+ * added using addLogger.
+ *
+ * @param name The name of the logger to retrieve
+ */
+ public synchronized Logger getLogger(final String name) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ return getClassLoaderInfo(classLoader).loggers.get(name);
+ }
+
+
+ /**
+ * Get an enumeration of the logger names currently defined in the
+ * classloader local configuration.
+ */
+ public synchronized Enumeration<String> getLoggerNames() {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ return
Collections.enumeration(getClassLoaderInfo(classLoader).loggers.keySet());
+ }
+
+
+ /**
+ * Get the value of the specified property in the classloader local
+ * configuration.
+ *
+ * @param name The property name
+ */
+ public String getProperty(String name) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ String prefix = this.prefix.get();
+ if (prefix != null) {
+ name = prefix + name;
+ }
+ ClassLoaderLogInfo info = getClassLoaderInfo(classLoader);
+ String result = info.props.getProperty(name);
+ // If the property was not found, and the current classloader had no
+ // configuration (property list is empty), look for the parent classloader
+ // properties.
+ if ((result == null) && (info.props.isEmpty())) {
+ ClassLoader current = classLoader.getParent();
+ while (current != null) {
+ info = classLoaderLoggers.get(current);
+ if (info != null) {
+ result = info.props.getProperty(name);
+ if ((result != null) || (!info.props.isEmpty())) {
+ break;
+ }
+ }
+ current = current.getParent();
+ }
+ if (result == null) {
+ result = super.getProperty(name);
+ }
+ }
+ // Simple property replacement (mostly for folder names)
+ if (result != null) {
+ result = replace(result);
+ }
+ return result;
+ }
+
+
+ public void readConfiguration()
+ throws IOException, SecurityException {
+
+ checkAccess();
+
+ readConfiguration(Thread.currentThread().getContextClassLoader());
+
+ }
+
+ public void readConfiguration(InputStream is)
+ throws IOException, SecurityException {
+
+ checkAccess();
+ reset();
+
+ readConfiguration(is, Thread.currentThread().getContextClassLoader());
+
+ }
+
+ // ------------------------------------------------------ Protected Methods
+
+
+ /**
+ * Retrieve the configuration associated with the specified classloader. If
+ * it does not exist, it will be created.
+ *
+ * @param classLoader The classloader for which we will retrieve or build the
+ * configuration
+ */
+ protected ClassLoaderLogInfo getClassLoaderInfo(ClassLoader classLoader) {
+
+ if (classLoader == null) {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+ ClassLoaderLogInfo info = classLoaderLoggers.get(classLoader);
+ if (info == null) {
+ final ClassLoader classLoaderParam = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ readConfiguration(classLoaderParam);
+ } catch (IOException e) {
+ // Ignore
+ }
+ return null;
+ }
+ });
+ info = classLoaderLoggers.get(classLoader);
+ }
+ return info;
+ }
+
+
+ /**
+ * Read configuration for the specified classloader.
+ *
+ * @param classLoader
+ * @throws IOException Errot
+ */
+ protected void readConfiguration(ClassLoader classLoader)
+ throws IOException {
+
+ InputStream is = null;
+ // Special case for URL classloaders which are used in containers:
+ // only look in the local repositories to avoid redefining loggers 20 times
+ try {
+ if ((classLoader instanceof URLClassLoader)
+ && (((URLClassLoader)
classLoader).findResource("logging.properties") != null)) {
+ is = classLoader.getResourceAsStream("logging.properties");
+ }
+ } catch (AccessControlException ace) {
+ // No permission to configure logging in context
+ // Log and carry on
+ ClassLoaderLogInfo info =
classLoaderLoggers.get(ClassLoader.getSystemClassLoader());
+ if (info != null) {
+ Logger log = info.loggers.get("");
+ if (log != null) {
+ Permission perm = ace.getPermission();
+ if (perm instanceof FilePermission &&
perm.getActions().equals("read")) {
+ log.warning("Reading " + perm.getName() + " is not
permitted. See \"per context logging\" in the default catalina.policy
file.");
+ }
+ else {
+ log.warning("Reading logging.properties is not permitted in
some context. See \"per context logging\" in the default catalina.policy
file.");
+ log.warning("Original error was: " +
ace.getMessage());
+ }
+ }
+ }
+ }
+ if ((is == null) && (classLoader == ClassLoader.getSystemClassLoader()))
{
+ String configFileStr =
System.getProperty("java.util.logging.config.file");
+ if (configFileStr != null) {
+ try {
+ is = new FileInputStream(replace(configFileStr));
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ // Try the default JVM configuration
+ if (is == null) {
+ File defaultFile = new File(new
File(System.getProperty("java.home"), "lib"),
+ "logging.properties");
+ try {
+ is = new FileInputStream(defaultFile);
+ } catch (IOException e) {
+ // Critical problem, do something ...
+ }
+ }
+ }
+
+ Logger localRootLogger = new RootLogger();
+ if (is == null) {
+ // Retrieve the root logger of the parent classloader instead
+ ClassLoader current = classLoader.getParent();
+ ClassLoaderLogInfo info = null;
+ while (current != null && info == null) {
+ info = getClassLoaderInfo(current);
+ current = current.getParent();
+ }
+ if (info != null) {
+ localRootLogger.setParent(info.rootNode.logger);
+ }
+ }
+ ClassLoaderLogInfo info =
+ new ClassLoaderLogInfo(new LogNode(null, localRootLogger));
+ classLoaderLoggers.put(classLoader, info);
+
+ if (is != null) {
+ readConfiguration(is, classLoader);
+ }
+ addLogger(localRootLogger);
+
+ }
+
+
+ /**
+ * Load specified configuration.
+ *
+ * @param is InputStream to the properties file
+ * @param classLoader for which the configuration will be loaded
+ * @throws IOException If something wrong happens during loading
+ */
+ protected void readConfiguration(InputStream is, ClassLoader classLoader)
+ throws IOException {
+
+ ClassLoaderLogInfo info = classLoaderLoggers.get(classLoader);
+
+ try {
+ info.props.load(is);
+ } catch (IOException e) {
+ // Report error
+ System.err.println("Configuration error");
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (Throwable t) {}
+ }
+
+ // Create handlers for the root logger of this classloader
+ String rootHandlers = info.props.getProperty(".handlers");
+ String handlers = info.props.getProperty("handlers");
+ Logger localRootLogger = info.rootNode.logger;
+ if (handlers != null) {
+ StringTokenizer tok = new StringTokenizer(handlers, ",");
+ while (tok.hasMoreTokens()) {
+ String handlerName = (tok.nextToken().trim());
+ String handlerClassName = handlerName;
+ String prefix = "";
+ if (handlerClassName.length() <= 0) {
+ continue;
+ }
+ // Parse and remove a prefix (prefix start with a digit, such as
+ // "10WebappFooHanlder.")
+ if (Character.isDigit(handlerClassName.charAt(0))) {
+ int pos = handlerClassName.indexOf('.');
+ if (pos >= 0) {
+ prefix = handlerClassName.substring(0, pos + 1);
+ handlerClassName = handlerClassName.substring(pos + 1);
+ }
+ }
+ try {
+ this.prefix.set(prefix);
+ Handler handler =
+ (Handler) classLoader.loadClass(handlerClassName).newInstance();
+ // The specification strongly implies all configuration should be
done
+ // during the creation of the handler object.
+ // This includes setting level, filter, formatter and encoding.
+ this.prefix.set(null);
+ info.handlers.put(handlerName, handler);
+ if (rootHandlers == null) {
+ localRootLogger.addHandler(handler);
+ }
+ } catch (Exception e) {
+ // Report error
+ System.err.println("Handler error");
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ }
+
+
+ /**
+ * Set parent child relationship between the two specified loggers.
+ *
+ * @param logger
+ * @param parent
+ */
+ protected static void doSetParentLogger(final Logger logger,
+ final Logger parent) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ logger.setParent(parent);
+ return null;
+ }
+ });
+ }
+
+
+ /**
+ * System property replacement in the given string.
+ *
+ * @param str The original string
+ * @return the modified string
+ */
+ protected String replace(String str) {
+ String result = str;
+ int pos_start = result.indexOf("${");
+ if (pos_start != -1) {
+ int pos_end = result.indexOf('}');
+ if (pos_end != -1) {
+ String propName = result.substring(pos_start + 2, pos_end);
+ String replacement = System.getProperty(propName);
+ if (replacement != null) {
+ if(pos_start >0) {
+ result = result.substring(0,pos_start) +
+ replacement + replace(result.substring(pos_end + 1));
+ } else {
+ result = replacement + replace(result.substring(pos_end + 1));
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+
+ // ---------------------------------------------------- LogNode Inner Class
+
+
+ protected static final class LogNode {
+ Logger logger;
+
+ protected final Map<String, LogNode> children =
+ new HashMap<String, LogNode>();
+
+ protected final LogNode parent;
+
+ LogNode(final LogNode parent, final Logger logger) {
+ this.parent = parent;
+ this.logger = logger;
+ }
+
+ LogNode(final LogNode parent) {
+ this(parent, null);
+ }
+
+ LogNode findNode(String name) {
+ LogNode currentNode = this;
+ if (logger.getName().equals(name)) {
+ return this;
+ }
+ while (name != null) {
+ final int dotIndex = name.indexOf('.');
+ final String nextName;
+ if (dotIndex < 0) {
+ nextName = name;
+ name = null;
+ } else {
+ nextName = name.substring(0, dotIndex);
+ name = name.substring(dotIndex + 1);
+ }
+ LogNode childNode = currentNode.children.get(nextName);
+ if (childNode == null) {
+ childNode = new LogNode(currentNode);
+ currentNode.children.put(nextName, childNode);
+ }
+ currentNode = childNode;
+ }
+ return currentNode;
+ }
+
+ Logger findParentLogger() {
+ Logger logger = null;
+ LogNode node = parent;
+ while (node != null && logger == null) {
+ logger = node.logger;
+ node = node.parent;
+ }
+ return logger;
+ }
+
+ void setParentLogger(final Logger parent) {
+ for (final Iterator iter = children.values().iterator(); iter
+ .hasNext();) {
+ final LogNode childNode = (LogNode) iter.next();
+ if (childNode.logger == null) {
+ childNode.setParentLogger(parent);
+ } else {
+ doSetParentLogger(childNode.logger, parent);
+ }
+ }
+ }
+
+ }
+
+
+ // -------------------------------------------- ClassLoaderInfo Inner Class
+
+
+ protected static final class ClassLoaderLogInfo {
+ final LogNode rootNode;
+ final Map<String, Logger> loggers = new HashMap<String, Logger>();
+ final Map<String, Handler> handlers = new HashMap<String,
Handler>();
+ final Properties props = new Properties();
+
+ ClassLoaderLogInfo(final LogNode rootNode) {
+ this.rootNode = rootNode;
+ }
+
+ }
+
+
+ // ------------------------------------------------- RootLogger Inner Class
+
+
+ /**
+ * This class is needed to instantiate the root of each per classloader
+ * hierarchy.
+ */
+ protected class RootLogger extends Logger {
+ public RootLogger() {
+ super("", null);
+ }
+ }
+
+
+}
Added: trunk/build/unix/util/jbossweb/org/jboss/test/FileHandler.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/test/FileHandler.java
(rev 0)
+++ trunk/build/unix/util/jbossweb/org/jboss/test/FileHandler.java 2011-05-04 08:24:29 UTC
(rev 2763)
@@ -0,0 +1,273 @@
+/*
+ * 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.jboss.test;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.sql.Timestamp;
+import java.util.logging.ErrorManager;
+import java.util.logging.Filter;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+
+/**
+ * Implementation of <b>Handler</b> that appends log messages to a file
+ * named {prefix}.{date}.{suffix} in a configured directory, with an
+ * optional preceding timestamp.
+ *
+ * @version $Revision: 666 $ $Date: 2008-06-12 16:11:25 +0200 (Thu, 12 Jun 2008) $
+ */
+
+public class FileHandler
+ extends Handler {
+
+
+ // ------------------------------------------------------------ Constructor
+
+
+ public FileHandler() {
+ this(null, null, null);
+ }
+
+
+ public FileHandler(String directory, String prefix, String suffix) {
+ this.directory = directory;
+ this.prefix = prefix;
+ this.suffix = suffix;
+ configure();
+ open();
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The as-of date for the currently open log file, or a zero-length
+ * string if there is no open log file.
+ */
+ private String date = "";
+
+
+ /**
+ * The directory in which log files are created.
+ */
+ private String directory = null;
+
+
+ /**
+ * The prefix that is added to log file filenames.
+ */
+ private String prefix = null;
+
+
+ /**
+ * The suffix that is added to log file filenames.
+ */
+ private String suffix = null;
+
+
+ /**
+ * The PrintWriter to which we are currently logging, if any.
+ */
+ private PrintWriter writer = null;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Format and publish a <tt>LogRecord</tt>.
+ *
+ * @param record description of the log event
+ */
+ public void publish(LogRecord record) {
+
+ if (!isLoggable(record)) {
+ return;
+ }
+
+ // Construct the timestamp we will use, if requested
+ Timestamp ts = new Timestamp(System.currentTimeMillis());
+ String tsString = ts.toString().substring(0, 19);
+ String tsDate = tsString.substring(0, 10);
+
+ // If the date has changed, switch log files
+ if (!date.equals(tsDate)) {
+ synchronized (this) {
+ if (!date.equals(tsDate)) {
+ close();
+ date = tsDate;
+ open();
+ }
+ }
+ }
+
+ String result = null;
+ try {
+ result = getFormatter().format(record);
+ } catch (Exception e) {
+ reportError(null, e, ErrorManager.FORMAT_FAILURE);
+ return;
+ }
+
+ try {
+ if (writer != null) {
+ writer.write(result);
+ writer.flush();
+ } else {
+ reportError("FileHandler is closed or not yet initialized, unable to
log ["+result+"]", null, ErrorManager.WRITE_FAILURE);
+ }
+ } catch (Exception e) {
+ reportError(null, e, ErrorManager.WRITE_FAILURE);
+ return;
+ }
+
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+
+ /**
+ * Close the currently open log file (if any).
+ */
+ public void close() {
+
+ try {
+ if (writer == null)
+ return;
+ writer.write(getFormatter().getTail(this));
+ writer.flush();
+ writer.close();
+ writer = null;
+ date = "";
+ } catch (Exception e) {
+ reportError(null, e, ErrorManager.CLOSE_FAILURE);
+ }
+
+ }
+
+
+ /**
+ * Flush the writer.
+ */
+ public void flush() {
+
+ try {
+ writer.flush();
+ } catch (Exception e) {
+ reportError(null, e, ErrorManager.FLUSH_FAILURE);
+ }
+
+ }
+
+
+ /**
+ * Configure from <code>LogManager</code> properties.
+ */
+ private void configure() {
+
+ Timestamp ts = new Timestamp(System.currentTimeMillis());
+ String tsString = ts.toString().substring(0, 19);
+ date = tsString.substring(0, 10);
+
+ String className = FileHandler.class.getName();
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ // Retrieve configuration of logging file name
+ if (directory == null)
+ directory = getProperty(className + ".directory",
"logs");
+ if (prefix == null)
+ prefix = getProperty(className + ".prefix", "juli.");
+ if (suffix == null)
+ suffix = getProperty(className + ".suffix", ".log");
+
+ // Get logging level for the handler
+ setLevel(Level.parse(getProperty(className + ".level", "" +
Level.ALL)));
+
+ // Get filter configuration
+ String filterName = getProperty(className + ".filter", null);
+ if (filterName != null) {
+ try {
+ setFilter((Filter) cl.loadClass(filterName).newInstance());
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+
+ // Set formatter
+ String formatterName = getProperty(className + ".formatter", null);
+ if (formatterName != null) {
+ try {
+ setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
+ } catch (Exception e) {
+ // Ignore
+ }
+ } else {
+ setFormatter(new SimpleFormatter());
+ }
+
+ // Set error manager
+ setErrorManager(new ErrorManager());
+
+ }
+
+
+ private String getProperty(String name, String defaultValue) {
+ String value = LogManager.getLogManager().getProperty(name);
+ if (value == null) {
+ value = defaultValue;
+ } else {
+ value = value.trim();
+ }
+ return value;
+ }
+
+
+ /**
+ * Open the new log file for the date specified by <code>date</code>.
+ */
+ private void open() {
+
+ // Create the directory if necessary
+ File dir = new File(directory);
+ dir.mkdirs();
+
+ // Open the current log file
+ try {
+ String pathname = dir.getAbsolutePath() + File.separator +
+ prefix + date + suffix;
+ writer = new PrintWriter(new FileWriter(pathname, true), true);
+ writer.write(getFormatter().getHead(this));
+ } catch (Exception e) {
+ reportError(null, e, ErrorManager.OPEN_FAILURE);
+ writer = null;
+ }
+
+ }
+
+
+}
Modified: trunk/build/unix/util/jbossweb/org/jboss/test/JBossWeb.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/test/JBossWeb.java 2011-05-03 09:44:00 UTC
(rev 2762)
+++ trunk/build/unix/util/jbossweb/org/jboss/test/JBossWeb.java 2011-05-04 08:24:29 UTC
(rev 2763)
@@ -42,8 +42,6 @@
import org.apache.catalina.core.*;
import org.apache.catalina.startup.HostConfig;
-import org.apache.catalina.LifecycleListener;
-
public class JBossWeb extends Embedded {
private String route = null;
@@ -222,7 +220,7 @@
}
public Connector addConnector(int port) throws IOException {
- return addConnector(port, "http");
+ return addConnector(port, "https");
}
public Connector addConnector(int port, String scheme) throws IOException {
@@ -234,6 +232,13 @@
Connector connector = createConnector( address,
port, scheme);
+ /* Set the SSL properties */
+ connector.setProperty("SSLCertificateFile", "newcert.pem");
+ connector.setProperty("SSLCertificateKeyFile",
"newkey.pem");
+ connector.setProperty("SSLPassword", "changeit");
+ connector.setProperty("SLEnabled", "true");
+ connector.setSecure(true);
+ connector.setScheme(scheme);
// Look in StandardService to see why it works ;-)
addConnector( connector );
Modified: trunk/build/unix/util/jbossweb/org/jboss/test/StartJBossWeb.java
===================================================================
--- trunk/build/unix/util/jbossweb/org/jboss/test/StartJBossWeb.java 2011-05-03 09:44:00
UTC (rev 2762)
+++ trunk/build/unix/util/jbossweb/org/jboss/test/StartJBossWeb.java 2011-05-04 08:24:29
UTC (rev 2763)
@@ -44,8 +44,12 @@
import org.apache.catalina.LifecycleListener;
+import org.jboss.logging.Logger;
+
public class StartJBossWeb {
+ private static Logger log = Logger.getLogger(StartJBossWeb.class);
+
/* Start a JBossWEB with domain */
public static void main(String[] args) {
@@ -61,22 +65,31 @@
domain = args[2];
serverport = Integer.parseInt(args[3]);
}
- System.out.println("Starting JBossWEB on " + port + " " +
node + " " + domain + " " + serverport);
+
+ log.info("Starting JBossWEB on " + port + " " + node + "
" + domain + " " + serverport);
try {
server = (StandardServer) ServerFactory.getServer();
server.setPort(serverport);
service = new JBossWeb(node, "localhost");
- service.addConnector(port);
+ AprLifecycleListener apr = new AprLifecycleListener();
+ server.addLifecycleListener(apr);
+
+ service.addConnector(port, "https", null);
server.addService(service);
+
+ // server.addLifecycleListener(apr);
+ server.init();
server.start();
} catch(IOException ex) {
ex.printStackTrace();
} catch (LifecycleException ex) {
ex.printStackTrace();
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
// Wait until we are stopped...