Search in sources :

Example 1 with DriverPortletContext

use of org.apache.pluto.container.driver.DriverPortletContext 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.
 */
@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);
        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)

Example 2 with DriverPortletContext

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

the class LocalPortletContextManager method getPortletApplication.

@Override
public PortletApplicationDefinition getPortletApplication(String applicationName) throws PortletContainerException {
    DriverPortletContext ipc = portletContexts.get(applicationName);
    if (ipc != null) {
        return ipc.getPortletApplicationDefinition();
    }
    String msg = "Unable to retrieve portlet application: '" + applicationName + "'";
    logger.warn(msg);
    throw new PortletContainerException(msg);
}
Also used : DriverPortletContext(org.apache.pluto.container.driver.DriverPortletContext) PortletContainerException(org.apache.pluto.container.PortletContainerException)

Aggregations

PortletContainerException (org.apache.pluto.container.PortletContainerException)2 DriverPortletContext (org.apache.pluto.container.driver.DriverPortletContext)2 ServletContext (javax.servlet.ServletContext)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