Author: julien(a)jboss.com
Date: 2007-03-31 08:57:50 -0400 (Sat, 31 Mar 2007)
New Revision: 6894
Added:
trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java
Log:
- added in server RequestControllerFactory so the request controller used by the portal
servlet can decided at runtime based on the server request
Added: trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java 2007-03-31
12:57:50 UTC (rev 6894)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * 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.core.controller;
+
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerInvocation;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ControllerFactory implements RequestControllerFactory
+{
+
+ /** . */
+ private RequestController classicController;
+
+ /** . */
+ private RequestController ajaxController;
+
+ public RequestController getClassicController()
+ {
+ return classicController;
+ }
+
+ public void setClassicController(RequestController classicController)
+ {
+ this.classicController = classicController;
+ }
+
+
+ public RequestController getAjaxController()
+ {
+ return ajaxController;
+ }
+
+ public void setAjaxController(RequestController ajaxController)
+ {
+ this.ajaxController = ajaxController;
+ }
+
+ public RequestController createRequestController(ServerInvocation invocation)
+ {
+
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ String value = req.getHeader("ajax");
+ if ("true".equalsIgnoreCase(value))
+ {
+ return ajaxController;
+ }
+ else
+ {
+ return classicController;
+ }
+
+
+// 02:03:58,636 INFO [STDOUT] host = localhost:8080
+// 02:03:58,636 INFO [STDOUT] user-agent = Mozilla/5.0 (Macintosh; U; Intel Mac OS
X; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0
+// 02:03:58,636 INFO [STDOUT] accept = text/javascript, text/html, application/xml,
text/xml, */*
+// 02:03:58,636 INFO [STDOUT] accept-language = fr,en-us;q=0.5
+// 02:03:58,637 INFO [STDOUT] accept-encoding = gzip,deflate
+// 02:03:58,637 INFO [STDOUT] accept-charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
+// 02:03:58,637 INFO [STDOUT] keep-alive = 300
+// 02:03:58,637 INFO [STDOUT] connection = keep-alive
+// 02:03:58,637 INFO [STDOUT] x-requested-with = XMLHttpRequest
+// 02:03:58,638 INFO [STDOUT] x-prototype-version = 1.5.0_rc1
+// 02:03:58,638 INFO [STDOUT] ajax = true
+// 02:03:58,639 INFO [STDOUT] referer =
http://localhost:8080/portal/auth/portal/dashboard/admin/default/
+// 02:03:58,639 INFO [STDOUT] cookie = JSESSIONID=A0B8EA1EEEAE6D977C0A8074D338B0EB
+ }
+}