portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r769669 - in /portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE: components/page-manager/src/test/org/apache/jetspeed/page/cache/ components/portal/src/java/org/apache/jetspeed/tools/pamanager/ components/portal/src/java/org/apa...
Date Wed, 29 Apr 2009 05:59:03 GMT
Author: rwatler
Date: Wed Apr 29 05:59:02 2009
New Revision: 769669

URL: http://svn.apache.org/viewvc?rev=769669&view=rev
Log:
JS2-893: Cluster Safe Portlet Application Manager Improvements
-----------------------------------------------------------------
- support concurrent startPortletApplication() invocation in both the default PAM and VersionedPAM implementations
- clean up preferences caching to ensure PAM rollbacks can be implemented
- allow PortletApplication objects to be constructed w/o loading prefs
- propagate error messages properly in multiple server test cases


Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/prefs/PreferencesProvider.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/versioned-deployment/deployment.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/deployment.xml

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java Wed Apr 29 05:59:02 2009
@@ -561,7 +561,7 @@
         
         private void logProcessLine(final String line)
         {
-            if ((line.indexOf("INFO") == -1) && ((line.indexOf("ERROR") != -1) || (line.indexOf("Exception") != -1) || line.matches("^\\s+at\\s")))
+            if ((line.indexOf("INFO") == -1) && ((line.indexOf("ERROR") != -1) || (line.indexOf("Exception") != -1) || line.matches("\\s+at\\s.*")))
             {
                 log.error("{"+name+"} "+line);
             }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java Wed Apr 29 05:59:02 2009
@@ -35,6 +35,7 @@
 import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
 import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
+import org.apache.jetspeed.prefs.PreferencesProvider;
 import org.apache.jetspeed.search.SearchEngine;
 import org.apache.jetspeed.security.PermissionManager;
 import org.apache.jetspeed.security.PortletPermission;
@@ -64,6 +65,7 @@
 
     protected PortletEntityAccessComponent entityAccess;
     protected PortletFactory        portletFactory;
+    protected PreferencesProvider   prefs;
     protected PortletRegistry       registry;
     protected PortletWindowAccessor windowAccess;
     protected SearchEngine          searchEngine;
@@ -82,15 +84,19 @@
     protected String appRoot;
     protected NodeManager nodeManager;
     
+    protected PortletApplicationManagement pamProxy;
+    protected boolean startOnSetPAMProxy;
+    
     /**
 	 * Creates a new PortletApplicationManager object.
 	 */
-	public PortletApplicationManager(PortletFactory portletFactory, PortletRegistry registry,
+	public PortletApplicationManager(PortletFactory portletFactory, PreferencesProvider prefs, PortletRegistry registry,
 		PortletEntityAccessComponent entityAccess, PortletWindowAccessor windowAccess,
         PermissionManager permissionManager, SearchEngine searchEngine,
         RoleManager roleManager, List permissionRoles, NodeManager nodeManager, String appRoot)
 	{
 		this.portletFactory     = portletFactory;
+		this.prefs              = prefs;
 		this.registry		    = registry;
 		this.entityAccess	    = entityAccess;
 		this.windowAccess	    = windowAccess;
@@ -102,14 +108,28 @@
         this.appRoot            = appRoot;
 	}
     
+    public void setPAMProxy(PortletApplicationManagement pamProxy)
+    {
+        this.pamProxy = pamProxy;
+        if (!started && startOnSetPAMProxy)
+        {
+            start();
+        }
+    }
+    
     public void start()
     {
+        if ( pamProxy == null)
+        {
+            startOnSetPAMProxy = true;
+            return;
+        }
         if ( descriptorChangeMonitorInterval > 0 )
         {
             try
             {
                 monitor = new DescriptorChangeMonitor(Thread.currentThread().getThreadGroup(),
-                                                "PortletApplicationManager Descriptor Change Monitor Thread", this, descriptorChangeMonitorInterval, maxRetriedStarts);
+                                                "PortletApplicationManager Descriptor Change Monitor Thread", pamProxy, descriptorChangeMonitorInterval, maxRetriedStarts);
 
                 monitor.setContextClassLoader(getClass().getClassLoader());
                 monitor.start();
@@ -168,7 +188,7 @@
 		throws RegistryException
 	{
         checkStarted();
-        startPA(contextName, "/"+contextName, warStruct, paClassLoader, MutablePortletApplication.LOCAL);
+        retryStartPortletApplication(contextName, "/"+contextName, warStruct, paClassLoader, MutablePortletApplication.LOCAL);
 	}
 
     public void startInternalApplication(String contextName) throws RegistryException
@@ -184,7 +204,7 @@
             app.setApplicationType(MutablePortletApplication.INTERNAL);
             registry.updatePortletApplication(app);
         }
-        startPA(contextName, "/"+contextName, dir, contextClassLoader, MutablePortletApplication.INTERNAL);
+        retryStartPortletApplication(contextName, "/"+contextName, dir, contextClassLoader, MutablePortletApplication.INTERNAL);
         // startInternal(contextName, warStruct, paClassLoader, true);        
     }
     
@@ -203,7 +223,7 @@
         Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
         try
         {
-            startPA(contextName, contextPath, warStruct, paClassLoader, MutablePortletApplication.WEBAPP);
+            retryStartPortletApplication(contextName, contextPath, warStruct, paClassLoader, MutablePortletApplication.WEBAPP);
         }
         finally
         {
@@ -212,6 +232,50 @@
         
     }    
 
+    protected void retryStartPortletApplication(String contextName, String contextPath, FileSystemHelper warStruct, ClassLoader paClassLoader, int paType) throws RegistryException
+    {
+        // Retry to start application according to configuration. Note
+        // that this method is not declared transactional to allow clean
+        // retries within a single transaction.
+        RegistryException tryStartException = null;
+        for (int i = 0; (i < maxRetriedStarts+1); i++)
+        {
+            try
+            {
+                // try to start portlet application
+                pamProxy.tryStartPortletApplication(contextName, contextPath, warStruct, paClassLoader, paType, 0, true);
+                // continue on success
+                tryStartException = null;
+                break;
+            }
+            catch (RegistryException re)
+            {
+                // save exception
+                tryStartException = re;
+            }
+            // brief pause between retries to let portlet application
+            // state settle
+            try
+            {
+                Thread.sleep(50);
+            }
+            catch (InterruptedException ie)
+            {
+            }
+        }
+        // throw try start exception
+        if (tryStartException != null)
+        {
+            log.error("Unable to start portlet application after "+maxRetriedStarts+" retries: "+tryStartException, tryStartException);
+            throw tryStartException;
+        }
+    }
+
+    public void tryStartPortletApplication(String contextName, String contextPath, FileSystemHelper warStruct, ClassLoader paClassLoader, int paType, long checksum, boolean silent) throws RegistryException
+    {
+        attemptStartPA(contextName, contextPath, warStruct, paClassLoader, paType, checksum, silent);
+    }
+
 	public void stopLocalPortletApplication(String contextName)
 		throws RegistryException
 	{
@@ -299,7 +363,7 @@
 	}
 
 	protected MutablePortletApplication registerPortletApplication(PortletApplicationWar paWar,
-		MutablePortletApplication oldPA, int paType, ClassLoader paClassLoader)
+        MutablePortletApplication oldPA, int paType, ClassLoader paClassLoader, boolean silent)
 		throws RegistryException
 	{
 		if (oldPA != null)
@@ -315,7 +379,8 @@
 		try
 		{
 			log.info("Loading portlet.xml...." + paName);
-			pa = paWar.createPortletApp(paClassLoader);
+			prefs.clearCachedApplicationPreferences(paName);
+			pa = paWar.createPortletApp(true, paClassLoader);
 			pa.setApplicationType(paType);
 
 			// load the web.xml
@@ -359,9 +424,15 @@
 		}
 		catch (Exception e)
 		{
+		    // clear any cached preferences to be rolled back
+		    prefs.clearCachedApplicationPreferences(paName);
+		    
 			String msg = "Failed to load portlet application for "
 				+ paWar.getPortletApplicationName();
-			log.error(msg, e);
+            if (!silent || log.isDebugEnabled())
+            {
+                log.error(msg, e);
+            }
 			throw new RegistryException(msg);
 		}
 
@@ -409,8 +480,14 @@
 		}
 		catch (Exception e)
 		{
-			String msg = "Failed to register portlet application, " + paName;
-			log.error(msg, e);
+            // clear any cached preferences to be rolled back
+            prefs.clearCachedApplicationPreferences(paName);
+
+            String msg = "Failed to register portlet application, " + paName;
+            if (!silent || log.isDebugEnabled())
+            {
+                log.error(msg, e);
+            }
 
 			if (registered)
 			{
@@ -420,7 +497,10 @@
 				}
 				catch (Exception re)
 				{
-					log.error("Failed to rollback registration of portlet application " + paName, re);
+                    if (!silent || log.isDebugEnabled())
+                    {
+                        log.error("Failed to rollback registration of portlet application " + paName, re);
+                    }
 				}
 			}
 
@@ -428,15 +508,8 @@
 		}
 	}
 
