You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2006/09/04 02:07:15 UTC

svn commit: r439881 - /shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java

Author: craigmcc
Date: Sun Sep  3 17:07:14 2006
New Revision: 439881

URL: http://svn.apache.org/viewvc?view=rev&rev=439881
Log:
After a quick chat with Sean about our dueling commits, we agreed that
*not* warning is the appropriate behavior, so I commented that out.
Not having any config parameter, but providing an instance of the
default resource (/WEB-INF/dialog-config.xml) is a nice standard
behavior, and mirrors how JSF handles faces-config.xml resources.

I left in the Log variable (because we're likely to want it later), but
adjusted the implementation to reflect recent "best practices" advice
from the Commons Logging docs:

* Static Log instances can cause webapp unload problems
  on some containers, so make it an instance variable.

* Because we are inside a Serializable object, we need to
  declare the Log instance transient since there is no
  guarantee that such instances are themselves Serializable.

* The previous change means we need to be able to re-create
  the instance on demand if needed.  That is done by a new
  private Log log() method implementation, which should be
  called by any code that actually wants to log something.

We need to review this kind of thing all the way throughout Shale at
some point.

SHALE-271

Modified:
    shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java

Modified: shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java?view=diff&rev=439881&r1=439880&r2=439881
==============================================================================
--- shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java (original)
+++ shale/sandbox/shale-dialog2-legacy/src/main/java/org/apache/shale/dialog2/legacy/LegacyDialogManager.java Sun Sep  3 17:07:14 2006
@@ -39,15 +39,8 @@
  */
 public final class LegacyDialogManager implements DialogContextManager, Serializable {
 
-    // -------------------------------------------------------- Static Variables
 
-    /**
-     * <p>The <code>Log</code> instance for this class.</p>
-     */
-    private static final Log log = LogFactory.getLog(DialogContextManager.class);
-
-
-    // ------------------------------------------------------ DialogContext Variables
+    // ------------------------------------------------- DialogContext Variables
 
 
     /**
@@ -67,6 +60,13 @@
 
 
     /**
+     * <p>The <code>Log</code> instance for this class.  This value is lazily
+     * instantiated, and is also transient and may need to be regenerated.</p>
+     */
+    private transient Log log = null;
+
+
+    /**
      * <p>Map containing all currently active {@link DialogContext} instances for
      * the current user.</p>
      */
@@ -149,8 +149,10 @@
           context.getExternalContext().getInitParameter(Globals.CONFIGURATION);
         if (resources == null) {
             resources = "";
-            log.warn("No dialog configuration information present.  Comma separated files should be listed under the " +
-                    "context parameter: " + Globals.CONFIGURATION);
+            // Because we process the default resource even if it is not
+            // explicitly listed, we don't want to warn here
+//            log().warn("No dialog configuration information present.  Comma separated files should be listed under the " +
+//                    "context parameter: " + Globals.CONFIGURATION);
         }
         int comma = 0;
         String path = null;
@@ -210,6 +212,17 @@
      */
     private String generateId() {
         return "" + ++serial;
+    }
+
+
+    /**
+     * <p>Return the <code>Log</code> instance for this instance.</p>
+     */
+    private Log log() {
+        if (this.log == null) {
+            this.log = LogFactory.getLog(LegacyDialogManager.class);
+        }
+        return this.log;
     }