David,
I re-factored it a it and called it PortletServletService instead of
PortletPrepareService because really it is a helper to the
PortletServlet.
I have a patch attached to http://issues.apache.org/jira/browse/
PLUTO-328 and attached below.
I would propose that the way to add "events" is to simply add methods
to this Service and scatter them throughout PortletServlet as we need
to.
I would also suggest (not strongly) that we simply fold the adminster
() method into to this new service - after coordinating with Eric
(perhaps another release).
Now off to debugging the Sakai Implementation of this new service...
Almost working :)
And once again - no need to hold up 1.1.1 for this.
/Chuck
On Mar 4, 2007, at 2:22 PM, David H. DeWolf wrote:
I like this . . .and I think we could support additional events as
well. I'd like to come up with an eventing model that's flexible
and easily scales. Do you mind if this waits until 1.1.2 so it
doesn't hold up 1.1.1?
Index:
pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
===================================================================
---
pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
(revision 514462)
+++
pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
(working copy)
@@ -23,6 +23,7 @@
import org.apache.pluto.spi.optional.PortletRegistryService;
import org.apache.pluto.spi.optional.PortletInfoService;
import org.apache.pluto.spi.optional.PortalAdministrationService;
+import org.apache.pluto.spi.optional.PortletServletService;
import org.apache.pluto.spi.optional.UserInfoService;
/**
@@ -41,6 +42,7 @@
private PortletEnvironmentService portletEnvironmentService;
private PortletInfoService portletInfoService;
private PortalAdministrationService portalAdministrationService;
+ private PortletServletService portletServletService;
private UserInfoService userInfoService;
@@ -55,6 +57,7 @@
portletEnvironmentService = new DefaultPortletEnvironmentService();
portletInfoService = new DefaultPortletInfoService();
portalAdministrationService = new DefaultPortalAdministrationService();
+ portletServletService = new DefaultPortletServletService();
userInfoService = new DefaultUserInfoService();
}
@@ -94,6 +97,10 @@
portalAdministrationService =
root.getPortalAdministrationService();
}
+ if(root.getPortletServletService() != null) {
+ portletServletService = root.getPortletServletService();
+ }
+
if(root.getUserInfoService() != null) {
userInfoService = root.getUserInfoService();
}
@@ -128,6 +135,10 @@
return portalAdministrationService;
}
+ public PortletServletService getPortletServletService() {
+ return portletServletService;
+ }
+
public UserInfoService getUserInfoService() {
return userInfoService;
}
Index:
pluto-container/src/main/java/org/apache/pluto/core/DefaultPortletServletService.java
===================================================================
---
pluto-container/src/main/java/org/apache/pluto/core/DefaultPortletServletService.java
(revision 0)
+++
pluto-container/src/main/java/org/apache/pluto/core/DefaultPortletServletService.java
(revision 0)
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.core;
+
+import org.apache.pluto.spi.optional.PortletServletService;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class DefaultPortletServletService implements PortletServletService {
+
+ private List portletServletListeners =
+ new ArrayList();
+
+ public List getPortletServletListeners () {
+ return portletServletListeners ;
+ }
+}
Property changes on:
pluto-container/src/main/java/org/apache/pluto/core/DefaultPortletServletService.java
___________________________________________________________________
Name: svn:keywords
+ Date Revision Author HeadURL Id
Name: svn:eol-style
+ native
Index: pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
===================================================================
--- pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
(revision 514462)
+++ pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
(working copy)
@@ -20,6 +20,8 @@
import org.apache.pluto.PortletContainerException;
import org.apache.pluto.spi.optional.PortalAdministrationService;
import org.apache.pluto.spi.optional.AdministrativeRequestListener;
+import org.apache.pluto.spi.optional.PortletServletService;
+import org.apache.pluto.spi.optional.PortletServletListener;
import org.apache.pluto.descriptors.portlet.PortletAppDD;
import org.apache.pluto.descriptors.portlet.PortletDD;
import org.apache.pluto.internal.InternalPortletConfig;
@@ -195,6 +197,18 @@
(RenderRequestImpl) portletRequest;
RenderResponseImpl renderResponse =
(RenderResponseImpl) portletResponse;
+
+ ContainerInvocation inv = ContainerInvocation.getInvocation();
+ PortletServletService pas =
+ inv.getPortletContainer()
+ .getOptionalContainerServices()
+ .getPortletServletService();
+
+ Iterator it = pas.getPortletServletListeners().iterator();
+ while(it.hasNext()) {
+ PortletServletListener l = (PortletServletListener)
it.next();
+ l.preRender(portletRequest, portletResponse);
+ }
portlet.render(renderRequest, renderResponse);
}
@@ -205,6 +219,19 @@
(ActionRequestImpl) portletRequest;
ActionResponseImpl actionResponse =
(ActionResponseImpl) portletResponse;
+
+ ContainerInvocation inv = ContainerInvocation.getInvocation();
+ PortletServletService pas =
+ inv.getPortletContainer()
+ .getOptionalContainerServices()
+ .getPortletServletService();
+
+ Iterator it = pas.getPortletServletListeners().iterator();
+ while(it.hasNext()) {
+ PortletServletListener l = (PortletServletListener)
it.next();
+ l.preAction(portletRequest, portletResponse);
+ }
+
portlet.processAction(actionRequest, actionResponse);
}
@@ -216,7 +243,7 @@
.getOptionalContainerServices()
.getPortalAdministrationService();
- Iterator it =
pas.getAdministrativeRequestListeners().iterator();
+ Iterator it =
pas.getAdministrativeRequestListeners().iterator();
while(it.hasNext()) {
AdministrativeRequestListener l
=(AdministrativeRequestListener)it.next();
l.administer(portletRequest, portletResponse);
Index:
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletService.java
===================================================================
---
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletService.java
(revision 0)
+++
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletService.java
(revision 0)
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.spi.optional;
+
+import java.util.List;
+
+/**
+ * Provides callback for executing portal administration
+ * tasks within the portlet environment. This is key for
+ * when the portal needs to accessing items such as the
+ * session.
+ *
+ * Example Use Cases:
+ * <ul>
+ * <li>PortletException
+ * <p>The portal wants to ensure that portlets never
+ * become stuck in an unusable state. To make sure
+ * this happens, they want the ability to clear the
+ * session if they repetedly catch exception from
+ * container invocations
+ * </p>
+ * <p>By implementing this services and registering
+ * and administrative request handler, the portal
+ * can invoke the doAdmin method of the container
+ * and then receive the request through the handler
+ * executing within the portlet environment (as
+ * opposed to the portal environment)
+ * </p>
+ * </li>
+ * </ul>
+ */
+public interface PortletServletService {
+
+ List getPortletServletListeners();
+
+}
Property changes on:
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletService.java
___________________________________________________________________
Name: svn:keywords
+ Date Revision Author HeadURL Id
Name: svn:eol-style
+ native
Index:
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletListener.java
===================================================================
---
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletListener.java
(revision 0)
+++
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletListener.java
(revision 0)
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.spi.optional;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+
+
+public interface PortletServletListener {
+
+ void preRender(PortletRequest request, PortletResponse response);
+
+ void preAction(PortletRequest request, PortletResponse response);
+
+}
Property changes on:
pluto-container/src/main/java/org/apache/pluto/spi/optional/PortletServletListener.java
___________________________________________________________________
Name: svn:keywords
+ Date Revision Author HeadURL Id
Name: svn:eol-style
+ native
Index:
pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
===================================================================
---
pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
(revision 514462)
+++
pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
(working copy)
@@ -22,6 +22,7 @@
import org.apache.pluto.spi.optional.PortletRegistryService;
import org.apache.pluto.spi.optional.PortletInfoService;
import org.apache.pluto.spi.optional.PortalAdministrationService;
+import org.apache.pluto.spi.optional.PortletServletService;
import org.apache.pluto.spi.optional.UserInfoService;
/**
@@ -87,6 +88,14 @@
*/
PortalAdministrationService getPortalAdministrationService();
+ /**
+ * Returns the service implementation used by
+ * the container in PortletServlet just prior to the
+ * Render and Action calls
+ *
+ * @return portlet preparation service
+ */
+ PortletServletService getPortletServletService();
/**
* Returns the user info service implementation used
Index:
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
===================================================================
---
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
(revision 514462)
+++
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
(working copy)
@@ -27,6 +27,7 @@
import org.apache.pluto.spi.optional.PortletRegistryService;
import org.apache.pluto.spi.optional.PortletInfoService;
import org.apache.pluto.spi.optional.PortalAdministrationService;
+import org.apache.pluto.spi.optional.PortletServletService;
import org.apache.pluto.spi.optional.UserInfoService;
import javax.portlet.PortalContext;
@@ -107,6 +108,11 @@
return null;
}
+ public PortletServletService getPortletServletService () {
+ return null;
+ }
+
+
public UserInfoService getUserInfoService() {
return null;
}