You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2008/10/22 09:06:43 UTC

svn commit: r706875 - in /portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/ components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/ comp...

Author: taylor
Date: Wed Oct 22 00:06:43 2008
New Revision: 706875

URL: http://svn.apache.org/viewvc?rev=706875&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-871
This commit hooks in the Pluto PortletRegistryService with both the PortletFactory and Jetspeed PortletRegistry. The PortletRegistryService interfaces need some work, we can sort that out later. The one required API from PortletRegistryService is getPortletContext, as its called by the container to get the invokers going. I had some problems getting a servlet config to the portlet factory, but may have found a way by wiring in, via Spring, the ServletContext to the PortletFactory, then getting a context for the portlet apps via the servlet api. Its untested but Im sure it will popup during tests. I hate to check in the PortletFactory in such a bad state, but I wanted to get the class loader map refactoring in there before quitting for the night.

Added:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/PortletFactoryInfo.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PlutoRegistryAdaptor.java
Modified:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedOptionalPlutoServices.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedPortletContext.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/registry.xml

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedOptionalPlutoServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedOptionalPlutoServices.java?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedOptionalPlutoServices.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedOptionalPlutoServices.java Wed Oct 22 00:06:43 2008
@@ -48,7 +48,7 @@
     public JetspeedOptionalPlutoServices(NamespaceMapper namespaceMapper, PortalAdministrationService adminService,
             PortletEnvironmentService environmentService, PortletInfoService portletInfoService,
             UserInfoService userInfoService, RequestAttributeService requestAttributeService,
-            PortletInvokerService invokerService)
+            PortletInvokerService invokerService, PortletRegistryService registryService, PortletPreferencesService preferencesService)
     {
         this.namespaceMapper = namespaceMapper;
         this.adminService = adminService;
@@ -57,6 +57,8 @@
         this.userInfoService = userInfoService;
         this.requestAttributeService = requestAttributeService;
         this.invokerService = invokerService;
+        this.registryService = registryService;
+        this.preferencesService = preferencesService;
     }
     
     public NamespaceMapper getNamespaceMapper()

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java Wed Oct 22 00:06:43 2008
@@ -27,116 +27,132 @@
 import javax.portlet.PortletException;
 import javax.portlet.PreferencesValidator;
 import javax.portlet.UnavailableException;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.container.JetspeedPortletConfig;
+import org.apache.jetspeed.container.JetspeedPortletContext;
 import org.apache.jetspeed.container.PortalAccessor;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.portlet.PortletObjectProxy;
