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

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


                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.
               
                if (this.portletProxyUsed && !PortletObjectProxy.isPortletObjectProxied())
                {
                    portlet = new JetspeedPortletProxyInstance(pd.getName(), (Portlet)clazz.newInstance(), this.autoSwitchEditDefaultsModeToEditMode, this.autoSwitchConfigMode, this.customConfigModePortletUniqueName);
                }
                else
                {
                    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

           
            //TODO: this is common to PAs as well, possible refactor
            MultiHashMap fieldMap = new MultiHashMap();
            fieldMap.put(ID, pd.getName());
           
            PortletApplication pa = (PortletApplication)pd.getPortletApplicationDefinition();
            fieldMap.put(PORTLET_APPLICATION, pa.getName());
           
            Collection mdFields = pd.getMetadata().getFields();
            for (Iterator fieldIter = mdFields.iterator(); fieldIter.hasNext();)
            {
                LocalizedField field = (LocalizedField) fieldIter.next();               
View Full Code Here

                if (messages.length()>0)
                {
                    messages.append(LINE_SEPARATOR);
                }
                messages.append(paName + ": ");
                PortletApplication pa = portletRegistry.getPortletApplication(paName);
                boolean thisPAStatus = portletFactory.isPortletApplicationRegistered(pa);
                if (thisPAStatus)
                {
                    messages.append("is up");
                }
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().toString());
                        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().toString());
            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

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

        try
        {                       
          synchronized (portletCache)
          {
            portlet = (PortletInstance)portletCache.get(portletName);
            if (null != portlet)
            {
                return portlet;
            }
           
            ClassLoader paCl = (ClassLoader)classLoaderMap.get(pa.getId().toString());
            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((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(portletName, portlet);
          }
        }
View Full Code Here

    protected int list(PrintWriter writer)
    {
        writer.println("Listed Portlet Applications");
        Iterator iter = registry.getPortletApplications().iterator();
        PortletApplication pa;
        while (iter.hasNext())
        {
            pa = (PortletApplication) iter.next();
            writer.println(pa.getId() + ":" + pa.getName() + ":" + pa.getWebApplicationDefinition().getContextRoot()
                           + ":" + (portletFactory.isPortletApplicationRegistered(pa) ? "ACTIVE" : "INACTIVE"));
        }
        return OK;
    }
View Full Code Here

        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

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.