[gatein-commits] gatein SVN: r4764 - in epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform: web/application/javascript and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Oct 22 05:18:26 EDT 2010


Author: thomas.heute at jboss.com
Date: 2010-10-22 05:18:26 -0400 (Fri, 22 Oct 2010)
New Revision: 4764

Modified:
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
   epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
Log:
JBEPP-552: WCM demo web app affects default portal's UI
Rolling back JBEPP-460: Using gatein-resources.xml should not mandate additional configuration of PortalContainerConfig


Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -19,8 +19,9 @@
 
 package org.exoplatform.portal.resource;
 
-import org.exoplatform.commons.utils.Safe;
 import org.exoplatform.commons.xml.DocumentSource;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
 import org.exoplatform.portal.resource.config.xml.SkinConfigParser;
 import org.gatein.common.logging.Logger;
 import org.gatein.common.logging.LoggerFactory;
@@ -52,9 +53,15 @@
    /** . */
    private static final String GATEIN_CONFIG_RESOURCE = "/WEB-INF/gatein-resources.xml";
 
-   public GateInSkinConfigDeployer(SkinService _skinService)
+   /**
+    * The name of the portal container
+    */
+   private final String portalContainerName;
+
+   public GateInSkinConfigDeployer(String portalContainerName, SkinService _skinService)
    {
       this.skinService = _skinService;
+      this.portalContainerName = portalContainerName;
    }
 
    @Override
@@ -65,29 +72,42 @@
          WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
          if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
          {
-            ServletContext scontext = event.getWebApp().getServletContext();
-            InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
-            if (is != null)
+            ServletContext scontext = null;
+            try
             {
+               scontext = event.getWebApp().getServletContext();
+               InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+               if (is == null)
+                  return;
                try
                {
-                  register(scontext);
+                  is.close();
                }
                catch (Exception ex)
                {
-                  log.error("An error occurs while registering '" + GATEIN_CONFIG_RESOURCE + "' from the context '"
-                     + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
+                  // ignore me
                }
-               finally
+               final PortalContainerPostInitTask task = new PortalContainerPostInitTask()
                {
-                  Safe.close(is);
-               }
+
+                  public void execute(ServletContext scontext, PortalContainer portalContainer)
+                  {
+                     register(scontext, portalContainer);
+                     skinService.registerContext(scontext);
+                  }
+               };
+               PortalContainer.addInitTask(scontext, task, portalContainerName);
             }
+            catch (Exception ex)
+            {
+               log.error("An error occurs while registering '" + GATEIN_CONFIG_RESOURCE + "' from the context '"
+                  + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
+            }
          }
       }
    }
 
-   private void register(ServletContext scontext)
+   private void register(ServletContext scontext, PortalContainer container)
    {
       URL url;
       try
@@ -107,8 +127,5 @@
          log.error("An error occurs while registering '" + GATEIN_CONFIG_RESOURCE + "' from the context '"
             + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
       }
-
-      //
-      skinService.registerContext(scontext);
    }
 }

Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -36,8 +36,11 @@
 
    private SkinService service;
 
-   public GateInSkinConfigRemoval(SkinService _service)
+   private String portalContainerName;
+
+   public GateInSkinConfigRemoval(String _portalContainerName, SkinService _service)
    {
+      this.portalContainerName = _portalContainerName;
       this.service = _service;
    }
 

Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -151,8 +151,8 @@
       portletThemes_ = new HashMap<String, Set<String>>();
       portalContainerName = context.getPortalContainerName();
       mainResolver = new MainResourceResolver(portalContainerName, skinConfigs_);
