[pal-cvs 3533] [1267] mt-safe.

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 31日 (金) 10:36:52 JST


Revision: 1267
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=1267
Author:   shinsuke
Date:     2008-10-31 10:36:52 +0900 (Fri, 31 Oct 2008)

Log Message:
-----------
mt-safe.

Modified Paths:
--------------
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java


-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java	2008-10-30 08:12:16 UTC (rev 1266)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java	2008-10-31 01:36:52 UTC (rev 1267)
@@ -971,43 +971,47 @@
             // search for existing folders along search paths
             List searchPaths = getView().getSearchPaths();
             searchFolders = new ArrayList(searchPaths.size());
-            Iterator pathsIter = searchPaths.iterator();
-            while (pathsIter.hasNext())
+            synchronized (searchPaths)
             {
-                // construct folder paths
-                SiteViewSearchPath searchPath = (SiteViewSearchPath) pathsIter
-                        .next();
-                String path = searchPath.toString();
-                if (!path.equals(Folder.PATH_SEPARATOR))
+                Iterator pathsIter = searchPaths.iterator();
+                while (pathsIter.hasNext())
                 {
-                    path += getPath();
-                }
-                else
-                {
-                    path = getPath();
-                }
+                    // construct folder paths
+                    SiteViewSearchPath searchPath = (SiteViewSearchPath) pathsIter
+                            .next();
+                    String path = searchPath.toString();
+                    if (!path.equals(Folder.PATH_SEPARATOR))
+                    {
+                        path += getPath();
+                    }
+                    else
+                    {
+                        path = getPath();
+                    }
 
-                // get existing folders from PageManager, create
-                // corresponding search folder objects, and add to
-                // search folders list
-                try
-                {
-                    Folder folder = getView().getPageManager().getFolder(path);
-                    if (folder != null)
+                    // get existing folders from PageManager, create
+                    // corresponding search folder objects, and add to
+                    // search folders list
+                    try
                     {
-                        searchFolders.add(new SearchFolder(folder, searchPath
-                                .getLocatorName()));
+                        Folder folder = getView().getPageManager().getFolder(
+                                path);
+                        if (folder != null)
+                        {
+                            searchFolders.add(new SearchFolder(folder,
+                                    searchPath.getLocatorName()));
+                        }
                     }
+                    catch (NodeException ne)
+                    {
+                    }
+                    catch (NodeNotFoundException ne)
+                    {
+                    }
+                    catch (SecurityException se)
+                    {
+                    }
                 }
-                catch (NodeException ne)
-                {
-                }
-                catch (NodeNotFoundException ne)
-                {
-                }
-                catch (SecurityException se)
-                {
-                }
             }
         }
 

Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java	2008-10-30 08:12:16 UTC (rev 1266)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java	2008-10-31 01:36:52 UTC (rev 1267)
@@ -559,8 +559,7 @@
                     if (sessionContext.getMenuDefinitionLocatorCache() == null)
                     {
                         sessionContext
-                                .setMenuDefinitionLocatorCache(Collections
-                                        .synchronizedMap(new HashMap(8)));
+                                .setMenuDefinitionLocatorCache(new HashMap(8));
                     }
                     sessionContext.getMenuDefinitionLocatorCache().put(locator,
                             menu);

Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java	2008-10-30 08:12:16 UTC (rev 1266)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java	2008-10-31 01:36:52 UTC (rev 1267)
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.Principal;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -155,8 +156,8 @@
      */
     public PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
     {
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators,
-                true, true);
+        return new PortalSiteRequestContextImpl(this, Collections
+                .synchronizedMap(requestProfileLocators), true, true);
     }
 
     /**
@@ -172,8 +173,8 @@
     public PortalSiteRequestContext newRequestContext(
             Map requestProfileLocators, boolean requestFallback)
     {
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators,
-                requestFallback, true);
+        return new PortalSiteRequestContextImpl(this, Collections
+                .synchronizedMap(requestProfileLocators), requestFallback, true);
     }
 
     /**
@@ -237,8 +238,11 @@
                 // all locators should have identical request paths, (do
                 // not execute profile locator though to determine path:
                 // simply use the request path)
-                locator = (ProfileLocator) requestProfileLocators.values()
-                        .iterator().next();
+                synchronized (requestProfileLocators)
+                {
+                    locator = (ProfileLocator) requestProfileLocators.values()
+                            .iterator().next();
+                }
                 requestPath = locator.getRequestPath();
             }
 
@@ -314,18 +318,20 @@
                         // clear all history entries for fallback
                         // request path in advance to make fallback
                         // page selection more predictable
-                        Iterator folderIter = getFolderPageHistory().keySet()
-                                .iterator();
-                        while (folderIter.hasNext())
+                        Map fphMap = getFolderPageHistory();
+                        Iterator folderIter = fphMap.keySet().iterator();
+                        synchronized (fphMap)
                         {
-                            Folder folder = (Folder) folderIter.next();
-                            if (folder.getUrl().equals(fallbackRequestPath))
+                            while (folderIter.hasNext())
                             {
-                                folderIter.remove();
-                                break;
+                                Folder folder = (Folder) folderIter.next();
+                                if (folder.getUrl().equals(fallbackRequestPath))
+                                {
+                                    folderIter.remove();
+                                    break;
+                                }
                             }
                         }
-
                         // retry requested page access
                         requestPath = fallbackRequestPath;
                     }
@@ -875,25 +881,28 @@
                 if (profileLocators != null)
                 {
                     boolean firstEntry = true;
-                    Iterator entriesIter = profileLocators.entrySet()
-                            .iterator();
-                    while (entriesIter.hasNext())
+                    synchronized (profileLocators)
                     {
-                        Map.Entry entry = (Map.Entry) entriesIter.next();
-                        String locatorName = (String) entry.getKey();
-                        ProfileLocator locator = (ProfileLocator) entry
-                                .getValue();
-                        if (!firstEntry)
+                        Iterator entriesIter = profileLocators.entrySet()
+                                .iterator();
+                        while (entriesIter.hasNext())
                         {
-                            debug.append(",");
+                            Map.Entry entry = (Map.Entry) entriesIter.next();
+                            String locatorName = (String) entry.getKey();
+                            ProfileLocator locator = (ProfileLocator) entry
+                                    .getValue();
+                            if (!firstEntry)
+                            {
+                                debug.append(",");
+                            }
+                            else
+                            {
+                                firstEntry = false;
+                            }
+                            debug.append(locatorName);
+                            debug.append("=");
+                            debug.append(locator.toString());
                         }
-                        else
-                        {
-                            firstEntry = false;
-                        }
-                        debug.append(locatorName);
-                        debug.append("=");
-                        debug.append(locator.toString());
                     }
                 }
                 else
@@ -948,8 +957,11 @@
         if ((siteView == null) && (pageManager != null)
                 && (profileLocators != null))
         {
-            // create new site view
-            siteView = new SiteView(pageManager, profileLocators);
+            synchronized (this)
+            {
+                // create new site view
+                siteView = new SiteView(pageManager, profileLocators);
+            }
 
             // log site view creation
             if (log.isDebugEnabled())
@@ -1065,7 +1077,6 @@
      */
     public Map getMenuDefinitionLocatorCache()
     {
-        // TODO Findbugs
         return menuDefinitionLocatorCache;
     }
 
