You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/10/17 22:10:33 UTC

svn commit: r325974 - in /cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components: ConnectionFactoryImpl.java LoggerImpl.java

Author: vgritsenko
Date: Mon Oct 17 13:10:28 2005
New Revision: 325974

URL: http://svn.apache.org/viewcvs?rev=325974&view=rev
Log:
cleanup

Modified:
    cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
    cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/LoggerImpl.java

Modified: cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java?rev=325974&r1=325973&r2=325974&view=diff
==============================================================================
--- cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java (original)
+++ cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java Mon Oct 17 13:10:28 2005
@@ -36,10 +36,6 @@
 /**
  * OJB ConnectionFactory implemenation to bridge into the Avalon DataSource
  * connection pooling component defined in the Cocoon configuration.
- * <p>
- * This class <b>must</b> be loaded a server's startup time, as its initialization
- * sets up some static attributes that are later used by another instance of this
- * same class created by OJB from the <code>OJB.properties</code> file. Yeah, weird...
  *
  * <p>This class has two faces to it:
  * <dl>
@@ -156,16 +152,16 @@
     }
 
     /**
-     * Implementation of <code>Startable</code> so that the component is preloaded even in lazy-loading mode,
-     * which is needed for it to subscribe to portal events.
+     * Implementation of <code>Startable</code> so that Cocoon-OJB integration
+     * works in lazy-loading mode.
      */
     public void start() throws Exception {
         // nothing
     }
 
     /**
-     * Implementation of <code>Startable</code> so that the component is preloaded even in lazy-loading mode,
-     * which is needed for it to subscribe to portal events.
+     * Implementation of <code>Startable</code> so that Cocoon-OJB integration
+     * works in lazy-loading mode.
      */
     public void stop() throws Exception {
         // nothing

Modified: cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/LoggerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/LoggerImpl.java?rev=325974&r1=325973&r2=325974&view=diff
==============================================================================
--- cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/LoggerImpl.java (original)
+++ cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/components/LoggerImpl.java Mon Oct 17 13:10:28 2005
@@ -29,10 +29,6 @@
 
 /**
  * OJB logger implementation delegating to the Avalon logger.
- * <p>
- * This class <b>must</b> be loaded a server's startup time, as its initialization
- * sets up some static attributes that are later used by another instance of this
- * same class created by OJB from the <code>OJB.properties</code> file. Yeah, weird...
  *
  * <p>This class has two faces to it:
  * <dl>
@@ -59,9 +55,8 @@
 
     /**
      * Root logger for all OJB loggers
-     * FIXME - we just initialize it with a NullLogger to prevent later NPEs
      */
-    private static org.apache.avalon.framework.logger.Logger LOGGER = new NullLogger();
+    private static org.apache.avalon.framework.logger.Logger LOGGER;
 
     private final String name;
     private transient int level;
@@ -83,6 +78,7 @@
 
     /**
      * Constructor used by OJB 1.1 to create a logger instance
+     * @noinspection UNUSED_SYMBOL
      */
     public LoggerImpl(String name, LoggingConfiguration config) {
         this(name);
@@ -97,12 +93,23 @@
 
     protected int getLevel() {
         if (logger == null) {
-            this.logger = LOGGER.getChildLogger(this.name);
-            if (this.logger.isDebugEnabled()) this.level = DEBUG;
-            else if (this.logger.isInfoEnabled()) this.level = INFO;
-            else if (this.logger.isWarnEnabled()) this.level = WARN;
-            else if (this.logger.isErrorEnabled()) this.level = ERROR;
-            else this.level = FATAL;
+            if (LOGGER == null) {
+                // Complain
+                System.err.println(LoggerImpl.class.getName() +
+                                   ": Logger was not initialized, OJB logging disabled! " +
+                                   "This logger implementation can be used only " +
+                                   "in context of Cocoon, and requires LoggerImpl " +
+                                   "component declared in cocoon.xconf.");
+                this.logger = new NullLogger();
+                this.level = FATAL;
+            } else {
+                this.logger = LOGGER.getChildLogger(this.name);
+                if (this.logger.isDebugEnabled()) this.level = DEBUG;
+                else if (this.logger.isInfoEnabled()) this.level = INFO;
+                else if (this.logger.isWarnEnabled()) this.level = WARN;
+                else if (this.logger.isErrorEnabled()) this.level = ERROR;
+                else this.level = FATAL;
+            }
         }
         return level;
     }
@@ -258,16 +265,16 @@
     }
 
     /**
-     * Implementation of <code>Startable</code> so that the component is preloaded even in lazy-loading mode,
-     * which is needed for it to subscribe to portal events.
+     * Implementation of <code>Startable</code> so that Cocoon-OJB integration
+     * works in lazy-loading mode.
      */
     public void start() throws Exception {
         // nothing
     }
 
     /**
-     * Implementation of <code>Startable</code> so that the component is preloaded even in lazy-loading mode,
-     * which is needed for it to subscribe to portal events.
+     * Implementation of <code>Startable</code> so that Cocoon-OJB integration
+     * works in lazy-loading mode.
      */
     public void stop() throws Exception {
         // nothing