Search in sources :

Example 1 with DriverPortletContextImpl

use of org.apache.pluto.driver.container.DriverPortletContextImpl in project uPortal by Jasig.

the class LocalPortletContextManager method register.

// Public Methods ----------------------------------------------------------
/**
     * Retrieves the PortletContext associated with the given ServletContext. If one does not exist,
     * it is created.
     *
     * @param config the servlet config.
     * @return the InternalPortletContext associated with the ServletContext.
     * @throws PortletContainerException
     */
@Override
public synchronized String register(ServletConfig config) throws PortletContainerException {
    ServletContext servletContext = config.getServletContext();
    String contextPath = servletContext.getContextPath();
    if (!portletContexts.containsKey(contextPath)) {
        PortletApplicationDefinition portletApp = this.getPortletAppDD(servletContext, contextPath, contextPath);
        DriverPortletContext portletContext = new DriverPortletContextImpl(servletContext, portletApp, requestDispatcherService);
        portletContext.setAttribute(PlatformApiBroker.PORTLET_CONTEXT_ATTRIBUTE_NAME, platformApiBroker);
        portletContexts.put(contextPath, portletContext);
        fireRegistered(portletContext);
        if (logger.isInfoEnabled()) {
            logger.info("Registered portlet application for context '" + contextPath + "'");
            logger.info("Registering " + portletApp.getPortlets().size() + " portlets for context " + portletContext.getApplicationName());
        }
        //TODO have the portlet servlet provide the portlet's classloader as parameter to this method
        //This approach is needed as all pluto callbacks in uPortal have an aspect that switches the thread classloader back
        //to uPortal's classloader.
        ClassLoader classLoader = ThreadContextClassLoaderAspect.getPreviousClassLoader();
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        classLoaders.put(portletApp.getName(), classLoader);
        for (PortletDefinition portlet : portletApp.getPortlets()) {
            String appName = portletContext.getApplicationName();
            if (appName == null) {
                throw new PortletContainerException("Portlet application name should not be null.");
            }
            portletConfigs.put(portletContext.getApplicationName() + "/" + portlet.getPortletName(), new DriverPortletConfigImpl(portletContext, portlet));
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("Portlet application for context '" + contextPath + "' already registered.");
        }
    }
    return contextPath;
}
Also used : DriverPortletContext(org.apache.pluto.container.driver.DriverPortletContext) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) DriverPortletConfigImpl(org.apache.pluto.driver.container.DriverPortletConfigImpl) ServletContext(javax.servlet.ServletContext) DriverPortletContextImpl(org.apache.pluto.driver.container.DriverPortletContextImpl) PortletContainerException(org.apache.pluto.container.PortletContainerException) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Aggregations

ServletContext (javax.servlet.ServletContext)1 PortletContainerException (org.apache.pluto.container.PortletContainerException)1 DriverPortletContext (org.apache.pluto.container.driver.DriverPortletContext)1 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)1 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)1 DriverPortletConfigImpl (org.apache.pluto.driver.container.DriverPortletConfigImpl)1 DriverPortletContextImpl (org.apache.pluto.driver.container.DriverPortletContextImpl)1