Author: phuong_vu
Date: 2010-09-16 23:30:39 -0400 (Thu, 16 Sep 2010)
New Revision: 4229
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
Log:
GTNPORTAL-1477 Using gatein-resources.xml should not mandate additional configuration of
PortalContainerConfig
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -19,9 +19,8 @@
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;
@@ -53,15 +52,9 @@
/** . */
private static final String GATEIN_CONFIG_RESOURCE =
"/WEB-INF/gatein-resources.xml";
- /**
- * The name of the portal container
- */
- private final String portalContainerName;
-
- public GateInSkinConfigDeployer(String portalContainerName, SkinService _skinService)
+ public GateInSkinConfigDeployer(SkinService _skinService)
{
this.skinService = _skinService;
- this.portalContainerName = portalContainerName;
}
@Override
@@ -72,42 +65,29 @@
WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
{
- ServletContext scontext = null;
- try
+ ServletContext scontext = event.getWebApp().getServletContext();
+ InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ if (is != null)
{
- scontext = event.getWebApp().getServletContext();
- InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
- if (is == null)
- return;
try
{
- is.close();
+ register(scontext);
}
catch (Exception ex)
{
- // ignore me
+ log.error("An error occurs while registering '" +
GATEIN_CONFIG_RESOURCE + "' from the context '"
+ + (scontext == null ? "unknown" :
scontext.getServletContextName()) + "'", ex);
}
- final PortalContainerPostInitTask task = new
PortalContainerPostInitTask()
+ finally
{
-
- public void execute(ServletContext scontext, PortalContainer
portalContainer)
- {
- register(scontext, portalContainer);
- skinService.registerContext(scontext);
- }
- };
- PortalContainer.addInitTask(scontext, task, portalContainerName);
+ Safe.close(is);
+ }
}
- 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, PortalContainer container)
+ private void register(ServletContext scontext)
{
URL url;
try
@@ -127,5 +107,8 @@
log.error("An error occurs while registering '" +
GATEIN_CONFIG_RESOURCE + "' from the context '"
+ (scontext == null ? "unknown" : scontext.getServletContextName())
+ "'", ex);
}
+
+ //
+ skinService.registerContext(scontext);
}
}
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -36,11 +36,8 @@
private SkinService service;
- private String portalContainerName;
-
- public GateInSkinConfigRemoval(String _portalContainerName, SkinService _service)
+ public GateInSkinConfigRemoval(SkinService _service)
{
- this.portalContainerName = _portalContainerName;
this.service = _service;
}
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -151,8 +151,8 @@
portletThemes_ = new HashMap<String, Set<String>>();
portalContainerName = context.getPortalContainerName();
mainResolver = new MainResourceResolver(portalContainerName, skinConfigs_);
- deployer = new GateInSkinConfigDeployer(portalContainerName, this);
- removal = new GateInSkinConfigRemoval(portalContainerName, this);
+ deployer = new GateInSkinConfigDeployer(this);
+ removal = new GateInSkinConfigRemoval(this);
}
/**
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -82,8 +82,8 @@
availableScriptsPaths_ = new ArrayList<String>();
availableScriptsKey_ = new ArrayList<Javascript>();
extendedJavascripts = new HashMap<String, String>();
- deployer = new JavascriptDeployer(context.getPortalContainerName(), this);
- removal = new JavascriptRemoval(context.getPortalContainerName(), this);
+ deployer = new JavascriptDeployer(this);
+ removal = new JavascriptRemoval(this);
object_view_of_merged_JS = new HashMap<String, List<String>>();
}
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -19,8 +19,7 @@
package org.exoplatform.web.application.javascript;
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.gatein.wci.WebAppEvent;
@@ -29,7 +28,6 @@
import org.gatein.wci.impl.DefaultServletContainerFactory;
import org.picocontainer.Startable;
-import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletContext;
@@ -52,15 +50,9 @@
/** . */
private final JavascriptConfigService javascriptService;
- /**
- * The name of the portal container
- */
- private final String portalContainerName;
-
- public JavascriptDeployer(String portalContainerName, JavascriptConfigService
javascriptService)
+ public JavascriptDeployer(JavascriptConfigService javascriptService)
{
this.javascriptService = javascriptService;
- this.portalContainerName = portalContainerName;
}
public void start()
@@ -80,47 +72,33 @@
WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
{
- ServletContext scontext = null;
- try
+ ServletContext scontext = event.getWebApp().getServletContext();
+ InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ if (is != null)
{
- scontext = event.getWebApp().getServletContext();
-
- InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
- if (is == null)
- return;
try
{
- is.close();
+ register(scontext);
}
catch (Exception ex)
{
- // ignore me
+ LOG.error("An error occurs while registering 'Javascript in
gatein-resources.xml' from the context '"
+ + (scontext == null ? "unknown" :
scontext.getServletContextName()) + "'", ex);
}
- final PortalContainerPostInitTask task = new
PortalContainerPostInitTask()
+ finally
{
-
- public void execute(ServletContext scontext, PortalContainer
portalContainer)
- {
- register(scontext, portalContainer);
- }
- };
- PortalContainer.addInitTask(scontext, task, portalContainerName);
+ Safe.close(is);
+ }
}
- 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, PortalContainer container)
+ private void register(ServletContext scontext)
{
- InputStream is = null;
+ InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
try
{
- is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
JavascriptConfigParser.processConfigResource(is, javascriptService, scontext);
}
catch (Exception ex)
@@ -130,17 +108,7 @@
}
finally
{
- if (is != null)
- {
- try
- {
- is.close();
- }
- catch (IOException e)
- {
- // ignore me
- }
- }
+ Safe.close(is);
}
}
}
\ No newline at end of file
Modified:
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
===================================================================
---
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java 2010-09-16
16:22:29 UTC (rev 4228)
+++
portal/branches/branch-r4047/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java 2010-09-17
03:30:39 UTC (rev 4229)
@@ -34,13 +34,10 @@
public class JavascriptRemoval implements WebAppListener, Startable
{
- private String portalContainerName;
-
private JavascriptConfigService javascriptService;
- public JavascriptRemoval(String _portalContainerName, JavascriptConfigService
_javascriptService)
+ public JavascriptRemoval(JavascriptConfigService _javascriptService)
{
- this.portalContainerName = _portalContainerName;
this.javascriptService = _javascriptService;
}