[slf4j-dev] svn commit: r639 - in slf4j/trunk: . slf4j-archetype slf4j-archetype/src slf4j-archetype/src/main slf4j-archetype/src/main/resources slf4j-archetype/src/main/resources/META-INF slf4j-archetype/src/main/resources/META-INF/maven slf4j-archetype/src/main/resources/archetype-resources slf4j-archetype/src/main/resources/archetype-resources/src slf4j-archetype/src/main/resources/archetype-resources/src/main slf4j-archetype/src/main/resources/archetype-resources/src/main/java slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl slf4j-archetype/src/main/resources/archetype-resources/src/test slf4j-archetype/src/main/resources/archetype-resources/src/test/java slf4j-jdk14/src/test/java/org/slf4j slf4j-log4j12/src/test/java/org/slf4j slf4j-nop/src/test/java/org/slf4j

ceki at slf4j.org ceki at slf4j.org
Tue Sep 5 22:48:47 CEST 2006


Author: ceki
Date: Tue Sep  5 22:48:47 2006
New Revision: 639

Added:
   slf4j/trunk/slf4j-archetype/
   slf4j/trunk/slf4j-archetype/notes.txt
   slf4j/trunk/slf4j-archetype/pom.xml
   slf4j/trunk/slf4j-archetype/src/
   slf4j/trunk/slf4j-archetype/src/main/
   slf4j/trunk/slf4j-archetype/src/main/resources/
   slf4j/trunk/slf4j-archetype/src/main/resources/META-INF/
   slf4j/trunk/slf4j-archetype/src/main/resources/META-INF/maven/
   slf4j/trunk/slf4j-archetype/src/main/resources/META-INF/maven/archetype.xml
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/pom.xml
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/LoggerFactory.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/MarkerFactory.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLogger.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLoggerFactory.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticLoggerBinder.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticMarkerBinder.java
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/test/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/test/java/
   slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/test/java/InvocationTest.java
   slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java
      - copied unchanged from r638, /slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocatonTest.java
   slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocationTest.java
      - copied unchanged from r638, /slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocatonTest.java
   slf4j/trunk/slf4j-nop/src/test/java/org/slf4j/InvocationTest.java
      - copied unchanged from r638, /slf4j/trunk/slf4j-nop/src/test/java/org/slf4j/InvocatonTest.java
Removed:
   slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocatonTest.java
   slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocatonTest.java
   slf4j/trunk/slf4j-nop/src/test/java/org/slf4j/InvocatonTest.java
Modified:
   slf4j/trunk/pom.xml

Log:
adding slf4j-archetype project for faster binding creation.