-	protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
-	        ClassLoader paClassLoader, int paType)
-	throws RegistryException
-	{
-	    startPA(contextName, contextPath, warStruct, paClassLoader, paType, 0);
-	}
-	
-	protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
-	        ClassLoader paClassLoader, int paType, long checksum)
+	protected void attemptStartPA(String contextName, String contextPath, FileSystemHelper warStruct,
+            ClassLoader paClassLoader, int paType, long checksum, boolean silent)
 	throws RegistryException
 	{
         boolean register = true;
@@ -464,7 +537,7 @@
             {
                 if (paClassLoader == null)
                 {
-                    paClassLoader = paWar.createClassloader(getClass().getClassLoader());
+                    paClassLoader = paWar.createClassloader(this.getClass().getClassLoader());
                 }                
                 // create checksum from PA descriptors
                 checksum = paWar.getPortletApplicationChecksum();                
@@ -477,7 +550,10 @@
             catch (IOException e)
             {
                 String msg = "Invalid PA WAR for " + contextName;
-                log.error(msg, e);
+                if (!silent || log.isDebugEnabled())
+                {
+                    log.error(msg, e);
+                }
                 if ( paClassLoader == null )
                 {
                     // nothing to be done about it anymore: this pa is beyond repair :(
@@ -521,7 +597,7 @@
                         {
 	                        log.debug("Register new portlet application " + contextName + ".");
                         }
-	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
+	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader, silent);
 	                }
 	                catch (Exception e)
 	                {
@@ -606,7 +682,7 @@
         			    {
         			        log.debug("Register (deploy=true) Portlet application " + contextName + " in database.");
                         }
-	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
+	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader, silent);
         			}
         			else
         				if (reregister)
@@ -654,7 +730,10 @@
         {
             String msg = "Error starting portlet application " + contextName;
             
-            log.error(msg, e);
+            if (!silent || log.isDebugEnabled())
+            {
+                log.error(msg, e);
+            }
             // monitor PA for changes
             // do not add monitor if a monitor already exists
             if (!monitored && changeMonitor != null)
@@ -969,13 +1048,13 @@
             }
         }        
 
