Author: trong.tran
Date: 2010-11-30 00:06:37 -0500 (Tue, 30 Nov 2010)
New Revision: 5371
Modified:
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebAppController.java
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebRequestHandler.java
exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml
exo/portal/branches/standalone/webui/portal/src/main/java/conf/portal/configuration.xml
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalController.java
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java
Log:
Move handler registration to configuration instead of code programming
the handler should initialize its corresponding WebuiApplication by itself
Modified:
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
---
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-30
05:06:37 UTC (rev 5371)
@@ -20,9 +20,11 @@
package org.exoplatform.web;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -133,6 +135,15 @@
handlers_.remove(path);
}
+ public void onHandlersInit(ServletConfig config) throws Exception
+ {
+ Collection<WebRequestHandler> handlers = handlers_.values();
+ for (WebRequestHandler handler : handlers)
+ {
+ handler.onInit(this, config);
+ }
+ }
+
/**
* This is the first method - in the eXo web framework - reached by incoming HTTP
request, it acts like a
* servlet service() method
Modified:
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebRequestHandler.java
===================================================================
---
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebRequestHandler.java 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/component/web/src/main/java/org/exoplatform/web/WebRequestHandler.java 2010-11-30
05:06:37 UTC (rev 5371)
@@ -19,6 +19,7 @@
package org.exoplatform.web;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -37,10 +38,9 @@
*/
abstract public class WebRequestHandler extends BaseComponentPlugin
{
-
- public void onInit(WebAppController controller) throws Exception
+ public void onInit(WebAppController controller, ServletConfig sConfig) throws
Exception
{
-
+
}
abstract public String[] getPath();
Modified: exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-30
04:24:48 UTC (rev 5370)
+++ exo/portal/branches/standalone/web/portal/src/main/webapp/WEB-INF/web.xml 2010-11-30
05:06:37 UTC (rev 5371)
@@ -272,23 +272,22 @@
<url-pattern>/download/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/standalone/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>RestServer</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
-
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/connector</url-pattern>
</servlet-mapping>
-
<servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/standalone/*</url-pattern>
- </servlet-mapping>
+
<session-config>
<session-timeout>30</session-timeout>
</session-config>
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/conf/portal/configuration.xml 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/conf/portal/configuration.xml 2010-11-30
05:06:37 UTC (rev 5371)
@@ -24,11 +24,29 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <type>org.exoplatform.portal.application.ApplicationStatisticService</type>
- </component>
+ <component>
+
<type>org.exoplatform.portal.application.ApplicationStatisticService</type>
+ </component>
- <component>
- <type>org.exoplatform.portal.application.PortalStatisticService</type>
- </component>
+ <component>
+ <type>org.exoplatform.portal.application.PortalStatisticService</type>
+ </component>
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.web.WebAppController</target-component>
+ <component-plugin>
+ <name>PortalRequestHandler</name>
+ <set-method>register</set-method>
+
<type>org.exoplatform.portal.application.PortalRequestHandler</type>
+ </component-plugin>
+ </external-component-plugins>
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.web.WebAppController</target-component>
+ <component-plugin>
+ <name>StandaloneAppRequestHandler</name>
+ <set-method>register</set-method>
+
<type>org.exoplatform.portal.application.StandaloneAppRequestHandler</type>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalController.java
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalController.java 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalController.java 2010-11-30
05:06:37 UTC (rev 5371)
@@ -73,15 +73,8 @@
// Set the full classloader of the portal container
Thread.currentThread().setContextClassLoader(portalContainer.getPortalClassLoader());
hasChanged = true;
- PortalApplication application = new PortalApplication(config);
- application.onInit();
- controller.addApplication(application);
- controller.register(new PortalRequestHandler());
- StandaloneApplication standaloneApplication = new
StandaloneApplication(config);
- standaloneApplication.onInit();
- controller.addApplication(standaloneApplication);
- controller.register(new StandaloneAppRequestHandler());
+ controller.onHandlersInit(config);
log.info("The WebAppController has been successfully initialized for the
portal '" + portalContainer.getName()
+ "'");
}
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-11-30
05:06:37 UTC (rev 5371)
@@ -32,6 +32,7 @@
import java.util.List;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -53,6 +54,14 @@
{
return PATHS;
}
+
+ @Override
+ public void onInit(WebAppController controller, ServletConfig sConfig) throws
Exception
+ {
+ PortalApplication application = new PortalApplication(sConfig);
+ application.onInit();
+ controller.addApplication(application);
+ }
/**
* This method will handle incoming portal request. It gets a reference to the
WebAppController
Modified:
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java
===================================================================
---
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java 2010-11-30
04:24:48 UTC (rev 5370)
+++
exo/portal/branches/standalone/webui/portal/src/main/java/org/exoplatform/portal/application/StandaloneAppRequestHandler.java 2010-11-30
05:06:37 UTC (rev 5371)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.application;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -35,6 +36,14 @@
return PATHS;
}
+ @Override
+ public void onInit(WebAppController controller, ServletConfig sConfig) throws
Exception
+ {
+ StandaloneApplication standaloneApplication = new StandaloneApplication(sConfig);
+ standaloneApplication.onInit();
+ controller.addApplication(standaloneApplication);
+ }
+
public void execute(WebAppController controller, HttpServletRequest req,
HttpServletResponse res) throws Exception
{
log.debug("Session ID = " + req.getSession().getId());