Author: pete.muir(a)jboss.org
Date: 2009-11-09 12:01:32 -0500 (Mon, 09 Nov 2009)
New Revision: 4871
Added:
extensions/trunk/logger/src/main/java/org/jboss/weld/log/Category.java
Removed:
extensions/trunk/logger/src/main/java/org/jboss/weld/log/Logger.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/
Modified:
extensions/trunk/logger/pom.xml
extensions/trunk/logger/src/main/java/org/jboss/weld/log/LoggerProducer.java
extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Finch.java
extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Sparrow.java
extensions/trunk/servlet/tests/src/test/java/org/jboss/weld/test/tomcat/lookup/ServletInjectionTest.java
Log:
switch to slf4j
Modified: extensions/trunk/logger/pom.xml
===================================================================
--- extensions/trunk/logger/pom.xml 2009-11-09 17:01:04 UTC (rev 4870)
+++ extensions/trunk/logger/pom.xml 2009-11-09 17:01:32 UTC (rev 4871)
@@ -44,17 +44,17 @@
</dependency>
<dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-logging</artifactId>
- </dependency>
-
- <dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.test-harness</groupId>
<artifactId>jboss-test-harness</artifactId>
<scope>test</scope>
Copied: extensions/trunk/logger/src/main/java/org/jboss/weld/log/Category.java (from rev
4867, extensions/trunk/logger/src/main/java/org/jboss/weld/log/Logger.java)
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/weld/log/Category.java
(rev 0)
+++ extensions/trunk/logger/src/main/java/org/jboss/weld/log/Category.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -0,0 +1,30 @@
+package org.jboss.weld.log;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+
+/**
+ * Specifies a Category for the injected logger
+ *
+ * @author Gavin King
+ */
+@Target({METHOD, FIELD, PARAMETER, TYPE})
+@Retention(RUNTIME)
+@Documented
+public @interface Category
+{
+ /**
+ * @return the log category
+ */
+ @Nonbinding
+ String value();
+}
Property changes on:
extensions/trunk/logger/src/main/java/org/jboss/weld/log/Category.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: extensions/trunk/logger/src/main/java/org/jboss/weld/log/Logger.java
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/weld/log/Logger.java 2009-11-09
17:01:04 UTC (rev 4870)
+++ extensions/trunk/logger/src/main/java/org/jboss/weld/log/Logger.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -1,32 +0,0 @@
-package org.jboss.weld.log;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-
-/**
- * Injects a log
- *
- * @author Gavin King
- */
-@Target({METHOD, FIELD, PARAMETER, TYPE})
-@Retention(RUNTIME)
-@Documented
-@Qualifier
-public @interface Logger
-{
- /**
- * @return the log category
- */
- @Nonbinding
- String value() default "";
-}
Modified: extensions/trunk/logger/src/main/java/org/jboss/weld/log/LoggerProducer.java
===================================================================
---
extensions/trunk/logger/src/main/java/org/jboss/weld/log/LoggerProducer.java 2009-11-09
17:01:04 UTC (rev 4870)
+++
extensions/trunk/logger/src/main/java/org/jboss/weld/log/LoggerProducer.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -20,6 +20,9 @@
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* The <code>LoggerProducer</code> provides a producer method for all
* @Logger annotated log objects. Each logger is application scoped
@@ -31,21 +34,19 @@
*/
public class LoggerProducer
{
- @Produces @Logger
- public Log produceLog(InjectionPoint injectionPoint)
+
+ @Produces
+ public Logger produceLog(InjectionPoint injectionPoint)
{
- Log log = null;
- String category = null;
-
- category = injectionPoint.getAnnotated().getAnnotation(Logger.class).value();
- if (category.length() == 0)
+ if (injectionPoint.getAnnotated().isAnnotationPresent(Category.class))
{
- log = Logging.getLog((Class<?>)
injectionPoint.getMember().getDeclaringClass());
+ String category =
injectionPoint.getAnnotated().getAnnotation(Category.class).value();
+ return LoggerFactory.getLogger(category);
}
else
{
- log = Logging.getLog(category);
+ return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass());
}
- return log;
}
+
}
Modified: extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Finch.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Finch.java 2009-11-09
17:01:04 UTC (rev 4870)
+++ extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Finch.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -2,13 +2,13 @@
import javax.inject.Inject;
-import org.jboss.weld.log.Log;
-import org.jboss.weld.log.Logger;
+import org.jboss.weld.log.Category;
+import org.slf4j.Logger;
public class Finch
{
- @Inject @Logger("Finch")
- private Log log;
+ @Inject @Category("Finch")
+ private Logger log;
public void generateLogMessage()
{
Modified: extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Sparrow.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Sparrow.java 2009-11-09
17:01:04 UTC (rev 4870)
+++ extensions/trunk/logger/src/test/java/org/jboss/weld/test/log/Sparrow.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -2,13 +2,12 @@
import javax.inject.Inject;
-import org.jboss.weld.log.Log;
-import org.jboss.weld.log.Logger;
+import org.slf4j.Logger;
class Sparrow
{
- @Inject @Logger
- private Log log;
+ @Inject
+ private Logger log;
public void generateLogMessage()
{
Modified:
extensions/trunk/servlet/tests/src/test/java/org/jboss/weld/test/tomcat/lookup/ServletInjectionTest.java
===================================================================
---
extensions/trunk/servlet/tests/src/test/java/org/jboss/weld/test/tomcat/lookup/ServletInjectionTest.java 2009-11-09
17:01:04 UTC (rev 4870)
+++
extensions/trunk/servlet/tests/src/test/java/org/jboss/weld/test/tomcat/lookup/ServletInjectionTest.java 2009-11-09
17:01:32 UTC (rev 4871)
@@ -7,13 +7,14 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.log4j.Logger;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.IntegrationTest;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
import org.jboss.weld.test.AbstractWeldTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -30,7 +31,7 @@
public class ServletInjectionTest extends AbstractWeldTest
{
- private static final Logger log = Logger.getLogger(ServletInjectionTest.class);
+ private static final Logger log =
LoggerFactory.getLogger(ServletInjectionTest.class);
@Override
@BeforeClass