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 zh...@apache.org on 2006/01/24 18:51:09 UTC
svn commit: r371965 - in
/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver:
./ config/ core/ services/portal/
Author: zheng
Date: Tue Jan 24 09:50:58 2006
New Revision: 371965
URL: http://svn.apache.org/viewcvs?rev=371965&view=rev
Log:
Updated javadoc, removed PortletWindowConfig.id (which is not necessary and should be generated.
Modified:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Tue Jan 24 09:50:58 2006
@@ -39,7 +39,8 @@
* The controller servlet used to drive the Portal Driver. All requests mapped
* to this servlet will be processed as Portal Requests.
*
- * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @version 1.0
* @since Sep 22, 2004
*/
@@ -50,51 +51,47 @@
/** The portlet container to which we will forward all portlet requests. */
protected PortletContainer container = null;
-
+
+
+ // HttpServlet Impl --------------------------------------------------------
+
+ public String getServletInfo() {
+ return "Pluto Portal Driver Servlet";
+ }
+
/**
- * Initialize the Portal Driver. Initialization completes the following
- * tasks:
- * <ul>
- * <li>Retrieve and cache the <code>PortletContainer</code>.</li>
- * <li>Retrieve and cache the <code>DriverConfigurationImpl</code>.</li>
- * </ul>
+ * Initialize the Portal Driver. This method retrieves the portlet container
+ * instance from the servlet context scope.
* @see PortletContainer
- * @see DriverConfiguration
*/
public void init() {
ServletContext servletContext = getServletContext();
container = (PortletContainer) servletContext.getAttribute(
AttributeKeys.PORTLET_CONTAINER);
- }
-
- private DriverConfiguration getDriverConfiguration() {
- return (DriverConfiguration) getServletContext()
- .getAttribute(AttributeKeys.DRIVER_CONFIG);
}
-
+
/**
- * Handle all requests.
+ * Handle all requests. All POST requests are passed to this method.
* @param request the incoming HttpServletRequest.
* @param response the incoming HttpServletResponse.
* @throws ServletException if an internal error occurs.
* @throws IOException if an error occurs writing to the response.
*/
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- PortalEnvironment environment = new PortalEnvironment(
+ PortalEnvironment portalEnvironment = new PortalEnvironment(
request, response);
- PortalURL currentURL = environment.getRequestedPortalURL();
+ PortalURL currentURL = portalEnvironment.getRequestedPortalURL();
String actionWindowId = currentURL.getActionWindow();
- PortletWindowConfig windowConfig = getDriverConfiguration().getPortletWindowConfig(
- actionWindowId);
+ PortletWindowConfig actionWindowConfig = getDriverConfiguration()
+ .getPortletWindowConfig(actionWindowId);
- // Window will only exist if there's an action.
- if (windowConfig != null) {
+ // Action window config will only exist if there is an action request.
+ if (actionWindowConfig != null) {
PortletWindowImpl portletWindow = new PortletWindowImpl(
- windowConfig, currentURL);
+ actionWindowConfig, currentURL);
if (LOG.isDebugEnabled()) {
LOG.debug("Processing action request for window: "
+ portletWindow.getId());
@@ -106,7 +103,10 @@
} catch (PortletException ex) {
throw new ServletException(ex);
}
- } else {
+ }
+
+ // Otherwise, handle the render request.
+ else {
PageConfig pageConfig = getPageConfig(currentURL);
request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
String uri = pageConfig.getUri();
@@ -115,27 +115,39 @@
}
}
- protected PageConfig getPageConfig(PortalURL currentURL) {
- String currentPage = currentURL.getRenderPath();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Rendering Portal: Requested Page: " + currentPage);
- }
- return getDriverConfiguration().getPageConfig(currentPage);
- }
-
-
/**
- * Pass all requests to {@link #doPost(HttpServletRequest, HttpServletResponse)}.
+ * Pass all POST requests to {@link #doGet(HttpServletRequest, HttpServletResponse)}.
* @param request the incoming servlet request.
* @param response the incoming servlet response.
* @throws ServletException if an exception occurs.
* @throws IOException if an exception occurs writing to the response.
*/
- public void doPost(HttpServletRequest request,
- HttpServletResponse response)
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
+
+
+ // Private Methods ---------------------------------------------------------
+
+ private PageConfig getPageConfig(PortalURL currentURL) {
+ String currentPage = currentURL.getRenderPath();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Rendering Portal: Requested Page: " + currentPage);
+ }
+ return getDriverConfiguration().getPageConfig(currentPage);
+ }
+
+ /**
+ * Returns the portal driver configuration object.
+ * @return the portal driver configuration object.
+ */
+ private DriverConfiguration getDriverConfiguration() {
+ return (DriverConfiguration) getServletContext().getAttribute(
+ AttributeKeys.DRIVER_CONFIG);
+ }
+
+
}
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java Tue Jan 24 09:50:58 2006
@@ -49,13 +49,17 @@
/** The KEY with which the container is bound to the context. */
private static final String CONTAINER_KEY = AttributeKeys.PORTLET_CONTAINER;
- /** The KEY with which the configuration is bound to the context. */
- private static final String CONFIG_KEY = AttributeKeys.DRIVER_CONFIG;
-
- private static final String ADMIN_KEY = AttributeKeys.DRIVER_ADMIN_CONFIG;
+ /** The KEY with which the driver configuration is bound to the context. */
+ private static final String DRIVER_CONFIG_KEY = AttributeKeys.DRIVER_CONFIG;
+ /** The KEY with which the admin configuration is bound to the context. */
+ private static final String ADMIN_CONFIG_KEY = AttributeKeys.DRIVER_ADMIN_CONFIG;
+
+
+ // ServletContextListener Impl ---------------------------------------------
+
/**
- * Receive the startup notification and subsequently start up the portal
+ * Receives the startup notification and subsequently starts up the portal
* driver. The following are done in this order:
* <ol>
* <li>Retrieve the ResourceConfig File</li>
@@ -72,15 +76,12 @@
*/
public void contextInitialized(ServletContextEvent event) {
ServletContext servletContext = event.getServletContext();
-
if (LOG.isInfoEnabled()) {
LOG.info("Starting up Pluto Portal Driver...");
}
-
initDriverConfiguration(servletContext);
initAdminConfiguration(servletContext);
initContainer(servletContext);
-
}
/**
@@ -96,126 +97,131 @@
destroyDriverConfiguration(servletContext);
}
-
-
+
+
+ // Private Initialization Methods ------------------------------------------
+
/**
- * Initialized the Portal Driver Configuration.
- *
- * @param servletContext
+ * Initializes the Portal Driver Configuration. This method loads the driver
+ * configuration object and saves it to the servlet context scope.
+ * @param servletContext the servlet context.
*/
private void initDriverConfiguration(ServletContext servletContext) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(" * Initializing Portal Driver Configuration...");
- }
-
- DriverConfiguration config = DriverConfigurationFactory
- .getFactory().getConfig(servletContext);
-
- if(config == null && LOG.isErrorEnabled()) {
- LOG.error("* Unable to locate Portal Driver Configuration.");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Initializing Portal Driver Configuration...");
}
- else if(config != null) {
- servletContext.setAttribute(CONFIG_KEY, config);
- if(LOG.isInfoEnabled()) {
- LOG.info("* Driver Configuration initialized to: "+config.getClass().getName());
+ DriverConfiguration driverConfig = DriverConfigurationFactory
+ .getFactory().getConfig(servletContext);
+ if (driverConfig == null) {
+ LOG.error("Unable to locate Portal Driver Configuration.");
+ } else {
+ servletContext.setAttribute(DRIVER_CONFIG_KEY, driverConfig);
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Driver Configuration initialized to: "
+ + driverConfig.getClass().getName());
}
}
}
/**
- * Initialize the Admin Configuration if available.
- * @param context
+ * Initializes the Admin Configuration if available. This method tries to
+ * load the admin configuration object. If it is not available,
+ * administration will not be allowed. Otherwise, saves it to the servlet
+ * context scope.
+ * @param servletContext the servlet context.
*/
- private void initAdminConfiguration(ServletContext context) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("* Initializing Portal Admin Configuration. . .");
- }
-
- AdminConfiguration config = DriverConfigurationFactory.getFactory()
- .getAdminConfig(context);
-
- if(config == null && LOG.isWarnEnabled()) {
- LOG.warn("* Admin Configuration not available. Administration will not be allowed.");
+ private void initAdminConfiguration(ServletContext servletContext) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Initializing Portal Admin Configuration...");
}
- else if(config != null) {
- context.setAttribute(ADMIN_KEY, config);
- if(LOG.isInfoEnabled()) {
- LOG.info("* Admin Configuration initialized to: "+config.getClass().getName());
+ AdminConfiguration adminConfig = DriverConfigurationFactory
+ .getFactory().getAdminConfig(servletContext);
+ if (adminConfig == null) {
+ LOG.warn("Admin Configuration not available. "
+ + "Administration will not be allowed.");
+ } else {
+ servletContext.setAttribute(ADMIN_CONFIG_KEY, adminConfig);
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Admin Configuration initialized to: "
+ + adminConfig.getClass().getName());
}
}
}
/**
- * Initialize the Container.
- * @param context
+ * Initializes the portlet container. This method constructs and initializes
+ * the portlet container, and saves it to the servlet context scope.
+ * @param servletContext the servlet context.
*/
- private void initContainer(ServletContext context) {
- DriverConfiguration config = (DriverConfiguration)
- context.getAttribute(CONFIG_KEY);
-
+ private void initContainer(ServletContext servletContext) {
+
+ // Retrieve the driver configuration from servlet context.
+ DriverConfiguration driverConfig = (DriverConfiguration)
+ servletContext.getAttribute(DRIVER_CONFIG_KEY);
+
try {
+
+ // Create portal context.
if (LOG.isDebugEnabled()) {
- LOG.debug(" * Creating portal context ["
- + config.getPortalName() + "/"
- + config.getPortalVersion() + "]...");
+ LOG.debug("Creating portal context ["
+ + driverConfig.getPortalName() + "/"
+ + driverConfig.getPortalVersion() + "]...");
}
-
- PortalContextImpl portalContext = new PortalContextImpl(config);
-
+ PortalContextImpl portalContext =
+ new PortalContextImpl(driverConfig);
+
+ // Create container services.
if (LOG.isDebugEnabled()) {
- LOG.debug(" * Creating container services...");
+ LOG.debug("Creating container services...");
}
ContainerServicesImpl containerServices =
- new ContainerServicesImpl(
- portalContext,
- config
- );
-
+ new ContainerServicesImpl(portalContext, driverConfig);
+
+ // Create portlet container.
if (LOG.isDebugEnabled()) {
- LOG.debug(" * Creating portlet container...");
+ LOG.debug("Creating portlet container...");
}
-
PortletContainerFactory factory =
- PortletContainerFactory.getInstance();
-
+ PortletContainerFactory.getInstance();
PortletContainer container = factory.createContainer(
- config.getContainerName(),
+ driverConfig.getContainerName(),
containerServices,
- containerServices
- );
-
+ containerServices);
+
+ // Initialize portlet container.
if (LOG.isDebugEnabled()) {
- LOG.debug(" * Initializing portlet container...");
+ LOG.debug("Initializing portlet container...");
}
-
- container.init(context);
+ container.init(servletContext);
+ // Save portlet container to the servlet context scope.
+ servletContext.setAttribute(CONTAINER_KEY, container);
if (LOG.isInfoEnabled()) {
LOG.info("Pluto Portal Driver started.");
}
- context.setAttribute(CONTAINER_KEY, container);
-
} catch (DriverConfigurationException ex) {
LOG.error("Unable to retrieve driver configuration "
- + "due to configuration error: " + ex.getMessage(), ex
- );
+ + "due to configuration error: " + ex.getMessage(), ex);
} catch (PortletContainerException ex) {
LOG.error("Unable to start up portlet container: "
- + ex.getMessage(), ex
- );
+ + ex.getMessage(), ex);
}
}
-
-
+
+
+ // Private Destruction Methods ---------------------------------------------
+
+ /**
+ * Destroyes the portlet container and removes it from servlet context.
+ * @param servletContext the servlet context.
+ */
private void destroyContainer(ServletContext servletContext) {
if (LOG.isInfoEnabled()) {
LOG.info("Shutting down Pluto Portal Driver...");
}
-
PortletContainer container = (PortletContainer)
servletContext.getAttribute(CONTAINER_KEY);
-
if (container != null) {
try {
container.destroy();
@@ -230,44 +236,50 @@
}
}
}
-
+
+ /**
+ * Destroyes the portal driver config and removes it from servlet context.
+ * @param servletContext the servlet context.
+ */
private void destroyDriverConfiguration(ServletContext servletContext) {
- DriverConfiguration config = (DriverConfiguration)
- servletContext.getAttribute(CONFIG_KEY);
-
- if(config != null) {
+ DriverConfiguration driverConfig = (DriverConfiguration)
+ servletContext.getAttribute(DRIVER_CONFIG_KEY);
+ if (driverConfig != null) {
try {
- config.destroy();
- if(LOG.isInfoEnabled()) {
- LOG.info("Pluto Portal Driver Config shutdown.");
+ driverConfig.destroy();
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Pluto Portal Driver Config destroyed.");
}
- }
- catch(DriverConfigurationException dce) {
-
- }
- finally {
- servletContext.removeAttribute(CONFIG_KEY);
+ } catch (DriverConfigurationException ex) {
+ LOG.error("Unable to destroy portal driver config: "
+ + ex.getMessage(), ex);
+ } finally {
+ servletContext.removeAttribute(DRIVER_CONFIG_KEY);
}
}
}
+
+ /**
+ * Destroyes the portal admin config and removes it from servlet context.
+ * @param servletContext the servlet context.
+ */
private void destroyAdminConfiguration(ServletContext servletContext) {
- AdminConfiguration config = (AdminConfiguration)
- servletContext.getAttribute(ADMIN_KEY);
-
- if(config != null) {
+ AdminConfiguration adminConfig = (AdminConfiguration)
+ servletContext.getAttribute(ADMIN_CONFIG_KEY);
+ if (adminConfig != null) {
try {
- config.destroy();
- if(LOG.isInfoEnabled()) {
- LOG.info("Pluto Portal Admin Config shutdown.");
+ adminConfig.destroy();
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Pluto Portal Admin Config destroyed.");
}
- }
- catch(DriverConfigurationException dce) {
-
- }
- finally {
- servletContext.removeAttribute(ADMIN_KEY);
+ } catch(DriverConfigurationException ex) {
+ LOG.error("Unable to destroy portal admin config: "
+ + ex.getMessage(), ex);
+ } finally {
+ servletContext.removeAttribute(ADMIN_CONFIG_KEY);
}
}
}
+
}
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java Tue Jan 24 09:50:58 2006
@@ -17,18 +17,14 @@
import org.apache.pluto.PortletContainer;
import org.apache.pluto.driver.services.portal.PageConfig;
-import org.apache.pluto.driver.services.portal.PortletWindowConfig;
import org.apache.pluto.driver.config.AdminConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import java.util.ArrayList;
-import java.text.NumberFormat;
import java.io.IOException;
/**
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java Tue Jan 24 09:50:58 2006
@@ -25,90 +25,103 @@
import java.io.InputStream;
/**
- * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ *
+ * @see DriverConfiguration
+ * @see AdminConfiguration
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @version 1.0
* @since Sep 23, 2004
*/
public class DriverConfigurationFactory {
-
- private static final Log LOG =
- LogFactory.getLog(DriverConfigurationFactory.class);
-
- private static final String DRIVER_CONFIG =
- "/WEB-INF/pluto-portal-driver-services-config.xml";
-
-
- private static DriverConfigurationFactory factory;
-
+
+ /** Logger. */
+ private static final Log LOG = LogFactory.getLog(
+ DriverConfigurationFactory.class);
+
+ /** Portal driver services configuration file name. */
+ private static final String DRIVER_CONFIG_FILE =
+ "/WEB-INF/pluto-portal-driver-services-config.xml";
+
+ /** The singleton factory instance. */
+ private static final DriverConfigurationFactory factory =
+ new DriverConfigurationFactory();
+
+
+ // Private Member Variables ------------------------------------------------
+
+ private XmlBeanFactory beanFactory = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Private constructor that prevents external instantiation.
+ */
+ private DriverConfigurationFactory() {
+ // Do nothing.
+ }
+
+ /**
+ * Returns the singleton factory instance.
+ * @return the singleton factory instance.
+ */
public static DriverConfigurationFactory getFactory() {
- if (factory == null) {
- factory = new DriverConfigurationFactory();
- }
return factory;
}
-
- private XmlBeanFactory beanFactory;
-
- private DriverConfigurationFactory() {
-
- }
-
- public DriverConfiguration getConfig(ServletContext context) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Retrieving driver configuration from: "+DRIVER_CONFIG);
+
+
+ // Public Methods ----------------------------------------------------------
+
+ public DriverConfiguration getConfig(ServletContext servletContext) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Retrieving driver config from: " + DRIVER_CONFIG_FILE);
}
-
try {
- DriverConfiguration configuration = (DriverConfiguration)
- getBeanFactory(context).getBean("DriverConfiguration");
-
- configuration.init(context);
-
-
+ DriverConfiguration driverConfig = (DriverConfiguration)
+ getBeanFactory(servletContext).getBean(
+ "DriverConfiguration");
+ driverConfig.init(servletContext);
if(LOG.isDebugEnabled()) {
- LOG.debug(
- "Driver ResourceConfig of type "+configuration.getClass() +
- " Initialized and Ready For Service"
- );
+ LOG.debug("Driver config of type " + driverConfig.getClass()
+ + " Initialized and Ready For Service.");
}
- return configuration;
- }
- catch(NoSuchBeanDefinitionException nsbde) {
- throw new DriverConfigurationException("Unable to find Driver Configuration.", nsbde);
+ return driverConfig;
+ } catch(NoSuchBeanDefinitionException ex) {
+ throw new DriverConfigurationException(
+ "Unable to find Driver Configuration.", ex);
}
-
}
-
-
- public AdminConfiguration getAdminConfig(ServletContext context) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Retrieving admin configuration from: "+DRIVER_CONFIG);
+
+
+ public AdminConfiguration getAdminConfig(ServletContext servletContext) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Retrieving admin config from: " + DRIVER_CONFIG_FILE);
}
-
try {
- AdminConfiguration configuration = (AdminConfiguration)
- getBeanFactory(context).getBean("AdminConfiguration");
-
- configuration.init(context);
+ AdminConfiguration adminConfig = (AdminConfiguration)
+ getBeanFactory(servletContext).getBean(
+ "AdminConfiguration");
+ adminConfig.init(servletContext);
if(LOG.isDebugEnabled()) {
- LOG.debug(
- "Admin config of type "+configuration.getClass() +
- "Initialized and ready for service."
- );
+ LOG.debug("Admin config of type " + adminConfig.getClass()
+ + "Initialized and ready for service.");
}
- return configuration;
- }
-
- catch(NoSuchBeanDefinitionException nsbde) {
+ return adminConfig;
+ } catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
-
- private XmlBeanFactory getBeanFactory(ServletContext context) {
- if(beanFactory == null) {
- InputStream in =
- context.getResourceAsStream(DRIVER_CONFIG);
- beanFactory = new XmlBeanFactory(new InputStreamResource(in, "Driver Configuration"));
+
+
+ // Private Methods ---------------------------------------------------------
+
+ private XmlBeanFactory getBeanFactory(ServletContext servletContext) {
+ if (beanFactory == null) {
+ InputStream is = servletContext.getResourceAsStream(
+ DRIVER_CONFIG_FILE);
+ beanFactory = new XmlBeanFactory(new InputStreamResource(
+ is, "Driver Configuration"));
}
return beanFactory;
}
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java Tue Jan 24 09:50:58 2006
@@ -55,14 +55,11 @@
HttpServletResponse response) {
this.request = request;
this.response = response;
- init();
- }
-
- private void init() {
- requestedPortalURL = PortalUrlFactory.getFactory()
+ // Parse servlet request and construct portal URL.
+ this.requestedPortalURL = PortalUrlFactory.getFactory()
.createPortalUrl(request);
// Set Environment in servlet request scope for later use.
- this.request.setAttribute(REQUEST_PORTALENV, this);
+ request.setAttribute(REQUEST_PORTALENV, this);
}
/**
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java Tue Jan 24 09:50:58 2006
@@ -27,17 +27,33 @@
import org.apache.pluto.driver.util.ObjectIdImpl;
import org.apache.pluto.om.ObjectID;
+/**
+ * Implementation of javax.portlet.PortletWindow interface.
+ */
public class PortletWindowImpl implements PortletWindow {
-
- private PortletWindowConfig config;
- private PortalURL url;
- private ObjectIdImpl objectIdImpl;
-
- public PortletWindowImpl(PortletWindowConfig config, PortalURL url) {
+
+ // Private Member Variables ------------------------------------------------
+
+ private PortletWindowConfig config = null;
+ private PortalURL portalURL = null;
+ private ObjectIdImpl objectIdImpl = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Constructs an instance.
+ * @param config the portlet window configuration.
+ * @param portalURL the portal URL.
+ */
+ public PortletWindowImpl(PortletWindowConfig config, PortalURL portalURL) {
this.config = config;
- this.url = url;
+ this.portalURL = portalURL;
}
-
+
+
+ // PortletWindow Impl ------------------------------------------------------
+
public String getContextPath() {
return config.getContextPath();
}
@@ -47,11 +63,11 @@
}
public WindowState getWindowState() {
- return url.getWindowState(getId().toString());
+ return portalURL.getWindowState(getId().toString());
}
public PortletMode getPortletMode() {
- return url.getPortletMode(getId().toString());
+ return portalURL.getPortletMode(getId().toString());
}
public ObjectID getId() {
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java?rev=371965&r1=371964&r2=371965&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java Tue Jan 24 09:50:58 2006
@@ -16,22 +16,35 @@
package org.apache.pluto.driver.services.portal;
/**
- * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * Configuration of a portlet window on the portal page.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
*/
public class PortletWindowConfig {
-
- private String id;
- private String contextPath;
- private String portletName;
-
+
+ // Private Member Variables ------------------------------------------------
+
+ /** The context path of the associated portlet. */
+ private String contextPath = null;
+
+ /** The portlet name. */
+ private String portletName = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * No-arg constructor.
+ */
public PortletWindowConfig() {
+ // Do nothing.
}
-
+
+
+ // Public Methods ----------------------------------------------------------
+
public String getId() {
- if(id == null) {
- return createPortletId(contextPath, portletName);
- }
- return id;
+ return createPortletId(contextPath, portletName);
}
public String getContextPath() {
@@ -49,25 +62,65 @@
public void setPortletName(String portletName) {
this.portletName = portletName;
}
-
+
+
+ // Public Static Methods ---------------------------------------------------
+
+ /**
+ * Creates the portlet ID from context path and portlet name. The portlet ID
+ * is constructed by concatinating the context path and the portlet name
+ * using a dot ('.').
+ * @param contextPath the portlet context path.
+ * @param portletName the portlet name.
+ */
public static String createPortletId(String contextPath,
String portletName) {
return contextPath + "." + portletName;
}
-
+
+ /**
+ * Parses out the portlet context path from the portlet ID.
+ * @param portletId the portlet ID to parse.
+ * @return the portlet context path.
+ */
public static String parseContextPath(String portletId) {
- int idx = portletId.indexOf('.');
- if(idx < 1 || idx == portletId.length() -1) {
- throw new IllegalArgumentException("Invalid Portlet Id: "+portletId);
- }
- return portletId.substring(0, idx);
+ int index = getSeparatorIndex(portletId);
+ return portletId.substring(0, index);
}
-
+
+ /**
+ * Parses out the portlet context path from the portlet ID.
+ * @param portletId the portlet ID to parse.
+ * @return the portlet context path.
+ * @throws IllegalArgumentException if portlet ID is invalid.
+ */
public static String parsePortletName(String portletId) {
- int idx = portletId.indexOf('.');
- if(idx < 1 || idx == portletId.length() -1) {
- throw new IllegalArgumentException("Invalid Portlet Id: "+portletId);
- }
- return portletId.substring(idx+1, portletId.length());
+ int index = getSeparatorIndex(portletId);
+ return portletId.substring(index + 1);
}
+
+
+ // Private Static Method ---------------------------------------------------
+
+ /**
+ * Parses the portlet ID and returns the separator (".") index. The portlet
+ * ID passed in should be a valid ID: not null, not starts with ".",
+ * not ends with ".", and contains ".".
+ * @param portletId the portlet ID to parse.
+ * @return the separator index.
+ * @throws IllegalArgumentException if portlet ID is null or invalid.
+ */
+ private static int getSeparatorIndex(String portletId)
+ throws IllegalArgumentException {
+ if (portletId == null) {
+ throw new IllegalArgumentException("Invalid portlet ID: null");
+ }
+ int index = portletId.indexOf(".");
+ if (index <= 0 || index == portletId.length() - 1) {
+ throw new IllegalArgumentException("Invalid portlet ID: " + portletId);
+ }
+ return index;
+ }
+
}
+