[portal-commits] JBoss Portal SVN: r8890 - in branches/UIServer: core/src/main/org/jboss/portal/core/presentation and 9 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Mon Nov 12 17:33:29 EST 2007


Author: sohil.shah at jboss.com
Date: 2007-11-12 17:33:29 -0500 (Mon, 12 Nov 2007)
New Revision: 8890

Added:
   branches/UIServer/core/src/main/org/jboss/portal/core/presentation/
   branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/
   branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
   branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/PortalObjectReaderImpl.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PortalObjectReader.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServer.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServerImpl.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorResponse.java
Removed:
   branches/UIServer/core/src/main/org/jboss/portal/core/processor/
   branches/UIServer/core/src/main/org/jboss/portal/core/spi/
   branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/processor/
   branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/spi/
Modified:
   branches/UIServer/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
   branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/ajax/PortalEntryPoint.java
   branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml
Log:
refactoring

Added: branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
--- branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java	                        (rev 0)
+++ branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,224 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import java.io.InputStream;
+import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
+
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.server.RequestControllerDispatcher;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+import org.jboss.portal.uiserver.protocol.Page;
+import org.jboss.portal.uiserver.protocol.Window;
+
+/**
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public class MainProcessor extends AbstractJBossService implements Processor
+{
+   /**
+    * 
+    */
+   private static Logger log = Logger.getLogger(MainProcessor.class);
+   
+   /**
+    * 
+    */
+   private RequestController requestController = null;
+   
+   /**
+    * 
+    * @return
+    */   
+   public RequestController getRequestController()
+   {
+      return requestController;
+   }
+
+   /**
+    * 
+    * @param requestController
+    */
+   public void setRequestController(RequestController requestController)
+   {
+      this.requestController = requestController;
+   }
+
+   /**
+    * 
+    */
+   public ProcessorResponse process(ProcessorRequest request) throws ServerException
+   { 
+      try
+      {
+         /*
+         This should process the request sent in from the UIServer using whatever framework the core Portal implements
+         Basically based on the information sent in by the ProcessorRequest this component should have all the information
+         it needs to perform necessary action inside the Portal                 
+         the Processor should use the values sent in the ProcessorRequest object to perform
+         the appropriate action and then send its Response back to the UIServer which should process
+         the Response and sent a Response back to the client
+         */         
+         ProcessorResponse response = null;
+         
+         //For now, just for prototype sake just use the existing Controller to produce the outcome
+         request.getServerInvocation().setHandler(new RequestControllerDispatcher(this.requestController));
+         request.getServerInvocation().invokeNext();
+               
+         //Get access to the core Portal objects to be used after the execution of the incoming Portal request
+         //by the Portal Controller
+         ServerInvocation invocation = request.getServerInvocation();
+         ServletContextDispatcher dispatcher = new ServletContextDispatcher(invocation.getServerContext().getClientRequest(), 
+         invocation.getServerContext().getClientResponse(), invocation.getRequest().getServer().getServletContainerContext());  
+         String task = (String)invocation.getServerContext().getClientRequest().getAttribute("pfTask");
+         if(task.equals("aggregate"))
+         {
+            //Handle page aggregation and sending result back to the client
+            MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
+            PageResult pageResult = (PageResult)invocation.getServerContext().getClientRequest().getAttribute("pageResult");
+            
+            //Now generate a ProcessorResponse by mapping the data produced during the execution of
+            //the Portal Request
+            String contentType = markupInfo.getContentType() + "; charset=" + markupInfo.getCharset();
+            Page pageToBeDisplayed = new Page();
+            pageToBeDisplayed.setCurrentlyDisplayed(true);
+            
+            //Setup information inside the page object
+            pageToBeDisplayed.setName(pageResult.getPageName());
+            List windows = this.getWindows(pageResult.getWindowContextMap());
+            if(windows != null)
+            {
+               pageToBeDisplayed.getChildren().addAll(windows);
+            }
+            
+            //
+            List updatedPages = new ArrayList();
+            updatedPages.add(pageToBeDisplayed);
+            
+            //Generate the response to be sent back for processing by the Presentation Framework
+            response = new ProcessorResponse(dispatcher, contentType, markupInfo.getCharset(), updatedPages);
+         }
+         else if(task.equals("stream"))
+         {
+            //Handle sending back binary content back to the client
+            String contentType = (String)invocation.getServerContext().getClientRequest().getAttribute("contentType");
+            InputStream in = (InputStream)invocation.getServerContext().getClientRequest().getAttribute("inputStream");
+            
+            //Process and see if binary content needs to be sent back...
+            //In this case write the response to the OutputStream directly
+            //There is no need for any Presentation Framework processing            
+            if(contentType != null && in != null)
+            {
+               HttpServletResponse resp = invocation.getServerContext().getClientResponse();
+               resp.setContentType(contentType);
+               ServletOutputStream sout = null;
+               try
+               {
+                  sout = resp.getOutputStream();
+                  byte[] buf = new byte[2048];
+                  int len;
+                  while ((len = in.read(buf)) > 0)
+                  {
+                     sout.write(buf, 0, len);
+                  }
+                  sout.flush();
+               }
+               finally
+               {
+                  IOTools.safeClose(in);
+                  IOTools.safeClose(sout);
+               }
+            }
+         }
+         else if(task.equals("redirect"))
+         {
+            //Handle sendRedirect back to the client
+            String url = (String)invocation.getServerContext().getClientRequest().getAttribute("url");
+            invocation.getServerContext().getClientResponse().sendRedirect(url);            
+         }
+         else if(task.equals("error"))
+         {
+            //Handle sendingErrror back to the client
+            Integer errorCode = (Integer)invocation.getServerContext().getClientRequest().getAttribute("errorCode");
+            invocation.getServerContext().getClientResponse().sendError(errorCode.intValue());
+         }
+         
+         
+         return response;
+      }
+      catch(Exception e)
+      {
+         throw new ServerException(e);
+      }
+   }
+   
+   /**
+    * 
+    * @param windowContexts
+    * @return
+    */
+   private List getWindows(Map windowContexts)
+   {
+      List windows = null;
+      
+      if(windowContexts != null)
+      {
+         windows = new ArrayList();
+         for(Iterator itr=windowContexts.keySet().iterator(); itr.hasNext();)
+         {
+            String windowId = (String)itr.next();
+            WindowContext windowContext = (WindowContext)windowContexts.get(windowId);
+            WindowResult windowResult = windowContext.getResult();
+            
+            Window window = new Window(windowId, windowResult.getTitle(), 
+            windowResult.getContent(), windowResult.getHeaderContent(), 
+            windowResult.getWindowState(), windowResult.getMode());
+            
+            windows.add(window);
+         }
+      }
+      
+      return windows;
+   }
+}

