You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by at...@apache.org on 2008/05/03 15:06:05 UTC
svn commit: r653073 - in /portals/pluto/branches/2.0-spi-refactoring:
pluto-container/src/main/java/org/apache/pluto/
pluto-container/src/main/java/org/apache/pluto/core/
pluto-container/src/main/java/org/apache/pluto/internal/
pluto-portal-driver-impl...
Author: ate
Date: Sat May 3 06:06:05 2008
New Revision: 653073
URL: http://svn.apache.org/viewvc?rev=653073&view=rev
Log:
Getting rid of the servletContext dependency in EventContainer and PortletContainer.
It was only used by the *Portal Driver* EventProviderImpl and it was simple to refactor it out
Also, removing PortletContainer.getPortletApplicationDescriptor method (also only used by the EventProviderImpl).
The EventProviderImpl now appropriately uses the PortletRegisteryService to retrieve a PortletApp instead of delegating to the PortletContainer to do the same.
And yes, all TCK 2.0 tests still passes :)
Modified:
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/Configuration.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/EventContainer.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/EventContainer.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/EventContainer.java Sat May 3 06:06:05 2008
@@ -45,6 +45,4 @@
*/
public void fireEvent(HttpServletRequest request, HttpServletResponse response,
PortletWindow window, Event event) throws PortletException, IOException, PortletContainerException;
-
- public ServletContext getServletContext();
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java Sat May 3 06:06:05 2008
@@ -19,12 +19,9 @@
import java.io.IOException;
import javax.portlet.PortletException;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.pluto.om.portlet.PortletApp;
-
/**
* The publicized entry point into Pluto. The base functionality of the portlet
* container can be enhanced or even modified by PortletContainerServices.
@@ -52,12 +49,10 @@
public interface PortletContainer {
/**
- * Initializes the container for use within the given servlet context.
- * @param servletContext the servlet context.
+ * Initializes the container
* @throws PortletContainerException if an error occurs.
*/
- void init(ServletContext servletContext)
- throws PortletContainerException;
+ void init() throws PortletContainerException;
/**
* Shuts down the container. After calling this method it is no longer valid
@@ -168,22 +163,4 @@
* @return the container services provided by either the portal or the defaults.
*/
OptionalContainerServices getOptionalContainerServices();
-
- /**
- * Retrieve the {@link PortletApp} for the portlet
- * located at the supplied context.
- *
- * Must not return null.
- *
- * @param context the context of the portlet
- * @return the portlet application descriptor
- * @throws PortletContainerException if the container has trouble obtaining
- * the context of the portlet, or retrieving
- * the <code>PortletAppDD</code>
- */
- PortletApp getPortletApplicationDescriptor(String context)
- throws PortletContainerException;
-
- public ServletContext getServletContext();
-
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java Sat May 3 06:06:05 2008
@@ -28,7 +28,6 @@
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -50,14 +49,12 @@
import org.apache.pluto.internal.InternalRenderResponse;
import org.apache.pluto.internal.InternalResourceRequest;
import org.apache.pluto.internal.InternalResourceResponse;
-import org.apache.pluto.internal.PortletDescriptorRegistry;
import org.apache.pluto.internal.PortletEntity;
import org.apache.pluto.internal.impl.EventRequestImpl;
import org.apache.pluto.internal.impl.EventResponseImpl;
import org.apache.pluto.internal.impl.PortletRequestImpl;
import org.apache.pluto.internal.impl.PortletResponseImpl;
import org.apache.pluto.internal.impl.StateAwareResponseImpl;
-import org.apache.pluto.om.portlet.PortletApp;
import org.apache.pluto.spi.EventProvider;
import org.apache.pluto.spi.FilterManager;
import org.apache.pluto.spi.PortletURLProvider;
@@ -92,9 +89,6 @@
/** The optional container services associated with this container. */
private final OptionalContainerServices optionalContainerServices;
- /** The servlet context associated with this container. */
- private ServletContext servletContext;
-
/** Flag indicating whether or not we've been initialized. */
private boolean initialized = false;
@@ -123,14 +117,8 @@
* Initialize the container for use within the given configuration scope.
* @param servletContext the servlet context of the portal webapp.
*/
- public void init(ServletContext servletContext)
+ public void init()
throws PortletContainerException {
- if (servletContext == null) {
- throw new PortletContainerException(
- "Unable to initialize portlet container [" + name + "]: "
- + "servlet context is null.");
- }
- this.servletContext = servletContext;
this.initialized = true;
infoWithName("Container initialized successfully.");
}
@@ -147,7 +135,6 @@
* Destroy this container.
*/
public void destroy() {
- this.servletContext = null;
this.initialized = false;
infoWithName("Container destroyed.");
}
@@ -413,50 +400,6 @@
return optionalContainerServices;
}
- public PortletApp getPortletApplicationDescriptor(String context)
- throws PortletContainerException {
-
- // make sure the container has initialized
- ensureInitialized();
-
- // sanity check
- if (context == null || context.trim().equals("")) {
- final String msg = "Context was null or the empty string.";
- errorWithName(msg);
- throw new PortletContainerException(msg);
- }
-
- // obtain the context of the portlet
- ServletContext portletCtx = PortletContextManager.getPortletContext(servletContext, context);
- if (portletCtx == null) {
- final String msg = "Unable to obtain the servlet context for " +
- "portlet context [" + context + "]. Ensure the portlet has " +
- "been deployed and that cross context support is enabled.";
- errorWithName(msg);
- throw new PortletContainerException(msg);
- }
-
- // obtain the portlet application descriptor for the portlet
- // context.
- PortletApp portletAppDD = PortletDescriptorRegistry
- .getRegistry()
- .getPortletAppDD(portletCtx);
-
- // we can't return null
- if (portletAppDD == null) {
- final String msg = "Obtained a null portlet application description for " +
- "portlet context [" + context + "]";
- errorWithName(msg);
- throw new PortletContainerException(msg);
- }
-
- return portletAppDD;
- }
-
- public ServletContext getServletContext() {
- return servletContext;
- }
-
/**
* Fire Event for the portlet associated with the given portlet window and eventName
* @param portletWindow the portlet window.
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java Sat May 3 06:06:05 2008
@@ -25,15 +25,12 @@
import java.util.List;
import java.util.Map;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pluto.PortletContainerException;
-import org.apache.pluto.internal.Configuration;
import org.apache.pluto.internal.InternalPortletConfig;
import org.apache.pluto.internal.InternalPortletContext;
import org.apache.pluto.internal.PortletDescriptorRegistry;
@@ -266,19 +263,6 @@
LOG.info("Portlet Context '" + context.getApplicationId() + "' removed.");
}
-//
-// Utility
-
- public static ServletContext getPortletContext(ServletContext portalContext, String portletContextPath) {
- if (Configuration.preventUnecessaryCrossContext()) {
- String portalPath = getContextPath(portalContext);
- if (portalPath.equals(portletContextPath)) {
- return portalContext;
- }
- }
- return portalContext.getContext(portletContextPath);
- }
-
/**
* Servlet 2.5 ServletContext.getContextPath() method.
*/
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/Configuration.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/Configuration.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/Configuration.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/Configuration.java Sat May 3 06:06:05 2008
@@ -46,13 +46,6 @@
private static final String BUFFER_SUPPORT =
"org.apache.pluto.ALLOW_BUFFER";
- /**
- * org.apache.pluto.PREVENT_UNECESSARY_CROSS_CONTEXT
- */
- private static final String PREVENT_UNECESSARY_CROSS_CONTEXT =
- "org.apache.pluto.PREVENT_UNECESSARY_CROSS_CONTEXT";
-
-
public static String getPortletAppDescriptorServiceImpl() {
String impl = BUNDLE.getString(DESCRIPTOR_SERVICE);
if (LOG.isDebugEnabled()) {
@@ -73,18 +66,4 @@
}
return buffering.booleanValue();
}
-
- private static Boolean prevent;
-
- public static boolean preventUnecessaryCrossContext() {
- if (prevent == null) {
- try {
- String test = BUNDLE.getString(PREVENT_UNECESSARY_CROSS_CONTEXT);
- prevent = new Boolean(test);
- } catch (MissingResourceException mre) {
- prevent = Boolean.FALSE;
- }
- }
- return prevent.booleanValue();
- }
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java Sat May 3 06:06:05 2008
@@ -201,8 +201,8 @@
* The {@link PortletContainerImpl} to fire the events
*/
public void fireEvents(EventContainer eventContainer) {
- ServletContext servletContext = eventContainer.getServletContext();
- DriverConfiguration driverConfig = (DriverConfiguration) servletContext
+ ServletContext containerServletContext = PortalRequestContext.getContext(request).getServletContext();
+ DriverConfiguration driverConfig = (DriverConfiguration) containerServletContext
.getAttribute(AttributeKeys.DRIVER_CONFIG);
PortalURL portalURL = PortalURLParserImpl.getParser().parse(request);
@@ -215,7 +215,7 @@
this.savedEvents.setProcessed(eActual);
List<String> portletNames = getAllPortletsRegisteredForEvent(
- eActual, driverConfig);
+ eActual, driverConfig, containerServletContext);
Collection<PortletWindowConfig> portlets = getAllPortlets(driverConfig);
@@ -232,7 +232,7 @@
PortletWindowThread portletWindowThread = getPortletWindowThread(
- eventContainer, config, window);
+ eventContainer, config, window, containerServletContext);
// is this event
portletWindowThread.addEvent(eActual);
@@ -253,18 +253,22 @@
}
private List<String> getAllPortletsRegisteredForEvent(Event event,
- DriverConfiguration driverConfig) {
+ DriverConfiguration driverConfig, ServletContext containerServletContext) {
Set<String> resultSet = new HashSet<String>();
List<String> resultList = new ArrayList<String>();
QName eventName = event.getQName();
Collection<PortletWindowConfig> portlets = getAllPortlets(driverConfig);
+ if (portletRegistry == null) {
+ portletRegistry = ((PortletContainer) containerServletContext
+ .getAttribute(AttributeKeys.PORTLET_CONTAINER))
+ .getOptionalContainerServices().getPortletRegistryService();
+ }
for (PortletWindowConfig portlet : portlets) {
String contextPath = portlet.getContextPath();
PortletApp portletAppDD = null;
try {
- portletAppDD = container
- .getPortletApplicationDescriptor(contextPath);
+ portletAppDD = portletRegistry.getPortletApplication(contextPath);
List<Portlet> portletDDs = portletAppDD.getPortlets();
List<QName> aliases = getAllAliases(eventName, portletAppDD);
for (Portlet portletDD : portletDDs) {
@@ -363,10 +367,9 @@
*/
private PortletWindowThread getPortletWindowThread(
EventContainer eventContainer, PortletWindowConfig config,
- PortletWindow window) {
- ServletContext servletContext = eventContainer.getServletContext();
+ PortletWindow window, ServletContext containerServletContext) {
if (portletRegistry == null) {
- portletRegistry = ((PortletContainer) servletContext
+ portletRegistry = ((PortletContainer) containerServletContext
.getAttribute(AttributeKeys.PORTLET_CONTAINER))
.getOptionalContainerServices().getPortletRegistryService();
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java?rev=653073&r1=653072&r2=653073&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java Sat May 3 06:06:05 2008
@@ -181,7 +181,7 @@
// Initialize portlet container.
LOG.debug(" [4] Initializing portlet container...");
- container.init(servletContext);
+ container.init();
// Save portlet container to the servlet context scope.
servletContext.setAttribute(CONTAINER_KEY, container);