-        private PortletApplicationManager pam;
+        private PortletApplicationManagement pam;
         private long interval;
         private boolean started = true;
         private ArrayList monitorInfos;
         private int maxRetriedStarts;
 
-        public DescriptorChangeMonitor(ThreadGroup group, String name, PortletApplicationManager pam, long interval, int maxretriedStarts)
+        public DescriptorChangeMonitor(ThreadGroup group, String name, PortletApplicationManagement pam, long interval, int maxretriedStarts)
         {
             super(group, name);
             this.pam = pam;
@@ -1105,8 +1184,8 @@
                                 {
                                     try
                                     {
-                                        pam.startPA(monitorInfo.getContextName(), monitorInfo.getContextPath(), new DirectoryHelper(monitorInfo.getPADir()),
-                                                monitorInfo.getPAClassLoader(), monitorInfo.getPortletApplicationType(), monitorInfo.getChecksum());
+                                        pam.tryStartPortletApplication(monitorInfo.getContextName(), monitorInfo.getContextPath(), new DirectoryHelper(monitorInfo.getPADir()),
+                                                                       monitorInfo.getPAClassLoader(), monitorInfo.getPortletApplicationType(), monitorInfo.getChecksum(), true);
                                         // great! we have a successful start. set unsuccessful starts to 0
                                         monitorInfo.setUnsuccessfulStarts(0);
                                     }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java Wed Apr 29 05:59:02 2009
@@ -31,6 +31,7 @@
 import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.om.common.LocalizedField;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.prefs.PreferencesProvider;
 import org.apache.jetspeed.search.SearchEngine;
 import org.apache.jetspeed.security.PermissionManager;
 import org.apache.jetspeed.security.RoleManager;
@@ -61,12 +62,12 @@
 {
     private static final Log    log = LogFactory.getLog("deployment");
         
-    public VersionedPortletApplicationManager(PortletFactory portletFactory, PortletRegistry registry, 
+    public VersionedPortletApplicationManager(PortletFactory portletFactory, PreferencesProvider prefs, PortletRegistry registry, 
             PortletEntityAccessComponent entityAccess, PortletWindowAccessor windowAccess,
             PermissionManager permissionManager, SearchEngine searchEngine,  RoleManager roleManager,
             List permissionRoles, /* node manager, */ String appRoot)
     {
-        super(portletFactory, registry, entityAccess, windowAccess, permissionManager, 
+        super(portletFactory, prefs, registry, entityAccess, windowAccess, permissionManager, 
                 searchEngine, roleManager, permissionRoles, null, appRoot); 
                
     }
@@ -87,8 +88,8 @@
     }
         
     // override to implement versioning logic
-    protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
-            ClassLoader paClassLoader, int paType, long checksum)
+    protected void attemptStartPA(String contextName, String contextPath, FileSystemHelper warStruct,
+            ClassLoader paClassLoader, int paType, long checksum, boolean silent)
     throws RegistryException
     {
         PortletApplicationWar paWar = null;
@@ -105,7 +106,10 @@
             catch (IOException e)
             {
                 String msg = "Invalid PA WAR for " + contextName;
-                log.error(msg, e);
+                if (!silent || log.isDebugEnabled())
+                {
+                    log.error(msg, e);
+                }
                 if ( paClassLoader == null )
                 {
                     // nothing to be done about it anymore: this pa is beyond repair :(
@@ -115,11 +119,11 @@
             }
             
             MutablePortletApplication regPA = registry.getPortletApplication(contextName);
-            MutablePortletApplication newPA = paWar.createPortletApp();
+            MutablePortletApplication newPA = paWar.createPortletApp(false);
             if (regPA == null)
             {
                 System.out.println("**** New portlet app found - registration required..." + contextName);
-                regPA = this.registerPortletApplication(paWar, null, paType, paClassLoader);
+                regPA = registerPortletApplication(paWar, null, paType, paClassLoader, silent);
             }
             else
             {
@@ -130,7 +134,7 @@
                 if (newVersion.compareTo(regVersion) > 0)
                 {
                     System.out.println(" - **** New Version is greater: registration required... " + contextName);
-                    regPA = this.registerPortletApplication(paWar, regPA, paType, paClassLoader);                    
+                    regPA = registerPortletApplication(paWar, regPA, paType, paClassLoader, silent);                    
                 }
                 else
                 {
@@ -146,7 +150,10 @@
         catch (Exception e)
         {
             String msg = "Error starting portlet application " + contextName;            
-            log.error(msg, e);
+            if (!silent || log.isDebugEnabled())
+            {
+                log.error(msg, e);
+            }
             throw new RegistryException(msg, e);
         }
     }
@@ -166,4 +173,4 @@
         }
         return version;
     }
-}
\ No newline at end of file
+}

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java Wed Apr 29 05:59:02 2009
@@ -120,7 +120,7 @@
         WebApplicationDescriptor wad = new WebApplicationDescriptor(new FileReader(webappDescriptor), "/" + appName);
         MutableWebApplication webapp = wad.createWebApplication();
         PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader(appDescriptor), appName);        
-        MutablePortletApplication app = pad.createPortletApplication();                
+        MutablePortletApplication app = pad.createPortletApplication(true);                
         app.setWebApplicationDefinition(webapp);
         ExtendedPortletMetadata extMetaData = new ExtendedPortletMetadata(new FileReader(extendedDescriptor), app);
         extMetaData.load();        

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java Wed Apr 29 05:59:02 2009
@@ -68,10 +68,10 @@
         this.appName = appName;
     }
 