Added: branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/PortalObjectReaderImpl.java
===================================================================
--- branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/PortalObjectReaderImpl.java	                        (rev 0)
+++ branches/UIServer/core/src/main/org/jboss/portal/core/presentation/server/PortalObjectReaderImpl.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalContainer;
+
+import org.jboss.portal.uiserver.protocol.Portal;
+import org.jboss.portal.uiserver.protocol.PortalObject;
+import org.jboss.portal.uiserver.protocol.Page;
+import org.jboss.portal.uiserver.protocol.Window;
+import org.jboss.portal.presentation.server.PortalObjectReader;
+
+/**
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ * 
+ */
+public class PortalObjectReaderImpl extends AbstractJBossService implements PortalObjectReader
+{
+   private PortalObjectContainer portalObjectContainer = null;
+
+   /**
+    * 
+    * @return
+    */
+   public PortalObjectContainer getPortalObjectContainer()
+   {
+      return portalObjectContainer;
+   }
+
+   /**
+    * 
+    * @param portalObjectContainer
+    */
+   public void setPortalObjectContainer(
+         PortalObjectContainer portalObjectContainer)
+   {
+      this.portalObjectContainer = portalObjectContainer;
+   }
+
+   /**
+    * 
+    */
+   public Portal findPortal(String id)
+   {
+      Portal portal = null;
+      PortalContainer portalContainer = this.portalObjectContainer.getContext();
+
+      org.jboss.portal.core.model.portal.Portal cour = portalContainer
+            .getPortal(id);
+      if (cour != null)
+      {
+         portal = new Portal();
+         portal.setId(cour.getId().toString());
+         portal.setName(cour.getName());
+
+         // Setup top level children for this node
+         Collection children = cour.getChildren();
+         Collection portalChildren = new ArrayList();
+         for (Iterator itr = children.iterator(); itr.hasNext();)
+         {
+            org.jboss.portal.core.model.portal.PortalObject child = (org.jboss.portal.core.model.portal.PortalObject) itr
+                  .next();
+
+            PortalObject portalChild = null;
+
+            if (child instanceof org.jboss.portal.core.model.portal.Page)
+            {
+               portalChild = new Page();
+               portalChild.setId(child.getId().toString());
+               portalChild.setName(child.getName());
+               portalChild.setParent(portal);
+               portalChildren.add(portalChild);
+            }
+            else if (child instanceof org.jboss.portal.core.model.portal.Window)
+            {
+               portalChild = new Window();
+               portalChild.setId(child.getId().toString());
+               portalChild.setName(child.getName());
+               portalChild.setParent(portal);
+               portalChildren.add(portalChild);
+            }
+         }
+
+         portal.setChildren(portalChildren);
+      }
+
+      return portal;
+   }
+
+   /**
+    * 
+    */
+   public PortalObject findPortalObject(PortalObject parent, String id)
+   {
+      PortalObject portalObject = null;
+      PortalContainer portalContainer = this.portalObjectContainer.getContext();
+
+      //Find the Portal to introspect
+      int startIndex = 1;
+      int endIndex = id.indexOf('/', startIndex);
+      String portalName = id.substring(startIndex, endIndex);
+      org.jboss.portal.core.model.portal.Portal portal = portalContainer.getPortal(portalName);      
+      if(portal == null)
+      {
+         return null;
+      }
+      
+      //Find the Portal Object inside this Portal represented by the id
+      org.jboss.portal.core.model.portal.PortalObject cour = null; 
+      StringTokenizer st = new StringTokenizer(id, "/");
+      while(st.hasMoreTokens())
+      {
+         String token = st.nextToken();
+         
+         if(cour == null)
+         {
+            cour = portal.getChild(token);
+         }
+         else
+         {
+            cour = cour.getChild(token);
+         }         
+      }
+            
+      //Map the Portal Object to the protocol Portal Object
+      if (cour != null)
+      {
+         if (cour instanceof org.jboss.portal.core.model.portal.Page)
+         {
+            portalObject = new Page();
+         }
+         else if (cour instanceof org.jboss.portal.core.model.portal.Window)
+         {
+            portalObject = new Window();
+         }
+
+         if (portalObject != null)
+         {
+            portalObject.setId(cour.getId().toString());
+            portalObject.setName(cour.getName());
+            portalObject.setParent(parent);
+
+            // Setup top level children for this node
+            Collection children = cour.getChildren();
+            Collection portalChildren = new ArrayList();
+            for (Iterator itr = children.iterator(); itr.hasNext();)
+            {
+               org.jboss.portal.core.model.portal.PortalObject child = (org.jboss.portal.core.model.portal.PortalObject) itr
+                     .next();
+
+               PortalObject portalChild = null;
+
+               if (child instanceof org.jboss.portal.core.model.portal.Page)
+               {
+                  portalChild = new Page();
+                  portalChild.setId(child.getId().toString());
+                  portalChild.setName(child.getName());
+                  portalChild.setParent(portalObject);
+                  portalChildren.add(portalChild);
+               }
+               else if (child instanceof org.jboss.portal.core.model.portal.Window)
+               {
+                  portalChild = new Window();
+                  portalChild.setId(child.getId().toString());
+                  portalChild.setName(child.getName());
+                  portalChild.setParent(portalObject);
+                  portalChildren.add(portalChild);
+               }
+            }
+            portalObject.setChildren(portalChildren);
+         }
+      }
+
+      return portalObject;
+   }
+}

