[embjopr-commits] EMBJOPR SVN: r1049 - branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Mon Jun 18 14:31:54 EDT 2012


Author: ips
Date: 2012-06-18 14:31:53 -0400 (Mon, 18 Jun 2012)
New Revision: 1049

Modified:
   branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java
Log:
This is a fix for https://issues.jboss.org/browse/EMBJOPR-360. We do it in this method, because we know by the time the method is called, one or more Facelets pages have been compiled, and the problematic Facelets code that disables defaultUseCaches is only executed once when com.sun.facelets.compiler.Compiler.initialize() is called when the first Facelets page from this webapp is about to be compiled.


Modified: branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java
===================================================================
--- branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java	2012-05-18 14:58:56 UTC (rev 1048)
+++ branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java	2012-06-18 18:31:53 UTC (rev 1049)
@@ -19,6 +19,8 @@
  */
 package org.jboss.on.embedded.ui;
 
+import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -28,6 +30,8 @@
 import javax.faces.context.FacesContext;
 import javax.faces.event.ValueChangeEvent;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.jetbrains.annotations.NotNull;
 import org.rhq.core.domain.measurement.Availability;
 import org.rhq.core.domain.measurement.DataType;
@@ -68,6 +72,8 @@
 @Scope(ScopeType.EVENT)
 public class SummaryAction
 {
+    private static final Log log = LogFactory.getLog(SummaryAction.class);
+
     @In
     private transient FacesMessages facesMessages;
 
@@ -117,6 +123,8 @@
 
     private String resourceTypeFilter;
 
+    private static boolean defaultUseCachesEnabled;
+
     /**
      * determines which summary page should be displayed, based on the current navigation node
      *
@@ -124,6 +132,13 @@
      */
     public String view()
     {
+        // This is a fix for https://issues.jboss.org/browse/EMBJOPR-360. We do it in this method, because we know by
+        // the time the method is called, one or more Facelets pages have been compiled, and the problematic Facelets
+        // code that disables defaultUseCaches is only executed once when
+        // com.sun.facelets.compiler.Compiler.initialize() is called when the first Facelets page from this webapp is
+        // about to be compiled.
+        enableDefaultUseCaches();
+
         // TODO could consider renaming this getCurrentNavigationNode()
         JONTreeNode selectedNode = navigationAction.getSelectedNode();
         return selectedNode.getSummaryActionOutcome(this).getOutcome();
@@ -343,4 +358,21 @@
         }
         FacesContext.getCurrentInstance().renderResponse();
     }
+
+    private static void enableDefaultUseCaches() {
+        if (!defaultUseCachesEnabled) {
+            try {
+                // The below URL is arbitrary - it just needs to be a valid URL that we can use to create a
+                // URLConnection.
+                URL url = new URL("http://foo.bar/");
+                URLConnection urlConnection = url.openConnection();
+                urlConnection.setDefaultUseCaches(true);
+                log.debug("Enabled defaultUseCaches for URLConnections (see https://issues.jboss.org/browse/EMBJOPR-360).");
+            } catch (Exception e) {
+                log.error("Failed to enable defaultUseCaches for URLConnections (see https://issues.jboss.org/browse/EMBJOPR-360).", e);
+            } finally {
+                defaultUseCachesEnabled = true;
+            }
+        }
+    }
 }



More information about the embjopr-commits mailing list