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/10/16 12:07:44 UTC
svn commit: r705194 - in /portals/pluto/branches/2.0-spi-refactoring:
pluto-container-api/src/main/java/org/apache/pluto/core/
pluto-container-api/src/main/java/org/apache/pluto/spi/optional/
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driv...
Author: ate
Date: Thu Oct 16 03:07:42 2008
New Revision: 705194
URL: http://svn.apache.org/viewvc?rev=705194&view=rev
Log:
PLUTO-509: final cleanup of the Portlet API model beans
- fixing Pluto Portal Driver internal usage of the PortletApplication id as contextPath reference
- also added startup timer handling in the PortletServlet, (similar/based upon JetspeedContainerServlet) as PlutoServices might not yet have been initialized.
Modified:
portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/spi/optional/PortletRegistryService.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-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedWindowStateServiceImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
portals/pluto/branches/2.0-spi-refactoring/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java Thu Oct 16 03:07:42 2008
@@ -18,6 +18,8 @@
import java.io.IOException;
import java.util.Iterator;
+import java.util.Timer;
+import java.util.TimerTask;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -32,6 +34,7 @@
import javax.portlet.ResourceResponse;
import javax.portlet.ResourceServingPortlet;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -99,6 +102,9 @@
private ContainerInvocationService containerInvocationService;
+ private boolean started = false;
+ private Timer startTimer = null;
+
// HttpServlet Impl --------------------------------------------------------
public String getServletInfo()
@@ -112,92 +118,99 @@
* @throws ServletException
* if an error occurs while loading portlet.
*/
- public void init() throws ServletException
+ public void init(ServletConfig config) throws ServletException
{
// Call the super initialization method.
- super.init();
+ super.init(config);
// Retrieve portlet name as defined as an initialization parameter.
portletName = getInitParameter("portlet-name");
- registryService = PlutoServices.getServices()
- .getPortletRegistryService();
- if (registryService == null) // TODO: wait for Pluto to come on line
- { throw new ServletException(
- "Pluto container has not yet come online, startup sequence error, registry service not available");
+ started = false;
- }
- containerInvocationService = PlutoServices.getServices()
- .getContainerInvocationService();
- if (containerInvocationService == null) // TODO: wait for Pluto to come
- // on line
- { throw new ServletException(
- "Pluto container has not yet come online, startup sequence error, container invocation service not available");
-
- }
- try
+ startTimer = new Timer(true);
+ final ServletContext servletContext = getServletContext();
+ final ClassLoader paClassLoader = Thread.currentThread().getContextClassLoader();
+ startTimer.schedule(new TimerTask()
{
- ServletConfig sConfig = getServletConfig();
- if (sConfig == null)
+ public void run()
{
- String msg = "Problem obtaining servlet configuration(getServletConfig() returns null).";
- throw new PortletContainerException(msg);
+ if (startTimer != null)
+ {
+ if (attemptRegistration(servletContext, paClassLoader ))
+ {
+ startTimer.cancel();
+ startTimer = null;
+ }
+ }
}
+ }, 1, 10000);
+ }
+
+ protected boolean attemptRegistration(ServletContext context, ClassLoader paClassLoader)
+ {
+ if (PlutoServices.getServices() != null)
+ {
+ registryService = PlutoServices.getServices().getPortletRegistryService();
+ containerInvocationService = PlutoServices.getServices().getContainerInvocationService();
+ try
+ {
+ ServletConfig sConfig = getServletConfig();
+ if (sConfig == null)
+ {
+ String msg = "Problem obtaining servlet configuration(getServletConfig() returns null).";
+ context.log(msg);
+ return true;
+ }
- String applicationName = registryService.register(sConfig);
- portletContext = (InternalPortletContext) registryService
- .getPortletContext(applicationName);
- portletConfig = (InternalPortletConfig) registryService
- .getPortletConfig(applicationName, portletName);
+ String applicationName = registryService.register(sConfig);
+ portletContext = (InternalPortletContext) registryService.getPortletContext(applicationName);
+ portletConfig = (InternalPortletConfig) registryService.getPortletConfig(applicationName, portletName);
- }
- catch (PortletContainerException ex)
- {
- System.err.println(ex.getMessage());
- throw new ServletException(ex);
- }
+ }
+ catch (PortletContainerException ex)
+ {
+ context.log(ex.getMessage(),ex);
+ return true;
+ }
- PortletDefinition portletDD = portletConfig.getPortletDefinition();
+ PortletDefinition portletDD = portletConfig.getPortletDefinition();
- // Create and initialize the portlet wrapped in the servlet.
- try
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class clazz = loader.loadClass((portletDD.getPortletClass()));
- portlet = (Portlet) clazz.newInstance();
- portlet.init(portletConfig);
- initializeEventPortlet();
- initializeResourceServingPortlet();
- }
- catch (ClassNotFoundException ex)
- {
- System.err.println(ex.getMessage());
- throw new ServletException(ex);
- }
- catch (IllegalAccessException ex)
- {
- System.err.println(ex.getMessage());
- throw new ServletException(ex);
- }
- catch (InstantiationException ex)
- {
- System.err.println(ex.getMessage());
- throw new ServletException(ex);
- }
- catch (PortletException ex)
- {
- System.err.println(ex.getMessage());
- throw new ServletException(ex);
+// Create and initialize the portlet wrapped in the servlet.
+ try
+ {
+ Class clazz = paClassLoader.loadClass((portletDD.getPortletClass()));
+ portlet = (Portlet) clazz.newInstance();
+ portlet.init(portletConfig);
+ initializeEventPortlet();
+ initializeResourceServingPortlet();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ context.log(ex.getMessage(),ex);
+ return true;
+ }
}
+ return false;
}
public void destroy()
{
- registryService.remove(portletContext);
- if (portlet != null)
+ if ( startTimer != null )
+ {
+ startTimer.cancel();
+ startTimer = null;
+ }
+ else if ( started )
{
- portlet.destroy();
+ started = false;
+ registryService.remove(portletContext);
+ if (portlet != null)
+ {
+ portlet.destroy();
+ }
}
super.destroy();
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/spi/optional/PortletRegistryService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/spi/optional/PortletRegistryService.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/spi/optional/PortletRegistryService.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container-api/src/main/java/org/apache/pluto/spi/optional/PortletRegistryService.java Thu Oct 16 03:07:42 2008
@@ -84,7 +84,7 @@
/**
* Retreive the Portlet for the specified portlet.
*
- * @param applicationId portlet application name
+ * @param applicationName portlet application name
* @param portletName portlet name
* @return portlet
* @throws PortletContainerException if portlet or application unknown
@@ -104,7 +104,7 @@
/**
* Retrieve the ClassLoader of the specified portlet application
- * @param applicationId portlet application name
+ * @param applicationName portlet application name
* @return classLoader
*/
ClassLoader getClassLoader(String applicationName)
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=705194&r1=705193&r2=705194&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 Thu Oct 16 03:07:42 2008
@@ -266,9 +266,14 @@
for (PortletWindowConfig portlet : portlets) {
String contextPath = portlet.getContextPath();
+ String applicationName = contextPath;
+ if (applicationName.length() >0 )
+ {
+ applicationName = applicationName.substring(1);
+ }
PortletApplicationDefinition portletAppDD = null;
try {
- portletAppDD = portletRegistry.getPortletApplication(contextPath);
+ portletAppDD = portletRegistry.getPortletApplication(applicationName);
List<PortletDefinition> portletDDs = portletAppDD.getPortlets();
List<QName> aliases = getAllAliases(eventName, portletAppDD);
for (PortletDefinition portletDD : portletDDs) {
@@ -505,6 +510,12 @@
.getContext(request).getServletContext();
String applicationId = PortletWindowConfig
.parseContextPath(portletWindow.getId().getStringId());
+ String applicationName = applicationId;
+ if (applicationId.length() >0 )
+ {
+ applicationName = applicationId.substring(1);
+ }
+
String portletName = PortletWindowConfig
.parsePortletName(portletWindow.getId().getStringId());
if (portletRegistry == null) {
@@ -514,7 +525,7 @@
}
List<EventDefinitionReference> events = null;
try {
- events = portletRegistry.getPortlet(applicationId,
+ events = portletRegistry.getPortlet(applicationName,
portletName).getSupportedPublishingEvents();
} catch (PortletContainerException e1) {
e1.printStackTrace();
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.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/impl/resource/SupportedModesServiceImpl.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java Thu Oct 16 03:07:42 2008
@@ -92,6 +92,11 @@
public boolean isPortletModeSupportedByPortlet(String portletId, String mode) {
String applicationId = PortletWindowConfig.parseContextPath(portletId);
+ String applicationName = applicationId;
+ if (applicationName.length() >0 )
+ {
+ applicationName = applicationName.substring(1);
+ }
String portletName = PortletWindowConfig.parsePortletName(portletId);
// since SupportedModesService is consulted per portal portal mode per portlet
// per render request, store a reference to the registry instead of looking
@@ -108,7 +113,7 @@
LOG.error("Optional Portlet Registry Service not found.");
throw new PortletContainerException("Optional Portlet Registry Service not found.");
}
- PortletApplicationDefinition ctx = portletRegistry.getPortletApplication(applicationId);
+ PortletApplicationDefinition ctx = portletRegistry.getPortletApplication(applicationName);
Iterator i = ctx.getPortlets().iterator();
while(i.hasNext()) {
PortletDefinition dd = (PortletDefinition)i.next();
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedWindowStateServiceImpl.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/impl/resource/SupportedWindowStateServiceImpl.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedWindowStateServiceImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedWindowStateServiceImpl.java Thu Oct 16 03:07:42 2008
@@ -142,6 +142,11 @@
// we look to see if it is a custom window state.
String appId = PortletWindowConfig.parseContextPath(portletId);
+ String applicationName = appId;
+ if (applicationName.length() >0 )
+ {
+ applicationName = applicationName.substring(1);
+ }
PortletApplicationDefinition portletAppDD = null;
if (portletRegistry == null)
@@ -155,7 +160,7 @@
try
{
- portletAppDD = portletRegistry.getPortletApplication(appId);
+ portletAppDD = portletRegistry.getPortletApplication(applicationName);
}
catch ( PortletContainerException e )
{
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Thu Oct 16 03:07:42 2008
@@ -209,9 +209,15 @@
private void setPublicRenderParameter(HttpServletRequest request, PortalURL portalURL, String portletID)throws ServletException, PortletContainerException {
String applicationId = PortletWindowConfig.parseContextPath(portletID);
+ String applicationName = applicationId;
+ if (applicationName.length() >0 )
+ {
+ applicationName = applicationName.substring(1);
+ }
+
String portletName = PortletWindowConfig.parsePortletName(portletID);
PortletDefinition portletDD = container.getOptionalContainerServices().getPortletRegistryService()
- .getPortlet(applicationId, portletName);
+ .getPortlet(applicationName, portletName);
Enumeration<String> parameterNames = request.getParameterNames();
if (parameterNames != null){
while(parameterNames.hasMoreElements()){
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java Thu Oct 16 03:07:42 2008
@@ -58,11 +58,17 @@
this.portalURL = portalURL;
try
{
- this.entity = new PortletEntityImpl(container.getOptionalContainerServices().getPortletRegistryService().getPortlet(config.getContextPath(), config.getPortletName()));
+ String applicationName = config.getContextPath();
+ if (applicationName.length() >0 )
+ {
+ applicationName = applicationName.substring(1);
+ }
+ this.entity = new PortletEntityImpl(container.getOptionalContainerServices().getPortletRegistryService().getPortlet(applicationName, config.getPortletName()));
}
catch (PortletContainerException ex)
{
String message = "Unable to load Portlet App Deployment Descriptor:"+ ex.getMessage();
+ ex.printStackTrace();
LOG.error(message, ex);
throw new RuntimeException(message);
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java Thu Oct 16 03:07:42 2008
@@ -74,13 +74,18 @@
public void doAddPortlet(ActionRequest request) {
String page = request.getParameter("page");
- String applicationId = request.getParameter("applications");
- String portletId = request.getParameter("availablePortlets");
+ String applicationName = request.getParameter("applications");
+ String portletName = request.getParameter("availablePortlets");
- LOG.info("Request: Add [applicationId=" + applicationId + ":portletId=" + portletId + "] to page '" + page + "'");
+ LOG.info("Request: Add [applicationName=" + applicationName + ":portletName=" + portletName + "] to page '" + page + "'");
+ String contextPath = applicationName;
+ if (contextPath.length() > 0)
+ {
+ contextPath = "/" + contextPath;
+ }
PageConfig config = getPageConfig(page);
- config.addPortlet(applicationId, portletId);
+ config.addPortlet(contextPath, portletName);
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp?rev=705194&r1=705193&r2=705194&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp Thu Oct 16 03:07:42 2008
@@ -96,10 +96,10 @@
<script type="text/javascript">
var <portlet:namespace/>portlets = new Array();
<c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.portletContexts}" var="app">
- <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'] = new Array();
- <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'][0] = 'Select. . .';
+ <portlet:namespace/>portlets['<c:out value="${app.applicationName}"/>'] = new Array();
+ <portlet:namespace/>portlets['<c:out value="${app.applicationName}"/>'][0] = 'Select. . .';
<c:forEach items="${app.portletApplicationDefinition.portlets}" var="portlet" varStatus="loopStatus">
- <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'][<c:out value="${loopStatus.index + 1}"/>] = '<c:out value="${portlet.portletName}"/>';
+ <portlet:namespace/>portlets['<c:out value="${app.applicationName}"/>'][<c:out value="${loopStatus.index + 1}"/>] = '<c:out value="${portlet.portletName}"/>';
</c:forEach>
</c:forEach>
@@ -129,7 +129,7 @@
<select name="applications" onChange="<portlet:namespace/>doSwitch(this)">
<option value='-'>Select. . .</option>
<c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.portletContexts}" var="app">
- <option value="<c:out value="${app.applicationId}"/>"><c:out value="${app.applicationName}"/></option>
+ <option value="<c:out value="${app.applicationName}"/>"><c:out value="${app.applicationName}"/></option>
</c:forEach>
</select>