-    public MutablePortletApplication createPortletApplication()
+    public MutablePortletApplication createPortletApplication(boolean populatePreferences)
     throws PortletApplicationException
     {
-        return createPortletApplication(this.getClass().getClassLoader());
+        return createPortletApplication(populatePreferences, this.getClass().getClassLoader());
     }
     
     /**
@@ -81,7 +81,7 @@
      * @return MutablePortletApplication newly created MutablePortletApplication with
      * all values of the portlet application descriptor mapped into it.
      */
-    public MutablePortletApplication createPortletApplication(ClassLoader classLoader)
+    public MutablePortletApplication createPortletApplication(boolean populatePreferences, ClassLoader classLoader)
         throws PortletApplicationException
     {
         try
@@ -136,9 +136,11 @@
             digester.addBeanPropertySetter("portlet-app/portlet/portlet-info/short-title", "shortTitle");
             digester.addCallMethod("portlet-app/portlet/portlet-info/keywords", "setKeywords", 0, new Class[]{String.class});
             digester.addSetNext("portlet-app/portlet/portlet-info", "addLanguage");
-            
-            digester.addRuleSet(new PortletPreferenceRuleSet());
 
+            if (populatePreferences)
+            {
+                digester.addRuleSet(new PortletPreferenceRuleSet());
+            }
             
             digester.addObjectCreate("portlet-app/user-attribute", UserAttributeImpl.class);
             digester.addBeanPropertySetter("portlet-app/user-attribute/description", "description");

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java Wed Apr 29 05:59:02 2009
@@ -225,14 +225,14 @@
      * @throws IOException
      * @see org.apache.jetspeed.uitl.descriptor.PortletApplicationDescriptor
      */
-    public MutablePortletApplication createPortletApp(ClassLoader classLoader) throws PortletApplicationException, IOException
+    public MutablePortletApplication createPortletApp(boolean populatePreferences, ClassLoader classLoader) throws PortletApplicationException, IOException
     {
         Reader portletXmlReader = getReader(PORTLET_XML_PATH);
         
         try
         {
             PortletApplicationDescriptor paDescriptor = new PortletApplicationDescriptor(portletXmlReader, paName);
-            portletApp = paDescriptor.createPortletApplication(classLoader);
+            portletApp = paDescriptor.createPortletApplication(populatePreferences, classLoader);
             // validate(portletApplication);
             Reader extMetaDataXml = null;
             try
@@ -278,10 +278,10 @@
         }
     }
 
-    public MutablePortletApplication createPortletApp() 
+    public MutablePortletApplication createPortletApp(boolean populatePreferences) 
     throws PortletApplicationException, IOException
     {
-        return createPortletApp(this.getClass().getClassLoader());
+        return createPortletApp(populatePreferences, this.getClass().getClassLoader());
     }
     
     /**

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java Wed Apr 29 05:59:02 2009
@@ -74,7 +74,7 @@
     {
         System.out.println("Testing loadPortletApplicationTree");
         PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("./test/testdata/deploy/portlet.xml"), "unit-test");
-        MutablePortletApplication app = pad.createPortletApplication();            
+        MutablePortletApplication app = pad.createPortletApplication(false);            
         assertNotNull("App is null", app);
         assertNotNull("Version is null", app.getVersion());
         assertTrue("Version invalid: " + app.getVersion(), app.getVersion().equals("1.0"));

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletApplicationManager.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletApplicationManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletApplicationManager.java Wed Apr 29 05:59:02 2009
@@ -46,15 +46,9 @@
 {
     private static final Log log = LogFactory.getLog(TestPortletApplicationManager.class);
 
-    /*
-     * TODO: this test case is properly run with concurrent PAM access
-     * enabled, use of the versioned PAM, and with multiple restarts.
-     * Test will not pass with those settings, so these are being used
-     * temporarily until these issues are addressed.
-     */
-    public static final boolean TEST_CONCURRENT_PAM_ACCESS = false;
+    public static final boolean TEST_CONCURRENT_PAM_ACCESS = true;
     public static final boolean TEST_USE_VERSIONED_PAM = false;
-    public static final int TEST_PORTLET_APPLICATION_RESTARTS = 1;
+    public static final int TEST_PORTLET_APPLICATION_RESTARTS = 5;
 
     public static final String CONTEXT_NAME = "test-pa";
     public static final String CONTEXT_PATH = "/"+CONTEXT_NAME;
@@ -207,6 +201,7 @@
                 if (TEST_CONCURRENT_PAM_ACCESS)
                 {
                     // start portlet application asynchronously in background threads per server
+                    log.info("test concurrent register/start/stop portlet application, iteration "+i+"...");
                     TestExecuteThread startPortletApplication0 = new TestExecuteThread(server0, "portletApplicationManagerServer.startPortletApplication();");
                     TestExecuteThread startPortletApplication1 = new TestExecuteThread(server1, "portletApplicationManagerServer.startPortletApplication();");
                     startPortletApplication0.start();
@@ -219,6 +214,7 @@
                 else
                 {
                     // stop portlet application synchronously
+                    log.info("test serial register/start/stop portlet application, iteration "+i+"...");
                     result = server0.execute("portletApplicationManagerServer.startPortletApplication();");
                     assertTrue(result.indexOf("Exception") == -1);
                     result = server1.execute("portletApplicationManagerServer.startPortletApplication();");
@@ -230,6 +226,7 @@
                 result = server0.execute("portletApplicationManagerServer.stopPortletApplication();");
                 assertTrue(result.indexOf("Exception") == -1);
                 // unregister portlet application
+                log.info("test unregister portlet application, iteration "+i+"...");
                 try
                 {
                     portletApplicationManager.unregisterPortletApplication(CONTEXT_NAME);
@@ -418,7 +415,7 @@
         
         private void logProcessLine(final String line)
         {
-            if ((line.indexOf("INFO") == -1) && ((line.indexOf("ERROR") != -1) || (line.indexOf("Exception") != -1) || line.matches("^\\s+at\\s")))
+            if ((line.indexOf("INFO") == -1) && ((line.indexOf("ERROR") != -1) || (line.indexOf("Exception") != -1) || line.matches("\\s+at\\s.*")))
             {
                 log.error("{"+name+"} "+line);
             }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java Wed Apr 29 05:59:02 2009
@@ -95,7 +95,7 @@
     {
         System.out.println("Testing loadPortletApplicationTree");
         PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("./test/testdata/deploy/portlet.xml"), "unit-test");
-        MutablePortletApplication app = pad.createPortletApplication();
+        MutablePortletApplication app = pad.createPortletApplication(true);
         assertNotNull("App is null", app);
         assertNotNull("Version is null", app.getVersion());
         assertTrue("Version invalid: " + app.getVersion(), app.getVersion().equals("1.0"));
@@ -304,7 +304,7 @@
         }
 
         PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("./test/testdata/deploy/portlet2.xml"), "HW_App");
-        app = pad.createPortletApplication();
+        app = pad.createPortletApplication(true);
 
         app.setName("HW_App");
 

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java Wed Apr 29 05:59:02 2009
@@ -81,7 +81,7 @@
         File warFile = new File("./test/testdata/deploy/webapp");
         PortletApplicationWar paWar = new PortletApplicationWar(new DirectoryHelper(warFile), "unit-test", "/" );
 
-        MutablePortletApplication app = paWar.createPortletApp();
+        MutablePortletApplication app = paWar.createPortletApp(false);
         assertNotNull("App is null", app);
 
         MutableWebApplication webApp = paWar.createWebApp();

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java Wed Apr 29 05:59:02 2009
@@ -98,7 +98,7 @@
     private void innerTestSetUserInfoMap(UserInfoManager uim) throws Exception
     {
         PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("test/testdata/deploy/portlet.xml"), "unit-test");
-        portletApp = pad.createPortletApplication();
+        portletApp = pad.createPortletApplication(true);
         assertNotNull("App is null", portletApp);
 
         // persist the app

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java Wed Apr 29 05:59:02 2009
@@ -456,10 +456,18 @@
     	}
     	
         NodeCache key = new NodeCache(hit);
-        getPersistenceBrokerTemplate().store(hit.getNode()); // avoid racing condition with the db and with cluster notification
-        											// do the db first
-        preferenceCache.remove(key.getCacheKey()); // not sure we should actually do that, could also just update the node
-        addToCache(key);
+        try
+        {
+            getPersistenceBrokerTemplate().store(hit.getNode()); // avoid racing condition with the db and with cluster notification
+                                                                 // do the db first
+            preferenceCache.remove(key.getCacheKey());           // not sure we should actually do that, could also just update the node
+            addToCache(key);
+        }
+        catch (Exception e)
+        {
+            preferenceCache.removeQuiet(key.getCacheKey());      // remove problematic nodes from cache
+            throw new RuntimeException("Failed to store node of type " + node.getNodeType() + " for the path " + node.getFullPath() + ".  " + e.toString(), e);
+        }
     }
 
     /**
@@ -656,5 +664,46 @@
     {
         NodeImplProxy.setProvider(null);
         preferenceCache = null;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.prefs.PreferencesProvider#clearCachedApplicationPreferences(java.lang.String)
+     */
+    public void clearCachedApplicationPreferences(String portletApplicationName)
+    {
+        String portletDefPrefPath = "/" + MutablePortletApplication.PREFS_ROOT + "/" + portletApplicationName + "/";
+        long start = System.currentTimeMillis();        
+        int count = clearCachedNodeAndAllChildren(portletDefPrefPath);
+        long elapsed = System.currentTimeMillis() - start;
+        System.out.println("++++ PREFS:PA clear cached " + count + " pref nodes for app " + portletDefPrefPath + " in " + elapsed + " milliseconds.");
     }    
+
+    /**
+     * Clear node and all children based on specified path from cache.
+     * 
+     * @param path full path of node to remove
+     * @return count of nodes cleared from cache
+     */
+    protected int clearCachedNodeAndAllChildren(String path)
+    {
+        int count = 0;
+        String root = path.substring(0, path.length()-1);
+        List preferenceCacheKeys = preferenceCache.getKeys();
+        for (Iterator iter = preferenceCacheKeys.iterator(); iter.hasNext();)
+        {
+            CacheElement preferenceCacheElement = preferenceCache.get(iter.next());
+            if (preferenceCacheElement != null)
+            {
+                String preferenceFullPath = ((NodeCache)preferenceCacheElement.getContent()).getNode().getFullPath();
+                if (preferenceFullPath.startsWith(path) || preferenceFullPath.equals(root))
+                {
+                    if (preferenceCache.removeQuiet(preferenceCacheElement.getKey()))
+                    {
+                        count++;
+                    }
+                }
+            }
+        }
+        return count;
+    }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java Wed Apr 29 05:59:02 2009
@@ -103,8 +103,6 @@
     {
         ((Observer) Preferences.userRoot()).update(null, null);
         ((Observer) Preferences.systemRoot()).update(null, null);
-        userRoot.disposeNode();
-        systemRoot.disposeNode();
         userRoot.ppw.dispose();
         userRoot = null;
         systemRoot = null;

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java Wed Apr 29 05:59:02 2009
@@ -51,19 +51,17 @@
     /** System <tt>Preferences</tt> node type. */
     public static final int SYSTEM_NODE_TYPE = 1;
 
-    /** The current <code>Node</code> object. */
-    private Node node = null;
-
     /** Logger. */
     private static final Log log = LogFactory.getLog(PreferencesImpl.class);
 
-    PreferencesProviderWrapper ppw;
+    PreferencesImpl parent;
     
-    void disposeNode()
-    {
-        node = null;
-    }
+    PreferencesProviderWrapper ppw;
 
+    String nodeName;
+    
+    int nodeType;
+    
     /**
      * <p>
      * Constructs a root node in the underlying datastore if they have not yet
@@ -80,55 +78,12 @@
     PreferencesImpl(PreferencesImpl parent, PreferencesProviderWrapper ppw, String nodeName, int nodeType) throws IllegalStateException
     {
         super(parent, nodeName);
+        this.parent = parent;
         this.ppw = ppw;
-        try
-        {
-            node = ppw.provider().getNode(this.absolutePath(), nodeType);
-            newNode = false;
-        }
-        catch (NodeDoesNotExistException e1)
-        {
-            try
-            {
-                if (parent != null)
-                {
-                    this.node = ppw.provider().createNode(parent.getNode(), nodeName, nodeType, this.absolutePath());
-                }
-                else
-                {
-                    this.node = ppw.provider().createNode(null, nodeName, nodeType, this.absolutePath());
-                }
-
-                newNode = true;
-            }
-            catch (FailedToCreateNodeException e)
-            {
-                IllegalStateException ise = new IllegalStateException("Failed to create new Preferences of type "
-                        + nodeType + " for path " + this.absolutePath());
-                ise.initCause(e);
-                throw ise;
-            }
-            catch (NodeAlreadyExistsException e)
-            {
-                try
-                {
-                    node = ppw.provider().getNode(this.absolutePath(), nodeType);
-                    newNode = false;
-                }
-                catch (NodeDoesNotExistException e2)
-                {
-                    // If we get this at this point something is very wrong
-                    IllegalStateException ise = new IllegalStateException(
-                            "Unable to create node for Preferences of type "
-                                    + nodeType
-                                    + " for path "
-                                    + this.absolutePath()
-                                    + ".  If you see this exception at this, it more than likely means that the Preferences backing store is corrupt.");
-                    ise.initCause(e2);
-                    throw ise;
-                }
-            }
-        }
+        this.nodeName = nodeName;
+        this.nodeType = nodeType;
+        // aggressively fetch/create node
+        getNode();
     }        
 
     /**
@@ -161,7 +116,7 @@
      */
     public AbstractPreferences childSpi(String name)
     {
-        return new PreferencesImpl(this, ppw, name, node.getNodeType());
+        return new PreferencesImpl(this, ppw, name, nodeType);
     }
 
     /**
@@ -169,7 +124,6 @@
      */
     public void flushSpi() throws BackingStoreException
     {
-        ppw.provider().storeNode(this.node);
     }
 
     /**
@@ -178,8 +132,7 @@
     public String getSpi(String key)
     {
         String value = null;
-        Collection properties = node.getNodeProperties();
-
+        Collection properties = getNode().getNodeProperties();
         for (Iterator i = properties.iterator(); i.hasNext();)
         {
             Property curProp = (Property) i.next();
@@ -198,7 +151,7 @@
     {
         ArrayList propertyNames = new ArrayList();
 
-        Collection propCol = node.getNodeProperties();
+        Collection propCol = getNode().getNodeProperties();
         if ((null != propCol) && propCol.size() > 0)
         {
             for (Iterator j = propCol.iterator(); j.hasNext();)
@@ -221,6 +174,7 @@
      */
     public void putSpi(String key, String value)
     {
+        Node node = getNode();
         Collection properties = node.getNodeProperties();
         if (null == properties)
         {
@@ -252,6 +206,9 @@
         }
 
         ppw.provider().storeNode(node);
+
+        // mark stored node as old
+        newNode = false;
     }
 
     /**
@@ -259,13 +216,17 @@
      */
     public void removeNodeSpi() throws BackingStoreException
     {
+        // remove node from db
         Node parentNode = null;
         Preferences parent = parent();
         if (parent != null && parent instanceof PreferencesImpl)
         {
             parentNode = ((PreferencesImpl) parent).getNode();
         }
-        ppw.provider().removeNode(parentNode, node);
+        ppw.provider().removeNode(parentNode, getNode());
+
+        // mark removed node as new
+        newNode = true;
     }
 
     /**
@@ -273,8 +234,9 @@
      */
     public void removeSpi(String key)
     {
+        boolean removed = false;
+        Node node = getNode();
         Collection properties = node.getNodeProperties();
-
         for (Iterator i = properties.iterator(); i.hasNext();)
         {
             Property curProp = (Property) i.next();
@@ -282,10 +244,16 @@
             if ((curProp.getPropertyName().equals(key)))
             {
                 i.remove();
+                removed = true;
             }
         }
-        // Update node.
-        ppw.provider().storeNode(node);
+        if (removed)
+        {
+            ppw.provider().storeNode(node);
+
+            // mark stored node as old
+            newNode = false;
+        }
     }
 
     /**
@@ -306,6 +274,49 @@
      */
     public Node getNode()
     {
+        Node node;
+        try
+        {
+            node = ppw.provider().getNode(absolutePath(), nodeType);
+            newNode = false;
+        }
+        catch (NodeDoesNotExistException e1)
+        {
+            try
+            {
+                if (parent != null)
+                {
+                    node = ppw.provider().createNode(parent.getNode(), nodeName, nodeType, absolutePath());
+                }
+                else
+                {
+                    node = ppw.provider().createNode(null, nodeName, nodeType, absolutePath());
+                }
+                newNode = true;
+            }
+            catch (FailedToCreateNodeException e)
+            {
+                IllegalStateException ise = new IllegalStateException("Failed to create new Preferences of type " + nodeType + " for path " + absolutePath());
+                ise.initCause(e);
+                throw ise;
+            }
+            catch (NodeAlreadyExistsException e)
+            {
+                try
+                {
+                    node = ppw.provider().getNode(absolutePath(), nodeType);
+                    newNode = false;
+                }
+                catch (NodeDoesNotExistException e2)
+                {
+                    // If we get this at this point something is very wrong
+                    IllegalStateException ise = new IllegalStateException("Unable to create node for Preferences of type " + nodeType + " for path " + absolutePath() + ". " +
+                                                                          "If you see this exception at this, it more than likely means that the Preferences backing store is corrupt.");
+                    ise.initCause(e2);
+                    throw ise;
+                }
+            }
+        }
         return node;
     }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/prefs/PreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/prefs/PreferencesProvider.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/prefs/PreferencesProvider.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/prefs/PreferencesProvider.java Wed Apr 29 05:59:02 2009
@@ -120,4 +120,20 @@
      * @throws Exception
      */
     void init() throws Exception;
+
+    /**
+     * Preload preferences for specified portlet application.
+     * 
+     * @param portletApplicationName application name
+     * @throws NodeDoesNotExistException
+     */
+    void preloadApplicationPreferences(String portletApplicationName) throws NodeDoesNotExistException;
+    
+    /**
+     * Clear cached preferences for specified portlet application.
+     * 
+     * @param portletApplicationName application name
+     * @throws NodeDoesNotExistException
+     */
+    void clearCachedApplicationPreferences(String portletApplicationName);
 }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java Wed Apr 29 05:59:02 2009
@@ -48,4 +48,6 @@
   void startInternalApplication(String contextName) throws RegistryException;
   void stopLocalPortletApplication(String contextName) throws RegistryException;
   public void unregisterPortletApplication(String paName) throws RegistryException;
+
+  void tryStartPortletApplication(String contextName, String contextPath, FileSystemHelper warStruct, ClassLoader paClassLoader, int paType, long checksum, boolean silent) throws RegistryException;
 }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/versioned-deployment/deployment.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/versioned-deployment/deployment.xml?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/versioned-deployment/deployment.xml (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/versioned-deployment/deployment.xml Wed Apr 29 05:59:02 2009
@@ -23,6 +23,7 @@
   	   class="org.apache.jetspeed.tools.pamanager.VersionedPortletApplicationManager" init-method="start" destroy-method="stop"
   >  	   
   	   <constructor-arg><ref bean="portletFactory"/></constructor-arg>
+  	   <constructor-arg><ref bean="org.apache.jetspeed.prefs.PreferencesProvider"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.components.portletregistry.PortletRegistry"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.container.window.PortletWindowAccessor"/></constructor-arg>
@@ -65,7 +66,7 @@
         </property>
         <property name="transactionAttributes">
             <props>
-                <prop key="start*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="try*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="stop*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="unregister*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="register*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
@@ -74,6 +75,21 @@
         </property>
     </bean>
 
+  <!-- Inject PAM Proxy into PAM implementation -->
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+    <property name="targetObject">
+      <ref bean="org.apache.jetspeed.tools.pamanager.PortletApplicationManager" />
+    </property>
+    <property name="targetMethod">
+      <value>setPAMProxy</value>
+    </property>
+    <property name="arguments">
+      <list>
+        <ref bean="PAM" />
+      </list>
+    </property>
+  </bean>
+
   <!-- Portlet Application and Decorator deployment event listeners -->
   <bean id="portletAppDeploymentListener" 
   	   class="org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener"   	   
@@ -114,4 +130,4 @@
        </constructor-arg>
   </bean>    
 
-</beans>
\ No newline at end of file
+</beans>

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/deployment.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/deployment.xml?rev=769669&r1=769668&r2=769669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/deployment.xml (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/deployment.xml Wed Apr 29 05:59:02 2009
@@ -41,6 +41,7 @@
   	   class="org.apache.jetspeed.tools.pamanager.PortletApplicationManager" init-method="start" destroy-method="stop"
   >  	   
   	   <constructor-arg><ref bean="portletFactory"/></constructor-arg>
+  	   <constructor-arg><ref bean="org.apache.jetspeed.prefs.PreferencesProvider"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.components.portletregistry.PortletRegistry"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/></constructor-arg>
   	   <constructor-arg><ref bean="org.apache.jetspeed.container.window.PortletWindowAccessor"/></constructor-arg>
@@ -84,7 +85,7 @@
         </property>
         <property name="transactionAttributes">
             <props>
-                <prop key="start*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="try*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="stop*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="unregister*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                 <prop key="register*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
@@ -93,6 +94,21 @@
         </property>
     </bean>
 
+  <!-- Inject PAM Proxy into PAM implementation -->
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+    <property name="targetObject">
+      <ref bean="org.apache.jetspeed.tools.pamanager.PortletApplicationManager" />
+    </property>
+    <property name="targetMethod">
+      <value>setPAMProxy</value>
+    </property>
+    <property name="arguments">
+      <list>
+        <ref bean="PAM" />
+      </list>
+    </property>
+  </bean>
+
   <!-- Portlet Application and Decorator deployment event listeners -->
   <bean id="portletAppDeploymentListener" 
   	   class="org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener"   	   
@@ -133,4 +149,4 @@
        </constructor-arg>
   </bean>    
 
-</beans>
\ No newline at end of file
+</beans>



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


Mime
View raw message