Author: julien(a)jboss.com
Date: 2007-03-31 08:56:57 -0400 (Sat, 31 Mar 2007)
New Revision: 6893
Added:
trunk/server/src/main/org/jboss/portal/server/RequestControllerFactory.java
trunk/server/src/main/org/jboss/portal/server/impl/RequestControllerFactoryImpl.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
trunk/portlet-server/src/resources/test-sar/META-INF/jboss-service.xml
trunk/portlet-server/src/resources/test-war/WEB-INF/web.xml
trunk/portlet-server/src/resources/test/info/test-info-sar/META-INF/jboss-service.xml
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
trunk/server/src/resources/test-agent-war/WEB-INF/web.xml
trunk/server/src/resources/test/test-charset-sar/META-INF/jboss-service.xml
trunk/server/src/resources/test/test-parameters-sar/META-INF/jboss-service.xml
trunk/server/src/resources/test/test-response-sar/META-INF/jboss-service.xml
trunk/server/src/resources/test/test-servlet-defaultservletmapping-war/WEB-INF/web.xml
trunk/server/src/resources/test/test-servlet-pathmapping-war/WEB-INF/web.xml
trunk/server/src/resources/test/test-servlet-rootpathmapping-war/WEB-INF/web.xml
trunk/server/src/resources/test/test-servlet-sar/META-INF/jboss-service.xml
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
Log:
- added in server RequestControllerFactory so the request controller used by the portal
servlet can decided at runtime based on the server request
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -25,6 +25,12 @@
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.core.controller.command.mapper.URLFactory;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.classic.HandlerResponse;
+import org.jboss.portal.core.controller.classic.CommandForward;
+import org.jboss.portal.core.controller.classic.HTTPResponse;
+import org.jboss.portal.core.controller.classic.ResponseHandler;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.instance.InstanceContainer;
@@ -33,12 +39,19 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.request.URLContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class Controller extends AbstractJBossService implements
RequestController
+public abstract class Controller extends AbstractJBossService implements
RequestController, ResponseHandler
{
/** . */
@@ -158,4 +171,156 @@
this.stackFactory = stackFactory;
}
+ /**
+ * Handle a command which means it executes the command and reacts upon the response
created by the command.
+ *
+ * @param ctx the controller context
+ * @param cmd the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void handleCommand(final ControllerContext ctx, final ControllerCommand cmd)
throws ServerException
+ {
+ HandlerResponse handlerResp = executeCommand(ctx, cmd);
+
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
+
+ // Find out if we can execute in the same server invocation
+ if (handlerResp instanceof CommandForward)
+ {
+ CommandForward forward = (CommandForward)handlerResp;
+ URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
+ if (requiresRedirect(cmd, urlContext, forward))
+ {
+ String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
+ sendResponse(ctx, new HTTPResponse.SendRedirect(url));
+ }
+ else
+ {
+ handleCommand(ctx, forward.getCommand());
+ }
+ }
+ else
+ {
+ HTTPResponse hr = (HTTPResponse)handlerResp;
+ sendResponse(ctx, hr);
+ }
+ }
+
+ /**
+ * All http responses in the stack should be handled here.
+ */
+ protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
+ {
+ try
+ {
+ resp.sendResponse(ctx.getServerInvocation().getServerContext());
+ }
+ catch (IOException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ }
+
+ protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd)
throws ServerException
+ {
+ URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
+
+ try
+ {
+ // Execute command
+ Object commandResponse = ctx.execute(cmd);
+
+ // Handle the result, might be null if no handling done
+ return handleResponse(ctx, cmd, commandResponse);
+ }
+ catch (CommandRedirectionException e)
+ {
+ // Handle the redirection as forward
+ return new CommandForward(e.getRedirection(), null);
+ }
+ catch (InsufficientTransportGuaranteeException e)
+ {
+ urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
+ ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
+ String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ catch (ControllerSecurityException e)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.isSecure(), true);
+ ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
+ String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ log.error("Resource not found " + e.getRef(), e);
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
+ }
+ catch (ControllerException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (ServletException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
+ {
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)currentCmdInfo).isIdempotent())
+ {
+ return true;
+ }
+ else
+ {
+ URLContext nextURLCtx = forward.getURLContext();
+ boolean currentAuthenticated = currentURLCtx.isAuthenticated();
+ if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = currentURLCtx.isSecure();
+ if (nextURLCtx != null && nextURLCtx.isSecure() &&
!currentSecure)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -26,12 +26,19 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.controller.classic.HandlerResponse;
+import org.jboss.portal.core.controller.classic.CommandForward;
import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
+import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.theme.page.WindowResult;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletException;
+import java.io.IOException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -68,5 +75,45 @@
e.printStackTrace();
}
}
+ else
+ {
+ // Invoke the chain that creates the initial command
+ ControllerCommand cmd = commandFactory.doMapping(invocation,
invocation.getServerContext().getPortalHost(),
invocation.getServerContext().getPortalContextPath(),
invocation.getServerContext().getPortalRequestPath());
+
+ //
+ if (cmd == null)
+ {
+ // Handle that case
+ throw new ServerException("No command was produced by the command
factory");
+ }
+
+ // Create controller context
+ ControllerContext ctx = new ControllerContext(invocation, this);
+
+ // Handle the command created
+ handleCommand(ctx, cmd);
+ }
}
+
+ public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
+ {
+ if (response instanceof UpdateWindowMarkupResponse)
+ {
+ UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
+ RenderWindowCommand rwc = new RenderWindowCommand(updateMarkup.getWindowId());
+ return new CommandForward(rwc, null);
+ }
+ else if (response instanceof WindowResult)
+ {
+ WindowResult windowResult = (WindowResult)response;
+ // todo
+ }
+ else
+ {
+ System.out.println("Not yet handled " + response);
+ }
+
+ //
+ return null;
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -26,9 +26,10 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
-import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.server.AbstractServerURL;
+import org.jboss.portal.server.request.URLContext;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -65,11 +66,23 @@
url.append(req.getContextPath()).append("/ajax");
//
+
+ //
PageRendition rendition = (PageRendition)response;
Map pageProps = rendition.getPageResult().getPageProperties();
+
pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
+
+ // Compute prefix
+// AbstractServerURL tmp = new AbstractServerURL();
+// tmp.setPortalRequestPath("/");
+//
cmd.getControllerContext().getServerInvocation().getServerContext().renderURL(tmp,
URLContext.newInstance(false, false));
+
+ pageProps.put(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL, "");
+
+
pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "true");
- pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL, url.toString());
+ pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL, url.toString());
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -61,7 +61,6 @@
new PortletInstanceResponseHandler()
};
-
public void handle(ServerInvocation invocation) throws ServerException
{
// Invoke the chain that creates the initial command
@@ -81,167 +80,19 @@
handleCommand(ctx, cmd);
}
- /**
- * Handle a command which means it executes the command and reacts upon the response
created by the command.
- *
- * @param ctx the controller context
- * @param cmd the command
- * @throws ServerException
- */
- protected void handleCommand(final ControllerContext ctx, final ControllerCommand cmd)
throws ServerException
+ public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
{
- HandlerResponse handlerResp = executeCommand(ctx, cmd);
-
- //
- if (handlerResp == null)
+ for (int i = 0;i < handlers.length;i++)
{
- return;
- }
-
- // Find out if we can execute in the same server invocation
- if (handlerResp instanceof CommandForward)
- {
- CommandForward forward = (CommandForward)handlerResp;
- URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
- if (requiresRedirect(cmd, urlContext, forward))
+ ResponseHandler handler = handlers[i];
+ HandlerResponse handlerResponse = handler.handleResponse(ctx, cmd, response);
+ if (handlerResponse != null)
{
- String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
- sendResponse(ctx, new HTTPResponse.SendRedirect(url));
+ return handlerResponse;
}
- else
- {
- handleCommand(ctx, forward.getCommand());
- }
}
- else
- {
- HTTPResponse hr = (HTTPResponse)handlerResp;
- sendResponse(ctx, hr);
- }
- }
- /**
- * All http responses in the stack should be handled here.
- */
- protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
- {
- try
- {
- resp.sendResponse(ctx.getServerInvocation().getServerContext());
- }
- catch (IOException e)
- {
- log.error("Cound not send http response", e);
- }
- catch (ServletException e)
- {
- log.error("Cound not send http response", e);
- }
+ //
+ return null;
}
-
- protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd)
throws ServerException
- {
- URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
-
- try
- {
- // Execute command
- Object commandResponse = ctx.execute(cmd);
-
- // Handle the result
- for (int i = 0;i < handlers.length;i++)
- {
- ResponseHandler handler = handlers[i];
- HandlerResponse handlerResponse = handler.handleResponse(ctx, cmd,
commandResponse);
- if (handlerResponse != null)
- {
- return handlerResponse;
- }
- }
-
- // We were not able to determine a suitable response
- return null;
- }
- catch (CommandRedirectionException e)
- {
- // Handle the redirection as forward
- return new CommandForward(e.getRedirection(), null);
- }
- catch (InsufficientTransportGuaranteeException e)
- {
- urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- catch (ControllerSecurityException e)
- {
- if (urlContext.isAuthenticated())
- {
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.isSecure(), true);
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- }
- catch (ResourceNotFoundException e)
- {
- log.error("Resource not found " + e.getRef(), e);
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
- }
- catch (ControllerException e)
- {
- throw new ServerException(e);
- }
- catch (ServletException e)
- {
- throw new ServerException(e);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- /**
- * Return true if the execution of the next command requires a redirect.
- *
- * @param currentCmd the current command which has been executed
- * @param currentURLCtx the request URL context
- * @param forward the forward
- * @return
- */
- public boolean requiresRedirect(
- ControllerCommand currentCmd,
- URLContext currentURLCtx,
- CommandForward forward)
- {
- CommandInfo currentCmdInfo = currentCmd.getInfo();
- if (currentCmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)currentCmdInfo).isIdempotent())
- {
- return true;
- }
- else
- {
- URLContext nextURLCtx = forward.getURLContext();
- boolean currentAuthenticated = currentURLCtx.isAuthenticated();
- if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
- {
- return true;
- }
- else
- {
- boolean currentSecure = currentURLCtx.isSecure();
- if (nextURLCtx != null && nextURLCtx.isSecure() &&
!currentSecure)
- {
- return true;
- }
- }
- }
- return false;
- }
}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -950,8 +950,26 @@
<depends
optional-attribute-name="CustomizationManager"
proxy-type="attribute">portal:service=CustomizationManager</depends>
+ <depends
+ optional-attribute-name="ContentRendererRegistry"
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.core.controller.ControllerFactory"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="ClassicController"
+ proxy-type="attribute">portal:controller=Core</depends>
+ <depends
+ optional-attribute-name="AjaxController"
+ proxy-type="attribute">portal:controller=Ajax</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.server.impl.ServerImpl"
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-03-31 05:20:07 UTC
(rev 6892)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-03-31 12:56:57 UTC
(rev 6893)
@@ -46,9 +46,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Core</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
<security-role-ref>
@@ -67,9 +67,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Core</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
<security-role-ref>
Modified:
trunk/portlet-server/src/resources/test/info/test-info-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/portlet-server/src/resources/test/info/test-info-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/portlet-server/src/resources/test/info/test-info-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -112,6 +112,18 @@
<depends optional-attribute-name="TestDriverRegistry"
proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:controller=Request</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.test.portlet.info.MetaInfoTest"
Modified: trunk/portlet-server/src/resources/test-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/portlet-server/src/resources/test-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/portlet-server/src/resources/test-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -275,6 +275,18 @@
<attribute name="RedirectAfterAction">false</attribute>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+
proxy-type="attribute">portal:controller=Request,redirect=true</depends>
+ </mbean>
+
<!-- Portlet deployment factory -->
<mbean
code="org.jboss.portal.portlet.deployment.jboss.PortletAppDeploymentFactory"
Modified: trunk/portlet-server/src/resources/test-war/WEB-INF/web.xml
===================================================================
--- trunk/portlet-server/src/resources/test-war/WEB-INF/web.xml 2007-03-31 05:20:07 UTC
(rev 6892)
+++ trunk/portlet-server/src/resources/test-war/WEB-INF/web.xml 2007-03-31 12:56:57 UTC
(rev 6893)
@@ -39,9 +39,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Request,redirect=true</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
<security-role-ref>
@@ -59,11 +59,11 @@
<param-value>false</param-value>
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
- <init-param>
- <param-name>controllerName</param-name>
-
<param-value>portal:controller=Request,redirect=false</param-value>
- <description>The request controller for the portal
servlet</description>
- </init-param>
+ <init-param>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
+ </init-param>
<load-on-startup>0</load-on-startup>
<security-role-ref>
<role-name>Test</role-name>
Added: trunk/server/src/main/org/jboss/portal/server/RequestControllerFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/RequestControllerFactory.java
(rev 0)
+++ trunk/server/src/main/org/jboss/portal/server/RequestControllerFactory.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.server;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface RequestControllerFactory
+{
+
+ RequestController createRequestController(ServerInvocation invocation);
+
+}
Added:
trunk/server/src/main/org/jboss/portal/server/impl/RequestControllerFactoryImpl.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/impl/RequestControllerFactoryImpl.java
(rev 0)
+++
trunk/server/src/main/org/jboss/portal/server/impl/RequestControllerFactoryImpl.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.server.impl;
+
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerInvocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RequestControllerFactoryImpl implements RequestControllerFactory
+{
+
+ /** . */
+ private RequestController controller;
+
+ public RequestController getController()
+ {
+ return controller;
+ }
+
+ public void setController(RequestController controller)
+ {
+ this.controller = controller;
+ }
+
+ public RequestController createRequestController(ServerInvocation invocation)
+ {
+ return controller;
+ }
+}
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -31,7 +31,6 @@
import org.jboss.portal.common.util.URLTools;
import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.server.PortalConstants;
-import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.RequestControllerDispatcher;
import org.jboss.portal.server.Server;
import org.jboss.portal.server.ServerException;
@@ -39,6 +38,8 @@
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.ServerRequest;
import org.jboss.portal.server.ServerResponse;
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.impl.ServerInvocationContextImpl;
import org.jboss.portal.server.request.URLContext;
@@ -94,16 +95,16 @@
private boolean asDefaultServlet;
/** The controller for this servlet. */
- private RequestController controller;
+ private RequestControllerFactory controllerFactory;
/** The controller name. */
- private String controllerName;
+ private String controllerFactoryName;
/** Configure the as default servlet. */
public void init() throws ServletException
{
asDefaultServlet = getAsDefaultServletInitValue();
- controllerName = getServletConfig().getInitParameter("controllerName");
+ controllerFactoryName =
getServletConfig().getInitParameter("controllerFactoryName");
}
/**
@@ -147,23 +148,23 @@
return interceptorStack;
}
- protected final RequestController getController()
+ protected final RequestControllerFactory getControllerFactory()
{
- if (controller == null)
+ if (controllerFactory == null)
{
try
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
- controller = (RequestController)MBeanProxy.get(RequestController.class, new
ObjectName(controllerName), mbeanServer);
+ controllerFactory =
(RequestControllerFactory)MBeanProxy.get(RequestControllerFactory.class, new
ObjectName(controllerFactoryName), mbeanServer);
}
catch (Exception e)
{
- String msg = "Cannot get controller " + controllerName;
+ String msg = "Cannot get controller " + controllerFactoryName;
log.error(msg, e);
throw new IllegalStateException(msg);
}
}
- return controller;
+ return controllerFactory;
}
private String retrieveMediaType(String contentType)
@@ -368,7 +369,8 @@
invocation.setResponse(response);
//
- RequestController controller = getController();
+ RequestControllerFactory controllerFactory = getControllerFactory();
+ RequestController controller =
controllerFactory.createRequestController(invocation);
invocation.setHandler(new RequestControllerDispatcher(controller));
//
Modified: trunk/server/src/resources/test/test-charset-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/server/src/resources/test/test-charset-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/server/src/resources/test/test-charset-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -85,6 +85,18 @@
<depends optional-attribute-name="TestDriverRegistry"
proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:controller=Request</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.test.server.charset.GetTest"
Modified: trunk/server/src/resources/test/test-parameters-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/server/src/resources/test/test-parameters-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/server/src/resources/test/test-parameters-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -84,6 +84,18 @@
<depends optional-attribute-name="TestDriverRegistry"
proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:controller=Request</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.test.server.parameters.GetTest"
Modified: trunk/server/src/resources/test/test-response-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/server/src/resources/test/test-response-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/server/src/resources/test/test-response-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -84,6 +84,18 @@
<depends optional-attribute-name="TestDriverRegistry"
proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:controller=Request</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.test.server.response.EncodeResponseTest"
Modified:
trunk/server/src/resources/test/test-servlet-defaultservletmapping-war/WEB-INF/web.xml
===================================================================
---
trunk/server/src/resources/test/test-servlet-defaultservletmapping-war/WEB-INF/web.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/server/src/resources/test/test-servlet-defaultservletmapping-war/WEB-INF/web.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -36,9 +36,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Request</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
Modified: trunk/server/src/resources/test/test-servlet-pathmapping-war/WEB-INF/web.xml
===================================================================
---
trunk/server/src/resources/test/test-servlet-pathmapping-war/WEB-INF/web.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/server/src/resources/test/test-servlet-pathmapping-war/WEB-INF/web.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -36,9 +36,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Request</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
Modified:
trunk/server/src/resources/test/test-servlet-rootpathmapping-war/WEB-INF/web.xml
===================================================================
---
trunk/server/src/resources/test/test-servlet-rootpathmapping-war/WEB-INF/web.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/server/src/resources/test/test-servlet-rootpathmapping-war/WEB-INF/web.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -36,9 +36,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Request</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
Modified: trunk/server/src/resources/test/test-servlet-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/server/src/resources/test/test-servlet-sar/META-INF/jboss-service.xml 2007-03-31
05:20:07 UTC (rev 6892)
+++ trunk/server/src/resources/test/test-servlet-sar/META-INF/jboss-service.xml 2007-03-31
12:56:57 UTC (rev 6893)
@@ -84,6 +84,18 @@
<depends optional-attribute-name="TestDriverRegistry"
proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
</mbean>
+ <!-- The controller factory -->
+ <mbean
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
+ name="portal:service=ControllerFactory"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:controller=Request</depends>
+ </mbean>
+
<!-- -->
<mbean
code="org.jboss.portal.test.server.servlet.RootPathMappingTest"
Modified: trunk/server/src/resources/test-agent-war/WEB-INF/web.xml
===================================================================
--- trunk/server/src/resources/test-agent-war/WEB-INF/web.xml 2007-03-31 05:20:07 UTC (rev
6892)
+++ trunk/server/src/resources/test-agent-war/WEB-INF/web.xml 2007-03-31 12:56:57 UTC (rev
6893)
@@ -36,9 +36,9 @@
<description>The servlet needs to know wether it is set as a default
servlet or not</description>
</init-param>
<init-param>
- <param-name>controllerName</param-name>
- <param-value>portal:controller=Request</param-value>
- <description>The request controller for the portal
servlet</description>
+ <param-name>controllerFactoryName</param-name>
+ <param-value>portal:service=ControllerFactory</param-value>
+ <description>The request controller factory for the portal
servlet</description>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -128,7 +128,7 @@
//
Map pageProps = new HashMap();
pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL,
"http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -99,7 +99,7 @@
//
Map pageProps = new HashMap();
pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL,
"http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
Modified: trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-03-31 05:20:07
UTC (rev 6892)
+++ trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-03-31 12:56:57
UTC (rev 6893)
@@ -91,10 +91,15 @@
/**
*
*/
- public static final String PORTAL_AJAX_REMOTE_URL =
"theme.ajax.remove_url";
+ public static final String PORTAL_AJAX_ASYNC_SERVER_URL =
"theme.ajax.async_server_url";
/**
*
*/
+ public static final String PORTAL_AJAX_CLASSIC_SERVER_URL =
"theme.ajax.classic_server_url";
+
+ /**
+ *
+ */
public static final String PORTAL_AJAX_OBJECT_ENABLED =
"theme.ajax.object_enabled";
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-31
05:20:07 UTC (rev 6892)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-31
12:56:57 UTC (rev 6893)
@@ -88,7 +88,8 @@
{
StringBuffer markup = renderContext.getMarkupFragment();
String jsBase =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
- String remoteURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_REMOTE_URL);
+ String asyncServerURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL);
+ String classicServerURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL);
//
Object onPage =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
@@ -107,7 +108,8 @@
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/effects.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/dragdrop.js'></script>\n");
markup.append("<script type='text/javascript'>\n");
-
markup.append("remote_server_url=\"").append(remoteURL).append(";\"\n");
+
markup.append("async_server_url=\"").append(asyncServerURL).append(";\"\n");
+
markup.append("classic_server_url=\"").append(classicServerURL).append("\";\n");
String sendData = "" +
"function sendData(action, windowId, fromPos, fromRegionId, toPos,
toRegionId) {\n" +
@@ -132,7 +134,7 @@
" {\n" +
" }\n" +
" }\n" +
- " new Ajax.Request(remote_server_url, options);\n" +
+ " new Ajax.Request(async_server_url, options);\n" +
"}";
markup.append(sendData);
@@ -195,9 +197,24 @@
String v = "" +
"function bilto(event)\n" +
"{\n" +
- " var source = Event.element(event);\n" +
- " alert(source.id);\n" +
- " Event.stop(event);;\n" +
+// " var source = Event.element(event);\n" +
+// " if (source.nodeName == \"A\") {;\n" +
+// " var url = source.href;\n" +
+// " var parameters = \"\";\n" +
+// " var pos = url.indexOf(\"?\");\n" +
+// " if (pos != -1) {\n" +
+// " parameters = url.substring(pos + 1);\n" +
+// " url = url.substring(0, pos);\n" +
+// " }\n" +
+// " Event.stop(event);\n" +
+// " var options = {\n" +
+// " parameters:parameters,\n" +
+// " asynchronous:true,\n" +
+// " method:\"get\",\n" +
+// "
requestHeaders:[\"ajax\",\"true\"],\n" +
+// " };" +
+// " new Ajax.Request(url, options);\n" +
+// " }\n" +
"}\n";
markup.append(v);
@@ -224,11 +241,11 @@
// Find the dyna portlets
"var portlets_on_page =
document.getElementsByClassName(\"dyna-portlet\");\n" +
- // Add listener for those portlets
-// "for(var i = 0;i < portlets_on_page.length;i++) {\n" +
-// " var portlet = portlets_on_page[i];\n" +
-// " Event.observe(portlet, 'click', bilto);\n" +
-// "}\n" +
+ // Add listener for teh dyna portlets
+ "for(var i = 0;i < portlets_on_page.length;i++) {\n" +
+ " var portlet = portlets_on_page[i];\n" +
+ " Event.observe(portlet, 'click', bilto);\n" +
+ "}\n" +
"</script>\n");
}