You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2017/08/24 21:51:45 UTC

svn commit: r1806090 - in /myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces: application/viewstate/SerializedViewCollection.java flow/cdi/ClientWindowFacesFlowLRUMap.java flow/cdi/FacesFlowClientWindowCollection.java

Author: tandraschko
Date: Thu Aug 24 21:51:45 2017
New Revision: 1806090

URL: http://svn.apache.org/viewvc?rev=1806090&view=rev
Log:
MYFACES-4135 Replace LRUMap

Modified:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/ClientWindowFacesFlowLRUMap.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FacesFlowClientWindowCollection.java

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java?rev=1806090&r1=1806089&r2=1806090&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java Thu Aug 24 21:51:45 2017
@@ -25,9 +25,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 import javax.faces.context.FacesContext;
-import org.apache.commons.collections.map.LRUMap;
 import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.spi.ViewScopeProvider;
+import org.apache.myfaces.shared.util.LRULinkedHashMap;
 
 /**
  *
@@ -252,13 +252,13 @@ class SerializedViewCollection implement
         {
             Integer i = getNumberOfSequentialViewsInSession(context);
             int j = getNumberOfViewsInSession(context);
-            if (i != null && i.intValue() > 0)
+            if (i != null && i> 0)
             {
-                _lastWindowKeys = new LRUMap((j / i.intValue()) + 1);
+                _lastWindowKeys = new LRULinkedHashMap<>((j / i) + 1);
             }
             else
             {
-                _lastWindowKeys = new LRUMap(j + 1);
+                _lastWindowKeys = new LRULinkedHashMap(j + 1);
             }
         }
         _lastWindowKeys.put(id, key);

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/ClientWindowFacesFlowLRUMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/ClientWindowFacesFlowLRUMap.java?rev=1806090&r1=1806089&r2=1806090&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/ClientWindowFacesFlowLRUMap.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/ClientWindowFacesFlowLRUMap.java Thu Aug 24 21:51:45 2017
@@ -1,81 +1,53 @@
-/*
- * 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.myfaces.flow.cdi;
-
-import java.io.Serializable;
-import java.util.Map;
-import org.apache.commons.collections.map.LRUMap;
-
-/**
- *
- */
-class ClientWindowFacesFlowLRUMap extends LRUMap implements Serializable
-{
-    private transient FlowScopeBeanHolder holder;
-
-    public ClientWindowFacesFlowLRUMap()
-    {
-    }
-
-    public ClientWindowFacesFlowLRUMap(int maxSize)
-    {
-        super(maxSize);
-    }
-
-    public ClientWindowFacesFlowLRUMap(int maxSize, boolean scanUntilRemovable)
-    {
-        super(maxSize, scanUntilRemovable);
-    }
-
-    public ClientWindowFacesFlowLRUMap(int maxSize, float loadFactor)
-    {
-        super(maxSize, loadFactor);
-    }
-
-    public ClientWindowFacesFlowLRUMap(int maxSize, float loadFactor, boolean scanUntilRemovable)
-    {
-        super(maxSize, loadFactor, scanUntilRemovable);
-    }
-
-    public ClientWindowFacesFlowLRUMap(Map map)
-    {
-        super(map);
-    }
-
-    public ClientWindowFacesFlowLRUMap(Map map, boolean scanUntilRemovable)
-    {
-        super(map, scanUntilRemovable);
-    }
-    
-    public void setFlowScopeBeanHolder(FlowScopeBeanHolder holder)
-    {
-        this.holder = holder;
-    }
-    
-    @Override
-    protected boolean removeLRU(LinkEntry entry)
-    {
-        if (holder != null)
-        {
-            holder.clearFlowMap((String) entry.getKey());
-        }
-        return super.removeLRU(entry);
-    }
-}
+/*
+ * 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.myfaces.flow.cdi;
+
+import java.io.Serializable;
+import java.util.Map;
+import org.apache.myfaces.shared.util.LRULinkedHashMap;
+
+/**
+ *
+ */
+class ClientWindowFacesFlowLRUMap extends LRULinkedHashMap<String, String> implements Serializable
+{
+    private transient FlowScopeBeanHolder holder;
+
+    public ClientWindowFacesFlowLRUMap(int capacity)
+    {
+        super(capacity);
+    }
+
+    public void setFlowScopeBeanHolder(FlowScopeBeanHolder holder)
+    {
+        this.holder = holder;
+    }
+    
+    @Override
+    protected boolean removeEldestEntry(Map.Entry<String, String> eldest)
+    {
+        if (holder != null)
+        {
+            holder.clearFlowMap((String) eldest.getKey());
+        }
+
+        return super.removeEldestEntry(eldest);
+    }
+}

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FacesFlowClientWindowCollection.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FacesFlowClientWindowCollection.java?rev=1806090&r1=1806089&r2=1806090&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FacesFlowClientWindowCollection.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FacesFlowClientWindowCollection.java Thu Aug 24 21:51:45 2017
@@ -1,64 +1,64 @@
-/*
- * 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.myfaces.flow.cdi;
-
-import java.io.Serializable;
-
-/**
- * This class is a wrapper used to deal with concurrency issues when accessing the inner LRUMap.
- */
-class FacesFlowClientWindowCollection implements Serializable
-{
-    private ClientWindowFacesFlowLRUMap lruMap;
-
-    public FacesFlowClientWindowCollection(ClientWindowFacesFlowLRUMap lruMap)
-    {
-        this.lruMap = lruMap;
-    }
-
-    public FacesFlowClientWindowCollection()
-    {
-    }
-    
-    public synchronized void put(String key, String value)
-    {
-        lruMap.put(key, value);
-    }
-    
-    public synchronized String get(String key)
-    {
-        return (String) lruMap.get(key);
-    }
-    
-    public synchronized void remove(String key)
-    {
-        lruMap.remove(key);
-    }
-    
-    public synchronized boolean isEmpty()
-    {
-        return lruMap.isEmpty();
-    }
-    
-    public void setFlowScopeBeanHolder(FlowScopeBeanHolder holder)
-    {
-        lruMap.setFlowScopeBeanHolder(holder);
-    }
-    
-}
+/*
+ * 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.myfaces.flow.cdi;
+
+import java.io.Serializable;
+
+/**
+ * This class is a wrapper used to deal with concurrency issues when accessing the inner LRUMap.
+ */
+class FacesFlowClientWindowCollection implements Serializable
+{
+    private ClientWindowFacesFlowLRUMap map;
+
+    public FacesFlowClientWindowCollection(ClientWindowFacesFlowLRUMap map)
+    {
+        this.map = map;
+    }
+
+    public FacesFlowClientWindowCollection()
+    {
+    }
+    
+    public synchronized void put(String key, String value)
+    {
+        map.put(key, value);
+    }
+    
+    public synchronized String get(String key)
+    {
+        return map.get(key);
+    }
+    
+    public synchronized void remove(String key)
+    {
+        map.remove(key);
+    }
+    
+    public synchronized boolean isEmpty()
+    {
+        return map.isEmpty();
+    }
+    
+    public void setFlowScopeBeanHolder(FlowScopeBeanHolder holder)
+    {
+        map.setFlowScopeBeanHolder(holder);
+    }
+    
+}