-      deployer = new GateInSkinConfigDeployer(this);
-      removal = new GateInSkinConfigRemoval(this);
+      deployer = new GateInSkinConfigDeployer(portalContainerName, this);
+      removal = new GateInSkinConfigRemoval(portalContainerName, this);
    }
 
    /**

Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -82,8 +82,8 @@
       availableScriptsPaths_ = new ArrayList<String>();
       availableScriptsKey_ = new ArrayList<Javascript>();
       extendedJavascripts = new HashMap<String, String>();
-      deployer = new JavascriptDeployer(this);
-      removal = new JavascriptRemoval(this);
+      deployer = new JavascriptDeployer(context.getPortalContainerName(), this);
+      removal = new JavascriptRemoval(context.getPortalContainerName(), this);
       object_view_of_merged_JS = new HashMap<String, List<String>>();
    }
 

Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -19,7 +19,8 @@
 
 package org.exoplatform.web.application.javascript;
 
-import org.exoplatform.commons.utils.Safe;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 import org.gatein.wci.WebAppEvent;
@@ -28,6 +29,7 @@
 import org.gatein.wci.impl.DefaultServletContainerFactory;
 import org.picocontainer.Startable;
 
+import java.io.IOException;
 import java.io.InputStream;
 
 import javax.servlet.ServletContext;
@@ -50,9 +52,15 @@
    /** . */
    private final JavascriptConfigService javascriptService;
 
-   public JavascriptDeployer(JavascriptConfigService javascriptService)
+   /**
+    * The name of the portal container
+    */
+   private final String portalContainerName;
+
+   public JavascriptDeployer(String portalContainerName, JavascriptConfigService javascriptService)
    {
       this.javascriptService = javascriptService;
+      this.portalContainerName = portalContainerName;
    }
 
    public void start()
@@ -72,33 +80,47 @@
          WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
          if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
          {
-            ServletContext scontext = event.getWebApp().getServletContext();
-            InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
-            if (is != null)
+            ServletContext scontext = null;
+            try
             {
+               scontext = event.getWebApp().getServletContext();
+
+               InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+               if (is == null)
+                  return;
                try
                {
-                  register(scontext);
+                  is.close();
                }
                catch (Exception ex)
                {
-                  LOG.error("An error occurs while registering 'Javascript in gatein-resources.xml' from the context '"
-                     + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
+                  // ignore me
                }
-               finally
+               final PortalContainerPostInitTask task = new PortalContainerPostInitTask()
                {
-                  Safe.close(is);
-               }
+
+                  public void execute(ServletContext scontext, PortalContainer portalContainer)
+                  {
+                     register(scontext, portalContainer);
+                  }
+               };
+               PortalContainer.addInitTask(scontext, task, portalContainerName);
             }
+            catch (Exception ex)
+            {
+               LOG.error("An error occurs while registering 'Javascript in gatein-resources.xml' from the context '"
+                  + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
+            }
          }
       }
    }
 
-   private void register(ServletContext scontext)
+   private void register(ServletContext scontext, PortalContainer container)
    {
-      InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+      InputStream is = null;
       try
       {
+         is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
          JavascriptConfigParser.processConfigResource(is, javascriptService, scontext);
       }
       catch (Exception ex)
@@ -108,7 +130,17 @@
       }
       finally
       {
-         Safe.close(is);
+         if (is != null)
+         {
+            try
+            {
+               is.close();
+            }
+            catch (IOException e)
+            {
+               // ignore me
+            }
+         }
       }
    }
 }
\ No newline at end of file

Modified: epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java	2010-10-22 05:28:18 UTC (rev 4763)
+++ epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java	2010-10-22 09:18:26 UTC (rev 4764)
@@ -34,10 +34,13 @@
 public class JavascriptRemoval implements WebAppListener, Startable
 {
 
+   private String portalContainerName;
+
    private JavascriptConfigService javascriptService;
 
-   public JavascriptRemoval(JavascriptConfigService _javascriptService)
+   public JavascriptRemoval(String _portalContainerName, JavascriptConfigService _javascriptService)
    {
+      this.portalContainerName = _portalContainerName;
       this.javascriptService = _javascriptService;
    }
 



More information about the gatein-commits mailing list