Author: hoang_to
Date: 2010-11-18 02:38:55 -0500 (Thu, 18 Nov 2010)
New Revision: 5148
Modified:
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/WebAppController.java
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
EXOGTN-129: Cannot find the configuration for the component
Modified:
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
---
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-18
04:47:59 UTC (rev 5147)
+++
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-18
07:38:55 UTC (rev 5148)
@@ -49,7 +49,7 @@
private HashMap<String, Object> attributes_;
- private HashMap<String, Application> applications_;
+ private volatile HashMap<String, Application> applications_;
private HashMap<String, WebRequestHandler> handlers_;
@@ -89,15 +89,37 @@
return applications;
}
- public void removeApplication(String appId)
+ public synchronized void removeApplication(String appId)
{
applications_.remove(appId);
}
- public void addApplication(Application app)
- {
- applications_.put(app.getApplicationId(), app);
- }
+ /**
+ * This methods will add the new application if and only if it hasn't yet
+ * been registered
+ *
+ * @param app
+ * the {@link Application} to add
+ * @return the given application if no application with the same id has been
+ * added otherwise the application already registered
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Application> T addApplication(T app) {
+ Application result = getApplication(app.getApplicationId());
+ if (result == null) {
+ synchronized (this) {
+ result = getApplication(app.getApplicationId());
+ if (result == null) {
+ HashMap<String, Application> applications = new HashMap<String,
Application>(
+ applications_);
+ applications.put(app.getApplicationId(), app);
+ this.applications_ = applications;
+ result = app;
+ }
+ }
+ }
+ return (T) result;
+ }
public void register(WebRequestHandler handler) throws Exception
{
Modified:
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
===================================================================
---
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-11-18
04:47:59 UTC (rev 5147)
+++
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-11-18
07:38:55 UTC (rev 5148)
@@ -19,7 +19,14 @@
package org.exoplatform.webui.application;
-import org.exoplatform.webui.config.*;
+import org.exoplatform.webui.config.Component;
+import org.exoplatform.webui.config.ComponentHandle;
+import org.exoplatform.webui.config.Event;
+import org.exoplatform.webui.config.EventInterceptor;
+import org.exoplatform.webui.config.InitParams;
+import org.exoplatform.webui.config.Param;
+import org.exoplatform.webui.config.Validator;
+import org.exoplatform.webui.config.WebuiConfiguration;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
import org.exoplatform.webui.config.annotation.EventConfig;
@@ -50,12 +57,7 @@
*/
public class ConfigurationManager
{
- /**
- * todo (julien) : this map should be synchronized somehow
- * <p/>
- * The components of which we manage the configuration
- */
- private Map<String, Component> configs_ = new HashMap<String,
Component>();
+ private volatile Map<String, Component> configs_ = new HashMap<String,
Component>();
/** The logger. */
private final Logger log;
@@ -106,12 +108,14 @@
*
* @param configs An array of Component
*/
- void setComponentConfigs(Component[] configs)
+ synchronized void setComponentConfigs(Component[] configs)
{
+ Map<String, Component> tmpConfigs = new HashMap<String,
Component>(configs_);
for (Component component : configs)
{
- configs_.put(component.getKey(), component);
+ tmpConfigs.put(component.getKey(), component);
}
+ this.configs_ = tmpConfigs;
}
/**
@@ -190,7 +194,17 @@
}
//
- process(type);
+ synchronized (this)
+ {
+ if ((config = configs_.get(key)) == null)
+ {
+ process(type);
+ }
+ else
+ {
+ return config;
+ }
+ }
//
return configs_.get(key);
Modified:
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
---
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-18
04:47:59 UTC (rev 5147)
+++
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-18
07:38:55 UTC (rev 5148)
@@ -130,7 +130,7 @@
{
application = new PortletApplication(getPortletConfig());
application.onInit();
- controller.addApplication(application);
+ application = controller.addApplication(application);
}
return application;
}
Modified:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-11-18
04:47:59 UTC (rev 5147)
+++
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-11-18
07:38:55 UTC (rev 5148)
@@ -324,7 +324,7 @@
if (model != null)
{
application = GadgetUtil.toGadgetApplication(model);
- webController.addApplication(application);
+ application = webController.addApplication(application);
}
}
return application;
Show replies by date