Package javax.portlet

Examples of javax.portlet.Portlet


      try
      {
         log.debug("Loading portlet class " + className);
         Class portletClass = application.getContext().getClassLoader().loadClass(className);
         log.debug("Creating portlet object " + className);
         Portlet portlet = (Portlet)portletClass.newInstance();
         log.debug("Created portlet object " + className);
         initPortlet(portlet, config);
         log.debug("Initialized portlet object " + className);

         // We are safe, update state
View Full Code Here


     */
    public final void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        String portletName = null;
        Integer method = ContainerConstants.METHOD_NOOP;
        Portlet portlet = null;
        boolean destroyPortlet = false;
       
        try
        {
            method = (Integer) request.getAttribute(ContainerConstants.METHOD_ID);
            if (method == ContainerConstants.METHOD_NOOP)
            {
                return;
            }
           
            portlet = (Portlet)request.getAttribute(ContainerConstants.PORTLET);
            portletName = (String)request.getAttribute(ContainerConstants.PORTLET_NAME);
            request.removeAttribute(ContainerConstants.PORTLET);

            if (method == ContainerConstants.METHOD_ACTION)
            {
                ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                ActionResponse actionResponse = (ActionResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
                // inject the current request into the actionRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                ((HttpServletRequestWrapper)((HttpServletRequestWrapper)actionRequest).getRequest()).setRequest(request);

                portlet.processAction(actionRequest, actionResponse);
            }
            else if (method == ContainerConstants.METHOD_RENDER)
            {
                RenderRequest renderRequest = (RenderRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                RenderResponse renderResponse = (RenderResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
                // inject the current request into the renderRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                ((HttpServletRequestWrapper)((HttpServletRequestWrapper)renderRequest).getRequest()).setRequest(request);

                portlet.render(renderRequest, renderResponse);
            }

            // if we get this far we are home free
            return;
        }
        catch (Throwable t)
        {
            if ( t instanceof UnavailableException )
            {
                // destroy the portlet in the finally clause
                destroyPortlet = true;
            }
           
            if (method != ContainerConstants.METHOD_ACTION)
            {
                ServletContext context = getServletContext();
                context.log(JCS + "Error rendering portlet \"" + portletName + "\": " + t.toString(), t);
                try
                {
                    String errorTemplate = getInitParameter("portal.error.page");
                    if (errorTemplate == null)
                    {
                        errorTemplate = "/WEB-INF/templates/generic/html/error.vm";
                    }
                    if (null != context.getResource(errorTemplate))
                    {
                        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(errorTemplate);
                        request.setAttribute("e", t);
                        StringWriter stackTrace = new StringWriter();
                        t.printStackTrace(new PrintWriter(stackTrace));
                        request.setAttribute("stacktrace", stackTrace.toString());
                        dispatcher.include(request, response);
                    }
                    else
                    {
                        displayPortletNotAvailableMessage(t, response, portletName);
                    }
                }
                catch (Throwable e)
                {
                    displayPortletNotAvailableMessage(t, response, portletName);
                }
                finally
                {
                    t.printStackTrace();
                }
            }
            else
            {
                if ( t instanceof RuntimeException )
                {
                    throw (RuntimeException)t;
                }
                else if (t instanceof IOException )
                {
                    throw (IOException)t;
                }
                else if (t instanceof ServletException)
                {
                    throw (ServletException)t;
                }
                else
                {
                    throw new ServletException(t);
                }
            }
        }
        finally
        {
            if ( destroyPortlet )
            {
                // portlet throwed UnavailableException: take it out of service
                try
                {
                    portlet.destroy();
                }
                catch (Exception e)
                {
                    // never mind, it won't be used anymore.                
                }
View Full Code Here

                    Iterator portletDefinitions = pa.getPortletDefinitions().iterator();
                    while (portletDefinitions.hasNext())
                    {
                        PortletDefinition pd = (PortletDefinition) portletDefinitions.next();
                        String pdId = pd.getId().toString();
                        Portlet portlet = (Portlet) portletCache.remove(pdId);
                        if (portlet != null)
                        {
                            try
                            {
                                Thread.currentThread().setContextClassLoader(cl);
                                portlet.destroy();
                            }
                            finally
                            {
                                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
                            }
View Full Code Here

                if (!cdiMetaData.cdiInjectionEnabled) {
                    return;
                }

                Portlet portlet = managedPortletContainer.getPortletInstance();

                if (null != portlet) {
                    if (null != portlet.getClass() && "javax.portlet.faces.GenericFacesPortlet".equals(portlet.getClass().getName())) {
                        // Only perform injection on non JSF portlets
                        cdiMetaData.cdiInjectionEnabled = false;
                        cdiMetaDataMap.put(cdiMetaData.key, cdiMetaData);
                        return;
                    }
View Full Code Here

            if (method == ContainerConstants.METHOD_NOOP)
            {
                return;
            }
           
            Portlet portlet = (Portlet)request.getAttribute(ContainerConstants.PORTLET);
            request.removeAttribute(ContainerConstants.PORTLET);

            if (method == ContainerConstants.METHOD_ACTION)
            {
                ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                ActionResponse actionResponse = (ActionResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
                // inject the current request into the actionRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                ((HttpServletRequestWrapper)((HttpServletRequestWrapper)actionRequest).getRequest()).setRequest(request);

                portlet.processAction(actionRequest, actionResponse);
            }
            else if (method == ContainerConstants.METHOD_RENDER)
            {
                RenderRequest renderRequest = (RenderRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                RenderResponse renderResponse = (RenderResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
                // inject the current request into the renderRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                ((HttpServletRequestWrapper)((HttpServletRequestWrapper)renderRequest).getRequest()).setRequest(request);

                portlet.render(renderRequest, renderResponse);
            }

            // if we get this far we are home free
            return;
        }
View Full Code Here

            Iterator portletDefinitions = pa.getPortletDefinitions().iterator();
            while (portletDefinitions.hasNext())
            {               
              PortletDefinition pd = (PortletDefinition)portletDefinitions.next();
              Portlet portlet = (Portlet)portletCache.remove(pd.getId().toString());
              if ( portlet != null )
                {
                    try
                    {                       
                  Thread.currentThread().setContextClassLoader(cl);
                  portlet.destroy();
                }
                finally
                        {
                  Thread.currentThread().setContextClassLoader(currentContextClassLoader);
                        }
View Full Code Here

            return accessible.booleanValue();
        }
        else
        {
            Method helperMethod = null;
            Portlet nonProxyPortletObject = getNonProxyPortletObject();
           
            if (nonProxyPortletObject instanceof GenericPortlet)
            {
                helperMethod = GenericPortletUtils.getRenderModeHelperMethod((GenericPortlet) nonProxyPortletObject, mode);
            }
View Full Code Here

                return;
            }
           
            PortletDefinition portletDefinition = JetspeedPortletFactoryProxy.getCurrentPortletDefinition();                       
            portletName = portletDefinition.getName();
            Portlet portlet = JetspeedPortletFactoryProxy.getPortlet(this.getServletConfig(), portletDefinition);

            if (method == ContainerConstants.METHOD_ACTION)
            {
                ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                ActionResponse actionResponse = (ActionResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);

                portlet.processAction(actionRequest, actionResponse);
            }
            else if (method == ContainerConstants.METHOD_RENDER)
            {
                RenderRequest renderRequest = (RenderRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                RenderResponse renderResponse = (RenderResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);

                portlet.render(renderRequest, renderResponse);
            }

            // if we get this far we are home free
            return;
        }
View Full Code Here

TOP

Related Classes of javax.portlet.Portlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.