@@ -1077,7 +1088,7 @@
      */
     public void setMenuDefinitionLocatorCache(Map cache)
     {
-        menuDefinitionLocatorCache = cache;
+        menuDefinitionLocatorCache = Collections.synchronizedMap(cache);
     }
 
     /**
@@ -1098,49 +1109,52 @@
         // compare locator map sizes
         if (locators0.size() != locators1.size()) { return false; }
 
-        // compare locator map entries
-        Iterator entriesIter = locators0.entrySet().iterator();
-        if (entriesIter.hasNext())
+        synchronized (locators0)
         {
-            Map.Entry entry = (Map.Entry) entriesIter.next();
-            ProfileLocator locator0 = (ProfileLocator) entry.getValue();
-            ProfileLocator locator1 = (ProfileLocator) locators1.get(entry
-                    .getKey());
-            if (locator1 == null) { return false; }
-
-            // compare locators using the most specific,
-            // (i.e. first), locator properties array
-            // returned by the locator iterator
-            ProfileLocatorProperty[] properties0 = (ProfileLocatorProperty[]) locator0
-                    .iterator().next();
-            ProfileLocatorProperty[] properties1 = (ProfileLocatorProperty[]) locator1
-                    .iterator().next();
-            if ((properties0 != null) || (properties1 != null))
+            // compare locator map entries
+            Iterator entriesIter = locators0.entrySet().iterator();
+            if (entriesIter.hasNext())
             {
-                if ((properties0 == null) || (properties1 == null)
-                        || (properties0.length != properties1.length)) { return false; }
+                Map.Entry entry = (Map.Entry) entriesIter.next();
+                ProfileLocator locator0 = (ProfileLocator) entry.getValue();
+                ProfileLocator locator1 = (ProfileLocator) locators1.get(entry
+                        .getKey());
+                if (locator1 == null) { return false; }
 
-                // compare ordered locator properties
-                for (int i = 0, limit = properties0.length; (i < limit); i++)
+                // compare locators using the most specific,
+                // (i.e. first), locator properties array
+                // returned by the locator iterator
+                ProfileLocatorProperty[] properties0 = (ProfileLocatorProperty[]) locator0
+                        .iterator().next();
+                ProfileLocatorProperty[] properties1 = (ProfileLocatorProperty[]) locator1
+                        .iterator().next();
+                if ((properties0 != null) || (properties1 != null))
                 {
-                    // compare property names, control flags, navigation flags,
-                    // and values. note: properties values are compared only for
-                    // control or navigation properties; otherwise they are
-                    // assumed to contain variable request paths that should
-                    // be treated as equivalent
-                    if (!properties0[i].getName().equals(
-                            properties1[i].getName())
-                            || (properties0[i].isControl() && !properties1[i]
-                                    .isControl())
-                            || (properties0[i].isNavigation() && !properties1[i]
-                                    .isNavigation())
-                            || ((properties0[i].isControl() || properties0[i]
-                                    .isNavigation()) && (((properties0[i]
-                                    .getValue() == null) && (properties1[i]
-                                    .getValue() != null)) || ((properties0[i]
-                                    .getValue() != null) && !properties0[i]
-                                    .getValue().equals(
-                                            properties1[i].getValue()))))) { return false; }
+                    if ((properties0 == null) || (properties1 == null)
+                            || (properties0.length != properties1.length)) { return false; }
+
+                    // compare ordered locator properties
+                    for (int i = 0, limit = properties0.length; (i < limit); i++)
+                    {
+                        // compare property names, control flags, navigation flags,
+                        // and values. note: properties values are compared only for
+                        // control or navigation properties; otherwise they are
+                        // assumed to contain variable request paths that should
+                        // be treated as equivalent
+                        if (!properties0[i].getName().equals(
+                                properties1[i].getName())
+                                || (properties0[i].isControl() && !properties1[i]
+                                        .isControl())
+                                || (properties0[i].isNavigation() && !properties1[i]
+                                        .isNavigation())
+                                || ((properties0[i].isControl() || properties0[i]
+                                        .isNavigation()) && (((properties0[i]
+                                        .getValue() == null) && (properties1[i]
+                                        .getValue() != null)) || ((properties0[i]
+                                        .getValue() != null) && !properties0[i]
+                                        .getValue().equals(
+                                                properties1[i].getValue()))))) { return false; }
+                    }
                 }
             }
         }
@@ -1374,7 +1388,7 @@
     {
         if (folderPageHistory == null)
         {
-            folderPageHistory = new HashMap();
+            folderPageHistory = Collections.synchronizedMap(new HashMap());
         }
         return folderPageHistory;
     }

Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java	2008-10-30 08:12:16 UTC (rev 1266)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java	2008-10-31 01:36:52 UTC (rev 1267)
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.portalsite.view;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -146,7 +147,8 @@
         if ((searchPaths != null) && !searchPaths.isEmpty())
         {
             // validate search path format and existence
-            this.searchPaths = new ArrayList(searchPaths.size());
+            this.searchPaths = Collections.synchronizedList(new ArrayList(
+                    searchPaths.size()));
             StringBuffer searchPathsStringBuffer = new StringBuffer();
             Iterator pathsIter = searchPaths.iterator();
             while (pathsIter.hasNext())
@@ -350,18 +352,22 @@
             {
                 // DONE Findbugs
                 // Iterator locatorNameIter = locators.keySet().iterator();
-                Iterator locatorNameIter = locators.entrySet().iterator();
-                while (locatorNameIter.hasNext())
+                synchronized (locators)
                 {
-                    Map.Entry _entry = (Map.Entry) locatorNameIter.next();
-                    // String locatorName = (String) locatorNameIter.next();
-                    String locatorName = (String) _entry.getKey();
-                    if (!locatorName.equals(ProfileLocator.PAGE_LOCATOR))
+                    Iterator locatorNameIter = locators.entrySet().iterator();
+                    while (locatorNameIter.hasNext())
                     {
-                        // add alternate locator search paths
-                        mergeSearchPathList(locatorName,
-                        // (ProfileLocator) locators.get(locatorName),
-                                (ProfileLocator) _entry.getValue(), searchPaths);
+                        Map.Entry _entry = (Map.Entry) locatorNameIter.next();
+                        // String locatorName = (String) locatorNameIter.next();
+                        String locatorName = (String) _entry.getKey();
+                        if (!locatorName.equals(ProfileLocator.PAGE_LOCATOR))
+                        {
+                            // add alternate locator search paths
+                            mergeSearchPathList(locatorName,
+                                    // (ProfileLocator) locators.get(locatorName),
+                                    (ProfileLocator) _entry.getValue(),
+                                    searchPaths);
+                        }
                     }
                 }
             }


pal-cvs メーリングリストの案内
Zurück zum Archiv-Index