Modified: slf4j/trunk/pom.xml
==============================================================================
--- slf4j/trunk/pom.xml	(original)
+++ slf4j/trunk/pom.xml	Tue Sep  5 22:48:47 2006
@@ -1,148 +1,149 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-	<modelVersion>4.0.0</modelVersion>
-
-	<groupId>org.slf4j</groupId>
-	<artifactId>slf4j</artifactId>
-	<version>1.1.0</version>
-	<packaging>pom</packaging>
-	<name>SLF4J</name>
-
-
-	<url>http://www.slf4j.org</url>
-
-	<organization>
-		<name>QOS.ch</name>
-		<url>http://www.qos.ch</url>
-	</organization>
-	<inceptionYear>2005</inceptionYear>
-
-	<modules>
-		<module>slf4j-api</module>
-    <module>slf4j-simple</module>
-    <module>slf4j-nop</module>
-		<module>slf4j-jdk14</module>
-    <module>slf4j-log4j12</module>
-    <module>slf4j-jcl</module>
-    <module>jcl104-over-slf4j</module>
-    <module>slf4j-site</module>
-	</modules>
-
-	<dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-		</dependency>
-	</dependencies>
-	
-	<dependencyManagement>
-    <dependencies/>
-	</dependencyManagement>
-
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<configuration>
-					<source>1.4</source>
-					<target>1.4</target>
-				</configuration>
-			</plugin>
- 
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<configuration>
-					<forkMode>once</forkMode>
-					<reportFormat>plain</reportFormat>
-					<trimStackTrace>false</trimStackTrace>
-					<excludes>
-						<exclude>**/AllTest.java</exclude>
-						<exclude>**/PackageTest.java</exclude>
-					</excludes>
-				</configuration>
-			</plugin>		
-
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>        
-        <artifactId>maven-source-plugin</artifactId>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>              
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <destDir>/target/site/api</destDir>
-        	<aggregate>true</aggregate>
-					<links>
-						<link>
-							http://java.sun.com/j2se/1.5.0/docs/api
-						</link>
-					</links>
-          <groups>
-            <group>
-              <title>SLF4J packages</title>
-              <packages>org.slf4j.*</packages>
-            </group>
-            <group>
-              <title>Jakarta Commons Logging packages</title>
-              <packages>org.apache.commons.*</packages>
-            </group>
-          </groups>
-        </configuration>
-      </plugin>
-
-    </plugins>
-
-	</build>
-
-
-	<reporting>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-site-plugin</artifactId>
-			</plugin>
-
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-project-info-reports-plugin</artifactId>
-				<reportSets>
-					<reportSet><reports></reports></reportSet>
-				</reportSets>
-			</plugin>	    
-      
-      <plugin>
-				<artifactId>maven-assembly-plugin</artifactId>
-				<version>2.1</version>
-				<configuration>
-					<descriptors>
-						<descriptor>
-							src/main/assembly/source.xml
-						</descriptor>
-					</descriptors>
-					<finalName>slf4j-${project.version}</finalName>
-					<appendAssemblyId>false</appendAssemblyId>
-					<outputDirectory>target/site/dist/</outputDirectory>
-				</configuration>
-			</plugin>
-			
-    </plugins>
-
-	</reporting>
-	
-
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>org.slf4j</groupId>
+	<artifactId>slf4j</artifactId>
+	<version>1.1.0</version>
+	<packaging>pom</packaging>
+	<name>SLF4J</name>
+
+
+	<url>http://www.slf4j.org</url>
+
+	<organization>
+		<name>QOS.ch</name>
+		<url>http://www.qos.ch</url>
+	</organization>
+	<inceptionYear>2005</inceptionYear>
+
+	<modules>
+		<module>slf4j-api</module>
+    <module>slf4j-simple</module>
+    <module>slf4j-nop</module>
+		<module>slf4j-jdk14</module>
+    <module>slf4j-log4j12</module>
+    <module>slf4j-jcl</module>
+    <module>jcl104-over-slf4j</module>
+    <module>slf4j-site</module>
+
+    <module>slf4j-archetype</module>
+  </modules>
+
+	<dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+		</dependency>
+	</dependencies>
+	
+	<dependencyManagement>
+    <dependencies/>
+	</dependencyManagement>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.4</source>
+					<target>1.4</target>
+				</configuration>
+			</plugin>
+ 
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<forkMode>once</forkMode>
+					<reportFormat>plain</reportFormat>
+					<trimStackTrace>false</trimStackTrace>
+					<excludes>
+						<exclude>**/AllTest.java</exclude>
+						<exclude>**/PackageTest.java</exclude>
+					</excludes>
+				</configuration>
+			</plugin>		
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>        
+        <artifactId>maven-source-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>              
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <destDir>/target/site/api</destDir>
+        	<aggregate>true</aggregate>
+					<links>
+						<link>
+							http://java.sun.com/j2se/1.5.0/docs/api
+						</link>
+					</links>
+          <groups>
+            <group>
+              <title>SLF4J packages</title>
+              <packages>org.slf4j.*</packages>
+            </group>
+            <group>
+              <title>Jakarta Commons Logging packages</title>
+              <packages>org.apache.commons.*</packages>
+            </group>
+          </groups>
+        </configuration>
+      </plugin>
+
+    </plugins>
+
+	</build>
+
+
+	<reporting>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-site-plugin</artifactId>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-project-info-reports-plugin</artifactId>
+				<reportSets>
+					<reportSet><reports/></reportSet>
+				</reportSets>
+			</plugin>	    
+      
+      <plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<version>2.1</version>
+				<configuration>
+					<descriptors>
+						<descriptor>
+							src/main/assembly/source.xml
+						</descriptor>
+					</descriptors>
+					<finalName>slf4j-${project.version}</finalName>
+					<appendAssemblyId>false</appendAssemblyId>
+					<outputDirectory>target/site/dist/</outputDirectory>
+				</configuration>
+			</plugin>
+			
+    </plugins>
+
+	</reporting>
+	
+
 </project>
\ No newline at end of file

Added: slf4j/trunk/slf4j-archetype/notes.txt
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/notes.txt	Tue Sep  5 22:48:47 2006
@@ -0,0 +1 @@
+mvn archetype:create -DgroupId=org.slf4j -DartifactId=slf4j-archetype -DarchetypeArtifactId=maven-archetype-archetype

