pglezen 01/06/25 00:06:26 Modified: src/java/org/apache/log4j/examples/appserver AppServerCategory.java AppServerCategoryFactory.java package.html Log: AppServerCategory.java - Fixed a bug resulting from a mix-up in the execution ordering of static initializers from Category and AppServerCategory. AppServerCategoryFactory.java - Changed the overloaded method setMessageBundle(String) to setMessageBundleName(String). Overloading setters causes grief for bean introspectors. The setMessageBundle(ResourceBundle) method still stands as it always has. package.html - Added information on how to configure the appserver package using DOMConfigurator. Revision Changes Path 1.9 +3 -1 jakarta-log4j/src/java/org/apache/log4j/examples/appserver/AppServerCategory.java Index: AppServerCategory.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/appserver/AppServerCategory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AppServerCategory.java 2001/06/04 06:15:21 1.8 +++ AppServerCategory.java 2001/06/25 07:06:24 1.9 @@ -79,7 +79,7 @@ /** A reference to the factory to create <code>AppServerCategory</code> instances. */ - private static CategoryFactory factory = new AppServerCategoryFactory(null, null, null); + private static CategoryFactory factory; /** * Construct a new AppServerCategory with the provided @@ -147,6 +147,8 @@ * compatibility with the base class. */ public static Category getInstance(String name) { + if (factory == null) + factory = new AppServerCategoryFactory(); return Category.getInstance(name, factory); } 1.7 +5 -1 jakarta-log4j/src/java/org/apache/log4j/examples/appserver/AppServerCategoryFactory.java Index: AppServerCategoryFactory.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/appserver/AppServerCategoryFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AppServerCategoryFactory.java 2001/06/05 04:40:58 1.6 +++ AppServerCategoryFactory.java 2001/06/25 07:06:24 1.7 @@ -77,6 +77,7 @@ version = versionName; AppServerCategory.setFactory(this); + LogLog.debug("Setting AppServerCategory factory attribute."); } /** @@ -176,10 +177,13 @@ * Care should be taken to ensure the bundle file is somewhere * in the system classpath or loadable by this class's class * loader. + * + * Overloading the setMesageBundle method was deliberate to avoid + * trouble with Java Bean introspectors. * * @param filename name of the bundle file */ - public void setMessageBundle(String filename) + public void setMessageBundleName(String filename) { try { messageBundle = ResourceBundle.getBundle(filename); 1.7 +22 -16 jakarta-log4j/src/java/org/apache/log4j/examples/appserver/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/appserver/package.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- package.html 2001/06/05 04:40:58 1.6 +++ package.html 2001/06/25 07:06:25 1.7 @@ -14,10 +14,27 @@ <p> <h2>Configuration</h2> Using this package in your programs differs little from using -{@link org.apache.log4j.Category}. In this initial version, -only property file initialization is supported. +{@link org.apache.log4j.Category}. Both property file and XML +configurations are supported. -<h3>Automatic Configuration</h3> +<h3>XML Configuration</h3> +The following stanza from an XML file demonstrates the syntax +for XML configuration. +<p> +<table border=1> +<tr><td><pre> +<categoryFactory class="org.apache.log4j.examples.appserver.AppServerCategoryFactory"> + <param name="server" value="My Server"> + <param name="component" value="My Component"> + <param name="version" value="v2.5.1"> + <param name="messageBundleName" value="v2.5.1"> +</categoryFactory> +</pre></table> +<p> +To use the factory for a category, specify the corresponding +Category class name as the class attribute of the Category tag. + +<h3>Property File Configuration</h3> The following properties serve to configure the {@link org.apache.log4j.examples.appserver.AppServerCategoryFactory}. <p> @@ -32,7 +49,7 @@ <td>The value assigned to the component attribute. <tr><td><code><b>log4j.factory.version</b></code> <td>The value assigned to the version attribute. -<tr><td><code><b>log4j.factory.messageBundle</b></code> +<tr><td><code><b>log4j.factory.messageBundleName</b></code> <td>The name of bundle file to populate the message <code>ResourceBundle</code>. Because the <code>ResourceBundle.getBundle</code> method is used to load @@ -48,24 +65,13 @@ log4j.factory.server=TestServer log4j.factory.component=TestComponent log4j.factory.version=SomeVersion -log4j.factory.messageBundle=app_messages +log4j.factory.messageBundleName=app_messages log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.examples.appserver.AppServerPatternLayout log4j.appender.stdout.layout.ConversionPattern=[%h:%s:%b:%v] %m%n </pre></table> <p> -<!-- -There is <b>no</b> need to change your source code to go from using -<code>Category</code> to <code>AppServerCategory</code> if you are -using property files to configure your logging infrastructure. -Simply specifying the <code>AppServerCategoryFactory</code> -as the {@link org.apache.log4j.spi.CategoryFactory} implementation -does the trick. It installs the factory -as the default factory for the hierarchy so that -{@link org.apache.log4j.Category#getInstance(String)} always returns -the proper <code>Category</code> subclass. - --> The only change needed to your source file is to invoke the {@link org.apache.log4j.examples.appserver.AppServerCategory#getInstance(String)} instead of the usual {@link org.apache.log4j.Category#getInstance(String)} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]