Author: borges
Date: 2011-05-26 08:31:10 -0400 (Thu, 26 May 2011)
New Revision: 10738
Added:
trunk/hornetq-commons/hornetq-commons.iml
trunk/hornetq-commons/src/main/java/org/hornetq/core/
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/Logger.java
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java
trunk/hornetq-commons/src/main/java/org/hornetq/spi/
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/package-info.java
Removed:
trunk/hornetq-commons/hornetq-logging.iml
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/Logger.java
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/package-info.java
Modified:
trunk/hornetq-commons/pom.xml
trunk/hornetq-core/pom.xml
Log:
HORNETQ-698 Move hq-core logging classes into hq-commons
Copied: trunk/hornetq-commons/hornetq-commons.iml (from rev 10736,
trunk/hornetq-commons/hornetq-logging.iml)
===================================================================
--- trunk/hornetq-commons/hornetq-commons.iml (rev 0)
+++ trunk/hornetq-commons/hornetq-commons.iml 2011-05-26 12:31:10 UTC (rev 10738)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true"
type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6"
inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="hornetq-core" />
+ <orderEntry type="library" name="Maven:
org.jboss.netty:netty:3.2.3.Final" level="project" />
+ <orderEntry type="library" name="Maven: log4j:log4j:1.2.14"
level="project" />
+ </component>
+</module>
+
Deleted: trunk/hornetq-commons/hornetq-logging.iml
===================================================================
--- trunk/hornetq-commons/hornetq-logging.iml 2011-05-26 12:28:45 UTC (rev 10737)
+++ trunk/hornetq-commons/hornetq-logging.iml 2011-05-26 12:31:10 UTC (rev 10738)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true"
type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6"
inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/target" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="hornetq-core" />
- <orderEntry type="library" name="Maven:
org.jboss.netty:netty:3.2.3.Final" level="project" />
- <orderEntry type="library" name="Maven: log4j:log4j:1.2.14"
level="project" />
- </component>
-</module>
-
Modified: trunk/hornetq-commons/pom.xml
===================================================================
--- trunk/hornetq-commons/pom.xml 2011-05-26 12:28:45 UTC (rev 10737)
+++ trunk/hornetq-commons/pom.xml 2011-05-26 12:31:10 UTC (rev 10738)
@@ -14,9 +14,8 @@
<dependencies>
<dependency>
- <groupId>org.hornetq</groupId>
- <artifactId>hornetq-core</artifactId>
- <version>${project.version}</version>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
Copied: trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/Logger.java (from rev
10732, trunk/hornetq-core/src/main/java/org/hornetq/core/logging/Logger.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/Logger.java
(rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/Logger.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.logging;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.hornetq.core.logging.impl.JULLogDelegateFactory;
+import org.hornetq.spi.core.logging.LogDelegate;
+import org.hornetq.spi.core.logging.LogDelegateFactory;
+
+/**
+ *
+ * A Logger
+ *
+ * This class allows us to isolate all our logging dependencies in one place
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ */
+public class Logger
+{
+ public static final String LOGGER_DELEGATE_FACTORY_CLASS_NAME =
"org.hornetq.logger-delegate-factory-class-name";
+
+ private static volatile LogDelegateFactory delegateFactory;
+
+ private static final ConcurrentMap<Class<?>, Logger> loggers = new
ConcurrentHashMap<Class<?>, Logger>();
+
+ static
+ {
+ Logger.initialise();
+ }
+
+ public static synchronized void setDelegateFactory(final LogDelegateFactory
delegateFactory)
+ {
+ Logger.clear();
+
+ Logger.delegateFactory = delegateFactory;
+ }
+
+ private static void clear()
+ {
+ Logger.loggers.clear();
+ }
+
+ public static synchronized void reset()
+ {
+ Logger.clear();
+
+ Logger.initialise();
+ }
+
+ public static synchronized void initialise()
+ {
+ LogDelegateFactory delegateFactory;
+
+ // If a system property is specified then this overrides any delegate factory which
is set
+ // programmatically - this is primarily of use so we can configure the logger
delegate on the client side.
+ // call to System.getProperty is wrapped in a try block as it will fail if the
client runs in a secured
+ // environment
+ String className = JULLogDelegateFactory.class.getName();
+ try
+ {
+ className = System.getProperty(Logger.LOGGER_DELEGATE_FACTORY_CLASS_NAME);
+ }
+ catch (Exception e)
+ {
+ }
+
+ if (className != null)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Class<?> clz = loader.loadClass(className);
+ delegateFactory = (LogDelegateFactory)clz.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Error instantiating transformer
class \"" + className + "\"", e);
+ }
+ }
+ else
+ {
+ delegateFactory = new JULLogDelegateFactory();
+ }
+
+ Logger.delegateFactory = delegateFactory;
+
+ Logger.loggers.clear();
+ }
+
+ public static Logger getLogger(final Class<?> clazz)
+ {
+ Logger logger = Logger.loggers.get(clazz);
+
+ if (logger == null)
+ {
+ LogDelegate delegate = Logger.delegateFactory.createDelegate(clazz);
+
+ logger = new Logger(delegate);
+
+ Logger oldLogger = Logger.loggers.putIfAbsent(clazz, logger);
+
+ if (oldLogger != null)
+ {
+ logger = oldLogger;
+ }
+ }
+
+ return logger;
+ }
+
+ private final LogDelegate delegate;
+
+ Logger(final LogDelegate delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public LogDelegate getDelegate()
+ {
+ return delegate;
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return delegate.isInfoEnabled();
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return delegate.isDebugEnabled();
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return delegate.isTraceEnabled();
+ }
+
+ public void fatal(final Object message)
+ {
+ delegate.fatal(message);
+ }
+
+ public void fatal(final Object message, final Throwable t)
+ {
+ delegate.fatal(message, t);
+ }
+
+ public void error(final Object message)
+ {
+ delegate.error(message);
+ }
+
+ public void error(final Object message, final Throwable t)
+ {
+ delegate.error(message, t);
+ }
+
+ public void warn(final Object message)
+ {
+ delegate.warn(message);
+ }
+
+ public void warn(final Object message, final Throwable t)
+ {
+ delegate.warn(message, t);
+ }
+
+ public void info(final Object message)
+ {
+ delegate.info(message);
+ }
+
+ public void info(final Object message, final Throwable t)
+ {
+ delegate.info(message, t);
+ }
+
+ public void debug(final Object message)
+ {
+ delegate.debug(message);
+ }
+
+ public void debug(final Object message, final Throwable t)
+ {
+ delegate.debug(message, t);
+ }
+
+ public void trace(final Object message)
+ {
+ delegate.trace(message);
+ }
+
+ public void trace(final Object message, final Throwable t)
+ {
+ delegate.trace(message, t);
+ }
+
+}
Copied:
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java
(from rev 10732,
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java
(rev 0)
+++
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.logging.impl;
+
+import java.util.logging.Level;
+
+import org.hornetq.spi.core.logging.LogDelegate;
+
+/**
+ *
+ * A {@link LogDelegate} which delegates to java.util.logging
+ *
+ * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
+ *
+ */
+public class JULLogDelegate implements LogDelegate
+{
+ private final java.util.logging.Logger logger;
+
+ JULLogDelegate(final Class<?> clazz)
+ {
+ logger = java.util.logging.Logger.getLogger(clazz.getName());
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return logger.isLoggable(Level.INFO);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return logger.isLoggable(Level.FINE);
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return logger.isLoggable(Level.FINEST);
+ }
+
+ public void fatal(final Object message)
+ {
+ logger.log(Level.SEVERE, message == null ? "NULL" : message.toString());
+ }
+
+ public void fatal(final Object message, final Throwable t)
+ {
+ logger.log(Level.SEVERE, message == null ? "NULL" : message.toString(),
t);
+ }
+
+ public void error(final Object message)
+ {
+ logger.log(Level.SEVERE, message == null ? "NULL" : message.toString());
+ }
+
+ public void error(final Object message, final Throwable t)
+ {
+ logger.log(Level.SEVERE, message == null ? "NULL" : message.toString(),
t);
+ }
+
+ public void warn(final Object message)
+ {
+ logger.log(Level.WARNING, message == null ? "NULL" :
message.toString());
+ }
+
+ public void warn(final Object message, final Throwable t)
+ {
+ logger.log(Level.WARNING, message == null ? "NULL" : message.toString(),
t);
+ }
+
+ public void info(final Object message)
+ {
+ logger.log(Level.INFO, message == null ? "NULL" : message.toString());
+ }
+
+ public void info(final Object message, final Throwable t)
+ {
+ logger.log(Level.INFO, message == null ? "NULL" : message.toString(),
t);
+ }
+
+ public void debug(final Object message)
+ {
+ logger.log(Level.FINE, message == null ? "NULL" : message.toString());
+ }
+
+ public void debug(final Object message, final Throwable t)
+ {
+ logger.log(Level.FINE, message == null ? "NULL" : message.toString(),
t);
+ }
+
+ public void trace(final Object message)
+ {
+ logger.log(Level.FINEST, message == null ? "NULL" : message.toString());
+ }
+
+ public void trace(final Object message, final Throwable t)
+ {
+ logger.log(Level.FINEST, message == null ? "NULL" : message.toString(),
t);
+ }
+
+}
Copied:
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java
(from rev 10732,
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java)
===================================================================
---
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java
(rev 0)
+++
trunk/hornetq-commons/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.logging.impl;
+
+import org.hornetq.spi.core.logging.LogDelegate;
+import org.hornetq.spi.core.logging.LogDelegateFactory;
+
+/**
+ * A {@link LogDelegateFactory} which creates {@link JULLogDelegate} instances.
+ *
+ * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
+ *
+ *
+ */
+public class JULLogDelegateFactory implements LogDelegateFactory
+{
+ public LogDelegate createDelegate(final Class<?> clazz)
+ {
+ return new JULLogDelegate(clazz);
+ }
+}
Copied: trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java
(from rev 10732,
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java
(rev 0)
+++
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.spi.core.logging;
+
+/**
+ * I represent operations that are delegated to underlying logging frameworks.
+ *
+ * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
+ *
+ *
+ */
+public interface LogDelegate
+{
+ boolean isInfoEnabled();
+
+ boolean isDebugEnabled();
+
+ boolean isTraceEnabled();
+
+ void fatal(Object message);
+
+ void fatal(Object message, Throwable t);
+
+ void error(Object message);
+
+ void error(Object message, Throwable t);
+
+ void warn(Object message);
+
+ void warn(Object message, Throwable t);
+
+ void info(Object message);
+
+ void info(Object message, Throwable t);
+
+ void debug(Object message);
+
+ void debug(Object message, Throwable t);
+
+ void trace(Object message);
+
+ void trace(Object message, Throwable t);
+}
\ No newline at end of file
Copied:
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java
(from rev 10732,
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java)
===================================================================
---
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java
(rev 0)
+++
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.spi.core.logging;
+
+/**
+ * I am responsible for creating {@link LogDelegate} instances.
+ *
+ * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
+ *
+ *
+ */
+public interface LogDelegateFactory
+{
+ LogDelegate createDelegate(Class<?> clazz);
+}
Copied: trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/package-info.java
(from rev 10732,
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/package-info.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/package-info.java
(rev 0)
+++
trunk/hornetq-commons/src/main/java/org/hornetq/spi/core/logging/package-info.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.
+ */
+
+/**
+ * Logging SPI.
+ * <br>
+ * This package defines the Service Provide Interface to
+ * support different logging implementation.
+ */
+package org.hornetq.spi.core.logging;
+
Modified: trunk/hornetq-core/pom.xml
===================================================================
--- trunk/hornetq-core/pom.xml 2011-05-26 12:28:45 UTC (rev 10737)
+++ trunk/hornetq-core/pom.xml 2011-05-26 12:31:10 UTC (rev 10738)
@@ -14,6 +14,11 @@
<dependencies>
<dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</dependency>
Deleted: trunk/hornetq-core/src/main/java/org/hornetq/core/logging/Logger.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/logging/Logger.java 2011-05-26
12:28:45 UTC (rev 10737)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/logging/Logger.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,212 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.core.logging;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.hornetq.core.logging.impl.JULLogDelegateFactory;
-import org.hornetq.spi.core.logging.LogDelegate;
-import org.hornetq.spi.core.logging.LogDelegateFactory;
-
-/**
- *
- * A Logger
- *
- * This class allows us to isolate all our logging dependencies in one place
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class Logger
-{
- public static final String LOGGER_DELEGATE_FACTORY_CLASS_NAME =
"org.hornetq.logger-delegate-factory-class-name";
-
- private static volatile LogDelegateFactory delegateFactory;
-
- private static final ConcurrentMap<Class<?>, Logger> loggers = new
ConcurrentHashMap<Class<?>, Logger>();
-
- static
- {
- Logger.initialise();
- }
-
- public static synchronized void setDelegateFactory(final LogDelegateFactory
delegateFactory)
- {
- Logger.clear();
-
- Logger.delegateFactory = delegateFactory;
- }
-
- private static void clear()
- {
- Logger.loggers.clear();
- }
-
- public static synchronized void reset()
- {
- Logger.clear();
-
- Logger.initialise();
- }
-
- public static synchronized void initialise()
- {
- LogDelegateFactory delegateFactory;
-
- // If a system property is specified then this overrides any delegate factory which
is set
- // programmatically - this is primarily of use so we can configure the logger
delegate on the client side.
- // call to System.getProperty is wrapped in a try block as it will fail if the
client runs in a secured
- // environment
- String className = JULLogDelegateFactory.class.getName();
- try
- {
- className = System.getProperty(Logger.LOGGER_DELEGATE_FACTORY_CLASS_NAME);
- }
- catch (Exception e)
- {
- }
-
- if (className != null)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- Class<?> clz = loader.loadClass(className);
- delegateFactory = (LogDelegateFactory)clz.newInstance();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("Error instantiating transformer
class \"" + className + "\"", e);
- }
- }
- else
- {
- delegateFactory = new JULLogDelegateFactory();
- }
-
- Logger.delegateFactory = delegateFactory;
-
- Logger.loggers.clear();
- }
-
- public static Logger getLogger(final Class<?> clazz)
- {
- Logger logger = Logger.loggers.get(clazz);
-
- if (logger == null)
- {
- LogDelegate delegate = Logger.delegateFactory.createDelegate(clazz);
-
- logger = new Logger(delegate);
-
- Logger oldLogger = Logger.loggers.putIfAbsent(clazz, logger);
-
- if (oldLogger != null)
- {
- logger = oldLogger;
- }
- }
-
- return logger;
- }
-
- private final LogDelegate delegate;
-
- Logger(final LogDelegate delegate)
- {
- this.delegate = delegate;
- }
-
- public LogDelegate getDelegate()
- {
- return delegate;
- }
-
- public boolean isInfoEnabled()
- {
- return delegate.isInfoEnabled();
- }
-
- public boolean isDebugEnabled()
- {
- return delegate.isDebugEnabled();
- }
-
- public boolean isTraceEnabled()
- {
- return delegate.isTraceEnabled();
- }
-
- public void fatal(final Object message)
- {
- delegate.fatal(message);
- }
-
- public void fatal(final Object message, final Throwable t)
- {
- delegate.fatal(message, t);
- }
-
- public void error(final Object message)
- {
- delegate.error(message);
- }
-
- public void error(final Object message, final Throwable t)
- {
- delegate.error(message, t);
- }
-
- public void warn(final Object message)
- {
- delegate.warn(message);
- }
-
- public void warn(final Object message, final Throwable t)
- {
- delegate.warn(message, t);
- }
-
- public void info(final Object message)
- {
- delegate.info(message);
- }
-
- public void info(final Object message, final Throwable t)
- {
- delegate.info(message, t);
- }
-
- public void debug(final Object message)
- {
- delegate.debug(message);
- }
-
- public void debug(final Object message, final Throwable t)
- {
- delegate.debug(message, t);
- }
-
- public void trace(final Object message)
- {
- delegate.trace(message);
- }
-
- public void trace(final Object message, final Throwable t)
- {
- delegate.trace(message, t);
- }
-
-}
Deleted:
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java 2011-05-26
12:28:45 UTC (rev 10737)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegate.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,111 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.core.logging.impl;
-
-import java.util.logging.Level;
-
-import org.hornetq.spi.core.logging.LogDelegate;
-
-/**
- *
- * A {@link LogDelegate} which delegates to java.util.logging
- *
- * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
- *
- */
-public class JULLogDelegate implements LogDelegate
-{
- private final java.util.logging.Logger logger;
-
- JULLogDelegate(final Class<?> clazz)
- {
- logger = java.util.logging.Logger.getLogger(clazz.getName());
- }
-
- public boolean isInfoEnabled()
- {
- return logger.isLoggable(Level.INFO);
- }
-
- public boolean isDebugEnabled()
- {
- return logger.isLoggable(Level.FINE);
- }
-
- public boolean isTraceEnabled()
- {
- return logger.isLoggable(Level.FINEST);
- }
-
- public void fatal(final Object message)
- {
- logger.log(Level.SEVERE, message == null ? "NULL" : message.toString());
- }
-
- public void fatal(final Object message, final Throwable t)
- {
- logger.log(Level.SEVERE, message == null ? "NULL" : message.toString(),
t);
- }
-
- public void error(final Object message)
- {
- logger.log(Level.SEVERE, message == null ? "NULL" : message.toString());
- }
-
- public void error(final Object message, final Throwable t)
- {
- logger.log(Level.SEVERE, message == null ? "NULL" : message.toString(),
t);
- }
-
- public void warn(final Object message)
- {
- logger.log(Level.WARNING, message == null ? "NULL" :
message.toString());
- }
-
- public void warn(final Object message, final Throwable t)
- {
- logger.log(Level.WARNING, message == null ? "NULL" : message.toString(),
t);
- }
-
- public void info(final Object message)
- {
- logger.log(Level.INFO, message == null ? "NULL" : message.toString());
- }
-
- public void info(final Object message, final Throwable t)
- {
- logger.log(Level.INFO, message == null ? "NULL" : message.toString(),
t);
- }
-
- public void debug(final Object message)
- {
- logger.log(Level.FINE, message == null ? "NULL" : message.toString());
- }
-
- public void debug(final Object message, final Throwable t)
- {
- logger.log(Level.FINE, message == null ? "NULL" : message.toString(),
t);
- }
-
- public void trace(final Object message)
- {
- logger.log(Level.FINEST, message == null ? "NULL" : message.toString());
- }
-
- public void trace(final Object message, final Throwable t)
- {
- logger.log(Level.FINEST, message == null ? "NULL" : message.toString(),
t);
- }
-
-}
Deleted:
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java 2011-05-26
12:28:45 UTC (rev 10737)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/logging/impl/JULLogDelegateFactory.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,32 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.core.logging.impl;
-
-import org.hornetq.spi.core.logging.LogDelegate;
-import org.hornetq.spi.core.logging.LogDelegateFactory;
-
-/**
- * A {@link LogDelegateFactory} which creates {@link JULLogDelegate} instances.
- *
- * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
- *
- *
- */
-public class JULLogDelegateFactory implements LogDelegateFactory
-{
- public LogDelegate createDelegate(final Class<?> clazz)
- {
- return new JULLogDelegate(clazz);
- }
-}
Deleted: trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java 2011-05-26
12:28:45 UTC (rev 10737)
+++
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegate.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.spi.core.logging;
-
-/**
- * I represent operations that are delegated to underlying logging frameworks.
- *
- * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
- *
- *
- */
-public interface LogDelegate
-{
- boolean isInfoEnabled();
-
- boolean isDebugEnabled();
-
- boolean isTraceEnabled();
-
- void fatal(Object message);
-
- void fatal(Object message, Throwable t);
-
- void error(Object message);
-
- void error(Object message, Throwable t);
-
- void warn(Object message);
-
- void warn(Object message, Throwable t);
-
- void info(Object message);
-
- void info(Object message, Throwable t);
-
- void debug(Object message);
-
- void debug(Object message, Throwable t);
-
- void trace(Object message);
-
- void trace(Object message, Throwable t);
-}
\ No newline at end of file
Deleted:
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java 2011-05-26
12:28:45 UTC (rev 10737)
+++
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/LogDelegateFactory.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,26 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.spi.core.logging;
-
-/**
- * I am responsible for creating {@link LogDelegate} instances.
- *
- * @author <a href="kenny.macleod(a)kizoom.com">Kenny MacLeod</a>
- *
- *
- */
-public interface LogDelegateFactory
-{
- LogDelegate createDelegate(Class<?> clazz);
-}
Deleted: trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/package-info.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/package-info.java 2011-05-26
12:28:45 UTC (rev 10737)
+++
trunk/hornetq-core/src/main/java/org/hornetq/spi/core/logging/package-info.java 2011-05-26
12:31:10 UTC (rev 10738)
@@ -1,21 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.
- */
-
-/**
- * Logging SPI.
- * <br>
- * This package defines the Service Provide Interface to
- * support different logging implementation.
- */
-package org.hornetq.spi.core.logging;
-