Added: slf4j/trunk/slf4j-archetype/pom.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/pom.xml	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,15 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>slf4j</artifactId>
+    <groupId>org.slf4j</groupId>
+    <version>1.1.0</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.slf4j</groupId>
+  <artifactId>slf4j-archetype</artifactId>
+  <name>Archetype - slf4j-archetype</name>
+	<version>${parent.version}</version>
+
+  <url>http://www.slf4j.org</url>
+</project>
\ No newline at end of file

Added: slf4j/trunk/slf4j-archetype/src/main/resources/META-INF/maven/archetype.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/META-INF/maven/archetype.xml	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,13 @@
+
+<archetype>
+  <id>slf4j-archetype</id>
+  <sources>
+    <source>src/main/java/LoggerFactory.java</source>
+    <source>src/main/java/MarkerFactory.java</source>
+    <source>src/main/java/impl/StaticLoggerBinder.java</source>
+    <source>src/main/java/impl/StaticMarkerBinder.java</source>
+  </sources>
+  <testSources>
+    <source>src/test/java/InvocationTest.java</source>
+  </testSources>
+</archetype>

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/pom.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/pom.xml	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,23 @@
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  
+	<parent>
+		<groupId>org.slf4j</groupId>
+		<artifactId>slf4j</artifactId>
+		<version>1.1.0</version>
+	</parent>
+	
+  <groupId>$groupId</groupId>
+  <artifactId>$artifactId</artifactId>
+  <version>$version</version>
+	<packaging>jar</packaging>
+
+
+  <dependencies>   
+  </dependencies>
+
+</project>

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/LoggerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/LoggerFactory.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+package org.slf4j;
+
+import org.slf4j.impl.StaticLoggerBinder;
+import org.slf4j.impl.Util;
+
+/**
+ * The <code>LoggerFactory</code> is a utility class producing Loggers for
+ * various logging APIs, most notably for NLOG4J and JDK 1.4 logging. Other
+ * implementations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
+ * {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported.
+ * 
+ * <p>
+ * <code>LoggerFactory</code> is essentially a wrapper around an
+ * {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
+ * compile time.
+ * 
+ * <p>
+ * Please note that all methods in <code>LoggerFactory</code> are static.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public final class LoggerFactory {
+
+  static ILoggerFactory loggerFactory;
+
+  // private constructor prevents instantiation
+  private LoggerFactory() {
+  }
+
+
+  static {
+    try { 
+      loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory();
+    } catch (Exception e) {
+      // we should never get here
+      Util.reportFailure("Failed to instantiate logger ["
+          + StaticLoggerBinder.SINGLETON.getLoggerFactoryClassStr() + "]", e);
+    }
+  }
+
+  /**
+   * Return a logger named according to the name parameter using the statically
+   * bound {@link ILoggerFactory} instance.
+   * 
+   * @param name
+   *          The name of the logger.
+   * @return logger
+   */
+  public static Logger getLogger(String name) {
+    return loggerFactory.getLogger(name);
+  }
+
+  /**
+   * Return a logger named corresponding to the class passed as parameter, using
+   * the statically bound {@link ILoggerFactory} instance.
+   * 
+   * @param clazz
+   *          the returned logger will be named after clazz
+   * @return logger
+   */
+  public static Logger getLogger(Class clazz) {
+    return loggerFactory.getLogger(clazz.getName());
+  }
+
+  /**
+   * Return the {@link ILoggerFactory} instance in use.
+   * 
+   * <p>ILoggerFactory instance is bound with this class at compile
+   * time.
+   * 
+   * @return the ILoggerFactory instance in use
+   */
+  public static ILoggerFactory getILoggerFactory() {
+    return loggerFactory;
+  }
+}

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/MarkerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/MarkerFactory.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+package org.slf4j;
+
+import org.slf4j.impl.StaticMarkerBinder;
+import org.slf4j.impl.Util;
+
+/**
+ * MarkerFactory is a utility class producing {@link Marker} instances as
+ * appropriate for the logging system currently in use.
+ * 
+ * <p>
+ * This class is essentially implemented as a wrapper around an
+ * {@link IMarkerFactory} instance bound at compile time.
+ * 
+ * <p>
+ * Please note that all methods in this class are static.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class MarkerFactory {
+  static IMarkerFactory markerFactory;
+
+  private MarkerFactory() {
+  }
+
+  static {
+    try {
+      markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory();
+    } catch (Exception e) {
+      // we should never get here
+      Util.reportFailure("Could not instantiate instance of class ["
+          + StaticMarkerBinder.SINGLETON.getMarkerFactoryClassStr() + "]", e);
+    }
+  }
+
+  /**
+   * Return a Marker instance as specified by the name parameter using the
+   * previously bound {@link IMarkerFactory}instance.
+   * 
+   * @param name
+   *          The name of the {@link Marker} object to return.
+   * @return marker
+   */
+  public static Marker getMarker(String name) {
+    return markerFactory.getMarker(name);
+  }
+
+  /**
+   * Return the {@link IMarkerFactory}instance in use.
+   * 
+   * <p>The IMarkerFactory instance is usually bound with this class at 
+   * compile time.
+   * 
+   * @return the IMarkerFactory instance in use
+   */
+  public static IMarkerFactory getIMarkerFactory() {
+    return markerFactory;
+  }
+}
\ No newline at end of file

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLogger.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLogger.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.Logger;
+
+
+/**
+ * A direct NOP (no operation) implementation of {@link Logger}.
+ *
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class NOPLogger extends MarkerIgnoringBase {
+  /**
+   * The unique instance of NOPLogger.
+   */
+  public static final NOPLogger NOP_LOGGER = new NOPLogger();
+
+  /**
+   * There is no point in creating multiple instances of NOPLOgger, 
+   * except by derived classes, hence the protected  access for the constructor.
+   */
+  protected NOPLogger() {
+  }
+
+  /**
+   * Always returns the string value "NOP".
+   */
+  public String getName() {
+    return "NOP";
+  }
+
+  /**
+   * Always returns false.
+   * @return always false
+   */
+  final public boolean isDebugEnabled() {
+    return false;
+  }
+
+  /** A NOP implementation. */
+  final public void debug(String msg) {
+    // NOP
+  }
+
+  /** A NOP implementation.  */
+  final public void debug(String format, Object arg) {
+    // NOP
+  }
+
+  /** A NOP implementation.  */
+  public final void debug(String format, Object arg1, Object arg2) {
+    // NOP
+  }
+
+  /** A NOP implementation.  */
+  public final void debug(String format, Object[] argArray) {
+    // NOP
+  }
+  
+  
+  
+  /** A NOP implementation. */
+  final public void debug(String msg, Throwable t) {
+    // NOP
+  }
+
+  /**
+   * Always returns false.
+   * @return always false
+   */
+  final public boolean isInfoEnabled() {
+    // NOP
+    return false;
+  }
+
+
+  /** A NOP implementation. */
+  final public void info(String msg) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final  public void info(String format, Object arg1) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final public void info(String format, Object arg1, Object arg2) {
+    // NOP
+  }
+  
+  /** A NOP implementation.  */
+  public final void info(String format, Object[] argArray) {
+    // NOP
+  }
+
+
+  /** A NOP implementation. */
+  final public void info(String msg, Throwable t) {
+    // NOP
+  }
+
+
+  /**
+   * Always returns false.
+   * @return always false
+   */
+  final public boolean isWarnEnabled() {
+    return false;
+  }
+
+  /** A NOP implementation. */
+  final public void warn(String msg) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final public void warn(String format, Object arg1) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final public void warn(String format, Object arg1, Object arg2) {
+    // NOP
+  }
+  
+  /** A NOP implementation.  */
+  public final void warn(String format, Object[] argArray) {
+    // NOP
+  }
+
+
+  /** A NOP implementation. */
+  final public void warn(String msg, Throwable t) {
+    // NOP
+  }
+
+
+  /** A NOP implementation. */
+  final public boolean isErrorEnabled() {
+    return false;
+  }
+
+  /** A NOP implementation. */
+  final public void error(String msg) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final public void error(String format, Object arg1) {
+    // NOP
+  }
+
+  /** A NOP implementation. */
+  final public void error(String format, Object arg1, Object arg2) {
+    // NOP
+  }
+  
+  /** A NOP implementation.  */
+  public final void error(String format, Object[] argArray) {
+    // NOP
+  }
+
+
+  /** A NOP implementation. */
+  final public void error(String msg, Throwable t) {
+    // NOP
+  }
+}

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLoggerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/NOPLoggerFactory.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,57 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.ILoggerFactory;
+
+
+/**
+ * NOPLoggerFactory is an trivial implementation of {@link
+ * ILoggerFactory} which always returns the unique instance of
+ * NOPLogger.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class NOPLoggerFactory implements ILoggerFactory {
+  
+  public NOPLoggerFactory() {
+    // nothing to do
+  }
+  
+  public Logger getLogger(String name) {
+    return NOPLogger.NOP_LOGGER;
+  }
+
+}

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticLoggerBinder.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticLoggerBinder.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.IMarkerFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * The binding of {@link LoggerFactory} class with an actual instance of 
+ * {@link ILoggerFactory} is performed using information returned by this class. 
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   */
+  public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+  // Note: JCL gets substituted at build time by an appropriate Ant task
+  private static final String loggerFactoryClassStr = ${IMPL}LoggerFactory.class.getName();
+
+  /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method
+   * should always be the same object
+   */
+  private final ILoggerFactory loggerFactory;
+  
+  private StaticLoggerBinder() {
+    loggerFactory = new ${IMPL}LoggerFactory();
+  }
+  
+  public ILoggerFactory getLoggerFactory() {
+    return loggerFactory;
+  }
+  
+  public String getLoggerFactoryClassStr() {
+    return loggerFactoryClassStr;
+  }   
+}

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticMarkerBinder.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/main/java/impl/StaticMarkerBinder.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ * 
+ * The binding of {@link MarkerFactory} class with an actual instance of 
+ * {@link IMarkerFactory} is performed using information returned by this class. 
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class StaticMarkerBinder implements MarkerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   */
+  public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+  
+  final IMarkerFactory markerFactory = new BasicMarkerFactory();
+  
+  private StaticMarkerBinder() {
+  }
+  
+  /**
+   * Currently this method always returns an instance of 
+   * {@link BasicMarkerFactory}.
+   */
+  public IMarkerFactory getMarkerFactory() {
+    return markerFactory;
+  }
+  
+  /**
+   * Currently, this method returns the class name of
+   * {@link BasicMarkerFactory}.
+   */
+  public String getMarkerFactoryClassStr() {
+    return BasicMarkerFactory.class.getName();
+  }
+  
+  
+}