Modified: branches/UIServer/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- branches/UIServer/core/src/resources/portal-core-sar/META-INF/jboss-service.xml	2007-11-12 21:46:19 UTC (rev 8889)
+++ branches/UIServer/core/src/resources/portal-core-sar/META-INF/jboss-service.xml	2007-11-12 22:33:29 UTC (rev 8890)
@@ -1092,7 +1092,7 @@
          proxy-type="attribute">portal:service=ControlPolicy,type=Page</depends>
    </mbean>
    <mbean
-      code="org.jboss.portal.core.processor.MainProcessor"
+      code="org.jboss.portal.core.presentation.server.MainProcessor"
       name="portal:service=Processor"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -1111,7 +1111,7 @@
       <depends>portal:service=ControlPolicy,type=Page</depends>
    </mbean>
    <mbean
-      code="org.jboss.portal.core.spi.PortalObjectReaderImpl"
+      code="org.jboss.portal.core.presentation.server.PortalObjectReaderImpl"
       name="portal:container=PortalObjectReader"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PortalObjectReader.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PortalObjectReader.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PortalObjectReader.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import org.jboss.portal.uiserver.protocol.Portal;
+import org.jboss.portal.uiserver.protocol.PortalObject;
+
+/**
+ * The PortalObjectReader service is used to provide information about different Portal Objects stored in the system
+ * 
+ * It provides an implementation independent way to query this information without any coupling to low level Portal container
+ * implementation details
+ * 
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public interface PortalObjectReader
+{
+   /**
+    * Finds a Portal registered with the specified id in the system
+    * 
+    * @param id
+    * @return
+    */
+   public Portal findPortal(String id);
+   
+   /**
+    * Finds a PortalObject registered as a child of the specified parent
+    * 
+    * @param portal
+    * @param id
+    * @return
+    */
+   public PortalObject findPortalObject(PortalObject parent, String id);
+}

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServer.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServer.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+/**
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public interface PresentationServer
+{
+   /**
+    * 
+    * @return
+    */
+   public Processor getProcessor();
+   
+   /**
+    * 
+    * @return
+    */
+   public PortalObjectReader getPortalObjectReader();
+}

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServerImpl.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServerImpl.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/PresentationServerImpl.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -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.presentation.server;
+
+/**
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public class PresentationServerImpl implements PresentationServer
+{
+   private Processor processor = null;
+   private PortalObjectReader portalObjectReader = null;
+   
+   /**
+    * 
+    *
+    */
+   public PresentationServerImpl()
+   {
+      
+   }
+   
+   /**
+    * 
+    *
+    */
+   public void start()
+   {
+      
+   }
+   
+   /**
+    * 
+    *
+    */
+   public void stop()
+   {
+      
+   }
+   
+   /**
+    * 
+    */
+   public PortalObjectReader getPortalObjectReader()
+   {
+      return this.portalObjectReader;
+   }
+   
+   /**
+    * 
+    * @param portalObjectReader
+    */
+   public void setPortalObjectReader(PortalObjectReader portalObjectReader)
+   {
+      this.portalObjectReader = portalObjectReader;
+   }
+
+   /**
+    * 
+    */
+   public Processor getProcessor()
+   {
+      return this.processor;
+   }
+   
+   /**
+    * 
+    * @param processor
+    */
+   public void setProcessor(Processor processor)
+   {
+      this.processor = processor;
+   }
+}

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/Processor.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import org.jboss.portal.server.ServerException;
+
+/**
+ * UIServer calls the Processor to hand it 
+ * processing of an incoming Portal Request using the protocol between the two components encapsulated by the
+ * ProcessorRequest object
+ * 
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public interface Processor
+{
+   /**
+    * 
+    * @param request
+    * @throws ServerException
+    */
+   public ProcessorResponse process(ProcessorRequest request) throws ServerException;
+}

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorRequest.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import java.io.Serializable;
+
+import org.jboss.portal.uiserver.protocol.Portal;
+import org.jboss.portal.uiserver.protocol.PortalObject;
+import org.jboss.portal.server.ServerInvocation;
+
+
+/**
+ * ProcessorRequest is used to communicate information from the UIServer to the core Portal for it to process the incoming Portal request.
+ * 
+ * This object is part of the protocol between the UIServer and the core
+ * 
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public class ProcessorRequest implements Serializable
+{
+   /**
+    * Target object where action needs to be performed
+    */
+   private PortalObject target = null;
+   
+   /**
+    * The Portal that the target object belongs to
+    */
+   private Portal portal = null;
+   
+   /**
+    * The Portal action to be performed. For now, action and render
+    */
+   private String actionType = null;
+   
+   
+   private ServerInvocation serverInvocation = null;
+   
+   /**
+    * 
+    *
+    */
+   public ProcessorRequest(String actionType, ServerInvocation serverInvocation, Portal portal, PortalObject target)
+   {
+      this.actionType = actionType;
+      this.serverInvocation = serverInvocation;
+      this.portal = portal;
+      this.target = target;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public String getActionType()
+   {
+      return actionType;
+   }
+
+   /**
+    * 
+    * @param actionType
+    */
+   public void setActionType(String actionType)
+   {
+      this.actionType = actionType;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public Portal getPortal()
+   {
+      return portal;
+   }
+
+   /**
+    * 
+    * @param portal
+    */
+   public void setPortal(Portal portal)
+   {
+      this.portal = portal;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public PortalObject getTarget()
+   {
+      return target;
+   }
+
+   /**
+    * 
+    * @param target
+    */
+   public void setTarget(PortalObject target)
+   {
+      this.target = target;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public ServerInvocation getServerInvocation()
+   {
+      return serverInvocation;
+   }
+
+   /**
+    * 
+    * @param serverInvocation
+    */
+   public void setServerInvocation(ServerInvocation serverInvocation)
+   {
+      this.serverInvocation = serverInvocation;
+   }
+   
+   /**
+    * 
+    */
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("[actionType="+this.actionType+", portal="+this.portal+", target="+this.target+"]");
+      return buffer.toString();
+   }
+}

Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorResponse.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorResponse.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ProcessorResponse.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -0,0 +1,171 @@
+/******************************************************************************
+ * 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.presentation.server;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.portal.web.ServletContextDispatcher;
+
+import org.jboss.portal.uiserver.protocol.Page;
+
+/**
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ * 
+ */
+public class ProcessorResponse implements Serializable
+{
+   /**
+    * 
+    */
+   private ServletContextDispatcher dispatcher = null;
+   
+   /**
+    * Contains a list of pages that need to be updated on the client. These pages may not necessarily
+    * be the currently displayed page, but nevertheless, these are pages whose window content changed
+    * as a result of this particular Portal request processing.
+    * 
+    * For most usecases this probably only consist of the Page that is currently being displayed on the client
+    */
+   private List updatedPages = null;
+   
+   /**
+    * Content Type of the response being sent back to the client
+    */
+   private String contentType = null;
+   
+   /**
+    * Character Set of the response being sent back to the client
+    */
+   private String charSet = null;
+      
+   
+   /**
+    * 
+    * @param dispatcher
+    * @param updatedPages
+    */
+   public ProcessorResponse(ServletContextDispatcher dispatcher, String contentType, String charSet, List updatedPages)
+   {
+      this.dispatcher = dispatcher;
+      this.contentType = contentType;
+      this.charSet = charSet;
+      this.updatedPages = updatedPages;      
+   }
+   
+   /**
+    * 
+    * @return
+    */
+   public ServletContextDispatcher getDispatcher()
+   {
+      return dispatcher;
+   }
+
+   /**
+    * 
+    * @param dispatcher
+    */
+   public void setDispatcher(ServletContextDispatcher dispatcher)
+   {
+      this.dispatcher = dispatcher;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public List getUpdatedPages()
+   {
+      return updatedPages;
+   }
+
+   /**
+    * 
+    * @param updatedPages
+    */
+   public void setUpdatedPages(List updatedPages)
+   {
+      this.updatedPages = updatedPages;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public String getCharSet()
+   {
+      return charSet;
+   }
+
+   /**
+    * 
+    * @param charSet
+    */
+   public void setCharSet(String charSet)
+   {
+      this.charSet = charSet;
+   }
+
+   /**
+    * 
+    * @return
+    */
+   public String getContentType()
+   {
+      return contentType;
+   }
+
+   /**
+    * 
+    * @param contentType
+    */
+   public void setContentType(String contentType)
+   {
+      this.contentType = contentType;
+   }
+   
+   /**
+    * 
+    * @return
+    */
+   public Page findDisplayedPage()
+   {
+      Page displayedPage = null;
+      
+      if(this.updatedPages != null)
+      {
+         for(int i=0; i<this.updatedPages.size(); i++)
+         {
+            Page cour = (Page)this.updatedPages.get(i);
+            if(cour.isCurrentlyDisplayed())
+            {
+               displayedPage = cour;
+               break;
+            }
+         }
+      }
+      
+      return displayedPage;
+   }
+}

Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java	2007-11-12 21:46:19 UTC (rev 8889)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -69,7 +69,7 @@
 import org.jboss.portal.uiserver.protocol.Container;
 import org.jboss.portal.uiserver.protocol.Page;
 import org.jboss.portal.uiserver.protocol.Window;
-import org.jboss.portal.uiserver.processor.ProcessorResponse;
+import org.jboss.portal.presentation.server.ProcessorResponse;
 
 /**
  * The Portal Server Entry Point for classic html mode

Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java	2007-11-12 21:46:19 UTC (rev 8889)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -27,12 +27,12 @@
 import org.jboss.portal.uiserver.protocol.PortalObject;
 import org.jboss.portal.uiserver.protocol.Portal;
 
-import org.jboss.portal.uiserver.processor.Processor;
-import org.jboss.portal.uiserver.processor.ProcessorRequest;
-import org.jboss.portal.uiserver.processor.ProcessorResponse;
-import org.jboss.portal.uiserver.spi.PortalObjectReader;
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+import org.jboss.portal.presentation.server.PortalObjectReader;
+import org.jboss.portal.presentation.server.PresentationServer;
 
-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.ServerInvocation;
@@ -48,20 +48,16 @@
  * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
  *
  */
-public class UIServer extends AbstractJBossService implements RequestController
+public class UIServer implements RequestController
 {
    /**
     * 
     */
-   private PortalObjectReader portalObjectReader = null;
+   private PresentationServer presentationServer = null;
+      
    
    /**
     * 
-    */
-   private Processor processor = null;
-   
-   /**
-    * 
     *
     */
    public UIServer()
@@ -92,7 +88,7 @@
             String token = st.nextToken();         
             if(portal == null)
             {
-               portal = this.portalObjectReader.findPortal(token);
+               portal = this.presentationServer.getPortalObjectReader().findPortal(token);
                if(portal != null)
                {
                   buffer.append(token);
@@ -116,7 +112,7 @@
                   target = portal.findChild(id);
                   if(target == null)
                   {
-                     target = this.portalObjectReader.findPortalObject(portal, id);
+                     target = this.presentationServer.getPortalObjectReader().findPortalObject(portal, id);
                   }
                }
                else
@@ -124,7 +120,7 @@
                   PortalObject cour = target.findChild(id);
                   if(cour == null)
                   {
-                     target = this.portalObjectReader.findPortalObject(target, id);
+                     target = this.presentationServer.getPortalObjectReader().findPortalObject(target, id);
                   }
                   else
                   {
@@ -141,7 +137,7 @@
          }
          
          ProcessorRequest processorRequest = new ProcessorRequest(actionType, invocation, portal, target);
-         ProcessorResponse processorResponse = this.processor.process(processorRequest);
+         ProcessorResponse processorResponse = this.presentationServer.getProcessor().process(processorRequest);
                   
          //Go ahead and render to the client based on ProcessorResponse received from the core Portal 
          if(processorResponse != null)
@@ -153,40 +149,40 @@
       {
          throw new ServerException(e);
       }
-   }      
-   //-----------------------------------------------------------------------------------------------------------------------------------------------------------
+   }   
+   
    /**
     * 
+    *
     */
-   public PortalObjectReader getPortalObjectReader()
+   public void start()
    {
-      return portalObjectReader;
+      
    }
-
+   
    /**
     * 
-    * @param portalObjectReader
+    *
     */
-   public void setPortalObjectReader(PortalObjectReader portalObjectReader)
+   public void stop()
    {
-      this.portalObjectReader = portalObjectReader;
+      
    }
-
+   //-----------------------------------------------------------------------------------------------------------------------------------------------------------
    /**
     * 
-    * @return
     */
-   public Processor getProcessor()
+   public PresentationServer getPresentationServer()
    {
-      return processor;
+      return presentationServer;
    }
 
    /**
     * 
-    * @param processor
+    * @param presentationServer
     */
-   public void setProcessor(Processor processor)
+   public void setPresentationServer(PresentationServer presentationServer)
    {
-      this.processor = processor;
+      this.presentationServer = presentationServer;
    }      
 }

Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/ajax/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/ajax/PortalEntryPoint.java	2007-11-12 21:46:19 UTC (rev 8889)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/ajax/PortalEntryPoint.java	2007-11-12 22:33:29 UTC (rev 8890)
@@ -32,7 +32,7 @@
 import org.jboss.portal.uiserver.ajax.client.service.PortalRPC;
 import org.jboss.portal.uiserver.ajax.client.protocol.Page;
 import org.jboss.portal.uiserver.ajax.client.protocol.Window;
-import org.jboss.portal.uiserver.processor.ProcessorResponse;
+import org.jboss.portal.presentation.server.ProcessorResponse;
 import org.jboss.portal.uiserver.service.EntryPoint;
 
 import com.google.gwt.user.client.rpc.SerializationException;

Modified: branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml	2007-11-12 21:46:19 UTC (rev 8889)
+++ branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml	2007-11-12 22:33:29 UTC (rev 8890)
@@ -29,6 +29,14 @@
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
+      <depends optional-attribute-name="PresentationServer" proxy-type="attribute">portal:service=PresentationServer</depends>      
+  </mbean>
+  <mbean
+      code="org.jboss.portal.presentation.server.PresentationServerImpl"
+      name="portal:service=PresentationServer"
+      xmbean-dd=""
+      xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+      <xmbean/>
       <depends optional-attribute-name="PortalObjectReader" proxy-type="attribute">portal:container=PortalObjectReader</depends>
       <depends optional-attribute-name="Processor" proxy-type="attribute">portal:service=Processor</depends>
       <depends>portal:service=PageService</depends>




More information about the portal-commits mailing list