-import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.internal.InternalPortletContext;
+import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 
 /**
  * <p>
  * JetspeedPortletFactory
  * </p>
  * <p>
- *
+ * 
  * </p>
+ * 
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
  * @version $Id$
- *
+ * 
  */
 public class JetspeedPortletFactory implements PortletFactory
 {
 
     private Map portletCache;
+
     private Map validatorCache;
-    
-    private static final Log log = LogFactory.getLog(JetspeedPortletFactory.class);
-    private final Map classLoaderMap;
-    
+
+    private static final Log log = LogFactory
+            .getLog(JetspeedPortletFactory.class);
+
+    private final Map<String, PortletFactoryInfo> classLoaderMap;
+
     /**
-     * Flag whether this factory will create proxy instances for actual portlet instances or not.
+     * Flag whether this factory will create proxy instances for actual portlet
+     * instances or not.
      */
     private boolean portletProxyUsed;
-    
+
     /**
-     * Flag whether the instantiated proxy will switch edit_defaults mode to edit mode automatically or not.
+     * Flag whether the instantiated proxy will switch edit_defaults mode to
+     * edit mode automatically or not.
      */
     private boolean autoSwitchEditDefaultsModeToEditMode;
-    
+
     /**
-     * Flag whether the instantiated proxy will switch config mode to built-in config edit page or not.
+     * Flag whether the instantiated proxy will switch config mode to built-in
+     * config edit page or not.
      */
     private boolean autoSwitchConfigMode;
-    
+
     private String customConfigModePortletUniqueName;
+
+    private ServletConfig jetspeedConfig;
     
-    public JetspeedPortletFactory()
-    {
-        this(false, false);
-    }
-    
-    public JetspeedPortletFactory(boolean autoSwitchConfigMode, boolean autoSwitchEditDefaultsModeToEditMode)
+    public JetspeedPortletFactory(ServletConfig jetspeedConfig, boolean autoSwitchConfigMode,
+            boolean autoSwitchEditDefaultsModeToEditMode)
     {
-        this.portletCache =  Collections.synchronizedMap(new HashMap());
+        this.jetspeedConfig = jetspeedConfig;
+        this.portletCache = Collections.synchronizedMap(new HashMap());
         this.validatorCache = Collections.synchronizedMap(new HashMap());
-        classLoaderMap = Collections.synchronizedMap(new HashMap());
-        
+        classLoaderMap = Collections.synchronizedMap(new HashMap<String, PortletFactoryInfo>());
+
         this.autoSwitchConfigMode = autoSwitchConfigMode;
         this.autoSwitchEditDefaultsModeToEditMode = autoSwitchEditDefaultsModeToEditMode;
-        
+
         this.portletProxyUsed = (this.autoSwitchConfigMode || this.autoSwitchEditDefaultsModeToEditMode);
     }
-    
+
     public void setPortletProxyUsed(boolean portletProxyUsed)
     {
         this.portletProxyUsed = portletProxyUsed;
     }
-    
+
     public boolean getPortletProxyUsed()
     {
         return this.portletProxyUsed;
     }
-    
-    public void setCustomConfigModePortletUniqueName(String customConfigModePortletUniqueName)
+
+    public void setCustomConfigModePortletUniqueName(
+            String customConfigModePortletUniqueName)
     {
         this.customConfigModePortletUniqueName = customConfigModePortletUniqueName;
     }
-    
+
     public String getCustomConfigModePortletUniqueName()
     {
         return this.customConfigModePortletUniqueName;
     }
 
     public void registerPortletApplication(PortletApplication pa, ClassLoader cl)
+    {
+        synchronized (classLoaderMap)
         {
-            synchronized (classLoaderMap)
-            {
-                unregisterPortletApplication(pa);
-                classLoaderMap.put(pa.getId(), cl);
-            }
+            ServletContext servletContext = jetspeedConfig.getServletContext();
+            ServletContext portletAppContext = servletContext.getContext(pa.getName());
+            InternalPortletContext context = new JetspeedPortletContext(portletAppContext, pa);      
+            classLoaderMap.put(pa.getName(), new PortletFactoryInfo(cl, context));
+        }
     }
-    
+
     public void unregisterPortletApplication(PortletApplication pa)
     {
         synchronized (classLoaderMap)
         {
             synchronized (portletCache)
             {
-                ClassLoader cl = (ClassLoader) classLoaderMap.remove(pa.getId());
-                if (cl != null)
+                PortletFactoryInfo info = (PortletFactoryInfo) classLoaderMap.remove(pa.getName());
+                if (info != null)
                 {
-                    ClassLoader currentContextClassLoader = Thread.currentThread().getContextClassLoader();
-
-                    Iterator portletDefinitions = pa.getPortletDefinitions().iterator();
+                    ClassLoader cl = info.getClassLoader();
+                    ClassLoader currentContextClassLoader = Thread
+                            .currentThread().getContextClassLoader();
+                    Iterator portletDefinitions = pa.getPortletDefinitions()
+                            .iterator();
                     while (portletDefinitions.hasNext())
                     {
-                        PortletDefinition pd = (PortletDefinition) portletDefinitions.next();
-                        String pdId = pd.getId().toString();
+                        PortletDefinition pd = (PortletDefinition) portletDefinitions
+                                .next();
+                        String pdId = pd.getPortletName();
                         Portlet portlet = (Portlet) portletCache.remove(pdId);
                         if (portlet != null)
                         {
@@ -147,7 +163,8 @@
                             }
                             finally
                             {
-                                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
+                                Thread.currentThread().setContextClassLoader(
+                                        currentContextClassLoader);
                             }
                         }
                         validatorCache.remove(pdId);
@@ -156,49 +173,61 @@
             }
         }
     }
-    
+
     public PreferencesValidator getPreferencesValidator(PortletDefinition pd)
     {
         PreferencesValidator validator = null;
         try
         {
             String pdId = pd.getId().toString();
-            
+
             synchronized (validatorCache)
             {
-                validator = (PreferencesValidator)validatorCache.get(pdId);
-                if ( validator == null )
+                validator = (PreferencesValidator) validatorCache.get(pdId);
+                if (validator == null)
                 {
-                    String className = ((PortletDefinition)pd).getPreferenceValidatorClassname();
-                    if ( className != null )
+                    String className = ((PortletDefinition) 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
+                        PortletApplication pa = (PortletApplication) pd
+                                .getPortletApplicationDefinition();
+                        PortletFactoryInfo info = classLoaderMap.get(pa.getName());
+                        if (info != null)
                         {
-                            Class clazz = paCl.loadClass(className);
+                            ClassLoader paCl = info.getClassLoader();
+                            if (paCl == null) { throw new UnavailableException(
+                                    "Portlet Application " + pa.getName()
+                                            + " not available"); }
+    
+                            ClassLoader currentContextClassLoader = Thread
+                                    .currentThread().getContextClassLoader();
                             try
                             {
-                                Thread.currentThread().setContextClassLoader(paCl);
-                                validator = (PreferencesValidator)clazz.newInstance();
-                                validatorCache.put(pdId, validator);
+                                Class clazz = paCl.loadClass(className);
+                                try
+                                {
+                                    Thread.currentThread().setContextClassLoader(
+                                            paCl);
+                                    validator = (PreferencesValidator) clazz
+                                            .newInstance();
+                                    validatorCache.put(pdId, validator);
+                                }
+                                finally
+                                {
+                                    Thread.currentThread().setContextClassLoader(
+                                            currentContextClassLoader);
+                                }
                             }
-                            finally
+                            catch (Exception e)
                             {
-                                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
+                                String msg = "Cannot create PreferencesValidator instance "
+                                        + className
+                                        + " for Portlet "
+                                        + pd.getPortletName();
+                                log.error(msg, e);
                             }
                         }
-                        catch (Exception e)
-                        {
-                            String msg = "Cannot create PreferencesValidator instance "+className+" for Portlet "+pd.getPortletName();
-                            log.error(msg,e);
-                        }
                     }
                 }
             }
@@ -211,89 +240,112 @@
     }
 
     /**
-     * Gets a portlet by either creating it or returning a handle to it from the portlet 'cache'
+     * Gets a portlet by either creating it or returning a handle to it from the
+     * portlet 'cache'
      * 
-     * @param portletDefinition The definition of the portlet
-     * @return PortletInstance 
+     * @param portletDefinition
+     *            The definition of the portlet
+     * @return PortletInstance
      * @throws PortletException
      */
-    public PortletInstance getPortletInstance( ServletContext servletContext, PortletDefinition pd ) throws PortletException
+    public PortletInstance getPortletInstance(ServletContext servletContext,
+            PortletDefinition pd) throws PortletException
     {
         PortletInstance portlet = null;
         String pdId = pd.getId().toString();
-        PortletApplication pa = (PortletApplication)pd.getPortletApplicationDefinition();
+        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.getPortletClass());
-              try
+        {
+            synchronized (portletCache)
             {
-                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 = (PortletInstance) portletCache.get(pdId);
+                if (null != portlet) { return portlet; }
+
+                PortletFactoryInfo info = classLoaderMap.get(pa.getName());
+                ClassLoader paCl = info.getClassLoader();
+                if (paCl == null) 
+                { 
+                    throw new UnavailableException(
+                        "Portlet Application " + pa.getName()
+                                + " not available"); }
+
+                ClassLoader currentContextClassLoader = Thread.currentThread()
+                        .getContextClassLoader();
+
+                try
                 {
-                    portlet = new JetspeedPortletProxyInstance(pd.getPortletName(), (Portlet)clazz.newInstance(), this.autoSwitchEditDefaultsModeToEditMode, this.autoSwitchConfigMode, this.customConfigModePortletUniqueName);
+                    Class clazz = paCl.loadClass(pd.getPortletClass());
+                    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
+                                    .getPortletName(), (Portlet) clazz
+                                    .newInstance(),
+                                    this.autoSwitchEditDefaultsModeToEditMode,
+                                    this.autoSwitchConfigMode,
+                                    this.customConfigModePortletUniqueName);
+                        }
+                        else
+                        {
+                            portlet = new JetspeedPortletInstance(pd
+                                    .getPortletName(), (Portlet) clazz
+                                    .newInstance());
+                        }
+                    }
+                    finally
+                    {
+                        Thread.currentThread().setContextClassLoader(
+                                currentContextClassLoader);
+                    }
                 }
-                else
+                catch (Exception e)
                 {
-                    portlet = new JetspeedPortletInstance(pd.getPortletName(), (Portlet)clazz.newInstance());
+                    String msg = "Cannot create Portlet instance "
+                            + pd.getPortletClass()
+                            + " 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.getPortletClass()
+                            + " for Portlet Application " + pa.getName(), e1);
+                    throw e1;
+                }
+                portletCache.put(pdId, portlet);
             }
