Author: mwringe
Date: 2009-08-05 11:52:40 -0400 (Wed, 05 Aug 2009)
New Revision: 13678
Added:
jbossexo/modules/portlet/trunk/api/src/main/java/org/jboss/portal/portlet/api/invocation/SimplePortletInvocationContext.java
Modified:
jbossexo/modules/portlet/trunk/build/pom.xml
jbossexo/modules/portlet/trunk/exo/src/main/java/org/jboss/portal/portlet/exo/ExoKernelIntegration.java
jbossexo/modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
jbossexo/modules/portlet/trunk/portlet/pom.xml
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
Log:
Update the ExoKernel integration to expose the portletinvokerinterceptor as the
portletinvoker service for exo. Need to reneable the federation portlet support which will
become the actual portletinvoker service.
Add support for the exo resource bundle service.
Add SimplePortletInvocationContext for an easy portletinvocationcontext to be used with
eXo Portal.
Added:
jbossexo/modules/portlet/trunk/api/src/main/java/org/jboss/portal/portlet/api/invocation/SimplePortletInvocationContext.java
===================================================================
---
jbossexo/modules/portlet/trunk/api/src/main/java/org/jboss/portal/portlet/api/invocation/SimplePortletInvocationContext.java
(rev 0)
+++
jbossexo/modules/portlet/trunk/api/src/main/java/org/jboss/portal/portlet/api/invocation/SimplePortletInvocationContext.java 2009-08-05
15:52:40 UTC (rev 13678)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.portlet.api.invocation;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.api.ActionURL;
+import org.jboss.portal.portlet.api.ContainerURL;
+import org.jboss.portal.portlet.api.RenderURL;
+import org.jboss.portal.portlet.api.ResourceURL;
+import org.jboss.portal.portlet.api.URLFormat;
+import org.jboss.portal.portlet.api.spi.PortletInvocationContext;
+
+/**
+ * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class SimplePortletInvocationContext implements PortletInvocationContext
+{
+
+ private MarkupInfo markupInfo;
+ private HttpServletRequest req;
+ private HttpServletResponse resp;
+ private String baseURL;
+
+ public SimplePortletInvocationContext(MarkupInfo markupInfo, String baseURL)
+ {
+ this.markupInfo = markupInfo;
+ this.baseURL = baseURL;
+ }
+
+ public String encodeResourceURL(String url) throws IllegalArgumentException
+ {
+ throw new IllegalArgumentException("EncodeResourceURL method not yet
supported");
+ }
+
+ public MarkupInfo getMarkupInfo()
+ {
+ return this.markupInfo;
+ }
+
+ public String renderURL(ContainerURL containerURL, URLFormat format)
+ {
+ String url = baseURL;
+
+ String type;
+ if (containerURL instanceof RenderURL)
+ {
+ type = "render";
+ }
+ else if (containerURL instanceof ResourceURL)
+ {
+ type = "resource";
+ }
+ else if (containerURL instanceof ActionURL)
+ {
+ type = "action";
+ }
+ else
+ {
+ throw new Error("Unrecognized containerURL type");
+ }
+
+ url += "&portal:type=" + type;
+
+ //TODO: fix this part
+ url += "&portal:isSecure=" + "false";
+
+ return url;
+ }
+
+ public void renderURL(Writer writer, ContainerURL containerURL, URLFormat format)
throws IOException
+ {
+ String url = renderURL(containerURL, format);
+ writer.write(url);
+ }
+
+}
+
Modified: jbossexo/modules/portlet/trunk/build/pom.xml
===================================================================
--- jbossexo/modules/portlet/trunk/build/pom.xml 2009-08-05 15:46:33 UTC (rev 13677)
+++ jbossexo/modules/portlet/trunk/build/pom.xml 2009-08-05 15:52:40 UTC (rev 13678)
@@ -49,7 +49,8 @@
<version.ccpp-api>1.0</version.ccpp-api>
<version.xerces>2.9.1</version.xerces>
<version.exo.kernel>2.1.1</version.exo.kernel>
-
+ <!-- eXo PC dependency temporarily until we move over some of the pc classes in
the portlet module -->
+ <version.exo.pc>2.1.2-SNAPSHOT</version.exo.pc>
</properties>
<repositories>
@@ -353,8 +354,12 @@
<artifactId>exo.kernel.container</artifactId>
<version>${version.exo.kernel}</version>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portletcontainer</groupId>
+ <artifactId>exo.pc.component.common</artifactId>
+ <version>${version.exo.pc}</version>
+ </dependency>
-
</dependencies>
</dependencyManagement>
Modified:
jbossexo/modules/portlet/trunk/exo/src/main/java/org/jboss/portal/portlet/exo/ExoKernelIntegration.java
===================================================================
---
jbossexo/modules/portlet/trunk/exo/src/main/java/org/jboss/portal/portlet/exo/ExoKernelIntegration.java 2009-08-05
15:46:33 UTC (rev 13677)
+++
jbossexo/modules/portlet/trunk/exo/src/main/java/org/jboss/portal/portlet/exo/ExoKernelIntegration.java 2009-08-05
15:52:40 UTC (rev 13678)
@@ -83,10 +83,7 @@
// The portlet application deployer
portletApplicationRegistry = new PortletApplicationDeployer();
portletApplicationRegistry.setContainerPortletInvoker(containerPortletInvoker);
-// ServletContainer servletContainer =
(ServletContainer)container.getComponentInstance(ServletContainer.class);
-// servletContainer.addWebAppListener(portletApplicationRegistry);
-
//Container Stack
ContainerPortletDispatcher portletContainerDispatcher = new
ContainerPortletDispatcher();
EventPayloadInterceptor eventPayloadInterceptor = new EventPayloadInterceptor();
@@ -110,22 +107,9 @@
portletApplicationRegistry.setServletContainer(servletContainer);
contextDispatcherInterceptor.setServletContainer(servletContainer);
-// portletApplicationRegistry.start();
- //servletContainer.addWebAppListener(portletApplicationRegistry);
-
// The portlet container invoker continued
containerPortletInvoker.setNext(valveInterceptor);
- // Federating portlet invoker
- FederatingPortletInvoker federatingPortletInvoker = new
FederatingPortletInvokerService();
-
- // register local portlet invoker with federating portlet invoker
- federatingPortletInvoker.registerInvoker(LOCAL_PORTLET_INVOKER_ID,
containerPortletInvoker);
-
- /* register with container */
- container.registerComponentInstance(PortletInvoker.class,
federatingPortletInvoker);
-
-
// The producer portlet invoker
ProducerPortletInvoker producerPortletInvoker = new ProducerPortletInvoker();
producerPortletInvoker.setNext(containerPortletInvoker);
@@ -134,7 +118,8 @@
producerPortletInvoker.setStateConverter(producerStateConverter);
// register producer portlet invoker so that WSRP can use it
- container.registerComponentInstance(ProducerPortletInvoker.class,
producerPortletInvoker);
+ // TODO: renable this. We cannot have two services registered that provide the
portlet invoker interface
+ //container.registerComponentInstance(ProducerPortletInvoker.class,
producerPortletInvoker);
// The consumer portlet invoker
PortletCustomizationInterceptor portletCustomizationInterceptor = new
PortletCustomizationInterceptor();
@@ -144,8 +129,18 @@
PortletInvokerInterceptor consumerPortletInvoker = new
PortletInvokerInterceptor();
consumerPortletInvoker.setNext(consumerCacheInterceptor);
- container.registerComponentInstance(PortletInvokerInterceptor.class,
consumerPortletInvoker);
+ //container.registerComponentInstance(PortletInvoker.class,
consumerPortletInvoker);
+ // Federating portlet invoker
+ FederatingPortletInvoker federatingPortletInvoker = new
FederatingPortletInvokerService();
+
+ // register local portlet invoker with federating portlet invoker
+ federatingPortletInvoker.registerInvoker(LOCAL_PORTLET_INVOKER_ID,
consumerPortletInvoker);//containerPortletInvoker);
+
+ /* register with container */
+ container.registerComponentInstance(PortletInvoker.class, consumerPortletInvoker);
//federatingPortletInvoker);
+
+
portletApplicationRegistry.start();
}
Modified:
jbossexo/modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
===================================================================
---
jbossexo/modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2009-08-05
15:46:33 UTC (rev 13677)
+++
jbossexo/modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2009-08-05
15:52:40 UTC (rev 13678)
@@ -24,7 +24,6 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.jboss.portal.portlet.PortletInvokerInterceptor;
import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.controller.impl.ControllerRequestFactory;
@@ -105,7 +104,7 @@
//PortletInvoker invoker =
(PortletInvoker)getServletContext().getAttribute(WebBootstrap.BEAN_PREFIX +
"ConsumerPortletInvoker");
ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
- PortletInvoker invoker =
(PortletInvoker)exoContainer.getComponentInstanceOfType(PortletInvokerInterceptor.class);
+ PortletInvoker invoker =
(PortletInvoker)exoContainer.getComponentInstance(PortletInvoker.class);
//
PortalPrepareResponse prepareResponse = new PortalPrepareResponse(req, resp);
Modified: jbossexo/modules/portlet/trunk/portlet/pom.xml
===================================================================
--- jbossexo/modules/portlet/trunk/portlet/pom.xml 2009-08-05 15:46:33 UTC (rev 13677)
+++ jbossexo/modules/portlet/trunk/portlet/pom.xml 2009-08-05 15:52:40 UTC (rev 13678)
@@ -49,6 +49,13 @@
<artifactId>ccpp</artifactId>
</dependency>
+ <!-- temporaily add until we move some of the remaining eXo pc services into the
portlet module -->
+ <dependency>
+ <groupId>org.exoplatform.portletcontainer</groupId>
+ <artifactId>exo.pc.component.common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!--TEST SCOPE-->
<dependency>
<groupId>org.jboss.unit</groupId>
Modified:
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
---
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2009-08-05
15:46:33 UTC (rev 13677)
+++
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2009-08-05
15:52:40 UTC (rev 13678)
@@ -501,9 +501,16 @@
dreq.setAttribute(Constants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(Constants.JAVAX_PORTLET_LIFECYCLE_PHASE, phase);
- //
+ // TODO: look into this a bit more, there are issues on the Portal side about
+ // missing classes if this is not done.
+ ClassLoader currentThread = Thread.currentThread().getContextClassLoader();
+ ClassLoader classloader =
this.getPortletApplication().getContext().getClassLoader();
+ Thread.currentThread().setContextClassLoader(classloader);
+
chain.doFilter(req, resp);
+ Thread.currentThread().setContextClassLoader(currentThread);
+
//
return resp.getResponse();
}
Modified:
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
===================================================================
---
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2009-08-05
15:46:33 UTC (rev 13677)
+++
jbossexo/modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2009-08-05
15:52:40 UTC (rev 13678)
@@ -22,6 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168;
+import org.exoplatform.commons.utils.MapResourceBundle;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.resources.ResourceBundleService;
import org.jboss.portal.common.util.EmptyResourceBundle;
import org.jboss.portal.common.i18n.ParentChildResourceBundle;
import org.jboss.portal.common.i18n.ResourceBundleManager;
@@ -111,7 +115,24 @@
// log.debug("Created bundle " + baseName + " for locale " +
locale);
}
+ // Add portal specific resource bundles to the portlet
+ ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
+ ResourceBundleService bundleService = (ResourceBundleService)
exoContainer.getComponentInstance(ResourceBundleService.class);
+
+ if (bundleService != null)
+ {
+ for (String name : bundleService.getSharedResourceBundleNames())
+ {
+ ResourceBundle sharedResourceBundle = bundleService.getResourceBundle(name,
locale);
+ bundle = new ParentChildResourceBundle(bundle, sharedResourceBundle);
+ }
+ }
+
+ //needed for name recursion
+ MapResourceBundle mapRB = new MapResourceBundle(bundle, locale);
+ mapRB.resolveDependencies();
+
//
- return bundle;
+ return mapRB;
}
}