Added: slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/test/java/InvocationTest.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-archetype/src/main/resources/archetype-resources/src/test/java/InvocationTest.java	Tue Sep  5 22:48:47 2006
@@ -0,0 +1,121 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.CH
+ * 
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test whether invoking the SLF4J API causes problems or not.
+ * 
+ * @author Ceki Gulcu
+ *
+ */
+public class InvocatonTest extends TestCase {
+
+  public InvocatonTest (String arg0) {
+    super(arg0);
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
+  }
+  
+  public void test1() {
+    Logger logger = LoggerFactory.getLogger("test1");
+    logger.debug("Hello world.");
+  }
+  
+  public void test2() {
+    Integer i1 = new Integer(1);
+    Integer i2 = new Integer(2);
+    Integer i3 = new Integer(3);
+    Exception e = new Exception("This is a test exception.");
+    Logger logger = LoggerFactory.getLogger("test2");
+    
+    logger.debug("Hello world 1.");
+    logger.debug("Hello world {}", i1);
+    logger.debug("val={} val={}", i1, i2);
+    logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3});
+    
+    logger.debug("Hello world 2", e);
+    logger.info("Hello world 2.");
+ 
+    
+    logger.warn("Hello world 3.");
+    logger.warn("Hello world 3", e);
+ 
+  
+    logger.error("Hello world 4.");
+    logger.error("Hello world {}", new Integer(3)); 
+    logger.error("Hello world 4.", e);
+  }
+  
+  public void testNull() {
+    Logger logger = LoggerFactory.getLogger("testNull");
+    logger.debug(null);
+    logger.info(null);
+    logger.warn(null);
+    logger.error(null);
+    
+    Exception e = new Exception("This is a test exception.");
+    logger.debug(null, e);
+    logger.info(null, e);
+    logger.warn(null, e);
+    logger.error(null, e);
+  }
+  
+  public void testMarker() {
+    Logger logger = LoggerFactory.getLogger("testMarker");
+    Marker blue = MarkerFactory.getMarker("BLUE");
+    logger.debug(blue, "hello");
+    logger.info(blue, "hello");
+    logger.warn(blue, "hello");
+    logger.error(blue, "hello");
+    
+    logger.debug(blue, "hello {}", "world");
+    logger.info(blue, "hello {}", "world");
+    logger.warn(blue, "hello {}", "world");
+    logger.error(blue, "hello {}", "world");
+
+    logger.debug(blue, "hello {} and {} ", "world", "universe");
+    logger.info(blue, "hello {} and {} ", "world", "universe");
+    logger.warn(blue, "hello {} and {} ", "world", "universe");
+    logger.error(blue, "hello {} and {} ", "world", "universe");
+  }
+}



More information about the slf4j-dev mailing list