-              finally
-            {
-                Thread.currentThread().setContextClassLoader(currentContextClassLoader);
-              }
-            }
-            catch (Exception e)
-            {
-                String msg = "Cannot create Portlet instance "+pd.getPortletClass()+" 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.getPortletClass()+" for Portlet Application "+pa.getName(), e1);
-                throw e1;
-            }            
-            portletCache.put(pdId, portlet);
-          }
         }
         catch (PortletException pe)
         {
@@ -301,41 +353,64 @@
         }
         catch (Throwable e)
         {
-            log.error("PortletFactory: Failed to load portlet "+pd.getPortletClass(), e);
-            throw new UnavailableException( "Failed to load portlet " + pd.getPortletClass() +": "+e.toString());
+            log.error("PortletFactory: Failed to load portlet "
+                    + pd.getPortletClass(), e);
+            throw new UnavailableException("Failed to load portlet "
+                    + pd.getPortletClass() + ": " + e.toString());
         }
         return portlet;
     }
-    
+
     public void updatePortletConfig(PortletDefinition pd)
     {
         if (pd != null)
         {
-            //System.out.println("$$$$ updating portlet config for " + pd.getName());
+            // System.out.println("$$$$ updating portlet config for " +
+            // pd.getName());
             String key = pd.getId().toString();
-            PortletInstance instance = (PortletInstance)portletCache.get(key);
+            PortletInstance instance = (PortletInstance) portletCache.get(key);
             if (instance != null)
             {
-                JetspeedPortletConfig config = (JetspeedPortletConfig)instance.getConfig();
+                JetspeedPortletConfig config = (JetspeedPortletConfig) instance
+                        .getConfig();
                 config.setPortletDefinition(pd);
             }
         }
     }
