Package org.apache.jetspeed.om.common.portlet

Examples of org.apache.jetspeed.om.common.portlet.PortletApplication


        return OK;
    }

    protected int start(PrintWriter writer, String paName)
    {
        PortletApplication pa = null;
        if (paName != null)
        {
            pa = registry.getPortletApplication(paName);
        }
        if (pa == null)
        {
            writer.println("Error: Unknown Portlet Application " + paName);
            return ERROR_UNKNOWN_PA;
        }
        if (portletFactory.isPortletApplicationRegistered(pa))
        {
            writer.println("Warning: Portlet Application " + paName + " already started");
            return OK;
        }
        else if (pa.getApplicationType() == MutablePortletApplication.LOCAL)
        {
            writer.println("Error: Starting LOCAL Portlet Application " + paName + " not supported");
            return ERROR_UNSUPPORTED;
        }
        else if (!asm.isConnected())
        {
            writer.println("Error: Not connected to the server");
            return ERROR_UNAVAILABLE;
        }
        else
        {
            String response = null;
            try
            {
                ApplicationServerManagerResult result = asm.start(pa.getWebApplicationDefinition().getContextRoot());
                if (result.isOk())
                {
                    writer.println("Portlet Application " + paName + " started");
                    writer.println(result.getResponse());
                    return OK;
View Full Code Here


        }
    }

    protected int stop(PrintWriter writer, String paName)
    {
        PortletApplication pa = null;
        if (paName != null)
        {
            pa = registry.getPortletApplication(paName);
        }
        if (pa == null)
        {
            writer.println("Error: Unknown Portlet Application " + paName);
            return ERROR_UNKNOWN_PA;
        }
        if (!portletFactory.isPortletApplicationRegistered(pa))
        {
            writer.println("Portlet Application " + paName + " already stopped");
            return OK;
        }
        else if (pa.getApplicationType() == MutablePortletApplication.LOCAL)
        {
            writer.println("Error: Stopping LOCAL Portlet Application " + paName + " not supported");
            return ERROR_UNSUPPORTED;
        }
        else if (!asm.isConnected())
        {
            writer.println("Error: Not connected to the server");
            return ERROR_UNAVAILABLE;
        }
        else
        {
            String response = null;
            try
            {
                ApplicationServerManagerResult result = asm.stop(pa.getWebApplicationDefinition().getContextRoot());
                if (result.isOk())
                {
                    writer.println("Portlet Application " + paName + " stopped");
                    writer.println(result.getResponse());
                    return OK;
View Full Code Here

        {
            writer.println("Error: Not connected to the server");
            return ERROR_UNAVAILABLE;
        }

        PortletApplication pa = registry.getPortletApplication(paName);
        String response = null;
        try
        {
            ApplicationServerManagerResult result = asm.undeploy(pa.getWebApplicationDefinition().getContextRoot());
            if (result.isOk())
            {
                writer.println("Portlet Application " + paName + " undeployed");
                writer.println(result.getResponse());
                return OK;
View Full Code Here

        if (result != OK)
        {
            return result;
        }

        PortletApplication pa = registry.getPortletApplication(paName);
        try
        {
            registry.removeApplication(pa);
            writer.println("Portlet Application " + paName + " unregistered");
            return OK;
View Full Code Here

                if ( validator == null )
                {
                    String className = ((PortletDefinitionComposite)pd).getPreferenceValidatorClassname();
                    if ( className != null )
                    {
                        PortletApplication pa = (PortletApplication)pd.getPortletApplicationDefinition();
                        ClassLoader paCl = (ClassLoader)classLoaderMap.get(pa.getId());
                        if ( paCl == null )
                        {
                            throw new UnavailableException("Portlet Application "+pa.getName()+" not available");
                        }
                       
                        ClassLoader currentContextClassLoader = Thread.currentThread().getContextClassLoader();
                        try
                        {
View Full Code Here

     */
    public PortletInstance getPortletInstance( ServletContext servletContext, PortletDefinition pd ) throws PortletException
    {
        PortletInstance portlet = null;
        String pdId = pd.getId().toString();
        PortletApplication pa = (PortletApplication)pd.getPortletApplicationDefinition();

        try
        {                       
          synchronized (portletCache)
          {
            portlet = (PortletInstance)portletCache.get(pdId);
            if (null != portlet)
            {
                return portlet;
            }
           
            ClassLoader paCl = (ClassLoader)classLoaderMap.get(pa.getId());
            if ( paCl == null )
            {
                throw new UnavailableException("Portlet Application "+pa.getName()+" not available");
            }
           
            ClassLoader currentContextClassLoader = Thread.currentThread().getContextClassLoader();
            try
            {
              Class clazz = paCl.loadClass(pd.getClassName());
              try
            {
                Thread.currentThread().setContextClassLoader(paCl);
                // wrap new Portlet inside PortletInstance which ensures the destroy
                // method will wait for all its invocation threads to complete
                // and thereby releasing all its ClassLoader locks as needed for local portlets.
                portlet = new JetspeedPortletInstance(pd.getName(), (Portlet)clazz.newInstance());
            }
              finally
            {
                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
              }
            }
            catch (Exception e)
            {
                String msg = "Cannot create Portlet instance "+pd.getClassName()+" for Portlet Application "+pa.getName();
                log.error(msg,e);
                throw new UnavailableException(msg);
            }
     
            PortletContext portletContext = PortalAccessor.createPortletContext(servletContext, pa);           
            PortletConfig portletConfig = PortalAccessor.createPortletConfig(portletContext, pd);
           
            try
            {
              try
              {
                Thread.currentThread().setContextClassLoader(paCl);
            portlet.init(portletConfig);           
              }
              finally
              {
                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
              }
            }
            catch (PortletException e1)
            {
                log.error("Failed to initialize Portlet "+pd.getClassName()+" for Portlet Application "+pa.getName(), e1);
                throw e1;
            }           
            portletCache.put(pdId, portlet);
          }
        }
View Full Code Here

        ((ResourceLocatingServletContext) servletContext).setContext(paContextPath, paContext);

        try
        {
            ClassLoader paCl = createPAClassLoader(new File(paRootDir, "WEB-INF"));
            PortletApplication pa = portletRegistry.getPortletApplication(paName);       
            portletFactory.registerPortletApplication(pa, paCl);
        }
        catch (Exception e)
        {
            System.out.println("Failed to register portlet application, " + paName + ": " + e);
View Full Code Here

        }
        else if ( !Fragment.LAYOUT.equals(fragment.getType()) )
        {
            fragmentSupportsActions = true;
            String fragmentId = fragment.getId();
            PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();

            String portletName = portlet.getUniqueName();

            PortletMode currentMappedMode = pa.getMappedPortletMode(currentMode);
            WindowState currentMappedState = pa.getMappedWindowState(currentState);

            Object action;
            PortletMode mappedMode;
            PortletMode customMode;
            WindowState mappedState;
            WindowState customState;
           
            ArrayList actionTemplates = new ArrayList();
           
            DecoratorActionsFactory actionsAdapter = getDecoratorActionsAdapter(decoration);
           
            Iterator iter = actionsAdapter.getSupportedActions(requestContext, pa, window, currentMappedMode, currentMappedState, decoration).iterator();
           
            String currentModeAction = null;
            String currentStateAction = null;

            while ( iter.hasNext() )
            {
                action = iter.next();
                if ( action instanceof PortletMode )
                {
                    mappedMode = (PortletMode)action;
                    customMode = pa.getCustomPortletMode(mappedMode);
                   
                    if ( customMode != null )
                    {
                        boolean equalsCurrentMode = customMode.equals(currentMode);
                        if ( equalsCurrentMode )
                        {
                            currentModeAction = mappedMode.toString();
                        }
                        if ( ! equalsCurrentMode || isAjaxRequest )
                        {
                            if ( content.supportsPortletMode(customMode)
                                 && (!PortletMode.EDIT.equals(customMode) || pageActionAccess.isEditAllowed())
                                 && pageActionAccess.checkPortletMode(fragmentId, portletName, mappedMode)
                                 )
                            {
                                actionTemplates.add(new DecoratorActionTemplate(mappedMode, customMode));
                            }
                        }
                    }
                }
                else if ( action instanceof WindowState )
                {
                    mappedState = (WindowState)action;
                    customState = pa.getCustomWindowState(mappedState);

                    if ( customState != null )
                    {
                        boolean equalsCurrentState = customState.equals(currentState);
                        if ( equalsCurrentState )
View Full Code Here

    {
        if ( windowState != null )
        {
            if (!JetspeedActions.getStandardWindowStates().contains(windowState))
            {
                PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();
                windowState = pa.getMappedWindowState(windowState);
            }
            String windowId = window.getId().toString();
            PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
            if (state != null && (state.getWindowState() == null || !state.getWindowState().equals(windowState)))
            {
View Full Code Here

    {
        if ( portletMode != null )
        {
            if (!JetspeedActions.getStandardPortletModes().contains(portletMode))
            {
                PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();
                portletMode = pa.getMappedPortletMode(portletMode);
            }
            String windowId = window.getId().toString();
            PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
            if (state != null && (state.getPortletMode() == null || !state.getPortletMode().equals(portletMode)))
            {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.common.portlet.PortletApplication

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.