ceki 2005/01/11 07:57:40
Modified: src/xdocs ugli.xml
src/java/org/apache/log4j/spi DefaultRepositorySelector.java
RepositorySelector.java
src/java/org/apache/log4j/selector/servlet
ContextDetachingSCL.java
src/java/org/apache/log4j/helpers Constants.java
src/java/org/apache/log4j LogManager.java
tests/input/ugli basic.xml
src/java/org/apache/log4j/selector ContextJNDISelector.java
Log:
- Added getLoggerRepository.getLoggerRepository(String name) method to LR
interface.
- Other minor doc changes.
Revision Changes Path
1.4 +1 -1 logging-log4j/src/xdocs/ugli.xml
Index: ugli.xml
===================================================================
RCS file: /home/cvs/logging-log4j/src/xdocs/ugli.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ugli.xml 3 Jan 2005 16:16:35 -0000 1.3
+++ ugli.xml 11 Jan 2005 15:57:40 -0000 1.4
@@ -52,7 +52,7 @@
FAQ for more details.
</p>
- <h2>Swapping implementations at runtime</h2>
+ <h2>Swapping implementations at deployment time</h2>
<p>UGLI currently supports four implementations, namely, NOP,
Simple, JDK 1.4 logging and log4j. Log4j 1.3 ships with four
1.11 +16 -6
logging-log4j/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java
Index: DefaultRepositorySelector.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultRepositorySelector.java 8 Jan 2005 14:05:28 -0000 1.10
+++ DefaultRepositorySelector.java 11 Jan 2005 15:57:40 -0000 1.11
@@ -16,23 +16,33 @@
package org.apache.log4j.spi;
+import org.apache.log4j.helpers.Constants;
+
public class DefaultRepositorySelector implements RepositorySelector {
- LoggerRepository repository;
+ LoggerRepository defaultRepository;
public DefaultRepositorySelector(final LoggerRepository repository) {
- this.repository = repository;
+ this.defaultRepository = repository;
}
- public LoggerRepository getLoggerRepository() {
- return repository;
+ public LoggerRepository getLoggerRepository() {
+ return defaultRepository;
+ }
+
+ public LoggerRepository getLoggerRepository(final String name) {
+ if(Constants.DEFAULT_REPOSITORY_NAME.equals(name)) {
+ return defaultRepository;
+ } else {
+ return null;
+ }
}
/**
- * Does nothing.
+ * Does nothing, always returns null.
*
* @return Always null
*/
- public LoggerRepository detachRepository(String contextName) {
+ public LoggerRepository detachRepository(final String name) {
// do nothing, as the default repository cannot be removed
return null;
}
1.13 +15 -4
logging-log4j/src/java/org/apache/log4j/spi/RepositorySelector.java
Index: RepositorySelector.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/spi/RepositorySelector.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RepositorySelector.java 7 Jan 2005 20:47:38 -0000 1.12
+++ RepositorySelector.java 11 Jan 2005 15:57:40 -0000 1.13
@@ -32,6 +32,15 @@
* @since 1.2
* */
public interface RepositorySelector {
+
+ /**
+ * Get a [EMAIL PROTECTED] LoggerRepository} by name. If the named
repository does not
+ * exists or is unknown to this selector, then <code>null</code> is
returned.
+ *
+ * @since 1.3
+ */
+ public LoggerRepository getLoggerRepository(String name);
+
/**
* Returns a [EMAIL PROTECTED] LoggerRepository} depending on the context.
Implementors
* must make sure that under all circumstances a valid (non-null)
@@ -40,11 +49,13 @@
public LoggerRepository getLoggerRepository();
/**
- * Remove the repository with the given context name from the list
maintained
- * by the respository selector.
+ * Remove the repository with the given name from the list maintained by
the
+ * respository selector.
*
* <p>When applications are stopped or recycled, this method should be
called
- * to ensure that the associated repository is recycled as well.
+ * to ensure that the associated repository is recycled as well. After the
+ * repository is detached from this selector, the returned value, i.e. the
+ * detached repository, can be used to shutdown the repository.
*
* <p>If more than one application share the same logging context, then the
* applications need to coordinate their actions.
@@ -52,5 +63,5 @@
* @return The LoggerRepository instance that was detached.
* @since 1.3
*/
- public LoggerRepository detachRepository(String contextName);
+ public LoggerRepository detachRepository(String name);
}
1.3 +1 -2
logging-log4j/src/java/org/apache/log4j/selector/servlet/ContextDetachingSCL.java
Index: ContextDetachingSCL.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/selector/servlet/ContextDetachingSCL.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContextDetachingSCL.java 6 Jan 2005 19:27:03 -0000 1.2
+++ ContextDetachingSCL.java 11 Jan 2005 15:57:40 -0000 1.3
@@ -75,8 +75,7 @@
LoggerRepository lr =
repositorySelector.detachRepository(loggingContextName);
if(lr != null) {
Logger logger = lr.getLogger(this.getClass().getName());
- logger.debug("About to shutdown logger repository named
["+lr.getName()+
- "]");
+ logger.debug("About to shutdown logger repository named [{}]",
lr.getName());
lr.shutdown();
}
}
1.10 +8 -0
logging-log4j/src/java/org/apache/log4j/helpers/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/helpers/Constants.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Constants.java 6 Jan 2005 17:03:10 -0000 1.9
+++ Constants.java 11 Jan 2005 15:57:40 -0000 1.10
@@ -19,10 +19,18 @@
/**
* Constants used internally throughout log4j.
+ *
+ * @since 1.3
*/
public interface Constants {
static final String LOG4J_PACKAGE_NAME = "org.apache.log4j";
+
+ /**
+ * The name of the default repository is "default" (without the quotes).
+ */
+ static final String DEFAULT_REPOSITORY_NAME = "default";
+
static final String APPLICATION_KEY = "application";
static final String HOSTNAME_KEY = "hostname";
1.38 +1 -1 logging-log4j/src/java/org/apache/log4j/LogManager.java
Index: LogManager.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/LogManager.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- LogManager.java 8 Jan 2005 14:05:28 -0000 1.37
+++ LogManager.java 11 Jan 2005 15:57:40 -0000 1.38
@@ -72,7 +72,7 @@
static {
//System.out.println("**Start of LogManager static initializer");
defaultLoggerRepository = new Hierarchy(new RootLogger(Level.DEBUG));
- defaultLoggerRepository.setName("default");
+ defaultLoggerRepository.setName(Constants.DEFAULT_REPOSITORY_NAME);
// temporary repository
repositorySelector = new
DefaultRepositorySelector(defaultLoggerRepository);
1.2 +1 -1 logging-log4j/tests/input/ugli/basic.xml
Index: basic.xml
===================================================================
RCS file: /home/cvs/logging-log4j/tests/input/ugli/basic.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- basic.xml 8 Jan 2005 13:14:03 -0000 1.1
+++ basic.xml 11 Jan 2005 15:57:40 -0000 1.2
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
-<configuration xmlns='http://logging.apache.org/' debug="true">
+<configuration xmlns='http://logging.apache.org/' debug="false">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
1.17 +16 -5
logging-log4j/src/java/org/apache/log4j/selector/ContextJNDISelector.java
Index: ContextJNDISelector.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/selector/ContextJNDISelector.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ContextJNDISelector.java 7 Jan 2005 20:47:38 -0000 1.16
+++ ContextJNDISelector.java 11 Jan 2005 15:57:40 -0000 1.17
@@ -156,7 +156,7 @@
// we can't log here
}
- if (loggingContextName == null) {
+ if (loggingContextName == null ||
Constants.DEFAULT_REPOSITORY_NAME.equals(loggingContextName)) {
return LogManager.defaultLoggerRepository;
} else {
//System.out.println("loggingContextName is ["+loggingContextName+"]");
@@ -189,11 +189,22 @@
}
}
-
-
+ /**
+ * Get the logger repository with the corresponding name.
+ *
+ * <p>Returned value can be null if the selector is unaware of the
repository
+ * with the given name.
+ */
+ public LoggerRepository getLoggerRepository(String name) {
+ if( Constants.JNDI_CONTEXT_NAME.equals(name)) {
+ return LogManager.defaultLoggerRepository;
+ } else {
+ return (LoggerRepository) hierMap.get(name);
+ }
+ }
/**
- * Remove the repository with the given context name from the list of
- * known repositories.
+ * Remove the repository with the given name from the list of known
+ * repositories.
*
* @return the detached repository
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]