-    
+
     public ClassLoader getPortletApplicationClassLoader(PortletApplication pa)
     {
         synchronized (classLoaderMap)
         {
-          if ( pa != null )
-        {
-              return (ClassLoader)classLoaderMap.get(pa.getId());
-        }
-          return null;
+            if (pa != null) 
+            { 
+                PortletFactoryInfo info = classLoaderMap.get(pa.getName());
+                if (info != null)
+                    return info.getClassLoader(); 
+            }
+            return null;
         }
     }
-    
+
     public boolean isPortletApplicationRegistered(PortletApplication pa)
     {
         return getPortletApplicationClassLoader(pa) != null;
     }
+
+    public InternalPortletContext getPortletContext(PortletApplicationDefinition pad)
+        throws PortletContainerException
+    {
+        PortletFactoryInfo info = classLoaderMap.get(pad.getName());
+        if (info != null)
+        {
+            return info.getContext();
+        }
+        throw new PortletContainerException("App context not found for application " + pad.getName());
+//        ServletContext context = jetspeedConfig.getServletContext();
+//        ServletContext portletAppContext = context.getContext(pad.getName());
+//        JetspeedPortletContext jpc = new JetspeedPortletContext(portletAppContext, pad);
+//        classLoaderMap.put(pa.getName(), new PortletFactoryInfo(cl, context));        
+//        return jpc;
+    }
+
 }

Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/PortletFactoryInfo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/PortletFactoryInfo.java?rev=706875&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/PortletFactoryInfo.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/PortletFactoryInfo.java Wed Oct 22 00:06:43 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.factory;
+
+import org.apache.pluto.internal.InternalPortletContext;
+
+class PortletFactoryInfo
+{
+    private ClassLoader classLoader;
+    private InternalPortletContext context;
+
+    PortletFactoryInfo(ClassLoader loader, InternalPortletContext context)
+    {
+        this.classLoader = loader;
+        this.context = context;
+    }
+ 
+    public ClassLoader getClassLoader()
+    {
+        return classLoader;
+    }
+    
+    public InternalPortletContext getContext()
+    {
+        return context;
+    }    
+}

Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PlutoRegistryAdaptor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PlutoRegistryAdaptor.java?rev=706875&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PlutoRegistryAdaptor.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PlutoRegistryAdaptor.java Wed Oct 22 00:06:43 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components.portletregistry;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.ServletConfig;
+
+import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.internal.InternalPortletConfig;
+import org.apache.pluto.internal.InternalPortletContext;
+import org.apache.pluto.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.spi.optional.PortletRegistryListener;
+import org.apache.pluto.spi.optional.PortletRegistryService;
+
+/**
+ * The Pluto Registry is a hybrid of a factory and actua
+ * @author dtaylor
+ *
+ */
+public class PlutoRegistryAdaptor implements PortletRegistryService
+{
+    private PortletRegistry registry;
+    private PortletFactory factory;
+    
+    public PlutoRegistryAdaptor(PortletRegistry registry, PortletFactory factory)
+    {
+        this.registry = registry;
+        this.factory = factory;
+    }
+    
+    public void addPortletRegistryListener(PortletRegistryListener arg0)
+    {
+        // TODO: 2.2
+        throw new UnsupportedOperationException();
+    }
+
+    public ClassLoader getClassLoader(String applicationName)
+            throws PortletContainerException
+    {
+        return factory.getPortletApplicationClassLoader(registry.getPortletApplication(applicationName));
+    }
+
+    public PortletDefinition getPortlet(String applicationName, String portletName)
+            throws PortletContainerException
+    {
+        return registry.getPortletDefinitionByUniqueName(applicationName + "::" + portletName);
+    }
+
+    public PortletApplicationDefinition getPortletApplication(String name)
+            throws PortletContainerException
+    {
+        return registry.getPortletApplication(name);
+    }
+
+    public InternalPortletConfig getPortletConfig(String applicationName, String portletName)
+            throws PortletContainerException
+    {
+        PortletDefinition pd = registry.getPortletDefinitionByUniqueName(applicationName + "::" + portletName);
+        if (pd != null)
+        {
+//            factory.getPortletInstance(servletContext, pd)
+        }
+        // TODO: 2.2 not sure how to implement this
+        throw new UnsupportedOperationException();        
+    }
+
+    public InternalPortletContext getPortletContext(String applicationName)
+            throws PortletContainerException
+    {
+        // required method by Pluto 2.0
+        return factory.getPortletContext(registry.getPortletApplication(applicationName));
+    }
+
+    public Iterator<InternalPortletContext> getPortletContexts()
+    {
+        // TODO: 2.2
+        throw new UnsupportedOperationException();        
+    }
+
+    public Iterator<String> getRegisteredPortletApplicationNames()
+    {
+        List<String> result = new LinkedList<String>();
+        for( PortletApplication app : registry.getPortletApplications())
+        {
+            result.add(app.getName());
+        }
+        return result.iterator(); // TODO: 2.2 why an iterator?
+    }
+
+    public String register(ServletConfig servletConfig) throws PortletContainerException
+    {
+        // TODO: 2.2
+        throw new UnsupportedOperationException();
+    }
+
+    public void unregister(InternalPortletContext context)
+    {
+        // TODO: 2.2
+        throw new UnsupportedOperationException();        
+    }
+
+    public void removePortletRegistryListener(PortletRegistryListener arg0)
+    {
+        // TODO: 2.2
+        throw new UnsupportedOperationException();
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java Wed Oct 22 00:06:43 2008
@@ -35,7 +35,7 @@
  */
 public interface PortletRegistry
 {
-    Collection getAllPortletDefinitions();
+    Collection<PortletDefinition> getAllPortletDefinitions();
 
     /**
      * Retreives a PortletApplication by it's unique name.  We use
@@ -46,7 +46,7 @@
      */
     PortletApplication getPortletApplication( String name );
 
-    Collection getPortletApplications();
+    Collection<PortletApplication> getPortletApplications();
 
     /**
      * unique name is a string formed by the combination of a portlet's

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java Wed Oct 22 00:06:43 2008
@@ -21,6 +21,8 @@
 import javax.servlet.ServletContext;
 
 import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.internal.InternalPortletContext;
 import org.apache.pluto.om.portlet.PortletDefinition;
 
 /**
@@ -32,6 +34,7 @@
  * </p>
  * 
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * 
  * @version $Id$
  *  
  */
@@ -44,4 +47,5 @@
     PortletInstance getPortletInstance( ServletContext servletContext, PortletDefinition pd ) throws PortletException;
     PreferencesValidator getPreferencesValidator(PortletDefinition pd );
     void updatePortletConfig(PortletDefinition pd);
+    InternalPortletContext getPortletContext(PortletApplication pa)  throws PortletContainerException;
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedPortletContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedPortletContext.java?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedPortletContext.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedPortletContext.java Wed Oct 22 00:06:43 2008
@@ -21,11 +21,9 @@
 import java.util.Enumeration;
 import java.util.Iterator;
 
-import javax.servlet.ServletContext;
-import javax.servlet.RequestDispatcher;
-
-import javax.portlet.PortletContext;
 import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
 
 import org.apache.jetspeed.dispatcher.JetspeedRequestDispatcher;
 import org.apache.jetspeed.om.common.JetspeedServiceReference;
@@ -42,7 +40,7 @@
  * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  * @version $Id$
  */
-public class JetspeedPortletContext implements PortletContext, InternalPortletContext
+public class JetspeedPortletContext implements org.apache.pluto.internal.InternalPortletContext
 {
     /**
      * The path to the Local Portlet Apps directory
@@ -282,4 +280,20 @@
         return result;
 */        
     }
+
+    public String getApplicationName()
+    {
+        return this.application.getName();
+    }
+
+    public PortletApplicationDefinition getPortletApplicationDefinition()
+    {
+        return this.application;
+    }
+
+    public Enumeration<String> getContainerRuntimeOptions()
+    {
+        // TODO: 2.2
+        return null;
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml Wed Oct 22 00:06:43 2008
@@ -118,7 +118,8 @@
       <constructor-arg><ref bean="org.apache.pluto.services.UserInfoService"/></constructor-arg>            
       <constructor-arg><ref bean="org.apache.pluto.services.RequestAttributeService"/></constructor-arg>
       <constructor-arg><ref bean="org.apache.pluto.services.PortletInvokerService"/></constructor-arg>            
-	<!--  TODO: preferences, registry -->
+      <constructor-arg><ref bean="org.apache.pluto.services.PlutoRegistryServiceAdaptor"/></constructor-arg>            
+	<!--  TODO: preferences -->
     </bean>
     
     <bean id="org.apache.pluto.services.NamespaceMapper"
@@ -158,8 +159,11 @@
         <constructor-arg index="3"><ref bean="PortletRequestResponseUnwrapper"/></constructor-arg>
     </bean>
 
-
-
-
-    
+    <bean id="org.apache.pluto.services.PlutoRegistryServiceAdaptor"
+          class="org.apache.jetspeed.components.portletregistry.PlutoRegistryAdaptor">          
+	    <meta key="j2:cat" value="default" />
+	    <constructor-arg index="0"><ref bean="portletFactory" /></constructor-arg>         
+        <constructor-arg index="1"><ref bean="portletRegistry"/></constructor-arg>
+    </bean>
+        
 </beans>
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/registry.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/registry.xml?rev=706875&r1=706874&r2=706875&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/registry.xml (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/registry.xml Wed Oct 22 00:06:43 2008
@@ -21,14 +21,15 @@
   <!-- Portlet Factory -->
   <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory">
     <meta key="j2:cat" value="default,registry" />
+    <constructor-arg index='0'><ref bean='ServletConfig'/></constructor-arg>
     <!-- If the following constructor-arg is set to true, 
       proxy instances will switch config mode to built-in custom config mode portlet. -->
-    <constructor-arg index="0">
+    <constructor-arg index="1">
       <value>${supported.portletmode.autoswitch.config}</value>
     </constructor-arg>
     <!-- If the following constructor-arg is set to true, 
       proxy instances will switch edit_defaults mode to edit mode automatically for portlets not supporting edit_defaults mode. -->
-    <constructor-arg index="1">
+    <constructor-arg index="2">
       <value>${supported.portletmode.autoswitch.edit_defaults}</value>
     </constructor-arg>
     <!-- Surrogate portlet for config modes. -->



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org