exo-jcr SVN: r1062 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-15 09:15:35 -0500 (Tue, 15 Dec 2009)
New Revision: 1062
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
Log:
EXOJCR-300: fix order number
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 14:09:37 UTC (rev 1061)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 14:15:35 UTC (rev 1062)
@@ -390,7 +390,7 @@
if (vd.isByteArray())
{
- pvd = new ByteArrayPersistedValueData(vd.getAsByteArray(), vd.getOrderNumber());
+ pvd = new ByteArrayPersistedValueData(vd.getAsByteArray(), i);
values.add(pvd);
}
else
16 years, 7 months
exo-jcr SVN: r1061 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: storage/jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-15 09:09:37 -0500 (Tue, 15 Dec 2009)
New Revision: 1061
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
Log:
EXOJCR-300: fix orderNumber
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 13:52:25 UTC (rev 1060)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 14:09:37 UTC (rev 1061)
@@ -379,8 +379,10 @@
if (prevData.getValues() != null)
{
List<ValueData> values = new ArrayList<ValueData>();
- for (ValueData vd : prevData.getValues())
+ for (int i = 0; i < prevData.getValues().size(); i++)
{
+ ValueData vd = prevData.getValues().get(i);
+
if (vd instanceof TransientValueData)
{
TransientValueData tvd = (TransientValueData)vd;
@@ -401,7 +403,7 @@
// TODO review TransientValueData logic about spool file and stream
pvd =
new StreamPersistedValueData(destFile, tvd.getSpoolFile(), tvd.getSpoolFile() == null
- ? tvd.getOriginalStream() : null, vd.getOrderNumber());
+ ? tvd.getOriginalStream() : null, i);
values.add(pvd);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-12-15 13:52:25 UTC (rev 1060)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-12-15 14:09:37 UTC (rev 1061)
@@ -1903,7 +1903,6 @@
for (int i = 0; i < vdata.size(); i++)
{
ValueData vd = vdata.get(i);
- // TODO vd.setOrderNumber(i);
ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
InputStream stream;
int streamLength;
16 years, 7 months
exo-jcr SVN: r1060 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-15 08:52:25 -0500 (Tue, 15 Dec 2009)
New Revision: 1060
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
Log:
EXOJCR-313: WebdavMoveNodeTest added
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-15 13:36:16 UTC (rev 1059)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-15 13:52:25 UTC (rev 1060)
@@ -58,28 +58,28 @@
// check results
// cluster-node1
response = connection1.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
byte[] respData = response.getData();
assertEquals(data.length, respData.length);
assertTrue(java.util.Arrays.equals(data, respData));
// cluster-node2
response = connection2.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
respData = response.getData();
assertEquals(data.length, respData.length);
assertTrue(java.util.Arrays.equals(data, respData));
// cluster-node3
response = connection3.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
respData = response.getData();
assertEquals(data.length, respData.length);
assertTrue(java.util.Arrays.equals(data, respData));
// cluster-node4
response = connection4.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
respData = response.getData();
assertEquals(data.length, respData.length);
assertTrue(java.util.Arrays.equals(data, respData));
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-15 13:36:16 UTC (rev 1059)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-15 13:52:25 UTC (rev 1060)
@@ -38,22 +38,22 @@
// check is node exist
// cluster-node1
HTTPResponse response = connection1.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
assertTrue("_data_".equals(new String(response.getData())));
// cluster-node2
HTTPResponse response2 = connection2.getNode(nodeName);
- assertEquals(response2.getStatusCode(), 200);
+ assertEquals(200, response2.getStatusCode());
assertTrue("_data_".equals(new String(response2.getData())));
// cluster-node3
HTTPResponse response3 = connection3.getNode(nodeName);
- assertEquals(response3.getStatusCode(), 200);
+ assertEquals(200, response3.getStatusCode());
assertTrue("_data_".equals(new String(response3.getData())));
// cluster-node4
HTTPResponse response4 = connection4.getNode(nodeName);
- assertEquals(response4.getStatusCode(), 200);
+ assertEquals(200, response4.getStatusCode());
assertTrue("_data_".equals(new String(response4.getData())));
}
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java 2009-12-15 13:52:25 UTC (rev 1060)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: WebdavMoveNodeTest.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class WebdavMoveNodeTest extends BaseClusteringFunctionalTest
+{
+ public void testMoveNode() throws Exception
+ {
+ String newNodeName = nodeName + "new";
+
+ // add node
+ connection1.addNode(nodeName, "".getBytes());
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(200, response4.getStatusCode());
+
+ // move node on cluster-node3
+
+ response = connection3.Move(nodeName, newNodeName);
+ response.getStatusCode();
+
+ // check is node not exist
+ // cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(nodeName);
+ assertEquals(404, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(nodeName);
+ assertEquals(404, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(nodeName);
+ assertEquals(404, response4.getStatusCode());
+
+ // check is node exist
+ // cluster-node1
+ response = connection1.getNode(newNodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(newNodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(newNodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(newNodeName);
+ assertEquals(200, response4.getStatusCode());
+ }
+}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-15 13:36:16 UTC (rev 1059)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-15 13:52:25 UTC (rev 1060)
@@ -36,35 +36,35 @@
// check is exist cluster-node1
HTTPResponse response = connection1.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
//cluster-node2
response = connection2.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
//cluster-node3
response = connection3.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
//cluster-node4
response = connection4.getNode(nodeName);
- assertEquals(response.getStatusCode(), 200);
+ assertEquals(200, response.getStatusCode());
// remove node on cluster-node2
connection2.removeNode(nodeName);
// check cluster-node1
response = connection1.getNode(nodeName);
- assertEquals(response.getStatusCode(), 404);
+ assertEquals(404, response.getStatusCode());
// cluster-node2
response = connection2.getNode(nodeName);
- assertEquals(response.getStatusCode(), 404);
+ assertEquals(404, response.getStatusCode());
// cluster-node3
response = connection3.getNode(nodeName);
- assertEquals(response.getStatusCode(), 404);
+ assertEquals(404, response.getStatusCode());
// cluster-node4
response = connection4.getNode(nodeName);
- assertEquals(response.getStatusCode(), 404);
+ assertEquals(404, response.getStatusCode());
}
16 years, 7 months
exo-jcr SVN: r1059 - in kernel/branches/config-branch: exo.kernel.commons and 37 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-12-15 08:36:16 -0500 (Tue, 15 Dec 2009)
New Revision: 1059
Added:
kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java
kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml
Removed:
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml
Modified:
kernel/branches/config-branch/exo.kernel.commons/pom.xml
kernel/branches/config-branch/exo.kernel.component.cache/pom.xml
kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java
kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExpireKeyStartWithSelector.java
kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
kernel/branches/config-branch/exo.kernel.component.command/pom.xml
kernel/branches/config-branch/exo.kernel.component.common/pom.xml
kernel/branches/config-branch/exo.kernel.component.remote/pom.xml
kernel/branches/config-branch/exo.kernel.container/pom.xml
kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/client/http/ClientTypeMap.java
kernel/branches/config-branch/packaging/module/pom.xml
kernel/branches/config-branch/pom.xml
Log:
merge up to trunk revision 1056
Modified: kernel/branches/config-branch/exo.kernel.commons/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.commons/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.commons/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.commons</artifactId>
Modified: kernel/branches/config-branch/exo.kernel.component.cache/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.cache/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.cache</artifactId>
Modified: kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -19,27 +19,54 @@
package org.exoplatform.services.cache;
/**
+ * This class defines the main configuration properties of an {@link org.exoplatform.services.cache.ExoCache}
+ *
* @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
* @since Feb 20, 2005
* @version $Id: ExoCacheConfig.java 5799 2006-05-28 17:55:42Z geaz $
*/
-public class ExoCacheConfig
+public class ExoCacheConfig implements Cloneable
{
+ /**
+ * The name of the cache.
+ */
private String name;
+ /**
+ * The label of the cache.
+ */
private String label;
+ /**
+ * The maximum numbers of elements in cache.
+ */
private int maxSize;
+ /**
+ * The amount of time (in milliseconds) an element is not written or
+ * read before it is evicted.
+ */
private long liveTime;
- private boolean distributed = false;
+ /**
+ * Indicates if the cache is distributed
+ */
+ private boolean distributed;
- private boolean replicated = false;
+ /**
+ * Indicates if the cache is replicated
+ */
+ private boolean replicated;
+ /**
+ * The full qualified name of the cache implementation to use
+ */
private String implementation;
- private boolean logEnabled = false;
+ /**
+ * Indicates if the log is enabled
+ */
+ private boolean logEnabled;
public String getName()
{
@@ -91,8 +118,6 @@
distributed = b;
}
- // public void setDistributed(String b) { distributed_ = "true".equals(b) ; }
-
public boolean isRepicated()
{
return replicated;
@@ -122,4 +147,20 @@
{
this.logEnabled = enableLogging;
}
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public ExoCacheConfig clone() throws CloneNotSupportedException
+ {
+ try
+ {
+ return (ExoCacheConfig)super.clone();
+ }
+ catch (Exception e)
+ {
+ throw new AssertionError();
+ }
+ }
}
Copied: kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java (from rev 1056, kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache;
+
+/**
+ * This class allows you to create a new instance of {@link org.exoplatform.services.cache.ExoCache}
+ *
+ * @author <a href="mailto:dmitry.kataev@exoplatform.com">Dmytro Katayev</a>
+ * @version $Id$
+ *
+ */
+public interface ExoCacheFactory
+{
+
+ /**
+ * Creates a new instance of {@link org.exoplatform.services.cache.ExoCache}
+ * @param config the cache to create
+ * @return the new instance of {@link org.exoplatform.services.cache.ExoCache}
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException;
+
+}
Copied: kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java (from rev 1056, kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache;
+
+/**
+ * An exception that represents any type of exception that prevent the initialization of
+ * the {@link org.exoplatform.services.cache.ExoCache}
+ *
+ * @author <a href="mailto:dmitry.kataev@exoplatform.com">Dmytro Katayev</a>
+ * @version $Id$
+ *
+ */
+public class ExoCacheInitException extends Exception
+{
+
+ /**
+ * The serial version UID
+ */
+ private static final long serialVersionUID = -5612051266167302943L;
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCacheInitException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCacheInitException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCacheInitException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Modified: kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExpireKeyStartWithSelector.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExpireKeyStartWithSelector.java 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExpireKeyStartWithSelector.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -42,7 +42,7 @@
return false;
}
- public void onSelect(ExoCache<? extends K, ? extends V> cache, K key, ObjectCacheInfo<? extends V> ocinfo)
+ public void onSelect(ExoCache<? extends K, ? extends V> cache, K key, ObjectCacheInfo<? extends V> ocinfo) throws Exception
{
cache.remove(key);
}
Modified: kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,6 +25,8 @@
import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.cache.ExoCacheConfig;
import org.exoplatform.services.cache.ExoCacheConfigPlugin;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
import org.exoplatform.services.cache.SimpleExoCache;
import java.io.Serializable;
@@ -40,19 +42,29 @@
@ManagedBy(CacheServiceManaged.class)
public class CacheServiceImpl implements CacheService
{
- private HashMap<String, ExoCacheConfig> configs_ = new HashMap<String, ExoCacheConfig>();
+ private final HashMap<String, ExoCacheConfig> configs_ = new HashMap<String, ExoCacheConfig>();
private final ConcurrentHashMap<String, ExoCache<? extends Serializable, ?>> cacheMap_ =
new ConcurrentHashMap<String, ExoCache<? extends Serializable, ?>>();
- private ExoCacheConfig defaultConfig_;
+ private final ExoCacheConfig defaultConfig_;
- private LoggingCacheListener loggingListener_;
+ private final LoggingCacheListener loggingListener_;
+ private final ExoCacheFactory factory_;
+
CacheServiceManaged managed;
+ /**
+ *
+ */
public CacheServiceImpl(InitParams params) throws Exception
{
+ this(params, null);
+ }
+
+ public CacheServiceImpl(InitParams params, ExoCacheFactory factory) throws Exception
+ {
List<ExoCacheConfig> configs = params.getObjectParamValues(ExoCacheConfig.class);
for (ExoCacheConfig config : configs)
{
@@ -60,6 +72,7 @@
}
defaultConfig_ = configs_.get("default");
loggingListener_ = new LoggingCacheListener();
+ factory_ = factory == null ? new SimpleExoCacheFactory() : factory;
}
public void addExoCacheConfig(ComponentPlugin plugin)
@@ -111,40 +124,83 @@
ExoCacheConfig config = configs_.get(region);
if (config == null)
config = defaultConfig_;
- ExoCache<? extends Serializable, ?> cache;
- if (config.getImplementation() == null)
- {
- cache = new SimpleExoCache<Serializable, Object>();
- }
- else
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Class<ExoCache<? extends Serializable, ?>> clazz =
- (Class<ExoCache<? extends Serializable, ?>>)cl.loadClass(config.getImplementation());
- cache = clazz.newInstance();
- }
- cache.setName(region);
- cache.setLabel(config.getLabel());
- cache.setMaxSize(config.getMaxSize());
- cache.setLiveTime(config.getLiveTime());
- cache.setLogEnabled(config.isLogEnabled());
- if (cache.isLogEnabled())
- {
- cache.addCacheListener(loggingListener_);
- }
- //
+ // Ensure the configuration integrity
+ final ExoCacheConfig safeConfig = config.clone();
+ // Set the region as name
+ safeConfig.setName(region);
+ final ExoCache simple = factory_.createCache(safeConfig);
+
if (managed != null)
{
- managed.registerCache(cache);
+ managed.registerCache(simple);
}
-
- //
- return cache;
+ return simple;
}
public Collection<ExoCache<? extends Serializable, ?>> getAllCacheInstances()
{
return cacheMap_.values();
}
+
+ /**
+ * Default implementation of an {@link org.exoplatform.services.cache.ExoCacheFactory}
+ */
+ private class SimpleExoCacheFactory implements ExoCacheFactory
+ {
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ final ExoCache simple = createCacheInstance(config);
+ simple.setName(config.getName());
+ simple.setLabel(config.getLabel());
+ simple.setMaxSize(config.getMaxSize());
+ simple.setLiveTime(config.getLiveTime());
+ // simple.setReplicated(config.isRepicated());
+ // simple.setDistributed(config.isDistributed());
+ // if (simple.isDistributed()) {
+ // simple.addCacheListener(distrbutedListener_);
+ // }
+ simple.setLogEnabled(config.isLogEnabled());
+ if (simple.isLogEnabled())
+ {
+ simple.addCacheListener(loggingListener_);
+ }
+ return simple;
+ }
+
+ /**
+ * Create a new instance of ExoCache according to the given configuration
+ * @param config the ExoCache configuration
+ * @return a new instance of ExoCache
+ * @throws ExoCacheInitException if any exception happens while initializing the cache
+ */
+ @SuppressWarnings("unchecked")
+ private ExoCache createCacheInstance(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ if (config.getImplementation() == null)
+ {
+ // No implementation has been defined
+ return new SimpleExoCache();
+ }
+ else
+ {
+ // An implementation has been defined
+ final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ final Class clazz = cl.loadClass(config.getImplementation());
+ return (ExoCache)clazz.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("Cannot create instance of ExoCache of type "
+ + config.getImplementation(), e);
+ }
+ }
+ }
+ }
}
Modified: kernel/branches/config-branch/exo.kernel.component.command/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.command/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.command/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.command</artifactId>
Modified: kernel/branches/config-branch/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.common/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.common/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.common</artifactId>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3 (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,64 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta05-SNAPSHOT</version>
- </parent>
-
- <artifactId>exo.kernel.component.ext.cache.impl.jboss.v3</artifactId>
- <name>eXo Kernel :: Cache Extension :: JBoss Cache Implementation</name>
- <description>JBoss Cache Implementation for the Cache Service</description>
-
- <dependencies>
- <dependency>
- <groupId>org.exoplatform.tool</groupId>
- <artifactId>exo.tool.framework.junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.commons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.cache</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-core</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <!-- We add this system property due to some incompatibility between IPv6 and
- some JVM of Linux distributions such as Ubuntu and Fedora-->
- <property>
- <name>java.net.preferIPv4Stack</name>
- <value>true</value>
- </property>
- <!-- Avoid the firewall -->
- <property>
- <name>bind.address</name>
- <value>127.0.0.1</value>
- </property>
- <property>
- <name>jgroups.stack</name>
- <value>udp</value>
- </property>
-
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,64 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.kernel.component.ext.cache.impl.jboss.v3</artifactId>
+ <name>eXo Kernel :: Cache Extension :: JBoss Cache Implementation</name>
+ <description>JBoss Cache Implementation for the Cache Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <!-- We add this system property due to some incompatibility between IPv6 and
+ some JVM of Linux distributions such as Ubuntu and Fedora-->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Avoid the firewall -->
+ <property>
+ <name>bind.address</name>
+ <value>127.0.0.1</value>
+ </property>
+ <property>
+ <name>jgroups.stack</name>
+ <value>udp</value>
+ </property>
+
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,640 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.services.cache.CacheInfo;
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CacheListenerContext;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ObjectCacheInfo;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.notifications.annotation.NodeEvicted;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.event.EventImpl;
-import org.jboss.cache.notifications.event.NodeEvent;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * An {@link org.exoplatform.services.cache.ExoCache} implementation based on {@link org.jboss.cache.Node}.
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 20 juil. 2009
- */
-public abstract class AbstractExoCache<K extends Serializable, V> implements ExoCache<K, V>
-{
-
- /**
- * Logger.
- */
- private static final Log LOG = ExoLogger.getLogger(AbstractExoCache.class);
-
- private final AtomicInteger hits = new AtomicInteger(0);
-
- private final AtomicInteger misses = new AtomicInteger(0);
-
- private String label;
-
- private String name;
-
- private boolean distributed;
-
- private boolean replicated;
-
- private boolean logEnabled;
-
- private final CopyOnWriteArrayList<ListenerContext<K, V>> listeners;
-
- protected final CacheSPI<K, V> cache;
-
- public AbstractExoCache(ExoCacheConfig config, Cache<K, V> cache)
- {
- this.cache = (CacheSPI<K, V>)cache;
- this.listeners = new CopyOnWriteArrayList<ListenerContext<K, V>>();
- setDistributed(config.isDistributed());
- setLabel(config.getLabel());
- setName(config.getName());
- setLogEnabled(config.isLogEnabled());
- setReplicated(config.isRepicated());
- cache.getConfiguration().setInvocationBatchingEnabled(true);
- cache.addCacheListener(new CacheEventListener());
- }
-
- /**
- * {@inheritDoc}
- */
- public void addCacheListener(CacheListener<? super K, ? super V> listener)
- {
- if (listener == null)
- {
- throw new NullPointerException();
- }
- listeners.add(new ListenerContext<K, V>(listener, this));
- }
-
- /**
- * {@inheritDoc}
- */
- public void clearCache()
- {
- final Node<K, V> rootNode = cache.getRoot();
- for (Node<K, V> node : rootNode.getChildren())
- {
- if (node == null)
- {
- continue;
- }
- remove(getKey(node));
- }
- onClearCache();
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public V get(Serializable name)
- {
- if (name == null)
- {
- return null;
- }
- final V result = cache.get(getFqn(name), (K)name);
- if (result == null)
- {
- misses.incrementAndGet();
- }
- else
- {
- hits.incrementAndGet();
- }
- onGet((K)name, result);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheHit()
- {
- return hits.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheMiss()
- {
- return misses.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheSize()
- {
- return cache.getNumberOfNodes();
- }
-
- /**
- * {@inheritDoc}
- */
- public List<V> getCachedObjects()
- {
- final LinkedList<V> list = new LinkedList<V>();
- for (Node<K, V> node : cache.getRoot().getChildren())
- {
- if (node == null)
- {
- continue;
- }
- final V value = node.get(getKey(node));
- if (value != null)
- {
- list.add(value);
- }
- }
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLabel()
- {
- return label;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDistributed()
- {
- return distributed;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isLogEnabled()
- {
- return logEnabled;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isReplicated()
- {
- return replicated;
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(K key, V value) throws NullPointerException
- {
- if (key == null)
- {
- throw new NullPointerException("No null cache key accepted");
- }
- putOnly(key, value);
- onPut(key, value);
- }
-
- /**
- * Only puts the data into the cache nothing more
- */
- private V putOnly(K key, V value)
- {
- return cache.put(getFqn(key), key, value);
- }
-
- /**
- * {@inheritDoc}
- */
- public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
- {
- if (objs == null)
- {
- throw new NullPointerException("No null map accepted");
- }
- for (Serializable name : objs.keySet())
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null cache key accepted");
- }
- }
- cache.startBatch();
- int total = 0;
- try
- {
- // Start transaction
- for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
- {
- V value = putOnly(entry.getKey(), entry.getValue());
- if (value == null)
- {
- total++;
- }
- }
- cache.endBatch(true);
- // End transaction
- for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
- {
- onPut(entry.getKey(), entry.getValue());
- }
- }
- catch (Exception e)
- {
- cache.endBatch(false);
- LOG.warn("An error occurs while executing the putMap method", e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public V remove(Serializable name) throws NullPointerException
- {
- if (name == null)
- {
- throw new NullPointerException("No null cache key accepted");
- }
- final Fqn<Serializable> fqn = getFqn(name);
- final NodeSPI<K, V> node = cache.getNode(fqn);
- V result = null;
- if (node != null)
- {
- result = node.getDirect((K)name);
- if (cache.removeNode(fqn))
- {
- onRemove((K)name, result);
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public List<V> removeCachedObjects()
- {
- final List<V> list = getCachedObjects();
- clearCache();
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
- {
- if (selector == null)
- {
- throw new IllegalArgumentException("No null selector");
- }
- for (Node<K, V> node : cache.getRoot().getChildren())
- {
- if (node == null)
- {
- continue;
- }
- final K key = getKey(node);
- final V value = node.get(key);
- ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
- {
- public V get()
- {
- return value;
- }
-
- public long getExpireTime()
- {
- // Cannot know: The expire time is managed by JBoss Cache itself
- return -1;
- }
- };
- if (selector.select(key, info))
- {
- selector.onSelect(this, key, info);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDistributed(boolean distributed)
- {
- this.distributed = distributed;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLabel(String label)
- {
- this.label = label;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLogEnabled(boolean logEnabled)
- {
- this.logEnabled = logEnabled;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setReplicated(boolean replicated)
- {
- this.replicated = replicated;
- }
-
- /**
- * Returns the key related to the given node
- */
- private K getKey(Node<K, V> node)
- {
- return getKey(node.getFqn());
- }
-
- /**
- * Returns the key related to the given Fqn
- */
- @SuppressWarnings("unchecked")
- private K getKey(Fqn fqn)
- {
- return (K)fqn.get(0);
- }
-
- /**
- * Returns the Fqn related to the given name
- */
- private Fqn<Serializable> getFqn(Serializable name)
- {
- return Fqn.fromElements(name);
- }
-
- void onExpire(K key, V obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext<K, V> context : listeners)
- {
- try
- {
- context.onExpire(key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- void onRemove(K key, V obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext<K, V> context : listeners)
- {
- try
- {
- context.onRemove(key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- void onPut(K key, V obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext<K, V> context : listeners)
- try
- {
- context.onPut(key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- void onGet(K key, V obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext<K, V> context : listeners)
- try
- {
- context.onGet(key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- void onClearCache()
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext<K, V> context : listeners)
- try
- {
- context.onClearCache();
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- @org.jboss.cache.notifications.annotation.CacheListener
- public class CacheEventListener
- {
-
- @NodeEvicted
- public void nodeEvicted(NodeEvent ne)
- {
- if (ne.isPre())
- {
- // Cannot give the value since
- // since it disturbs the eviction
- // algorithms
- onExpire(getKey(ne.getFqn()), null);
- }
- }
-
- @NodeRemoved
- public void nodeRemoved(NodeEvent ne)
- {
- if (ne.isPre() && !ne.isOriginLocal())
- {
- final Node<K, V> node = cache.getNode(ne.getFqn());
- final K key = getKey(ne.getFqn());
- onRemove(key, node.get(key));
- }
- }
-
- @SuppressWarnings("unchecked")
- @NodeModified
- public void nodeModified(NodeEvent ne)
- {
- if (!ne.isOriginLocal() && !ne.isPre())
- {
- final K key = getKey(ne.getFqn());
- if (ne instanceof EventImpl)
- {
- EventImpl evt = (EventImpl)ne;
- Map<K, V> data = evt.getData();
- if (data != null)
- {
- onPut(key, data.get(key));
- return;
- }
- }
- final Node<K, V> node = cache.getNode(ne.getFqn());
- onPut(key, node.get(key));
- }
- }
- }
-
- private static class ListenerContext<K extends Serializable, V> implements CacheListenerContext, CacheInfo
- {
-
- /** . */
- private final ExoCache<K, V> cache;
-
- /** . */
- final CacheListener<? super K, ? super V> listener;
-
- public ListenerContext(CacheListener<? super K, ? super V> listener, ExoCache<K, V> cache)
- {
- this.listener = listener;
- this.cache = cache;
- }
-
- public CacheInfo getCacheInfo()
- {
- return this;
- }
-
- public String getName()
- {
- return cache.getName();
- }
-
- public int getMaxSize()
- {
- return cache.getMaxSize();
- }
-
- public long getLiveTime()
- {
- return cache.getLiveTime();
- }
-
- public int getSize()
- {
- return cache.getCacheSize();
- }
-
- void onExpire(K key, V obj) throws Exception
- {
- listener.onExpire(this, key, obj);
- }
-
- void onRemove(K key, V obj) throws Exception
- {
- listener.onRemove(this, key, obj);
- }
-
- void onPut(K key, V obj) throws Exception
- {
- listener.onPut(this, key, obj);
- }
-
- void onGet(K key, V obj) throws Exception
- {
- listener.onGet(this, key, obj);
- }
-
- void onClearCache() throws Exception
- {
- listener.onClearCache(this);
- }
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,640 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.CacheInfo;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.notifications.annotation.NodeEvicted;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.EventImpl;
+import org.jboss.cache.notifications.event.NodeEvent;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * An {@link org.exoplatform.services.cache.ExoCache} implementation based on {@link org.jboss.cache.Node}.
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public abstract class AbstractExoCache<K extends Serializable, V> implements ExoCache<K, V>
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(AbstractExoCache.class);
+
+ private final AtomicInteger hits = new AtomicInteger(0);
+
+ private final AtomicInteger misses = new AtomicInteger(0);
+
+ private String label;
+
+ private String name;
+
+ private boolean distributed;
+
+ private boolean replicated;
+
+ private boolean logEnabled;
+
+ private final CopyOnWriteArrayList<ListenerContext<K, V>> listeners;
+
+ protected final CacheSPI<K, V> cache;
+
+ public AbstractExoCache(ExoCacheConfig config, Cache<K, V> cache)
+ {
+ this.cache = (CacheSPI<K, V>)cache;
+ this.listeners = new CopyOnWriteArrayList<ListenerContext<K, V>>();
+ setDistributed(config.isDistributed());
+ setLabel(config.getLabel());
+ setName(config.getName());
+ setLogEnabled(config.isLogEnabled());
+ setReplicated(config.isRepicated());
+ cache.getConfiguration().setInvocationBatchingEnabled(true);
+ cache.addCacheListener(new CacheEventListener());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCacheListener(CacheListener<? super K, ? super V> listener)
+ {
+ if (listener == null)
+ {
+ throw new NullPointerException();
+ }
+ listeners.add(new ListenerContext<K, V>(listener, this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearCache()
+ {
+ final Node<K, V> rootNode = cache.getRoot();
+ for (Node<K, V> node : rootNode.getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ remove(getKey(node));
+ }
+ onClearCache();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V get(Serializable name)
+ {
+ if (name == null)
+ {
+ return null;
+ }
+ final V result = cache.get(getFqn(name), (K)name);
+ if (result == null)
+ {
+ misses.incrementAndGet();
+ }
+ else
+ {
+ hits.incrementAndGet();
+ }
+ onGet((K)name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheHit()
+ {
+ return hits.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheMiss()
+ {
+ return misses.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheSize()
+ {
+ return cache.getNumberOfNodes();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> getCachedObjects()
+ {
+ final LinkedList<V> list = new LinkedList<V>();
+ for (Node<K, V> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final V value = node.get(getKey(node));
+ if (value != null)
+ {
+ list.add(value);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDistributed()
+ {
+ return distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLogEnabled()
+ {
+ return logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isReplicated()
+ {
+ return replicated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(K key, V value) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ putOnly(key, value);
+ onPut(key, value);
+ }
+
+ /**
+ * Only puts the data into the cache nothing more
+ */
+ private V putOnly(K key, V value)
+ {
+ return cache.put(getFqn(key), key, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
+ {
+ if (objs == null)
+ {
+ throw new NullPointerException("No null map accepted");
+ }
+ for (Serializable name : objs.keySet())
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null cache key accepted");
+ }
+ }
+ cache.startBatch();
+ int total = 0;
+ try
+ {
+ // Start transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ V value = putOnly(entry.getKey(), entry.getValue());
+ if (value == null)
+ {
+ total++;
+ }
+ }
+ cache.endBatch(true);
+ // End transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ onPut(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (Exception e)
+ {
+ cache.endBatch(false);
+ LOG.warn("An error occurs while executing the putMap method", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V remove(Serializable name) throws NullPointerException
+ {
+ if (name == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ final Fqn<Serializable> fqn = getFqn(name);
+ final NodeSPI<K, V> node = cache.getNode(fqn);
+ V result = null;
+ if (node != null)
+ {
+ result = node.getDirect((K)name);
+ if (cache.removeNode(fqn))
+ {
+ onRemove((K)name, result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> removeCachedObjects()
+ {
+ final List<V> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
+ {
+ if (selector == null)
+ {
+ throw new IllegalArgumentException("No null selector");
+ }
+ for (Node<K, V> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final K key = getKey(node);
+ final V value = node.get(key);
+ ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
+ {
+ public V get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by JBoss Cache itself
+ return -1;
+ }
+ };
+ if (selector.select(key, info))
+ {
+ selector.onSelect(this, key, info);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDistributed(boolean distributed)
+ {
+ this.distributed = distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLogEnabled(boolean logEnabled)
+ {
+ this.logEnabled = logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReplicated(boolean replicated)
+ {
+ this.replicated = replicated;
+ }
+
+ /**
+ * Returns the key related to the given node
+ */
+ private K getKey(Node<K, V> node)
+ {
+ return getKey(node.getFqn());
+ }
+
+ /**
+ * Returns the key related to the given Fqn
+ */
+ @SuppressWarnings("unchecked")
+ private K getKey(Fqn fqn)
+ {
+ return (K)fqn.get(0);
+ }
+
+ /**
+ * Returns the Fqn related to the given name
+ */
+ private Fqn<Serializable> getFqn(Serializable name)
+ {
+ return Fqn.fromElements(name);
+ }
+
+ void onExpire(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onExpire(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onRemove(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onRemove(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onPut(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onPut(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onGet(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onGet(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onClearCache()
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onClearCache();
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ @org.jboss.cache.notifications.annotation.CacheListener
+ public class CacheEventListener
+ {
+
+ @NodeEvicted
+ public void nodeEvicted(NodeEvent ne)
+ {
+ if (ne.isPre())
+ {
+ // Cannot give the value since
+ // since it disturbs the eviction
+ // algorithms
+ onExpire(getKey(ne.getFqn()), null);
+ }
+ }
+
+ @NodeRemoved
+ public void nodeRemoved(NodeEvent ne)
+ {
+ if (ne.isPre() && !ne.isOriginLocal())
+ {
+ final Node<K, V> node = cache.getNode(ne.getFqn());
+ final K key = getKey(ne.getFqn());
+ onRemove(key, node.get(key));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
+ {
+ if (!ne.isOriginLocal() && !ne.isPre())
+ {
+ final K key = getKey(ne.getFqn());
+ if (ne instanceof EventImpl)
+ {
+ EventImpl evt = (EventImpl)ne;
+ Map<K, V> data = evt.getData();
+ if (data != null)
+ {
+ onPut(key, data.get(key));
+ return;
+ }
+ }
+ final Node<K, V> node = cache.getNode(ne.getFqn());
+ onPut(key, node.get(key));
+ }
+ }
+ }
+
+ private static class ListenerContext<K extends Serializable, V> implements CacheListenerContext, CacheInfo
+ {
+
+ /** . */
+ private final ExoCache<K, V> cache;
+
+ /** . */
+ final CacheListener<? super K, ? super V> listener;
+
+ public ListenerContext(CacheListener<? super K, ? super V> listener, ExoCache<K, V> cache)
+ {
+ this.listener = listener;
+ this.cache = cache;
+ }
+
+ public CacheInfo getCacheInfo()
+ {
+ return this;
+ }
+
+ public String getName()
+ {
+ return cache.getName();
+ }
+
+ public int getMaxSize()
+ {
+ return cache.getMaxSize();
+ }
+
+ public long getLiveTime()
+ {
+ return cache.getLiveTime();
+ }
+
+ public int getSize()
+ {
+ return cache.getCacheSize();
+ }
+
+ void onExpire(K key, V obj) throws Exception
+ {
+ listener.onExpire(this, key, obj);
+ }
+
+ void onRemove(K key, V obj) throws Exception
+ {
+ listener.onRemove(this, key, obj);
+ }
+
+ void onPut(K key, V obj) throws Exception
+ {
+ listener.onPut(this, key, obj);
+ }
+
+ void onGet(K key, V obj) throws Exception
+ {
+ listener.onGet(this, key, obj);
+ }
+
+ void onClearCache() throws Exception
+ {
+ listener.onClearCache(this);
+ }
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.jboss.cache.Cache;
-
-import java.io.Serializable;
-
-/**
- * This class is used to create the cache according to the given
- * configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 20 juil. 2009
- */
-public interface ExoCacheCreator
-{
-
- /**
- * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
- * @param config the configuration of the cache to apply
- * @param cache the cache to initialize
- * @exception ExoCacheInitException if an exception happens while initializing the cache
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException;
-
- /**
- * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
- * @return the expected type
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType();
-
- /**
- * Returns the name of the implementation expected by the creator. This is mainly used to be backward compatible
- * @return the expected by the creator
- */
- public String getExpectedImplementation();
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.jboss.cache.Cache;
+
+import java.io.Serializable;
+
+/**
+ * This class is used to create the cache according to the given
+ * configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public interface ExoCacheCreator
+{
+
+ /**
+ * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ * @param config the configuration of the cache to apply
+ * @param cache the cache to initialize
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException;
+
+ /**
+ * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
+ * @return the expected type
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType();
+
+ /**
+ * Returns the name of the implementation expected by the creator. This is mainly used to be backward compatible
+ * @return the expected by the creator
+ */
+ public String getExpectedImplementation();
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.exoplatform.container.component.BaseComponentPlugin;
-import org.exoplatform.container.xml.InitParams;
-
-/**
- * This class allows us to define new creators
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 20 juil. 2009
- */
-public class ExoCacheCreatorPlugin extends BaseComponentPlugin
-{
-
- /**
- * The list of all the creators defined for this ComponentPlugin
- */
- private final List<ExoCacheCreator> creators;
-
- public ExoCacheCreatorPlugin(InitParams params)
- {
- creators = new ArrayList<ExoCacheCreator>();
- List<?> configs = params.getObjectParamValues(ExoCacheCreator.class);
- for (int i = 0; i < configs.size(); i++)
- {
- ExoCacheCreator config = (ExoCacheCreator)configs.get(i);
- creators.add(config);
- }
- }
-
- /**
- * Returns all the creators defined for this ComponentPlugin
- */
- public List<ExoCacheCreator> getCreators()
- {
- return creators;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+
+/**
+ * This class allows us to define new creators
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class ExoCacheCreatorPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The list of all the creators defined for this ComponentPlugin
+ */
+ private final List<ExoCacheCreator> creators;
+
+ public ExoCacheCreatorPlugin(InitParams params)
+ {
+ creators = new ArrayList<ExoCacheCreator>();
+ List<?> configs = params.getObjectParamValues(ExoCacheCreator.class);
+ for (int i = 0; i < configs.size(); i++)
+ {
+ ExoCacheCreator config = (ExoCacheCreator)configs.get(i);
+ creators.add(config);
+ }
+ }
+
+ /**
+ * Returns all the creators defined for this ComponentPlugin
+ */
+ public List<ExoCacheCreator> getCreators()
+ {
+ return creators;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.exoplatform.container.component.BaseComponentPlugin;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-
-/**
- * This class is used to define custom configurations
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 23 juil. 2009
- */
-public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
-{
-
- /**
- * The map of all the creators defined for this ComponentPlugin
- */
- private final Map<String, String> configs;
-
- @SuppressWarnings("unchecked")
- public ExoCacheFactoryConfigPlugin(InitParams params)
- {
- configs = new HashMap<String, String>();
- for (Iterator<ValueParam> iterator = params.getValueParamIterator(); iterator.hasNext();)
- {
- ValueParam vParam = iterator.next();
- configs.put(vParam.getName(), vParam.getValue());
- }
- }
-
- /**
- * Returns all the configurations defined for this ComponentPlugin
- */
- public Map<String, String> getConfigs()
- {
- return configs;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+
+/**
+ * This class is used to define custom configurations
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 23 juil. 2009
+ */
+public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The map of all the creators defined for this ComponentPlugin
+ */
+ private final Map<String, String> configs;
+
+ @SuppressWarnings("unchecked")
+ public ExoCacheFactoryConfigPlugin(InitParams params)
+ {
+ configs = new HashMap<String, String>();
+ for (Iterator<ValueParam> iterator = params.getValueParamIterator(); iterator.hasNext();)
+ {
+ ValueParam vParam = iterator.next();
+ configs.put(vParam.getName(), vParam.getValue());
+ }
+ }
+
+ /**
+ * Returns all the configurations defined for this ComponentPlugin
+ */
+ public Map<String, String> getConfigs()
+ {
+ return configs;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheFactory;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.Configuration.CacheMode;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is the JBoss Cache implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 17 juil. 2009
- */
-public class ExoCacheFactoryImpl implements ExoCacheFactory
-{
-
- /**
- * The logger
- */
- private static final Log LOG = ExoLogger.getLogger(ExoCacheFactoryImpl.class);
-
- /**
- * The initial parameter key that defines the full path of the configuration template
- */
- private static final String CACHE_CONFIG_TEMPLATE_KEY = "cache.config.template";
-
- /**
- * The configuration manager that allows us to retrieve a configuration file in several different
- * manners
- */
- private final ConfigurationManager configManager;
-
- /**
- * The full path of the configuration template
- */
- private final String cacheConfigTemplate;
-
- /**
- * The mapping between the configuration types and the creators
- */
- private final Map<Class<? extends ExoCacheConfig>, ExoCacheCreator> mappingConfigTypeCreators =
- new HashMap<Class<? extends ExoCacheConfig>, ExoCacheCreator>();
-
- /**
- * The mapping between the implementations and the creators. This is mainly used for backward compatibility
- */
- private final Map<String, ExoCacheCreator> mappingImplCreators = new HashMap<String, ExoCacheCreator>();
-
- /**
- * The mapping between the cache names and the configuration paths
- */
- private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
-
- /**
- * The default creator
- */
- private final ExoCacheCreator defaultCreator = new FIFOExoCacheCreator();
-
- public ExoCacheFactoryImpl(InitParams params, ConfigurationManager configManager)
- {
- this.configManager = configManager;
- this.cacheConfigTemplate = getValueParam(params, CACHE_CONFIG_TEMPLATE_KEY);
- if (cacheConfigTemplate == null)
- {
- throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
- }
- }
-
- /**
- * To create a new cache instance according to the given configuration, we follow the steps below:
- *
- * 1. We first try to find if a specific location of the cache configuration has been defined thanks
- * to an external component plugin of type ExoCacheFactoryConfigPlugin
- * 2. If no specific location has been defined, we use the default configuration which is
- * "${CACHE_CONFIG_TEMPLATE_KEY}"
- */
- public ExoCache<Serializable, Object> createCache(ExoCacheConfig config) throws ExoCacheInitException
- {
- final String region = config.getName();
- final String customConfig = mappingCacheNameConfig.get(region);
- final Cache<Serializable, Object> cache;
- final CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
- final ExoCache<Serializable, Object> eXoCache;
- try
- {
- if (customConfig != null)
- {
- // A custom configuration has been set
- if (LOG.isInfoEnabled())
- LOG.info("A custom configuration has been set for the cache '" + region + "'.");
- cache = factory.createCache(configManager.getInputStream(customConfig), false);
- }
- else
- {
- // No custom configuration has been found, a configuration template will be used
- if (LOG.isInfoEnabled())
- LOG.info("The configuration template will be used for the the cache '" + region + "'.");
- cache = factory.createCache(configManager.getInputStream(cacheConfigTemplate), false);
- if (!config.isDistributed())
- {
- // The cache is local
- cache.getConfiguration().setCacheMode(CacheMode.LOCAL);
- }
- // Re initialize the template to avoid conflicts
- cleanConfigurationTemplate(cache, region);
- }
- final ExoCacheCreator creator = getExoCacheCreator(config);
- // Create the cache
- eXoCache = creator.create(config, cache);
- // Create the cache
- cache.create();
- // Start the cache
- cache.start();
- }
- catch (Exception e)
- {
- throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
- }
- return eXoCache;
- }
-
- /**
- * Add a list of creators to register
- * @param plugin the plugin that contains the creators
- */
- public void addCreator(ExoCacheCreatorPlugin plugin)
- {
- final List<ExoCacheCreator> creators = plugin.getCreators();
- for (ExoCacheCreator creator : creators)
- {
- mappingConfigTypeCreators.put(creator.getExpectedConfigType(), creator);
- mappingImplCreators.put(creator.getExpectedImplementation(), creator);
- }
- }
-
- /**
- * Add a list of custom configuration to register
- * @param plugin the plugin that contains the configs
- */
- public void addConfig(ExoCacheFactoryConfigPlugin plugin)
- {
- final Map<String, String> configs = plugin.getConfigs();
- mappingCacheNameConfig.putAll(configs);
- }
-
- /**
- * Returns the value of the ValueParam if and only if the value is not empty
- */
- private static String getValueParam(InitParams params, String key)
- {
- if (params == null)
- {
- return null;
- }
- final ValueParam vp = params.getValueParam(key);
- String result;
- if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0)
- {
- return null;
- }
- return result;
- }
-
- /**
- * Returns the most relevant ExoCacheCreator according to the give configuration
- */
- protected ExoCacheCreator getExoCacheCreator(ExoCacheConfig config)
- {
- ExoCacheCreator creator = mappingConfigTypeCreators.get(config.getClass());
- if (creator == null)
- {
- // No creator for this type has been found, let's try the implementation field
- creator = mappingImplCreators.get(config.getImplementation());
- if (creator == null)
- {
- // No creator can be found, we will use the default creator
- if (LOG.isInfoEnabled())
- LOG.info("No cache creator has been found for the the cache '" + config.getName()
- + "', the default one will be used.");
- return defaultCreator;
- }
- }
- if (LOG.isInfoEnabled())
- LOG.info("The cache '" + config.getName() + "' will be created with '" + creator.getClass() + "'.");
- return creator;
- }
-
- /**
- * Clean the configuration template to prevent conflicts
- */
- protected void cleanConfigurationTemplate(Cache<Serializable, Object> cache, String region)
- {
- final Configuration config = cache.getConfiguration();
- // Reset the eviction policies
- EvictionConfig evictionConfig = config.getEvictionConfig();
- if (evictionConfig == null)
- {
- // If not eviction config exists, we create an empty one
- evictionConfig = new EvictionConfig();
- config.setEvictionConfig(evictionConfig);
- }
- evictionConfig.setEvictionRegionConfigs(new LinkedList<EvictionRegionConfig>());
- // Rename the cluster name
- String clusterName = config.getClusterName();
- if (clusterName != null && (clusterName = clusterName.trim()).length() > 0)
- {
- config.setClusterName(clusterName + " " + region);
- }
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.Configuration.CacheMode;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is the JBoss Cache implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 17 juil. 2009
+ */
+public class ExoCacheFactoryImpl implements ExoCacheFactory
+{
+
+ /**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger(ExoCacheFactoryImpl.class);
+
+ /**
+ * The initial parameter key that defines the full path of the configuration template
+ */
+ private static final String CACHE_CONFIG_TEMPLATE_KEY = "cache.config.template";
+
+ /**
+ * The configuration manager that allows us to retrieve a configuration file in several different
+ * manners
+ */
+ private final ConfigurationManager configManager;
+
+ /**
+ * The full path of the configuration template
+ */
+ private final String cacheConfigTemplate;
+
+ /**
+ * The mapping between the configuration types and the creators
+ */
+ private final Map<Class<? extends ExoCacheConfig>, ExoCacheCreator> mappingConfigTypeCreators =
+ new HashMap<Class<? extends ExoCacheConfig>, ExoCacheCreator>();
+
+ /**
+ * The mapping between the implementations and the creators. This is mainly used for backward compatibility
+ */
+ private final Map<String, ExoCacheCreator> mappingImplCreators = new HashMap<String, ExoCacheCreator>();
+
+ /**
+ * The mapping between the cache names and the configuration paths
+ */
+ private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
+
+ /**
+ * The default creator
+ */
+ private final ExoCacheCreator defaultCreator = new FIFOExoCacheCreator();
+
+ public ExoCacheFactoryImpl(InitParams params, ConfigurationManager configManager)
+ {
+ this.configManager = configManager;
+ this.cacheConfigTemplate = getValueParam(params, CACHE_CONFIG_TEMPLATE_KEY);
+ if (cacheConfigTemplate == null)
+ {
+ throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
+ }
+ }
+
+ /**
+ * To create a new cache instance according to the given configuration, we follow the steps below:
+ *
+ * 1. We first try to find if a specific location of the cache configuration has been defined thanks
+ * to an external component plugin of type ExoCacheFactoryConfigPlugin
+ * 2. If no specific location has been defined, we use the default configuration which is
+ * "${CACHE_CONFIG_TEMPLATE_KEY}"
+ */
+ public ExoCache<Serializable, Object> createCache(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ final String region = config.getName();
+ final String customConfig = mappingCacheNameConfig.get(region);
+ final Cache<Serializable, Object> cache;
+ final CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+ final ExoCache<Serializable, Object> eXoCache;
+ try
+ {
+ if (customConfig != null)
+ {
+ // A custom configuration has been set
+ if (LOG.isInfoEnabled())
+ LOG.info("A custom configuration has been set for the cache '" + region + "'.");
+ cache = factory.createCache(configManager.getInputStream(customConfig), false);
+ }
+ else
+ {
+ // No custom configuration has been found, a configuration template will be used
+ if (LOG.isInfoEnabled())
+ LOG.info("The configuration template will be used for the the cache '" + region + "'.");
+ cache = factory.createCache(configManager.getInputStream(cacheConfigTemplate), false);
+ if (!config.isDistributed())
+ {
+ // The cache is local
+ cache.getConfiguration().setCacheMode(CacheMode.LOCAL);
+ }
+ // Re initialize the template to avoid conflicts
+ cleanConfigurationTemplate(cache, region);
+ }
+ final ExoCacheCreator creator = getExoCacheCreator(config);
+ // Create the cache
+ eXoCache = creator.create(config, cache);
+ // Create the cache
+ cache.create();
+ // Start the cache
+ cache.start();
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
+ }
+ return eXoCache;
+ }
+
+ /**
+ * Add a list of creators to register
+ * @param plugin the plugin that contains the creators
+ */
+ public void addCreator(ExoCacheCreatorPlugin plugin)
+ {
+ final List<ExoCacheCreator> creators = plugin.getCreators();
+ for (ExoCacheCreator creator : creators)
+ {
+ mappingConfigTypeCreators.put(creator.getExpectedConfigType(), creator);
+ mappingImplCreators.put(creator.getExpectedImplementation(), creator);
+ }
+ }
+
+ /**
+ * Add a list of custom configuration to register
+ * @param plugin the plugin that contains the configs
+ */
+ public void addConfig(ExoCacheFactoryConfigPlugin plugin)
+ {
+ final Map<String, String> configs = plugin.getConfigs();
+ mappingCacheNameConfig.putAll(configs);
+ }
+
+ /**
+ * Returns the value of the ValueParam if and only if the value is not empty
+ */
+ private static String getValueParam(InitParams params, String key)
+ {
+ if (params == null)
+ {
+ return null;
+ }
+ final ValueParam vp = params.getValueParam(key);
+ String result;
+ if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0)
+ {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the most relevant ExoCacheCreator according to the give configuration
+ */
+ protected ExoCacheCreator getExoCacheCreator(ExoCacheConfig config)
+ {
+ ExoCacheCreator creator = mappingConfigTypeCreators.get(config.getClass());
+ if (creator == null)
+ {
+ // No creator for this type has been found, let's try the implementation field
+ creator = mappingImplCreators.get(config.getImplementation());
+ if (creator == null)
+ {
+ // No creator can be found, we will use the default creator
+ if (LOG.isInfoEnabled())
+ LOG.info("No cache creator has been found for the the cache '" + config.getName()
+ + "', the default one will be used.");
+ return defaultCreator;
+ }
+ }
+ if (LOG.isInfoEnabled())
+ LOG.info("The cache '" + config.getName() + "' will be created with '" + creator.getClass() + "'.");
+ return creator;
+ }
+
+ /**
+ * Clean the configuration template to prevent conflicts
+ */
+ protected void cleanConfigurationTemplate(Cache<Serializable, Object> cache, String region)
+ {
+ final Configuration config = cache.getConfiguration();
+ // Reset the eviction policies
+ EvictionConfig evictionConfig = config.getEvictionConfig();
+ if (evictionConfig == null)
+ {
+ // If not eviction config exists, we create an empty one
+ evictionConfig = new EvictionConfig();
+ config.setEvictionConfig(evictionConfig);
+ }
+ evictionConfig.setEvictionRegionConfigs(new LinkedList<EvictionRegionConfig>());
+ // Rename the cluster name
+ String clusterName = config.getClusterName();
+ if (clusterName != null && (clusterName = clusterName.trim()).length() > 0)
+ {
+ config.setClusterName(clusterName + " " + region);
+ }
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.fifo;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the FIFO implementation
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class FIFOExoCacheConfig extends ExoCacheConfig
-{
-
- private int maxNodes;
-
- private long minTimeToLive;
-
- public int getMaxNodes()
- {
- return maxNodes;
- }
-
- public void setMaxNodes(int maxNodes)
- {
- this.maxNodes = maxNodes;
- }
-
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.fifo;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the FIFO implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class FIFOExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.fifo;
-
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
-import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.FIFOAlgorithmConfig;
-
-import java.io.Serializable;
-
-/**
- * The FIFO Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 20 juil. 2009
- */
-public class FIFOExoCacheCreator implements ExoCacheCreator
-{
-
- /**
- * The expected implementation name
- */
- public static final String EXPECTED_IMPL = "FIFO";
-
- /**
- * {@inheritDoc}
- */
- public String getExpectedImplementation()
- {
- return EXPECTED_IMPL;
- }
-
- /**
- * {@inheritDoc}
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return FIFOExoCacheConfig.class;
- }
-
- /**
- * {@inheritDoc}
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
- {
- if (config instanceof FIFOExoCacheConfig)
- {
- final FIFOExoCacheConfig fifoConfig = (FIFOExoCacheConfig)config;
- return create(config, cache, fifoConfig.getMaxNodes(), fifoConfig.getMinTimeToLive());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
- throws ExoCacheInitException
- {
- final Configuration configuration = cache.getConfiguration();
- final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
- fifo.setMinTimeToLive(minTimeToLive);
- // Create an eviction region config
- final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, fifo);
-
- final EvictionConfig evictionConfig = configuration.getEvictionConfig();
- evictionConfig.setDefaultEvictionRegionConfig(erc);
-
- return new AbstractExoCache<Serializable, Object>(config, cache)
- {
-
- public void setMaxSize(int max)
- {
- fifo.setMaxNodes(max);
- }
-
- public void setLiveTime(long period)
- {
- fifo.setMinTimeToLive(period);
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return fifo.getMaxNodes();
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return fifo.getMinTimeToLive();
- }
- };
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.fifo;
+
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
+
+import java.io.Serializable;
+
+/**
+ * The FIFO Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class FIFOExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "FIFO";
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return FIFOExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof FIFOExoCacheConfig)
+ {
+ final FIFOExoCacheConfig fifoConfig = (FIFOExoCacheConfig)config;
+ return create(config, cache, fifoConfig.getMaxNodes(), fifoConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
+ throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
+ fifo.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, fifo);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+
+ return new AbstractExoCache<Serializable, Object>(config, cache)
+ {
+
+ public void setMaxSize(int max)
+ {
+ fifo.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ fifo.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return fifo.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return fifo.getMinTimeToLive();
+ }
+ };
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.lfu;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LFU implementation
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class LFUExoCacheConfig extends ExoCacheConfig
-{
-
- private int maxNodes;
-
- private int minNodes;
-
- private long minTimeToLive;
-
- public int getMaxNodes()
- {
- return maxNodes;
- }
-
- public void setMaxNodes(int maxNodes)
- {
- this.maxNodes = maxNodes;
- }
-
- public int getMinNodes()
- {
- return minNodes;
- }
-
- public void setMinNodes(int minNodes)
- {
- this.minNodes = minNodes;
- }
-
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lfu;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LFU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LFUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private int minNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public int getMinNodes()
+ {
+ return minNodes;
+ }
+
+ public void setMinNodes(int minNodes)
+ {
+ this.minNodes = minNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.lfu;
-
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
-import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LFUAlgorithmConfig;
-
-import java.io.Serializable;
-
-/**
- * The LFU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class LFUExoCacheCreator implements ExoCacheCreator
-{
-
- /**
- * The expected implementation name
- */
- public static final String EXPECTED_IMPL = "LFU";
-
- /**
- * The default value for the parameter maxAge
- */
- protected int defaultMinNodes;
-
- /**
- * {@inheritDoc}
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
- {
- if (config instanceof LFUExoCacheConfig)
- {
- final LFUExoCacheConfig lfuConfig = (LFUExoCacheConfig)config;
- return create(config, cache, lfuConfig.getMaxNodes(), lfuConfig.getMinNodes(), lfuConfig.getMinTimeToLive());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(config, cache, config.getMaxSize(), defaultMinNodes, period > 0 ? period * 1000 : 0);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, int minNodes,
- long minTimeToLive) throws ExoCacheInitException
- {
- final Configuration configuration = cache.getConfiguration();
- final LFUAlgorithmConfig lfu = new LFUAlgorithmConfig(maxNodes, minNodes);
- lfu.setMinTimeToLive(minTimeToLive);
- // Create an eviction region config
- final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lfu);
-
- final EvictionConfig evictionConfig = configuration.getEvictionConfig();
- evictionConfig.setDefaultEvictionRegionConfig(erc);
- return new LFUExoCache(config, cache, lfu);
- }
-
- /**
- * {@inheritDoc}
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return LFUExoCacheConfig.class;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getExpectedImplementation()
- {
- return EXPECTED_IMPL;
- }
-
- /**
- * The LRU implementation of an ExoCache
- */
- public static class LFUExoCache extends AbstractExoCache<Serializable, Object>
- {
-
- private final LFUAlgorithmConfig lfu;
-
- public LFUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LFUAlgorithmConfig lfu)
- {
- super(config, cache);
- this.lfu = lfu;
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return lfu.getMinTimeToLive();
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return lfu.getMaxNodes();
- }
-
- @Managed
- @ManagedName("MinNodes")
- @ManagedDescription("This is the minimum number of nodes allowed in this region. This value determines what the eviction queue should prune down to per pass. e.g. If minNodes is 10 and the cache grows to 100 nodes, the cache is pruned down to the 10 most frequently used nodes when the eviction timer makes a pass through the eviction algorithm.")
- public long getMinNodes()
- {
- return lfu.getMinNodes();
- }
-
- public void setLiveTime(long period)
- {
- lfu.setMinTimeToLive(period);
- }
-
- public void setMaxSize(int max)
- {
- lfu.setMaxNodes(max);
- }
-
- @Managed
- public void setMinNodes(int minNodes)
- {
- lfu.setMinNodes(minNodes);
- }
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lfu;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.LFUAlgorithmConfig;
+
+import java.io.Serializable;
+
+/**
+ * The LFU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LFUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "LFU";
+
+ /**
+ * The default value for the parameter maxAge
+ */
+ protected int defaultMinNodes;
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof LFUExoCacheConfig)
+ {
+ final LFUExoCacheConfig lfuConfig = (LFUExoCacheConfig)config;
+ return create(config, cache, lfuConfig.getMaxNodes(), lfuConfig.getMinNodes(), lfuConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), defaultMinNodes, period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, int minNodes,
+ long minTimeToLive) throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final LFUAlgorithmConfig lfu = new LFUAlgorithmConfig(maxNodes, minNodes);
+ lfu.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lfu);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+ return new LFUExoCache(config, cache, lfu);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return LFUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * The LRU implementation of an ExoCache
+ */
+ public static class LFUExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final LFUAlgorithmConfig lfu;
+
+ public LFUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LFUAlgorithmConfig lfu)
+ {
+ super(config, cache);
+ this.lfu = lfu;
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return lfu.getMinTimeToLive();
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return lfu.getMaxNodes();
+ }
+
+ @Managed
+ @ManagedName("MinNodes")
+ @ManagedDescription("This is the minimum number of nodes allowed in this region. This value determines what the eviction queue should prune down to per pass. e.g. If minNodes is 10 and the cache grows to 100 nodes, the cache is pruned down to the 10 most frequently used nodes when the eviction timer makes a pass through the eviction algorithm.")
+ public long getMinNodes()
+ {
+ return lfu.getMinNodes();
+ }
+
+ public void setLiveTime(long period)
+ {
+ lfu.setMinTimeToLive(period);
+ }
+
+ public void setMaxSize(int max)
+ {
+ lfu.setMaxNodes(max);
+ }
+
+ @Managed
+ public void setMinNodes(int minNodes)
+ {
+ lfu.setMinNodes(minNodes);
+ }
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.lru;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LRU implementation
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class LRUExoCacheConfig extends ExoCacheConfig
-{
-
- private int maxNodes;
-
- private long timeToLive;
-
- private long maxAge;
-
- private long minTimeToLive;
-
- public int getMaxNodes()
- {
- return maxNodes;
- }
-
- public void setMaxNodes(int maxNodes)
- {
- this.maxNodes = maxNodes;
- }
-
- public long getTimeToLive()
- {
- return timeToLive;
- }
-
- public void setTimeToLive(long timeToLive)
- {
- this.timeToLive = timeToLive;
- }
-
- public long getMaxAge()
- {
- return maxAge;
- }
-
- public void setMaxAge(long maxAge)
- {
- this.maxAge = maxAge;
- }
-
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lru;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LRU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LRUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long timeToLive;
+
+ private long maxAge;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive)
+ {
+ this.timeToLive = timeToLive;
+ }
+
+ public long getMaxAge()
+ {
+ return maxAge;
+ }
+
+ public void setMaxAge(long maxAge)
+ {
+ this.maxAge = maxAge;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.lru;
-
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
-import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUAlgorithmConfig;
-
-import java.io.Serializable;
-
-/**
- * The LRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class LRUExoCacheCreator implements ExoCacheCreator
-{
-
- /**
- * The expected implementation name
- */
- public static final String EXPECTED_IMPL = "LRU";
-
- /**
- * The default value for the parameter timeToLive
- */
- protected long defaultTimeToLive;
-
- /**
- * The default value for the parameter maxAge
- */
- protected long defaultMaxAge;
-
- /**
- * {@inheritDoc}
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
- {
- if (config instanceof LRUExoCacheConfig)
- {
- final LRUExoCacheConfig lruConfig = (LRUExoCacheConfig)config;
- return create(config, cache, lruConfig.getMaxNodes(), lruConfig.getTimeToLive(), lruConfig.getMaxAge(),
- lruConfig.getMinTimeToLive());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(config, cache, config.getMaxSize(), defaultTimeToLive, defaultMaxAge, period > 0 ? period * 1000
- : 0);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long timeToLive,
- long maxAge, long minTimeToLive) throws ExoCacheInitException
- {
- final Configuration configuration = cache.getConfiguration();
- final LRUAlgorithmConfig lru = new LRUAlgorithmConfig(timeToLive, maxAge, maxNodes);
- lru.setMinTimeToLive(minTimeToLive);
- // Create an eviction region config
- final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lru);
-
- final EvictionConfig evictionConfig = configuration.getEvictionConfig();
- evictionConfig.setDefaultEvictionRegionConfig(erc);
- return new LRUExoCache(config, cache, lru);
- }
-
- /**
- * {@inheritDoc}
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return LRUExoCacheConfig.class;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getExpectedImplementation()
- {
- return EXPECTED_IMPL;
- }
-
- /**
- * The LRU implementation of an ExoCache
- */
- public static class LRUExoCache extends AbstractExoCache<Serializable, Object>
- {
-
- private final LRUAlgorithmConfig lru;
-
- public LRUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LRUAlgorithmConfig lru)
- {
- super(config, cache);
- this.lru = lru;
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return lru.getMinTimeToLive();
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return lru.getMaxNodes();
- }
-
- @Managed
- @ManagedName("TimeToLive")
- @ManagedDescription("The amount of time a node is not written to or read (in milliseconds) before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
- public long getTimeToLive()
- {
- return lru.getTimeToLive();
- }
-
- @Managed
- @ManagedName("MaxAges")
- @ManagedDescription("Lifespan of a node (in milliseconds) regardless of idle time before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
- public long getMaxAge()
- {
- return lru.getMaxAge();
- }
-
- public void setLiveTime(long period)
- {
- lru.setMinTimeToLive(period);
- }
-
- public void setMaxSize(int max)
- {
- lru.setMaxNodes(max);
- }
-
- @Managed
- public void setTimeToLive(long timeToLive)
- {
- lru.setTimeToLive(timeToLive);
- }
-
- @Managed
- public void setMaxAge(long maxAge)
- {
- lru.setMaxAge(maxAge);
- }
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lru;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+
+import java.io.Serializable;
+
+/**
+ * The LRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LRUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "LRU";
+
+ /**
+ * The default value for the parameter timeToLive
+ */
+ protected long defaultTimeToLive;
+
+ /**
+ * The default value for the parameter maxAge
+ */
+ protected long defaultMaxAge;
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof LRUExoCacheConfig)
+ {
+ final LRUExoCacheConfig lruConfig = (LRUExoCacheConfig)config;
+ return create(config, cache, lruConfig.getMaxNodes(), lruConfig.getTimeToLive(), lruConfig.getMaxAge(),
+ lruConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), defaultTimeToLive, defaultMaxAge, period > 0 ? period * 1000
+ : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long timeToLive,
+ long maxAge, long minTimeToLive) throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final LRUAlgorithmConfig lru = new LRUAlgorithmConfig(timeToLive, maxAge, maxNodes);
+ lru.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lru);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+ return new LRUExoCache(config, cache, lru);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return LRUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * The LRU implementation of an ExoCache
+ */
+ public static class LRUExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final LRUAlgorithmConfig lru;
+
+ public LRUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LRUAlgorithmConfig lru)
+ {
+ super(config, cache);
+ this.lru = lru;
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return lru.getMinTimeToLive();
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return lru.getMaxNodes();
+ }
+
+ @Managed
+ @ManagedName("TimeToLive")
+ @ManagedDescription("The amount of time a node is not written to or read (in milliseconds) before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
+ public long getTimeToLive()
+ {
+ return lru.getTimeToLive();
+ }
+
+ @Managed
+ @ManagedName("MaxAges")
+ @ManagedDescription("Lifespan of a node (in milliseconds) regardless of idle time before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
+ public long getMaxAge()
+ {
+ return lru.getMaxAge();
+ }
+
+ public void setLiveTime(long period)
+ {
+ lru.setMinTimeToLive(period);
+ }
+
+ public void setMaxSize(int max)
+ {
+ lru.setMaxNodes(max);
+ }
+
+ @Managed
+ public void setTimeToLive(long timeToLive)
+ {
+ lru.setTimeToLive(timeToLive);
+ }
+
+ @Managed
+ public void setMaxAge(long maxAge)
+ {
+ lru.setMaxAge(maxAge);
+ }
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.mru;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the MRU implementation
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class MRUExoCacheConfig extends ExoCacheConfig
-{
-
- private int maxNodes;
-
- private long minTimeToLive;
-
- public int getMaxNodes()
- {
- return maxNodes;
- }
-
- public void setMaxNodes(int maxNodes)
- {
- this.maxNodes = maxNodes;
- }
-
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.mru;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the MRU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class MRUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss.mru;
-
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
-import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.MRUAlgorithmConfig;
-
-import java.io.Serializable;
-
-/**
- * The MRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class MRUExoCacheCreator implements ExoCacheCreator
-{
-
- /**
- * The expected implementation name
- */
- public static final String EXPECTED_IMPL = "MRU";
-
- /**
- * {@inheritDoc}
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
- {
- if (config instanceof MRUExoCacheConfig)
- {
- final MRUExoCacheConfig mruConfig = (MRUExoCacheConfig)config;
- return create(config, cache, mruConfig.getMaxNodes(), mruConfig.getMinTimeToLive());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
- throws ExoCacheInitException
- {
- final Configuration configuration = cache.getConfiguration();
- final MRUAlgorithmConfig mru = new MRUAlgorithmConfig(maxNodes);
- mru.setMinTimeToLive(minTimeToLive);
- // Create an eviction region config
- final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, mru);
-
- final EvictionConfig evictionConfig = configuration.getEvictionConfig();
- evictionConfig.setDefaultEvictionRegionConfig(erc);
-
- return new AbstractExoCache<Serializable, Object>(config, cache)
- {
-
- public void setMaxSize(int max)
- {
- mru.setMaxNodes(max);
- }
-
- public void setLiveTime(long period)
- {
- mru.setMinTimeToLive(period);
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return mru.getMaxNodes();
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return mru.getMinTimeToLive();
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return MRUExoCacheConfig.class;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getExpectedImplementation()
- {
- return EXPECTED_IMPL;
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.mru;
+
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
+
+import java.io.Serializable;
+
+/**
+ * The MRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class MRUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "MRU";
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof MRUExoCacheConfig)
+ {
+ final MRUExoCacheConfig mruConfig = (MRUExoCacheConfig)config;
+ return create(config, cache, mruConfig.getMaxNodes(), mruConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
+ throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final MRUAlgorithmConfig mru = new MRUAlgorithmConfig(maxNodes);
+ mru.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, mru);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+
+ return new AbstractExoCache<Serializable, Object>(config, cache)
+ {
+
+ public void setMaxSize(int max)
+ {
+ mru.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ mru.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return mru.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return mru.getMinTimeToLive();
+ }
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return MRUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
-
- <!--
- isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
- -->
- <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
- writeSkewCheck="false" concurrencyLevel="500" />
-
- <!--
- Used to register a transaction manager and participate in ongoing
- transactions.
- -->
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
- syncCommitPhase="false" />
-
-
- <!--
- Used to register JMX statistics in any available MBean server
- -->
- <jmxStatistics enabled="false" />
-
- <!--
- If region based marshalling is used, defines whether new regions are
- inactive on startup.
- -->
- <startup regionsInactiveOnStartup="true" />
-
- <!--
- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
- DONT_REGISTER
- -->
- <shutdown hookBehavior="DEFAULT" />
-
- <!--
- Used to define async listener notification thread pool size
- -->
- <listeners asyncPoolSize="1" asyncQueueSize="100000" />
-
- <!--
- Used to enable invocation batching and allow the use of
- Cache.startBatch()/endBatch() methods.
- -->
- <invocationBatching enabled="true" />
-
-
- <!--
- This element specifies that the cache is clustered. modes supported:
- replication (r) or invalidation (i).
- -->
- <clustering mode="replication" clusterName="JBossCache-cluster">
-
- <!--
- Defines whether to retrieve state on startup
- -->
- <stateRetrieval timeout="20000" fetchInMemoryState="false" />
-
- <!--
- Network calls are synchronous.
- -->
- <sync replTimeout="20000" />
-
- <!--
- Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
- the class loader.
- -->
- <jgroupsConfig configFile="udp.xml">
- </jgroupsConfig>
- </clustering>
-
- <!--
- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
- -->
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="200000">
- <property name="maxNodes" value="3000" />
- <property name="timeToLive" value="0" />
- </default>
- </eviction>
-</jbosscache>
-
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="true" />
+
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+ Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
+ -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="3000" />
+ <property name="timeToLive" value="0" />
+ </default>
+ </eviction>
+</jbosscache>
+
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.cache.ExoCacheFactory</key>
- <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
- <init-params>
- <value-param>
- <name>cache.config.template</name>
- <value>jar:/conf/portal/cache-configuration-template.xml</value>
- </value-param>
- </init-params>
- </component>
-</configuration>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/resources/conf/portal/configuration.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,678 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CacheListenerContext;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheFactory;
-import org.exoplatform.services.cache.ObjectCacheInfo;
-import org.exoplatform.test.BasicTestCase;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class TestAbstractExoCache extends BasicTestCase
-{
-
- CacheService service;
-
- AbstractExoCache<Serializable, Object> cache;
-
- ExoCacheFactory factory;
-
- public TestAbstractExoCache(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
- this.cache = (AbstractExoCache<Serializable, Object>)service.getCacheInstance("myCache");
- this.factory = (ExoCacheFactory)PortalContainer.getInstance().getComponentInstanceOfType(ExoCacheFactory.class);
- }
-
- protected void tearDown() throws Exception
- {
- cache.clearCache();
- }
-
- public void testPut() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- assertEquals(3, cache.getCacheSize());
- cache.put(new MyKey("a"), "c");
- assertEquals(3, cache.getCacheSize());
- cache.put(new MyKey("d"), "c");
- assertEquals(4, cache.getCacheSize());
- }
-
- public void testClearCache() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- assertTrue(cache.getCacheSize() > 0);
- cache.clearCache();
- assertTrue(cache.getCacheSize() == 0);
- }
-
- public void testGet() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- assertEquals("a", cache.get(new MyKey("a")));
- cache.put(new MyKey("a"), "c");
- assertEquals("c", cache.get(new MyKey("a")));
- cache.remove(new MyKey("a"));
- assertEquals(null, cache.get(new MyKey("a")));
- assertEquals(null, cache.get(new MyKey("x")));
- }
-
- public void testRemove() throws Exception
- {
- cache.put(new MyKey("a"), 1);
- cache.put(new MyKey("b"), 2);
- cache.put(new MyKey("c"), 3);
- assertEquals(3, cache.getCacheSize());
- assertEquals(1, cache.remove(new MyKey("a")));
- assertEquals(2, cache.getCacheSize());
- assertEquals(2, cache.remove(new MyKey("b")));
- assertEquals(1, cache.getCacheSize());
- assertEquals(null, cache.remove(new MyKey("x")));
- assertEquals(1, cache.getCacheSize());
- }
-
- public void testPutMap() throws Exception
- {
- Map<Serializable, Object> values = new HashMap<Serializable, Object>();
- values.put(new MyKey("a"), "a");
- values.put(new MyKey("b"), "b");
- assertEquals(0, cache.getCacheSize());
- cache.putMap(values);
- assertEquals(2, cache.getCacheSize());
- values = new HashMap<Serializable, Object>()
- {
- private static final long serialVersionUID = 1L;
-
- public Set<Entry<Serializable, Object>> entrySet()
- {
- Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
- set.add(new Entry<Serializable, Object>()
- {
-
- public Object setValue(Object paramV)
- {
- return null;
- }
-
- public Object getValue()
- {
- throw new RuntimeException("An exception");
- }
-
- public Serializable getKey()
- {
- return "c";
- }
- });
- return set;
- }
- };
- values.put(new MyKey("e"), "e");
- values.put(new MyKey("d"), "d");
- cache.putMap(values);
- assertEquals(2, cache.getCacheSize());
- }
-
- public void testGetCachedObjects() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- cache.put(new MyKey("d"), null);
- assertEquals(4, cache.getCacheSize());
- List<Object> values = cache.getCachedObjects();
- assertEquals(3, values.size());
- assertTrue(values.contains("a"));
- assertTrue(values.contains("b"));
- assertTrue(values.contains("c"));
- }
-
- public void testRemoveCachedObjects() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- cache.put(new MyKey("d"), null);
- assertEquals(4, cache.getCacheSize());
- List<Object> values = cache.removeCachedObjects();
- assertEquals(3, values.size());
- assertTrue(values.contains("a"));
- assertTrue(values.contains("b"));
- assertTrue(values.contains("c"));
- assertEquals(0, cache.getCacheSize());
- }
-
- public void testSelect() throws Exception
- {
- cache.put(new MyKey("a"), 1);
- cache.put(new MyKey("b"), 2);
- cache.put(new MyKey("c"), 3);
- final AtomicInteger count = new AtomicInteger();
- CachedObjectSelector<Serializable, Object> selector = new CachedObjectSelector<Serializable, Object>()
- {
-
- public void onSelect(ExoCache<? extends Serializable, ? extends Object> cache, Serializable key, ObjectCacheInfo<? extends Object> ocinfo) throws Exception
- {
- assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
- assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
- count.incrementAndGet();
- }
-
- public boolean select(Serializable key, ObjectCacheInfo<? extends Object> ocinfo)
- {
- return true;
- }
- };
- cache.select(selector);
- assertEquals(3, count.intValue());
- }
-
- public void testGetHitsNMisses() throws Exception
- {
- int hits = cache.getCacheHit();
- int misses = cache.getCacheMiss();
- cache.put(new MyKey("a"), "a");
- cache.get(new MyKey("a"));
- cache.remove(new MyKey("a"));
- cache.get(new MyKey("a"));
- cache.get(new MyKey("z"));
- assertEquals(1, cache.getCacheHit() - hits);
- assertEquals(2, cache.getCacheMiss() - misses);
- }
-
- @SuppressWarnings("unchecked")
- public void testDistributedCache() throws Exception
- {
- System.out.println("WARNING: For Linux distributions the following JVM parameter must be set to true, java.net.preferIPv4Stack = " + System.getProperty("java.net.preferIPv4Stack"));
- ExoCacheConfig config = new ExoCacheConfig();
- config.setName("MyCacheDistributed");
- config.setMaxSize(5);
- config.setLiveTime(1000);
- config.setDistributed(true);
- ExoCacheConfig config2 = new ExoCacheConfig();
- config2.setName("MyCacheDistributed2");
- config2.setMaxSize(5);
- config2.setLiveTime(1000);
- config2.setDistributed(true);
- AbstractExoCache<Serializable, Object> cache1 = (AbstractExoCache<Serializable, Object>)factory.createCache(config);
- MyCacheListener listener1 = new MyCacheListener();
- cache1.addCacheListener(listener1);
- AbstractExoCache<Serializable, Object> cache2 = (AbstractExoCache<Serializable, Object>)factory.createCache(config);
- MyCacheListener listener2 = new MyCacheListener();
- cache2.addCacheListener(listener2);
- AbstractExoCache<Serializable, Object> cache3 = (AbstractExoCache<Serializable, Object>)factory.createCache(config2);
- MyCacheListener listener3 = new MyCacheListener();
- cache3.addCacheListener(listener3);
- try
- {
- cache1.put(new MyKey("a"), "b");
- assertEquals(1, cache1.getCacheSize());
- assertEquals("b", cache2.get(new MyKey("a")));
- assertEquals(1, cache2.getCacheSize());
- assertEquals(0, cache3.getCacheSize());
- assertEquals(1, listener1.put);
- assertEquals(1, listener2.put);
- assertEquals(0, listener3.put);
- assertEquals(0, listener1.get);
- assertEquals(1, listener2.get);
- assertEquals(0, listener3.get);
- cache2.put(new MyKey("b"), "c");
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals("c", cache1.get(new MyKey("b")));
- assertEquals(0, cache3.getCacheSize());
- assertEquals(2, listener1.put);
- assertEquals(2, listener2.put);
- assertEquals(0, listener3.put);
- assertEquals(1, listener1.get);
- assertEquals(1, listener2.get);
- assertEquals(0, listener3.get);
- cache3.put(new MyKey("c"), "d");
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals(1, cache3.getCacheSize());
- assertEquals("d", cache3.get(new MyKey("c")));
- assertEquals(2, listener1.put);
- assertEquals(2, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(1, listener1.get);
- assertEquals(1, listener2.get);
- assertEquals(1, listener3.get);
- cache2.put(new MyKey("a"), "a");
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals("a", cache1.get(new MyKey("a")));
- assertEquals(3, listener1.put);
- assertEquals(3, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(2, listener1.get);
- assertEquals(1, listener2.get);
- assertEquals(1, listener3.get);
- cache2.remove(new MyKey("a"));
- assertEquals(1, cache1.getCacheSize());
- assertEquals(1, cache2.getCacheSize());
- assertEquals(3, listener1.put);
- assertEquals(3, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(2, listener1.get);
- assertEquals(1, listener2.get);
- assertEquals(1, listener3.get);
- assertEquals(1, listener1.remove);
- assertEquals(1, listener2.remove);
- assertEquals(0, listener3.remove);
- cache1.clearCache();
- assertEquals(0, cache1.getCacheSize());
- assertEquals(null, cache2.get(new MyKey("b")));
- assertEquals(0, cache2.getCacheSize());
- assertEquals(3, listener1.put);
- assertEquals(3, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(2, listener1.get);
- assertEquals(2, listener2.get);
- assertEquals(1, listener3.get);
- assertEquals(2, listener1.remove);
- assertEquals(2, listener2.remove);
- assertEquals(0, listener3.remove);
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
- assertEquals(0, listener3.clearCache);
- Map<Serializable, Object> values = new HashMap<Serializable, Object>();
- values.put(new MyKey("a"), "a");
- values.put(new MyKey("b"), "b");
- cache1.putMap(values);
- assertEquals(2, cache1.getCacheSize());
- Thread.sleep(40);
- assertEquals("a", cache2.get(new MyKey("a")));
- assertEquals("b", cache2.get(new MyKey("b")));
- assertEquals(2, cache2.getCacheSize());
- assertEquals(5, listener1.put);
- assertEquals(5, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(2, listener1.get);
- assertEquals(4, listener2.get);
- assertEquals(1, listener3.get);
- assertEquals(2, listener1.remove);
- assertEquals(2, listener2.remove);
- assertEquals(0, listener3.remove);
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
- assertEquals(0, listener3.clearCache);
- values = new HashMap<Serializable, Object>()
- {
- private static final long serialVersionUID = 1L;
-
- public Set<Entry<Serializable, Object>> entrySet()
- {
- Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
- set.add(new Entry<Serializable, Object>()
- {
-
- public Object setValue(Object paramV)
- {
- return null;
- }
-
- public Object getValue()
- {
- throw new RuntimeException("An exception");
- }
-
- public Serializable getKey()
- {
- return "c";
- }
- });
- return set;
- }
- };
- values.put(new MyKey("e"), "e");
- values.put(new MyKey("d"), "d");
- cache1.putMap(values);
- assertEquals(2, cache1.getCacheSize());
- assertEquals(2, cache2.getCacheSize());
- assertEquals(5, listener1.put);
- assertEquals(5, listener2.put);
- assertEquals(1, listener3.put);
- assertEquals(2, listener1.get);
- assertEquals(4, listener2.get);
- assertEquals(1, listener3.get);
- assertEquals(2, listener1.remove);
- assertEquals(2, listener2.remove);
- assertEquals(0, listener3.remove);
- assertEquals(1, listener1.clearCache);
- assertEquals(0, listener2.clearCache);
- assertEquals(0, listener3.clearCache);
- }
- finally
- {
- cache1.cache.stop();
- cache2.cache.stop();
- cache3.cache.stop();
- }
- }
-
- public void testMultiThreading() throws Exception
- {
- long time = System.currentTimeMillis();
- final ExoCache<Serializable, Object> cache = service.getCacheInstance("test-multi-threading");
- final int totalElement = 100;
- final int totalTimes = 20;
- int reader = 20;
- int writer = 10;
- int remover = 5;
- int cleaner = 1;
- final CountDownLatch startSignalWriter = new CountDownLatch(1);
- final CountDownLatch startSignalOthers = new CountDownLatch(1);
- final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
- final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
- for (int i = 0; i < writer; i++)
- {
- final int index = i;
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalWriter.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- if (index == 0 && j == 0)
- {
- // The cache is full, we can launch the others
- startSignalOthers.countDown();
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- startSignalWriter.countDown();
- for (int i = 0; i < reader; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalOthers.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.get(new MyKey("key" + i));
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- for (int i = 0; i < remover; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalOthers.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.remove(new MyKey("key" + i));
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- doneSignal.await();
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- assertEquals(totalElement, cache.getCacheSize());
- final CountDownLatch startSignal = new CountDownLatch(1);
- final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
- for (int i = 0; i < writer; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal2.countDown();
- }
- }
- };
- thread.start();
- }
- for (int i = 0; i < cleaner; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- for (int j = 0; j < totalTimes; j++)
- {
- sleep(150);
- cache.clearCache();
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal2.countDown();
- }
- }
- };
- thread.start();
- }
- cache.clearCache();
- assertEquals(0, cache.getCacheSize());
- if (!errors.isEmpty())
- {
- for (Exception e : errors)
- {
- e.printStackTrace();
- }
- throw errors.get(0);
- }
- System.out.println("Total Time = " + (System.currentTimeMillis() - time));
- }
-
- public static class MyCacheListener implements CacheListener<Serializable, Object>
- {
-
- public int clearCache;
-
- public int expire;
-
- public int get;
-
- public int put;
-
- public int remove;
-
- public void onClearCache(ExoCache<Serializable, Object> cache) throws Exception
- {
- clearCache++;
- }
-
- public void onExpire(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
- {
- expire++;
- }
-
- public void onGet(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
- {
- get++;
- }
-
- public void onPut(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
- {
- put++;
- }
-
- public void onRemove(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
- {
- remove++;
- }
-
- public void onClearCache(CacheListenerContext context) throws Exception
- {
- clearCache++;
- }
-
- public void onExpire(CacheListenerContext context, Serializable key, Object obj) throws Exception
- {
- expire++;
- }
-
- public void onGet(CacheListenerContext context, Serializable key, Object obj) throws Exception
- {
- get++;
- }
-
- public void onPut(CacheListenerContext context, Serializable key, Object obj) throws Exception
- {
- put++;
- }
-
- public void onRemove(CacheListenerContext context, Serializable key, Object obj) throws Exception
- {
- remove++;
- }
- }
-
- public static class MyKey implements Serializable
- {
- private static final long serialVersionUID = 1L;
- public String value;
-
- public MyKey(String value)
- {
- this.value = value;
- }
-
- @Override
- public boolean equals(Object paramObject)
- {
- return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
- }
-
- @Override
- public int hashCode()
- {
- return value.hashCode();
- }
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,678 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestAbstractExoCache extends BasicTestCase
+{
+
+ CacheService service;
+
+ AbstractExoCache<Serializable, Object> cache;
+
+ ExoCacheFactory factory;
+
+ public TestAbstractExoCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ this.cache = (AbstractExoCache<Serializable, Object>)service.getCacheInstance("myCache");
+ this.factory = (ExoCacheFactory)PortalContainer.getInstance().getComponentInstanceOfType(ExoCacheFactory.class);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ cache.clearCache();
+ }
+
+ public void testPut() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("a"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("d"), "c");
+ assertEquals(4, cache.getCacheSize());
+ }
+
+ public void testClearCache() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertTrue(cache.getCacheSize() > 0);
+ cache.clearCache();
+ assertTrue(cache.getCacheSize() == 0);
+ }
+
+ public void testGet() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ assertEquals("a", cache.get(new MyKey("a")));
+ cache.put(new MyKey("a"), "c");
+ assertEquals("c", cache.get(new MyKey("a")));
+ cache.remove(new MyKey("a"));
+ assertEquals(null, cache.get(new MyKey("a")));
+ assertEquals(null, cache.get(new MyKey("x")));
+ }
+
+ public void testRemove() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ assertEquals(3, cache.getCacheSize());
+ assertEquals(1, cache.remove(new MyKey("a")));
+ assertEquals(2, cache.getCacheSize());
+ assertEquals(2, cache.remove(new MyKey("b")));
+ assertEquals(1, cache.getCacheSize());
+ assertEquals(null, cache.remove(new MyKey("x")));
+ assertEquals(1, cache.getCacheSize());
+ }
+
+ public void testPutMap() throws Exception
+ {
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ assertEquals(0, cache.getCacheSize());
+ cache.putMap(values);
+ assertEquals(2, cache.getCacheSize());
+ values = new HashMap<Serializable, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ cache.putMap(values);
+ assertEquals(2, cache.getCacheSize());
+ }
+
+ public void testGetCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(4, cache.getCacheSize());
+ List<Object> values = cache.getCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+ }
+
+ public void testRemoveCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(4, cache.getCacheSize());
+ List<Object> values = cache.removeCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+ assertEquals(0, cache.getCacheSize());
+ }
+
+ public void testSelect() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ final AtomicInteger count = new AtomicInteger();
+ CachedObjectSelector<Serializable, Object> selector = new CachedObjectSelector<Serializable, Object>()
+ {
+
+ public void onSelect(ExoCache<? extends Serializable, ? extends Object> cache, Serializable key, ObjectCacheInfo<? extends Object> ocinfo) throws Exception
+ {
+ assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
+ assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
+ count.incrementAndGet();
+ }
+
+ public boolean select(Serializable key, ObjectCacheInfo<? extends Object> ocinfo)
+ {
+ return true;
+ }
+ };
+ cache.select(selector);
+ assertEquals(3, count.intValue());
+ }
+
+ public void testGetHitsNMisses() throws Exception
+ {
+ int hits = cache.getCacheHit();
+ int misses = cache.getCacheMiss();
+ cache.put(new MyKey("a"), "a");
+ cache.get(new MyKey("a"));
+ cache.remove(new MyKey("a"));
+ cache.get(new MyKey("a"));
+ cache.get(new MyKey("z"));
+ assertEquals(1, cache.getCacheHit() - hits);
+ assertEquals(2, cache.getCacheMiss() - misses);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testDistributedCache() throws Exception
+ {
+ System.out.println("WARNING: For Linux distributions the following JVM parameter must be set to true, java.net.preferIPv4Stack = " + System.getProperty("java.net.preferIPv4Stack"));
+ ExoCacheConfig config = new ExoCacheConfig();
+ config.setName("MyCacheDistributed");
+ config.setMaxSize(5);
+ config.setLiveTime(1000);
+ config.setDistributed(true);
+ ExoCacheConfig config2 = new ExoCacheConfig();
+ config2.setName("MyCacheDistributed2");
+ config2.setMaxSize(5);
+ config2.setLiveTime(1000);
+ config2.setDistributed(true);
+ AbstractExoCache<Serializable, Object> cache1 = (AbstractExoCache<Serializable, Object>)factory.createCache(config);
+ MyCacheListener listener1 = new MyCacheListener();
+ cache1.addCacheListener(listener1);
+ AbstractExoCache<Serializable, Object> cache2 = (AbstractExoCache<Serializable, Object>)factory.createCache(config);
+ MyCacheListener listener2 = new MyCacheListener();
+ cache2.addCacheListener(listener2);
+ AbstractExoCache<Serializable, Object> cache3 = (AbstractExoCache<Serializable, Object>)factory.createCache(config2);
+ MyCacheListener listener3 = new MyCacheListener();
+ cache3.addCacheListener(listener3);
+ try
+ {
+ cache1.put(new MyKey("a"), "b");
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals("b", cache2.get(new MyKey("a")));
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(0, cache3.getCacheSize());
+ assertEquals(1, listener1.put);
+ assertEquals(1, listener2.put);
+ assertEquals(0, listener3.put);
+ assertEquals(0, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(0, listener3.get);
+ cache2.put(new MyKey("b"), "c");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("c", cache1.get(new MyKey("b")));
+ assertEquals(0, cache3.getCacheSize());
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+ assertEquals(0, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(0, listener3.get);
+ cache3.put(new MyKey("c"), "d");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(1, cache3.getCacheSize());
+ assertEquals("d", cache3.get(new MyKey("c")));
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ cache2.put(new MyKey("a"), "a");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("a", cache1.get(new MyKey("a")));
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ cache2.remove(new MyKey("a"));
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ cache1.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(null, cache2.get(new MyKey("b")));
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(2, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ Thread.sleep(40);
+ assertEquals("a", cache2.get(new MyKey("a")));
+ assertEquals("b", cache2.get(new MyKey("b")));
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(5, listener1.put);
+ assertEquals(5, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(4, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ values = new HashMap<Serializable, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(5, listener1.put);
+ assertEquals(5, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(4, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ }
+ finally
+ {
+ cache1.cache.stop();
+ cache2.cache.stop();
+ cache3.cache.stop();
+ }
+ }
+
+ public void testMultiThreading() throws Exception
+ {
+ long time = System.currentTimeMillis();
+ final ExoCache<Serializable, Object> cache = service.getCacheInstance("test-multi-threading");
+ final int totalElement = 100;
+ final int totalTimes = 20;
+ int reader = 20;
+ int writer = 10;
+ int remover = 5;
+ int cleaner = 1;
+ final CountDownLatch startSignalWriter = new CountDownLatch(1);
+ final CountDownLatch startSignalOthers = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
+ final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
+ for (int i = 0; i < writer; i++)
+ {
+ final int index = i;
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalWriter.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ if (index == 0 && j == 0)
+ {
+ // The cache is full, we can launch the others
+ startSignalOthers.countDown();
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ startSignalWriter.countDown();
+ for (int i = 0; i < reader; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.get(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < remover; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.remove(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ doneSignal.await();
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ assertEquals(totalElement, cache.getCacheSize());
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
+ for (int i = 0; i < writer; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ sleep(50);
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal2.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < cleaner; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ sleep(150);
+ cache.clearCache();
+ }
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ finally
+ {
+ doneSignal2.countDown();
+ }
+ }
+ };
+ thread.start();
+ }
+ cache.clearCache();
+ assertEquals(0, cache.getCacheSize());
+ if (!errors.isEmpty())
+ {
+ for (Exception e : errors)
+ {
+ e.printStackTrace();
+ }
+ throw errors.get(0);
+ }
+ System.out.println("Total Time = " + (System.currentTimeMillis() - time));
+ }
+
+ public static class MyCacheListener implements CacheListener<Serializable, Object>
+ {
+
+ public int clearCache;
+
+ public int expire;
+
+ public int get;
+
+ public int put;
+
+ public int remove;
+
+ public void onClearCache(ExoCache<Serializable, Object> cache) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
+
+ public void onClearCache(CacheListenerContext context) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
+ }
+
+ public static class MyKey implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+ public String value;
+
+ public MyKey(String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object paramObject)
+ {
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class TestExoCacheConfig extends ExoCacheConfig
-{
-
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestExoCacheConfig extends ExoCacheConfig
+{
+
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.jboss.cache.Cache;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class TestExoCacheCreator implements ExoCacheCreator
-{
-
- public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
- {
- return new TestExoCache();
- }
-
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return TestExoCacheConfig.class;
- }
-
- public String getExpectedImplementation()
- {
- return "TEST";
- }
-
- public static class TestExoCache implements ExoCache
- {
-
- public void addCacheListener(CacheListener listener)
- {
- // TODO Auto-generated method stub
-
- }
-
-
- public int getCacheHit()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getCacheMiss()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getCacheSize()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public List getCachedObjects()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getLabel()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public long getLiveTime()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getMaxSize()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getName()
- {
- return "name";
- }
-
- public boolean isDistributed()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isLogEnabled()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isReplicated()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- public void select(CachedObjectSelector selector) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setDistributed(boolean b)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setLabel(String s)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setLiveTime(long period)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setLogEnabled(boolean b)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setMaxSize(int max)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setName(String name)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setReplicated(boolean b)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void clearCache()
- {
- // TODO Auto-generated method stub
-
- }
-
- public Object get(Serializable key)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void put(Serializable key, Object value) throws NullPointerException
- {
- // TODO Auto-generated method stub
-
- }
-
- public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
- {
- // TODO Auto-generated method stub
-
- }
-
- public Object remove(Serializable key) throws NullPointerException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List removeCachedObjects()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.jboss.cache.Cache;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestExoCacheCreator implements ExoCacheCreator
+{
+
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ return new TestExoCache();
+ }
+
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return TestExoCacheConfig.class;
+ }
+
+ public String getExpectedImplementation()
+ {
+ return "TEST";
+ }
+
+ public static class TestExoCache implements ExoCache
+ {
+
+ public void addCacheListener(CacheListener listener)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public int getCacheHit()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheMiss()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public List getCachedObjects()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getLabel()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getLiveTime()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getMaxSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getName()
+ {
+ return "name";
+ }
+
+ public boolean isDistributed()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isLogEnabled()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isReplicated()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void select(CachedObjectSelector selector) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDistributed(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLabel(String s)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLiveTime(long period)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLogEnabled(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMaxSize(int max)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setName(String name)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setReplicated(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearCache()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object get(Serializable key)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void put(Serializable key, Object value) throws NullPointerException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object remove(Serializable key) throws NullPointerException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List removeCachedObjects()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator.TestExoCache;
-import org.exoplatform.test.BasicTestCase;
-import org.jboss.cache.config.Configuration.CacheMode;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 20 juil. 2009
- */
-public class TestExoCacheFactoryImpl extends BasicTestCase
-{
-
- CacheService service_;
-
- public TestExoCacheFactoryImpl(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
- }
-
- public void testCacheFactory()
- {
- ExoCache cache = service_.getCacheInstance("myCache");
- assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
- AbstractExoCache aCache = (AbstractExoCache)cache;
- assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
- aCache.cache.stop();
- cache = service_.getCacheInstance("cacheDistributed");
- assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
- aCache = (AbstractExoCache)cache;
- assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
- aCache.cache.stop();
- cache = service_.getCacheInstance("myCustomCache");
- assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
- aCache = (AbstractExoCache)cache;
- assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
- aCache.cache.stop();
- }
-
- public void testExoCacheCreator()
- {
- ExoCache cache = service_.getCacheInstance("test-default-impl");
- assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
- AbstractExoCache aCache = (AbstractExoCache)cache;
- aCache.cache.stop();
- cache = service_.getCacheInstance("test-custom-impl-with-old-config");
- assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
- cache = service_.getCacheInstance("test-custom-impl-with-new-config");
- assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator.TestExoCache;
+import org.exoplatform.test.BasicTestCase;
+import org.jboss.cache.config.Configuration.CacheMode;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class TestExoCacheFactoryImpl extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestExoCacheFactoryImpl(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testCacheFactory()
+ {
+ ExoCache cache = service_.getCacheInstance("myCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("cacheDistributed");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("myCustomCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ }
+
+ public void testExoCacheCreator()
+ {
+ ExoCache cache = service_.getCacheInstance("test-default-impl");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("test-custom-impl-with-old-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ cache = service_.getCacheInstance("test-custom-impl-with-new-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.test.BasicTestCase;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class TestFIFOCache extends BasicTestCase
-{
-
- CacheService service_;
-
- public TestFIFOCache(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
- }
-
- public void testPolicy() throws Exception
- {
- testPolicy("test-fifo");
- testPolicy("test-fifo-with-old-config");
- }
-
- private void testPolicy(String cacheName) throws Exception
- {
- ExoCache cache = service_.getCacheInstance(cacheName);
- cache.put("a", "a");
- cache.put("b", "a");
- cache.put("c", "a");
- cache.put("d", "a");
- assertEquals(4, cache.getCacheSize());
- cache.put("e", "a");
- assertEquals(5, cache.getCacheSize());
- cache.put("f", "a");
- assertEquals(6, cache.getCacheSize());
- Thread.sleep(500);
- assertEquals(6, cache.getCacheSize());
- Thread.sleep(600);
- assertEquals(5, cache.getCacheSize());
- cache.setMaxSize(3);
- cache.setLiveTime(1500);
- cache.put("g", "a");
- assertEquals(6, cache.getCacheSize());
- Thread.sleep(1100);
- assertEquals(3, cache.getCacheSize());
- cache.put("h", "a");
- cache.put("i", "a");
- cache.put("j", "a");
- cache.put("k", "a");
- assertEquals(7, cache.getCacheSize());
- Thread.sleep(500);
- assertEquals(4, cache.getCacheSize());
- Thread.sleep(1100);
- assertEquals(3, cache.getCacheSize());
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.test.BasicTestCase;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestFIFOCache extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestFIFOCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testPolicy() throws Exception
+ {
+ testPolicy("test-fifo");
+ testPolicy("test-fifo-with-old-config");
+ }
+
+ private void testPolicy(String cacheName) throws Exception
+ {
+ ExoCache cache = service_.getCacheInstance(cacheName);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(600);
+ assertEquals(5, cache.getCacheSize());
+ cache.setMaxSize(3);
+ cache.setLiveTime(1500);
+ cache.put("g", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(1100);
+ assertEquals(3, cache.getCacheSize());
+ cache.put("h", "a");
+ cache.put("i", "a");
+ cache.put("j", "a");
+ cache.put("k", "a");
+ assertEquals(7, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(4, cache.getCacheSize());
+ Thread.sleep(1100);
+ assertEquals(3, cache.getCacheSize());
+ }
+}
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl.jboss;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator.LRUExoCache;
-import org.exoplatform.test.BasicTestCase;
-
-/**
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo(a)exoplatform.com
- * 21 juil. 2009
- */
-public class TestLRUCache extends BasicTestCase
-{
-
- CacheService service_;
-
- public TestLRUCache(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
- }
-
- public void testPolicy() throws Exception
- {
- testPolicy("test-lru");
- testPolicy("test-lru-with-old-config");
- }
-
- private void testPolicy(String cacheName) throws Exception
- {
- LRUExoCache cache = (LRUExoCache)service_.getCacheInstance(cacheName);
- cache.put("a", "a");
- cache.put("b", "a");
- cache.put("c", "a");
- cache.put("d", "a");
- assertEquals(4, cache.getCacheSize());
- cache.put("e", "a");
- assertEquals(5, cache.getCacheSize());
- cache.put("f", "a");
- assertEquals(6, cache.getCacheSize());
- Thread.sleep(1000);
- assertFalse(cache.get("b") == null);
- assertFalse(cache.get("c") == null);
- assertFalse(cache.get("d") == null);
- Thread.sleep(600);
- assertEquals(3, cache.getCacheSize());
- Thread.sleep(500);
- assertEquals(0, cache.getCacheSize());
- cache.setMaxSize(3);
- cache.setTimeToLive(500);
- cache.setMaxAge(1000);
- cache.put("a", "a");
- cache.put("b", "a");
- cache.put("c", "a");
- cache.put("d", "a");
- assertEquals(4, cache.getCacheSize());
- cache.put("e", "a");
- assertEquals(5, cache.getCacheSize());
- cache.put("f", "a");
- Thread.sleep(500);
- cache.get("a");
- cache.get("b");
- assertEquals(3, cache.getCacheSize());
- Thread.sleep(600);
- assertEquals(0, cache.getCacheSize());
- }
-}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator.LRUExoCache;
+import org.exoplatform.test.BasicTestCase;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestLRUCache extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestLRUCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testPolicy() throws Exception
+ {
+ testPolicy("test-lru");
+ testPolicy("test-lru-with-old-config");
+ }
+
+ private void testPolicy(String cacheName) throws Exception
+ {
+ LRUExoCache cache = (LRUExoCache)service_.getCacheInstance(cacheName);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(1000);
+ assertFalse(cache.get("b") == null);
+ assertFalse(cache.get("c") == null);
+ assertFalse(cache.get("d") == null);
+ Thread.sleep(600);
+ assertEquals(3, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(0, cache.getCacheSize());
+ cache.setMaxSize(3);
+ cache.setTimeToLive(500);
+ cache.setMaxAge(1000);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ Thread.sleep(500);
+ cache.get("a");
+ cache.get("b");
+ assertEquals(3, cache.getCacheSize());
+ Thread.sleep(600);
+ assertEquals(0, cache.getCacheSize());
+ }
+}
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf)
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal)
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,183 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
-
- <!--
- isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
- -->
- <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
- writeSkewCheck="false" concurrencyLevel="500" />
-
-
- <!--
- Used to register a transaction manager and participate in ongoing
- transactions.
- -->
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
- syncCommitPhase="false" />
-
-
- <!--
- Used to register JMX statistics in any available MBean server
- -->
- <jmxStatistics enabled="false" />
-
- <!--
- If region based marshalling is used, defines whether new regions are
- inactive on startup.
- -->
- <startup regionsInactiveOnStartup="true" />
-
- <!--
- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
- DONT_REGISTER
- -->
- <shutdown hookBehavior="DEFAULT" />
-
-
- <!--
- Used to define async listener notification thread pool size
- -->
- <listeners asyncPoolSize="1" asyncQueueSize="100000" />
-
- <!--
- Used to enable invocation batching and allow the use of
- Cache.startBatch()/endBatch() methods.
- -->
- <invocationBatching enabled="false" />
-
- <!--
- serialization related configuration, used for replication and cache
- loading
- -->
-
- <!--
- serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
- marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
- -->
-
- <!--
- This element specifies that the cache is clustered. modes supported:
- replication (r) or invalidation (i).
- -->
- <clustering mode="replication" clusterName="JBossCache-cluster">
-
- <!--
- Defines whether to retrieve state on startup
- -->
- <stateRetrieval timeout="20000" fetchInMemoryState="false" />
-
- <!--
- Network calls are synchronous.
- -->
- <sync replTimeout="20000" />
-
- <!--
- Uncomment this for async replication.
- -->
-
- <!--
- <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
- serializationExecutorQueueSize="5000000"/>
- -->
-
- <!-- Uncomment to use Buddy Replication -->
- <!--
- <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
- searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
- = true </properties> </locator> </buddy>
- -->
-
- <!--
- Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
- the class loader.
- -->
- <jgroupsConfig configFile="udp.xml">
- <!--
- uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
- <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
-
- retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
- stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
- view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
-
- <pbcast.FLUSH timeout="0"/>
- -->
- </jgroupsConfig>
- </clustering>
-
- <!--
- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
- -->
- <eviction wakeUpInterval="50">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
- <property name="maxNodes" value="1" />
- <property name="timeToLive" value="5000" />
- </default>
- <!--
- region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
- algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
- name="minTimeToLive" value="4000" /> </region
- -->
- </eviction>
-
- <!--
- Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
- removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
- if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
- -->
- <!--
- <loaders passivation="false" shared="false"> <preload> <node fqn="/org/jboss" /> <node fqn="/org/tempdata" /> </preload>
- -->
- <!--
- we can have multiple cache loaders, which get chained
- -->
-
- <!--
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
-
- <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
- class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
-
- </singletonStore> </loader> </loaders>
- -->
-
-
- <!--
-
- Define custom interceptors. All custom interceptors need to extend
- org.jboss.cache.interceptors.base.CommandInterceptor
- -->
-
- <!--
-
- <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
- name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
- class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
- class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
-
- class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
-
- class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
- -->
-</jbosscache>
-
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="false" />
+
+ <!--
+ serialization related configuration, used for replication and cache
+ loading
+ -->
+
+ <!--
+ serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
+ marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
+ -->
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Uncomment this for async replication.
+ -->
+
+ <!--
+ <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
+ serializationExecutorQueueSize="5000000"/>
+ -->
+
+ <!-- Uncomment to use Buddy Replication -->
+ <!--
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
+ searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
+ = true </properties> </locator> </buddy>
+ -->
+
+ <!--
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ <!--
+ uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+
+ retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
+ stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+
+ <pbcast.FLUSH timeout="0"/>
+ -->
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+ Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
+ -->
+ <eviction wakeUpInterval="50">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="1" />
+ <property name="timeToLive" value="5000" />
+ </default>
+ <!--
+ region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
+ algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
+ name="minTimeToLive" value="4000" /> </region
+ -->
+ </eviction>
+
+ <!--
+ Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
+ removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
+ if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
+ -->
+ <!--
+ <loaders passivation="false" shared="false"> <preload> <node fqn="/org/jboss" /> <node fqn="/org/tempdata" /> </preload>
+ -->
+ <!--
+ we can have multiple cache loaders, which get chained
+ -->
+
+ <!--
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
+
+ <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
+ class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
+
+ </singletonStore> </loader> </loaders>
+ -->
+
+
+ <!--
+
+ Define custom interceptors. All custom interceptors need to extend
+ org.jboss.cache.interceptors.base.CommandInterceptor
+ -->
+
+ <!--
+
+ <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
+ name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
+ -->
+</jbosscache>
+
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,193 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
-
- <!--
- isolation levels supported: READ_COMMITTED and REPEATABLE_READ
-
- nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic
- (deprecated)
- -->
-
- <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
- writeSkewCheck="false" concurrencyLevel="500" />
-
- <!--
- Used to register a transaction manager and participate in ongoing
- transactions.
- -->
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
- syncCommitPhase="false" />
-
- <!--
- Used to register JMX statistics in any available MBean server
- -->
- <jmxStatistics enabled="false" />
-
- <!--
- If region based marshalling is used, defines whether new regions are
- inactive on startup.
- -->
- <startup regionsInactiveOnStartup="true" />
-
- <!--
- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
- DONT_REGISTER
- -->
- <shutdown hookBehavior="DEFAULT" />
-
- <!--
- Used to define async listener notification thread pool size
- -->
- <listeners asyncPoolSize="1" asyncQueueSize="100000" />
-
- <!--
- Used to enable invocation batching and allow the use of
- Cache.startBatch()/endBatch() methods.
- -->
- <invocationBatching enabled="false" />
-
- <!--
- serialization related configuration, used for replication and cache
- loading
- -->
-
- <!--
- serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
-
- marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
- -->
-
- <!--
- This element specifies that the cache is clustered. modes supported:
- replication (r) or invalidation (i).
- -->
- <clustering mode="replication" clusterName="JBossCache-cluster">
-
-
- <!--
- Defines whether to retrieve state on startup
- -->
- <stateRetrieval timeout="20000" fetchInMemoryState="false" />
-
- <!--
- Network calls are synchronous.
- -->
- <sync replTimeout="20000" />
-
- <!--
- Uncomment this for async replication.
- -->
-
- <!--
- <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
- serializationExecutorQueueSize="5000000"/>
- -->
-
- <!-- Uncomment to use Buddy Replication -->
- <!--
- <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
- searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
- = true </properties> </locator> </buddy>
- -->
-
- <!--
-
- Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
- the class loader.
- -->
- <jgroupsConfig configFile="udp.xml">
- <!--
- uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
- <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
-
- retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
- stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
- view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
-
- <pbcast.FLUSH timeout="0"/>
- -->
- </jgroupsConfig>
- </clustering>
-
- <!--
-
- Eviction configuration. WakeupInterval defines how often the eviction
- thread runs, in milliseconds. 0 means the eviction thread will never
- run.
- -->
- <eviction wakeUpInterval="500">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
- <property name="maxNodes" value="1" />
- <property name="timeToLive" value="5000" />
- </default>
-
- <!--
- region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
- algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
- name="minTimeToLive" value="4000" /> </region
- -->
- </eviction>
-
- <!--
- Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
- removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
- if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
- -->
- <!--
- <loaders passivation="false" shared="false">
- <preload>
- <node fqn="/org/jboss" />
- <node fqn="/org/tempdata" />
- </preload>
- -->
-
- <!--
- we can have multiple cache loaders, which get chained
- -->
-
- <!--
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
-
- <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
- class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
-
- </singletonStore> </loader> </loaders>
- -->
-
- <!--
- Define custom interceptors. All custom interceptors need to extend
- org.jboss.cache.interceptors.base.CommandInterceptor
- -->
-
- <!--
- <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
- name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
- class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
- class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
-
- class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
-
- class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
- -->
-</jbosscache>
-
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ
+
+ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic
+ (deprecated)
+ -->
+
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="false" />
+
+ <!--
+ serialization related configuration, used for replication and cache
+ loading
+ -->
+
+ <!--
+ serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
+
+ marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
+ -->
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Uncomment this for async replication.
+ -->
+
+ <!--
+ <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
+ serializationExecutorQueueSize="5000000"/>
+ -->
+
+ <!-- Uncomment to use Buddy Replication -->
+ <!--
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
+ searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
+ = true </properties> </locator> </buddy>
+ -->
+
+ <!--
+
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ <!--
+ uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+
+ retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
+ stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+
+ <pbcast.FLUSH timeout="0"/>
+ -->
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+
+ Eviction configuration. WakeupInterval defines how often the eviction
+ thread runs, in milliseconds. 0 means the eviction thread will never
+ run.
+ -->
+ <eviction wakeUpInterval="500">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="1" />
+ <property name="timeToLive" value="5000" />
+ </default>
+
+ <!--
+ region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
+ algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
+ name="minTimeToLive" value="4000" /> </region
+ -->
+ </eviction>
+
+ <!--
+ Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
+ removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
+ if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
+ -->
+ <!--
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/org/jboss" />
+ <node fqn="/org/tempdata" />
+ </preload>
+ -->
+
+ <!--
+ we can have multiple cache loaders, which get chained
+ -->
+
+ <!--
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
+
+ <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
+ class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
+
+ </singletonStore> </loader> </loaders>
+ -->
+
+ <!--
+ Define custom interceptors. All custom interceptors need to extend
+ org.jboss.cache.interceptors.base.CommandInterceptor
+ -->
+
+ <!--
+ <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
+ name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
+ -->
+</jbosscache>
+
Deleted: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -1,181 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
- <component>
- <key>org.exoplatform.services.cache.CacheService</key>
- <type>org.exoplatform.services.cache.impl.CacheServiceImpl</type>
-
- <init-params>
- <object-param>
- <name>cache.config.default</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>default</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>2</long></field>
- </object>
- </object-param>
- <object-param>
- <name>test-multi-threading</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
- <field name="name"><string>test-multi-threading</string></field>
- <field name="maxNodes"><int>-1</int></field>
- <field name="minTimeToLive"><long>0</long></field>
- </object>
- </object-param>
- <object-param>
- <name>cacheDistributed</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>cacheDistributed</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>2</long></field>
- <field name="distributed"><boolean>true</boolean></field>
- </object>
- </object-param>
- <object-param>
- <name>test-default-impl</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>test-default-impl</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>2</long></field>
- </object>
- </object-param>
- <object-param>
- <name>test-custom-impl-with-old-config</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>test-custom-impl-with-old-config</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>2</long></field>
- <field name="implementation"><string>TEST</string></field>
- </object>
- </object-param>
- <object-param>
- <name>test-custom-impl-with-new-config</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheConfig">
- <field name="name"><string>test-custom-impl-with-new-config</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>2</long></field>
- </object>
- </object-param>
- <object-param>
- <name>test-fifo-with-old-config</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>test-fifo-with-old-config</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>1</long></field>
- <field name="implementation"><string>FIFO</string></field>
- </object>
- </object-param>
- <object-param>
- <name>test-fifo</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
- <field name="name"><string>test-fifo</string></field>
- <field name="maxNodes"><int>5</int></field>
- <field name="minTimeToLive"><long>1000</long></field>
- </object>
- </object-param>
- <object-param>
- <name>test-lru-with-old-config</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.ExoCacheConfig">
- <field name="name"><string>test-lru-with-old-config</string></field>
- <field name="maxSize"><int>5</int></field>
- <field name="liveTime"><long>1</long></field>
- <field name="implementation"><string>LRU</string></field>
- </object>
- </object-param>
- <object-param>
- <name>test-lru</name>
- <description>The default cache configuration</description>
- <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheConfig">
- <field name="name"><string>test-lru</string></field>
- <field name="maxNodes"><int>5</int></field>
- <field name="minTimeToLive"><long>1000</long></field>
- <field name="maxAge"><long>2000</long></field>
- <field name="timeToLive"><long>1500</long></field>
- </object>
- </object-param>
- </init-params>
- </component>
-
- <component>
- <key>org.exoplatform.services.cache.ExoCacheFactory</key>
- <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
- <init-params>
- <value-param>
- <name>cache.config.template</name>
- <value>jar:/conf/portal/cache-configuration-template.xml</value>
- </value-param>
- </init-params>
- </component>
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
- <component-plugin>
- <name>addConfig</name>
- <set-method>addConfig</set-method>
- <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryConfigPlugin</type>
- <description>add Custom Configurations</description>
- <init-params>
- <value-param>
- <name>myCustomCache</name>
- <value>jar:/conf/portal/distributed-cache-configuration-template.xml</value>
- </value-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>addCreator</name>
- <set-method>addCreator</set-method>
- <type>org.exoplatform.services.cache.impl.jboss.ExoCacheCreatorPlugin</type>
- <description>add Exo Cache Creator</description>
- <init-params>
- <object-param>
- <name>Test</name>
- <description>The cache creator for testing purpose</description>
- <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator"></object>
- </object-param>
- <object-param>
- <name>FIFO</name>
- <description>The fifo cache creator</description>
- <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator"></object>
- </object-param>
- <object-param>
- <name>LRU</name>
- <description>The lru cache creator</description>
- <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator">
- <field name="defaultTimeToLive"><long>1500</long></field>
- <field name="defaultMaxAge"><long>2000</long></field>
- </object>
- </object-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-</configuration>
Copied: kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml (from rev 1056, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml)
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml (rev 0)
+++ kernel/branches/config-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.exoplatform.services.cache.CacheService</key>
+ <type>org.exoplatform.services.cache.impl.CacheServiceImpl</type>
+
+ <init-params>
+ <object-param>
+ <name>cache.config.default</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>default</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-multi-threading</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
+ <field name="name"><string>test-multi-threading</string></field>
+ <field name="maxNodes"><int>-1</int></field>
+ <field name="minTimeToLive"><long>0</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>cacheDistributed</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>cacheDistributed</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="distributed"><boolean>true</boolean></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-default-impl</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-default-impl</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="implementation"><string>TEST</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-new-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-new-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-fifo-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-fifo-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>1</long></field>
+ <field name="implementation"><string>FIFO</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-fifo</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
+ <field name="name"><string>test-fifo</string></field>
+ <field name="maxNodes"><int>5</int></field>
+ <field name="minTimeToLive"><long>1000</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-lru-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-lru-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>1</long></field>
+ <field name="implementation"><string>LRU</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-lru</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheConfig">
+ <field name="name"><string>test-lru</string></field>
+ <field name="maxNodes"><int>5</int></field>
+ <field name="minTimeToLive"><long>1000</long></field>
+ <field name="maxAge"><long>2000</long></field>
+ <field name="timeToLive"><long>1500</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+ <component-plugin>
+ <name>addConfig</name>
+ <set-method>addConfig</set-method>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryConfigPlugin</type>
+ <description>add Custom Configurations</description>
+ <init-params>
+ <value-param>
+ <name>myCustomCache</name>
+ <value>jar:/conf/portal/distributed-cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>addCreator</name>
+ <set-method>addCreator</set-method>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheCreatorPlugin</type>
+ <description>add Exo Cache Creator</description>
+ <init-params>
+ <object-param>
+ <name>Test</name>
+ <description>The cache creator for testing purpose</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator"></object>
+ </object-param>
+ <object-param>
+ <name>FIFO</name>
+ <description>The fifo cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator"></object>
+ </object-param>
+ <object-param>
+ <name>LRU</name>
+ <description>The lru cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator">
+ <field name="defaultTimeToLive"><long>1500</long></field>
+ <field name="defaultMaxAge"><long>2000</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
Modified: kernel/branches/config-branch/exo.kernel.component.remote/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.component.remote/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.component.remote/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.remote</artifactId>
Modified: kernel/branches/config-branch/exo.kernel.container/pom.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.container/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.container</artifactId>
Modified: kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/client/http/ClientTypeMap.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/client/http/ClientTypeMap.java 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/client/http/ClientTypeMap.java 2009-12-15 13:36:16 UTC (rev 1059)
@@ -94,7 +94,7 @@
String preferredMimeType = (String)preferredMimeTypeExp.evaluate(node, XPathConstants.STRING);
String renderer = (String)rendererExp.evaluate(node, XPathConstants.STRING);
HttpClientType clientInfo;
- if (renderer != null || renderer.length() > 0)
+ if (renderer != null && renderer.length() > 0)
{
clientInfo = new HttpClientType(name, userAgentPattern, preferredMimeType, renderer);
}
Modified: kernel/branches/config-branch/packaging/module/pom.xml
===================================================================
--- kernel/branches/config-branch/packaging/module/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/packaging/module/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: kernel/branches/config-branch/pom.xml
===================================================================
--- kernel/branches/config-branch/pom.xml 2009-12-15 13:35:49 UTC (rev 1058)
+++ kernel/branches/config-branch/pom.xml 2009-12-15 13:36:16 UTC (rev 1059)
@@ -30,7 +30,7 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
<packaging>pom</packaging>
<name>eXo Kernel</name>
@@ -42,9 +42,9 @@
</properties>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/kernel/tags/2.2.0-Beta04</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/kernel/tags/2.2.0-Beta04</developerConnection>
- <url>http://fisheye.jboss.org/browse/exo-jcr/kernel/tags/2.2.0-Beta04</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/kernel/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/kernel/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/exo-jcr/kernel/trunk</url>
</scm>
<modules>
@@ -53,6 +53,7 @@
<module>exo.kernel.component.common</module>
<module>exo.kernel.component.remote</module>
<module>exo.kernel.component.cache</module>
+ <module>exo.kernel.component.ext.cache.impl.jboss.v3</module>
<module>exo.kernel.component.command</module>
<module>packaging/module</module>
</modules>
@@ -78,8 +79,13 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.remote</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.4.O</version>
@@ -163,9 +169,14 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.10.GA</version>
+ <version>2.6.12.GA</version>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>3.2.0.GA</version>
+ </dependency>
+ <dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-bind</artifactId>
<version>${jibx.plugin.version}</version>
16 years, 7 months
exo-jcr SVN: r1058 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query: lucene and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-15 08:35:49 -0500 (Tue, 15 Dec 2009)
New Revision: 1058
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-291: PushState: disabled, added check if index directory removed from other side, added index-reader reopening if it is not current (actual).
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-15 13:25:52 UTC (rev 1057)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-15 13:35:49 UTC (rev 1058)
@@ -93,7 +93,7 @@
singletonStoreConfig.setSingletonStoreClass(IndexerSingletonStoreCacheLoader.class.getName());
//singletonStoreConfig.setSingletonStoreClass(SingletonStoreCacheLoader.class.getName());
Properties singletonStoreProperties = new Properties();
- singletonStoreProperties.setProperty("pushStateWhenCoordinator", "true");
+ singletonStoreProperties.setProperty("pushStateWhenCoordinator", "false");
singletonStoreProperties.setProperty("pushStateWhenCoordinatorTimeout", "10000");
singletonStoreConfig.setProperties(singletonStoreProperties);
singletonStoreConfig.setSingletonStoreEnabled(true);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2009-12-15 13:25:52 UTC (rev 1057)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2009-12-15 13:35:49 UTC (rev 1058)
@@ -49,575 +49,682 @@
* Concurrent access by <b>one</b> modifying thread and multiple read-only
* threads is safe!
*/
-abstract class AbstractIndex {
+abstract class AbstractIndex
+{
- /** The logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(AbstractIndex.class);
+ /** The logger instance for this class */
+ private static final Logger log = LoggerFactory.getLogger(AbstractIndex.class);
- /** PrintStream that pipes all calls to println(String) into log.info() */
- private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
+ /** PrintStream that pipes all calls to println(String) into log.info() */
+ private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
- /** Executor with a pool size equal to the number of available processors */
- private static final DynamicPooledExecutor EXECUTOR = new DynamicPooledExecutor();
+ /** Executor with a pool size equal to the number of available processors */
+ private static final DynamicPooledExecutor EXECUTOR = new DynamicPooledExecutor();
- /** The currently set IndexWriter or <code>null</code> if none is set */
- private IndexWriter indexWriter;
+ /** The currently set IndexWriter or <code>null</code> if none is set */
+ private IndexWriter indexWriter;
- /** The currently set IndexReader or <code>null</code> if none is set */
- private CommittableIndexReader indexReader;
+ /** The currently set IndexReader or <code>null</code> if none is set */
+ private CommittableIndexReader indexReader;
- /** The underlying Directory where the index is stored */
- private Directory directory;
+ /** The underlying Directory where the index is stored */
+ private Directory directory;
- /** Analyzer we use to tokenize text */
- private Analyzer analyzer;
+ /** Analyzer we use to tokenize text */
+ private Analyzer analyzer;
- /** The similarity in use for indexing and searching. */
- private final Similarity similarity;
+ /** The similarity in use for indexing and searching. */
+ private final Similarity similarity;
- /** Compound file flag */
- private boolean useCompoundFile = true;
+ /** Compound file flag */
+ private boolean useCompoundFile = true;
- /** maxFieldLength config parameter */
- private int maxFieldLength = SearchIndex.DEFAULT_MAX_FIELD_LENGTH;
+ /** maxFieldLength config parameter */
+ private int maxFieldLength = SearchIndex.DEFAULT_MAX_FIELD_LENGTH;
- /** termInfosIndexDivisor config parameter */
- private int termInfosIndexDivisor = SearchIndex.DEFAULT_TERM_INFOS_INDEX_DIVISOR;
+ /** termInfosIndexDivisor config parameter */
+ private int termInfosIndexDivisor = SearchIndex.DEFAULT_TERM_INFOS_INDEX_DIVISOR;
- /**
- * The document number cache if this index may use one.
- */
- private DocNumberCache cache;
+ /**
+ * The document number cache if this index may use one.
+ */
+ private DocNumberCache cache;
- /** The shared IndexReader for all read-only IndexReaders */
- private SharedIndexReader sharedReader;
+ /** The shared IndexReader for all read-only IndexReaders */
+ private SharedIndexReader sharedReader;
- /**
- * The most recent read-only reader if there is any.
- */
- private ReadOnlyIndexReader readOnlyReader;
+ /**
+ * The most recent read-only reader if there is any.
+ */
+ private ReadOnlyIndexReader readOnlyReader;
- /**
- * The indexing queue.
- */
- private IndexingQueue indexingQueue;
+ /**
+ * The indexing queue.
+ */
+ private IndexingQueue indexingQueue;
- /**
- * Flag that indicates whether there was an index present in the directory
- * when this AbstractIndex was created.
- */
- private boolean isExisting;
+ /**
+ * Flag that indicates whether there was an index present in the directory
+ * when this AbstractIndex was created.
+ */
+ private boolean isExisting;
- /**
- * Constructs an index with an <code>analyzer</code> and a
- * <code>directory</code>.
- *
- * @param analyzer the analyzer for text tokenizing.
- * @param similarity the similarity implementation.
- * @param directory the underlying directory.
- * @param cache the document number cache if this index should use
- * one; otherwise <code>cache</code> is
- * <code>null</code>.
- * @param indexingQueue the indexing queue.
- * @throws IOException if the index cannot be initialized.
- */
- AbstractIndex(Analyzer analyzer,
- Similarity similarity,
- Directory directory,
- DocNumberCache cache,
- IndexingQueue indexingQueue) throws IOException {
- this.analyzer = analyzer;
- this.similarity = similarity;
- this.directory = directory;
- this.cache = cache;
- this.indexingQueue = indexingQueue;
- this.isExisting = IndexReader.indexExists(directory);
+ /**
+ * Constructs an index with an <code>analyzer</code> and a
+ * <code>directory</code>.
+ *
+ * @param analyzer the analyzer for text tokenizing.
+ * @param similarity the similarity implementation.
+ * @param directory the underlying directory.
+ * @param cache the document number cache if this index should use
+ * one; otherwise <code>cache</code> is
+ * <code>null</code>.
+ * @param indexingQueue the indexing queue.
+ * @throws IOException if the index cannot be initialized.
+ */
+ AbstractIndex(Analyzer analyzer, Similarity similarity, Directory directory, DocNumberCache cache,
+ IndexingQueue indexingQueue) throws IOException
+ {
+ this.analyzer = analyzer;
+ this.similarity = similarity;
+ this.directory = directory;
+ this.cache = cache;
+ this.indexingQueue = indexingQueue;
+ this.isExisting = IndexReader.indexExists(directory);
- if (!isExisting) {
- indexWriter = new IndexWriter(directory, analyzer,
- IndexWriter.MaxFieldLength.LIMITED);
- // immediately close, now that index has been created
- indexWriter.close();
- indexWriter = null;
- }
- }
+ if (!isExisting)
+ {
+ indexWriter = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+ // immediately close, now that index has been created
+ indexWriter.close();
+ indexWriter = null;
+ }
+ }
- /**
- * Default implementation returns the same instance as passed
- * in the constructor.
- *
- * @return the directory instance passed in the constructor
- */
- Directory getDirectory() {
- return directory;
- }
+ /**
+ * Default implementation returns the same instance as passed
+ * in the constructor.
+ *
+ * @return the directory instance passed in the constructor
+ */
+ Directory getDirectory()
+ {
+ return directory;
+ }
- /**
- * Returns <code>true</code> if this index was openend on a directory with
- * an existing index in it; <code>false</code> otherwise.
- *
- * @return <code>true</code> if there was an index present when this index
- * was created; <code>false</code> otherwise.
- */
- boolean isExisting() {
- return isExisting;
- }
+ /**
+ * Returns <code>true</code> if this index was openend on a directory with
+ * an existing index in it; <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if there was an index present when this index
+ * was created; <code>false</code> otherwise.
+ */
+ boolean isExisting()
+ {
+ return isExisting;
+ }
- /**
- * Adds documents to this index and invalidates the shared reader.
- *
- * @param docs the documents to add.
- * @throws IOException if an error occurs while writing to the index.
- */
- void addDocuments(Document[] docs) throws IOException {
- final IndexWriter writer = getIndexWriter();
- DynamicPooledExecutor.Command[] commands =
- new DynamicPooledExecutor.Command[docs.length];
- for (int i = 0; i < docs.length; i++) {
- // check if text extractor completed its work
- final Document doc = getFinishedDocument(docs[i]);
- // create a command for inverting the document
- commands[i] = new DynamicPooledExecutor.Command() {
- public Object call() throws Exception {
- long time = System.currentTimeMillis();
- writer.addDocument(doc);
- return new Long(System.currentTimeMillis() - time);
- }
- };
- }
- DynamicPooledExecutor.Result[] results = EXECUTOR.executeAndWait(commands);
- invalidateSharedReader();
- IOException ex = null;
- for (int i = 0; i < results.length; i++) {
- if (results[i].getException() != null) {
- Throwable cause = results[i].getException().getCause();
- if (ex == null) {
- // only throw the first exception
- if (cause instanceof IOException) {
- ex = (IOException) cause;
- } else {
- throw Util.createIOException(cause);
- }
- } else {
- // all others are logged
- log.warn("Exception while inverting document", cause);
- }
- } else {
- log.debug("Inverted document in {} ms", results[i].get());
+ /**
+ * Adds documents to this index and invalidates the shared reader.
+ *
+ * @param docs the documents to add.
+ * @throws IOException if an error occurs while writing to the index.
+ */
+ void addDocuments(Document[] docs) throws IOException
+ {
+ final IndexWriter writer = getIndexWriter();
+ DynamicPooledExecutor.Command[] commands = new DynamicPooledExecutor.Command[docs.length];
+ for (int i = 0; i < docs.length; i++)
+ {
+ // check if text extractor completed its work
+ final Document doc = getFinishedDocument(docs[i]);
+ // create a command for inverting the document
+ commands[i] = new DynamicPooledExecutor.Command()
+ {
+ public Object call() throws Exception
+ {
+ long time = System.currentTimeMillis();
+ writer.addDocument(doc);
+ return new Long(System.currentTimeMillis() - time);
}
- }
- if (ex != null) {
- throw ex;
- }
- }
+ };
+ }
+ DynamicPooledExecutor.Result[] results = EXECUTOR.executeAndWait(commands);
+ invalidateSharedReader();
+ IOException ex = null;
+ for (int i = 0; i < results.length; i++)
+ {
+ if (results[i].getException() != null)
+ {
+ Throwable cause = results[i].getException().getCause();
+ if (ex == null)
+ {
+ // only throw the first exception
+ if (cause instanceof IOException)
+ {
+ ex = (IOException)cause;
+ }
+ else
+ {
+ throw Util.createIOException(cause);
+ }
+ }
+ else
+ {
+ // all others are logged
+ log.warn("Exception while inverting document", cause);
+ }
+ }
+ else
+ {
+ log.debug("Inverted document in {} ms", results[i].get());
+ }
+ }
+ if (ex != null)
+ {
+ throw ex;
+ }
+ }
- /**
- * Removes the document from this index. This call will not invalidate
- * the shared reader. If a subclass whishes to do so, it should overwrite
- * this method and call {@link #invalidateSharedReader()}.
- *
- * @param idTerm the id term of the document to remove.
- * @throws IOException if an error occurs while removing the document.
- * @return number of documents deleted
- */
- int removeDocument(Term idTerm) throws IOException {
- return getIndexReader().deleteDocuments(idTerm);
- }
+ /**
+ * Removes the document from this index. This call will not invalidate
+ * the shared reader. If a subclass whishes to do so, it should overwrite
+ * this method and call {@link #invalidateSharedReader()}.
+ *
+ * @param idTerm the id term of the document to remove.
+ * @throws IOException if an error occurs while removing the document.
+ * @return number of documents deleted
+ */
+ int removeDocument(Term idTerm) throws IOException
+ {
+ return getIndexReader().deleteDocuments(idTerm);
+ }
- /**
- * Returns an <code>IndexReader</code> on this index. This index reader
- * may be used to delete documents.
- *
- * @return an <code>IndexReader</code> on this index.
- * @throws IOException if the reader cannot be obtained.
- */
- protected synchronized CommittableIndexReader getIndexReader() throws IOException {
- if (indexWriter != null) {
- indexWriter.close();
- log.debug("closing IndexWriter.");
- indexWriter = null;
- }
- if (indexReader == null) {
- IndexReader reader = IndexReader.open(getDirectory());
- reader.setTermInfosIndexDivisor(termInfosIndexDivisor);
- indexReader = new CommittableIndexReader(reader);
- }
- return indexReader;
- }
+ /**
+ * Returns an <code>IndexReader</code> on this index. This index reader
+ * may be used to delete documents.
+ *
+ * @return an <code>IndexReader</code> on this index.
+ * @throws IOException if the reader cannot be obtained.
+ */
+ protected synchronized CommittableIndexReader getIndexReader() throws IOException
+ {
+ if (indexWriter != null)
+ {
+ indexWriter.close();
+ log.debug("closing IndexWriter.");
+ indexWriter = null;
+ }
+
+ if (indexReader == null || !indexReader.isCurrent())
+ {
+ IndexReader reader = IndexReader.open(getDirectory());
+ reader.setTermInfosIndexDivisor(termInfosIndexDivisor);
+ indexReader = new CommittableIndexReader(reader);
+ }
+ return indexReader;
+ }
- /**
- * Returns a read-only index reader, that can be used concurrently with
- * other threads writing to this index. The returned index reader is
- * read-only, that is, any attempt to delete a document from the index
- * will throw an <code>UnsupportedOperationException</code>.
- *
- * @param initCache if the caches in the index reader should be initialized
- * before the index reader is returned.
- * @return a read-only index reader.
- * @throws IOException if an error occurs while obtaining the index reader.
- */
- synchronized ReadOnlyIndexReader getReadOnlyIndexReader(boolean initCache)
- throws IOException {
- // get current modifiable index reader
- CommittableIndexReader modifiableReader = getIndexReader();
- long modCount = modifiableReader.getModificationCount();
- if (readOnlyReader != null) {
- if (readOnlyReader.getDeletedDocsVersion() == modCount) {
- // reader up-to-date
- readOnlyReader.acquire();
- return readOnlyReader;
- } else {
- // reader outdated
- if (readOnlyReader.getRefCount() == 1) {
- // not in use, except by this index
- // update the reader
- readOnlyReader.updateDeletedDocs(modifiableReader);
- readOnlyReader.acquire();
- return readOnlyReader;
- } else {
- // cannot update reader, it is still in use
- // need to create a new instance
- readOnlyReader.release();
- readOnlyReader = null;
- }
+ /**
+ * Returns a read-only index reader, that can be used concurrently with
+ * other threads writing to this index. The returned index reader is
+ * read-only, that is, any attempt to delete a document from the index
+ * will throw an <code>UnsupportedOperationException</code>.
+ *
+ * @param initCache if the caches in the index reader should be initialized
+ * before the index reader is returned.
+ * @return a read-only index reader.
+ * @throws IOException if an error occurs while obtaining the index reader.
+ */
+ synchronized ReadOnlyIndexReader getReadOnlyIndexReader(boolean initCache) throws IOException
+ {
+ // get current modifiable index reader
+ CommittableIndexReader modifiableReader = getIndexReader();
+ long modCount = modifiableReader.getModificationCount();
+ if (readOnlyReader != null)
+ {
+ if (readOnlyReader.getDeletedDocsVersion() == modCount)
+ {
+ // reader up-to-date
+ readOnlyReader.acquire();
+ return readOnlyReader;
+ }
+ else
+ {
+ // reader outdated
+ if (readOnlyReader.getRefCount() == 1)
+ {
+ // not in use, except by this index
+ // update the reader
+ readOnlyReader.updateDeletedDocs(modifiableReader);
+ readOnlyReader.acquire();
+ return readOnlyReader;
}
- }
- // if we get here there is no up-to-date read-only reader
- // capture snapshot of deleted documents
- BitSet deleted = new BitSet(modifiableReader.maxDoc());
- for (int i = 0; i < modifiableReader.maxDoc(); i++) {
- if (modifiableReader.isDeleted(i)) {
- deleted.set(i);
+ else
+ {
+ // cannot update reader, it is still in use
+ // need to create a new instance
+ readOnlyReader.release();
+ readOnlyReader = null;
}
- }
- if (sharedReader == null) {
- // create new shared reader
- IndexReader reader = IndexReader.open(getDirectory(), true);
- reader.setTermInfosIndexDivisor(termInfosIndexDivisor);
- CachingIndexReader cr = new CachingIndexReader(
- reader, cache, initCache);
- sharedReader = new SharedIndexReader(cr);
- }
- readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
- readOnlyReader.acquire();
- return readOnlyReader;
- }
+ }
+ }
+ // if we get here there is no up-to-date read-only reader
+ // capture snapshot of deleted documents
+ BitSet deleted = new BitSet(modifiableReader.maxDoc());
+ for (int i = 0; i < modifiableReader.maxDoc(); i++)
+ {
+ if (modifiableReader.isDeleted(i))
+ {
+ deleted.set(i);
+ }
+ }
+ if (sharedReader == null)
+ {
+ // create new shared reader
+ IndexReader reader = IndexReader.open(getDirectory(), true);
+ reader.setTermInfosIndexDivisor(termInfosIndexDivisor);
+ CachingIndexReader cr = new CachingIndexReader(reader, cache, initCache);
+ sharedReader = new SharedIndexReader(cr);
+ }
+ readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
+ readOnlyReader.acquire();
+ return readOnlyReader;
+ }
- /**
- * Returns a read-only index reader, that can be used concurrently with
- * other threads writing to this index. The returned index reader is
- * read-only, that is, any attempt to delete a document from the index
- * will throw an <code>UnsupportedOperationException</code>.
- *
- * @return a read-only index reader.
- * @throws IOException if an error occurs while obtaining the index reader.
- */
- protected ReadOnlyIndexReader getReadOnlyIndexReader()
- throws IOException {
- return getReadOnlyIndexReader(false);
- }
+ /**
+ * Returns a read-only index reader, that can be used concurrently with
+ * other threads writing to this index. The returned index reader is
+ * read-only, that is, any attempt to delete a document from the index
+ * will throw an <code>UnsupportedOperationException</code>.
+ *
+ * @return a read-only index reader.
+ * @throws IOException if an error occurs while obtaining the index reader.
+ */
+ protected ReadOnlyIndexReader getReadOnlyIndexReader() throws IOException
+ {
+ return getReadOnlyIndexReader(false);
+ }
- /**
- * Returns an <code>IndexWriter</code> on this index.
- * @return an <code>IndexWriter</code> on this index.
- * @throws IOException if the writer cannot be obtained.
- */
- protected synchronized IndexWriter getIndexWriter() throws IOException {
- if (indexReader != null) {
- indexReader.close();
- log.debug("closing IndexReader.");
- indexReader = null;
- }
- if (indexWriter == null) {
- indexWriter = new IndexWriter(getDirectory(), analyzer,
- new IndexWriter.MaxFieldLength(maxFieldLength));
- indexWriter.setSimilarity(similarity);
- indexWriter.setUseCompoundFile(useCompoundFile);
- indexWriter.setInfoStream(STREAM_LOGGER);
- }
- return indexWriter;
- }
+ /**
+ * Returns an <code>IndexWriter</code> on this index.
+ * @return an <code>IndexWriter</code> on this index.
+ * @throws IOException if the writer cannot be obtained.
+ */
+ protected synchronized IndexWriter getIndexWriter() throws IOException
+ {
+ if (indexReader != null)
+ {
+ indexReader.close();
+ log.debug("closing IndexReader.");
+ indexReader = null;
+ }
+ if (indexWriter == null)
+ {
+ indexWriter = new IndexWriter(getDirectory(), analyzer, new IndexWriter.MaxFieldLength(maxFieldLength));
+ indexWriter.setSimilarity(similarity);
+ indexWriter.setUseCompoundFile(useCompoundFile);
+ indexWriter.setInfoStream(STREAM_LOGGER);
+ }
+ return indexWriter;
+ }
- /**
- * Commits all pending changes to the underlying <code>Directory</code>.
- * @throws IOException if an error occurs while commiting changes.
- */
- protected void commit() throws IOException {
- commit(false);
- }
+ /**
+ * Commits all pending changes to the underlying <code>Directory</code>.
+ * @throws IOException if an error occurs while commiting changes.
+ */
+ protected void commit() throws IOException
+ {
+ commit(false);
+ }
- /**
- * Commits all pending changes to the underlying <code>Directory</code>.
- *
- * @param optimize if <code>true</code> the index is optimized after the
- * commit.
- * @throws IOException if an error occurs while commiting changes.
- */
- protected synchronized void commit(boolean optimize) throws IOException {
- if (indexReader != null) {
- log.debug("committing IndexReader.");
- indexReader.flush();
- }
- if (indexWriter != null) {
- log.debug("committing IndexWriter.");
- indexWriter.commit();
- }
- // optimize if requested
- if (optimize) {
- IndexWriter writer = getIndexWriter();
- writer.optimize();
- writer.close();
- indexWriter = null;
- }
- }
+ /**
+ * Commits all pending changes to the underlying <code>Directory</code>.
+ *
+ * @param optimize if <code>true</code> the index is optimized after the
+ * commit.
+ * @throws IOException if an error occurs while commiting changes.
+ */
+ protected synchronized void commit(boolean optimize) throws IOException
+ {
+ if (indexReader != null)
+ {
+ log.debug("committing IndexReader.");
+ indexReader.flush();
+ }
+ if (indexWriter != null)
+ {
+ log.debug("committing IndexWriter.");
+ indexWriter.commit();
+ }
+ // optimize if requested
+ if (optimize)
+ {
+ IndexWriter writer = getIndexWriter();
+ writer.optimize();
+ writer.close();
+ indexWriter = null;
+ }
+ }
- /**
- * Closes this index, releasing all held resources.
- */
- synchronized void close() {
- releaseWriterAndReaders();
- if (directory != null) {
- try {
- directory.close();
- } catch (IOException e) {
- directory = null;
- }
- }
- }
+ /**
+ * Closes this index, releasing all held resources.
+ */
+ synchronized void close()
+ {
+ releaseWriterAndReaders();
+ if (directory != null)
+ {
+ try
+ {
+ directory.close();
+ }
+ catch (IOException e)
+ {
+ directory = null;
+ }
+ }
+ }
- /**
- * Releases all potentially held index writer and readers.
- */
- protected void releaseWriterAndReaders() {
- if (indexWriter != null) {
- try {
- indexWriter.close();
- } catch (IOException e) {
- log.warn("Exception closing index writer: " + e.toString());
- }
- indexWriter = null;
- }
- if (indexReader != null) {
- try {
- indexReader.close();
- } catch (IOException e) {
- log.warn("Exception closing index reader: " + e.toString());
- }
- indexReader = null;
- }
- if (readOnlyReader != null) {
- try {
- readOnlyReader.release();
- } catch (IOException e) {
- log.warn("Exception closing index reader: " + e.toString());
- }
- readOnlyReader = null;
- }
- if (sharedReader != null) {
- try {
- sharedReader.release();
- } catch (IOException e) {
- log.warn("Exception closing index reader: " + e.toString());
- }
- sharedReader = null;
- }
- }
-
- /**
- * @return the number of bytes this index occupies in memory.
- */
- synchronized long getRamSizeInBytes() {
- if (indexWriter != null) {
- return indexWriter.ramSizeInBytes();
- } else {
- return 0;
- }
- }
-
- /**
- * Closes the shared reader.
- *
- * @throws IOException if an error occurs while closing the reader.
- */
- protected synchronized void invalidateSharedReader() throws IOException {
- // also close the read-only reader
- if (readOnlyReader != null) {
+ /**
+ * Releases all potentially held index writer and readers.
+ */
+ protected void releaseWriterAndReaders()
+ {
+ if (indexWriter != null)
+ {
+ try
+ {
+ indexWriter.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing index writer: " + e.toString());
+ }
+ indexWriter = null;
+ }
+ if (indexReader != null)
+ {
+ try
+ {
+ indexReader.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing index reader: " + e.toString());
+ }
+ indexReader = null;
+ }
+ if (readOnlyReader != null)
+ {
+ try
+ {
readOnlyReader.release();
- readOnlyReader = null;
- }
- // invalidate shared reader
- if (sharedReader != null) {
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing index reader: " + e.toString());
+ }
+ readOnlyReader = null;
+ }
+ if (sharedReader != null)
+ {
+ try
+ {
sharedReader.release();
- sharedReader = null;
- }
- }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception closing index reader: " + e.toString());
+ }
+ sharedReader = null;
+ }
+ }
- /**
- * Returns a document that is finished with text extraction and is ready to
- * be added to the index.
- *
- * @param doc the document to check.
- * @return <code>doc</code> if it is finished already or a stripped down
- * copy of <code>doc</code> without text extractors.
- * @throws IOException if the document cannot be added to the indexing
- * queue.
- */
- private Document getFinishedDocument(Document doc) throws IOException {
- if (!Util.isDocumentReady(doc)) {
- Document copy = new Document();
- // mark the document that reindexing is required
- copy.add(new Field(FieldNames.REINDEXING_REQUIRED, "",
- Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
- Iterator fields = doc.getFields().iterator();
- while (fields.hasNext()) {
- Fieldable f = (Fieldable) fields.next();
- Fieldable field = null;
- Field.TermVector tv = getTermVectorParameter(f);
- Field.Store stored = getStoreParameter(f);
- Field.Index indexed = getIndexParameter(f);
- if (f instanceof LazyTextExtractorField || f.readerValue() != null) {
- // replace all readers with empty string reader
- field = new Field(f.name(), new StringReader(""), tv);
- } else if (f.stringValue() != null) {
- field = new Field(f.name(), f.stringValue(),
- stored, indexed, tv);
- } else if (f.isBinary()) {
- field = new Field(f.name(), f.binaryValue(), stored);
- }
- if (field != null) {
- field.setOmitNorms(f.getOmitNorms());
- copy.add(field);
- }
+ /**
+ * @return the number of bytes this index occupies in memory.
+ */
+ synchronized long getRamSizeInBytes()
+ {
+ if (indexWriter != null)
+ {
+ return indexWriter.ramSizeInBytes();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Closes the shared reader.
+ *
+ * @throws IOException if an error occurs while closing the reader.
+ */
+ protected synchronized void invalidateSharedReader() throws IOException
+ {
+ // also close the read-only reader
+ if (readOnlyReader != null)
+ {
+ readOnlyReader.release();
+ readOnlyReader = null;
+ }
+ // invalidate shared reader
+ if (sharedReader != null)
+ {
+ sharedReader.release();
+ sharedReader = null;
+ }
+ }
+
+ /**
+ * Returns a document that is finished with text extraction and is ready to
+ * be added to the index.
+ *
+ * @param doc the document to check.
+ * @return <code>doc</code> if it is finished already or a stripped down
+ * copy of <code>doc</code> without text extractors.
+ * @throws IOException if the document cannot be added to the indexing
+ * queue.
+ */
+ private Document getFinishedDocument(Document doc) throws IOException
+ {
+ if (!Util.isDocumentReady(doc))
+ {
+ Document copy = new Document();
+ // mark the document that reindexing is required
+ copy.add(new Field(FieldNames.REINDEXING_REQUIRED, "", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
+ Iterator fields = doc.getFields().iterator();
+ while (fields.hasNext())
+ {
+ Fieldable f = (Fieldable)fields.next();
+ Fieldable field = null;
+ Field.TermVector tv = getTermVectorParameter(f);
+ Field.Store stored = getStoreParameter(f);
+ Field.Index indexed = getIndexParameter(f);
+ if (f instanceof LazyTextExtractorField || f.readerValue() != null)
+ {
+ // replace all readers with empty string reader
+ field = new Field(f.name(), new StringReader(""), tv);
}
- // schedule the original document for later indexing
- Document existing = indexingQueue.addDocument(doc);
- if (existing != null) {
- // the queue already contained a pending document for this
- // node. -> dispose the document
- Util.disposeDocument(existing);
+ else if (f.stringValue() != null)
+ {
+ field = new Field(f.name(), f.stringValue(), stored, indexed, tv);
}
- // use the stripped down copy for now
- doc = copy;
- }
- return doc;
- }
+ else if (f.isBinary())
+ {
+ field = new Field(f.name(), f.binaryValue(), stored);
+ }
+ if (field != null)
+ {
+ field.setOmitNorms(f.getOmitNorms());
+ copy.add(field);
+ }
+ }
+ // schedule the original document for later indexing
+ Document existing = indexingQueue.addDocument(doc);
+ if (existing != null)
+ {
+ // the queue already contained a pending document for this
+ // node. -> dispose the document
+ Util.disposeDocument(existing);
+ }
+ // use the stripped down copy for now
+ doc = copy;
+ }
+ return doc;
+ }
- //-------------------------< properties >-----------------------------------
+ //-------------------------< properties >-----------------------------------
- /**
- * The lucene index writer property: useCompountFile
- */
- void setUseCompoundFile(boolean b) {
- useCompoundFile = b;
- if (indexWriter != null) {
- indexWriter.setUseCompoundFile(b);
- }
- }
+ /**
+ * The lucene index writer property: useCompountFile
+ */
+ void setUseCompoundFile(boolean b)
+ {
+ useCompoundFile = b;
+ if (indexWriter != null)
+ {
+ indexWriter.setUseCompoundFile(b);
+ }
+ }
- /**
- * The lucene index writer property: maxFieldLength
- */
- void setMaxFieldLength(int maxFieldLength) {
- this.maxFieldLength = maxFieldLength;
- if (indexWriter != null) {
- indexWriter.setMaxFieldLength(maxFieldLength);
- }
- }
+ /**
+ * The lucene index writer property: maxFieldLength
+ */
+ void setMaxFieldLength(int maxFieldLength)
+ {
+ this.maxFieldLength = maxFieldLength;
+ if (indexWriter != null)
+ {
+ indexWriter.setMaxFieldLength(maxFieldLength);
+ }
+ }
- /**
- * @return the current value for termInfosIndexDivisor.
- */
- public int getTermInfosIndexDivisor() {
- return termInfosIndexDivisor;
- }
+ /**
+ * @return the current value for termInfosIndexDivisor.
+ */
+ public int getTermInfosIndexDivisor()
+ {
+ return termInfosIndexDivisor;
+ }
- /**
- * Sets a new value for termInfosIndexDivisor.
- *
- * @param termInfosIndexDivisor the new value.
- */
- public void setTermInfosIndexDivisor(int termInfosIndexDivisor) {
- this.termInfosIndexDivisor = termInfosIndexDivisor;
- }
+ /**
+ * Sets a new value for termInfosIndexDivisor.
+ *
+ * @param termInfosIndexDivisor the new value.
+ */
+ public void setTermInfosIndexDivisor(int termInfosIndexDivisor)
+ {
+ this.termInfosIndexDivisor = termInfosIndexDivisor;
+ }
- //------------------------------< internal >--------------------------------
+ //------------------------------< internal >--------------------------------
- /**
- * Returns the index parameter set on <code>f</code>.
- *
- * @param f a lucene field.
- * @return the index parameter on <code>f</code>.
- */
- private Field.Index getIndexParameter(Fieldable f) {
- if (!f.isIndexed()) {
- return Field.Index.NO;
- } else if (f.isTokenized()) {
- return Field.Index.ANALYZED;
- } else {
- return Field.Index.NOT_ANALYZED;
- }
- }
+ /**
+ * Returns the index parameter set on <code>f</code>.
+ *
+ * @param f a lucene field.
+ * @return the index parameter on <code>f</code>.
+ */
+ private Field.Index getIndexParameter(Fieldable f)
+ {
+ if (!f.isIndexed())
+ {
+ return Field.Index.NO;
+ }
+ else if (f.isTokenized())
+ {
+ return Field.Index.ANALYZED;
+ }
+ else
+ {
+ return Field.Index.NOT_ANALYZED;
+ }
+ }
- /**
- * Returns the store parameter set on <code>f</code>.
- *
- * @param f a lucene field.
- * @return the store parameter on <code>f</code>.
- */
- private Field.Store getStoreParameter(Fieldable f) {
- if (f.isCompressed()) {
- return Field.Store.COMPRESS;
- } else if (f.isStored()) {
- return Field.Store.YES;
- } else {
- return Field.Store.NO;
- }
- }
+ /**
+ * Returns the store parameter set on <code>f</code>.
+ *
+ * @param f a lucene field.
+ * @return the store parameter on <code>f</code>.
+ */
+ private Field.Store getStoreParameter(Fieldable f)
+ {
+ if (f.isCompressed())
+ {
+ return Field.Store.COMPRESS;
+ }
+ else if (f.isStored())
+ {
+ return Field.Store.YES;
+ }
+ else
+ {
+ return Field.Store.NO;
+ }
+ }
- /**
- * Returns the term vector parameter set on <code>f</code>.
- *
- * @param f a lucene field.
- * @return the term vector parameter on <code>f</code>.
- */
- private Field.TermVector getTermVectorParameter(Fieldable f) {
- if (f.isStorePositionWithTermVector() && f.isStoreOffsetWithTermVector()) {
- return Field.TermVector.WITH_POSITIONS_OFFSETS;
- } else if (f.isStorePositionWithTermVector()) {
- return Field.TermVector.WITH_POSITIONS;
- } else if (f.isStoreOffsetWithTermVector()) {
- return Field.TermVector.WITH_OFFSETS;
- } else if (f.isTermVectorStored()) {
- return Field.TermVector.YES;
- } else {
- return Field.TermVector.NO;
- }
- }
+ /**
+ * Returns the term vector parameter set on <code>f</code>.
+ *
+ * @param f a lucene field.
+ * @return the term vector parameter on <code>f</code>.
+ */
+ private Field.TermVector getTermVectorParameter(Fieldable f)
+ {
+ if (f.isStorePositionWithTermVector() && f.isStoreOffsetWithTermVector())
+ {
+ return Field.TermVector.WITH_POSITIONS_OFFSETS;
+ }
+ else if (f.isStorePositionWithTermVector())
+ {
+ return Field.TermVector.WITH_POSITIONS;
+ }
+ else if (f.isStoreOffsetWithTermVector())
+ {
+ return Field.TermVector.WITH_OFFSETS;
+ }
+ else if (f.isTermVectorStored())
+ {
+ return Field.TermVector.YES;
+ }
+ else
+ {
+ return Field.TermVector.NO;
+ }
+ }
- /**
- * Adapter to pipe info messages from lucene into log messages.
- */
- private static final class LoggingPrintStream extends PrintStream {
+ /**
+ * Adapter to pipe info messages from lucene into log messages.
+ */
+ private static final class LoggingPrintStream extends PrintStream
+ {
- /** Buffer print calls until a newline is written */
- private StringBuffer buffer = new StringBuffer();
+ /** Buffer print calls until a newline is written */
+ private StringBuffer buffer = new StringBuffer();
- public LoggingPrintStream() {
- super(new OutputStream() {
- public void write(int b) {
- // do nothing
- }
- });
- }
+ public LoggingPrintStream()
+ {
+ super(new OutputStream()
+ {
+ public void write(int b)
+ {
+ // do nothing
+ }
+ });
+ }
- public void print(String s) {
- buffer.append(s);
- }
+ public void print(String s)
+ {
+ buffer.append(s);
+ }
- public void println(String s) {
- buffer.append(s);
- log.debug(buffer.toString());
- buffer.setLength(0);
- }
- }
+ public void println(String s)
+ {
+ buffer.append(s);
+ log.debug(buffer.toString());
+ buffer.setLength(0);
+ }
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-15 13:25:52 UTC (rev 1057)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-15 13:35:49 UTC (rev 1058)
@@ -30,6 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -834,9 +835,19 @@
for (int i = 0; i < indexes.size(); i++)
{
PersistentIndex pIdx = (PersistentIndex)indexes.get(i);
+
if (indexNames.contains(pIdx.getName()))
{
- readerList.add(pIdx.getReadOnlyIndexReader(initCache));
+ try
+ {
+ readerList.add(pIdx.getReadOnlyIndexReader(initCache));
+ }
+ catch (FileNotFoundException e)
+ {
+ if(directoryManager.hasDirectory(pIdx.getName())){
+ throw e;
+ }
+ }
}
}
readerList.add(volatileIndex.getReadOnlyIndexReader());
16 years, 7 months
exo-jcr SVN: r1057 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/cluster and 1 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-15 08:25:52 -0500 (Tue, 15 Dec 2009)
New Revision: 1057
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
Log:
EXOJCR-313: cluster functional tests updated - 4 cluster nodes support added
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml 2009-12-15 13:25:52 UTC (rev 1057)
@@ -53,7 +53,7 @@
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml 2009-12-15 13:25:52 UTC (rev 1057)
@@ -53,7 +53,7 @@
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml 2009-12-15 13:25:52 UTC (rev 1057)
@@ -53,7 +53,7 @@
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2009-12-15 13:25:52 UTC (rev 1057)
@@ -35,12 +35,24 @@
*/
public abstract class BaseClusteringFunctionalTest extends TestCase
{
- protected JCRWebdavConnection connection;
+ protected JCRWebdavConnection connection1;
+ protected JCRWebdavConnection connection2;
+
+ protected JCRWebdavConnection connection3;
+
+ protected JCRWebdavConnection connection4;
+
private String host = "localhost";
- private int port = 8080;
+ private int port1 = 8081;//8080;
+ private int port2 = 8082;
+
+ private int port3 = 8083;
+
+ private int port4 = 8084;
+
private String realm = "eXo REST services";
private String user = "root";
@@ -59,7 +71,10 @@
super.setUp();
CookieModule.setCookiePolicyHandler(null);
- connection = new JCRWebdavConnection(host, port, user, password, realm, workspacePath);
+ connection1 = new JCRWebdavConnection(host, port1, user, password, realm, workspacePath);
+ connection2 = new JCRWebdavConnection(host, port2, user, password, realm, workspacePath);
+ connection3 = new JCRWebdavConnection(host, port3, user, password, realm, workspacePath);
+ connection4 = new JCRWebdavConnection(host, port4, user, password, realm, workspacePath);
nodeName = generateUniqueName("removed_node_over_webdav");
}
@@ -76,8 +91,8 @@
{
super.tearDown();
- connection.removeNode(nodeName);
- connection.stop();
+ connection1.removeNode(nodeName);
+ connection1.stop();
}
protected File createBLOBTempFile(String prefix, int sizeInKb) throws IOException
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-15 13:25:52 UTC (rev 1057)
@@ -41,41 +41,49 @@
*/
private int sizeInMb = 5;
- //File blobFile = null;
-
public void testAddBLOB() throws Exception
{
+ // make a test blob
byte[] data = new byte[sizeInMb * 1024 * 1024];
Random random = new Random();
random.nextBytes(data);
+ // add node with blob data
HttpOutputStream stream = new HttpOutputStream();
-
- HTTPResponse response = connection.addNode(nodeName, stream);
+ HTTPResponse response = connection1.addNode(nodeName, stream);
loadStream(stream, new ByteArrayInputStream(data));
stream.close();
response.getStatusCode();
- // check results
- response = connection.getNode(nodeName);
-
+ // check results
+ // cluster-node1
+ response = connection1.getNode(nodeName);
assertEquals(response.getStatusCode(), 200);
byte[] respData = response.getData();
assertEquals(data.length, respData.length);
assertTrue(java.util.Arrays.equals(data, respData));
- }
- protected void loadStream(HttpOutputStream stream, int sizeInKb) throws IOException
- {
- byte[] data = new byte[1024]; // 1Kb
+ // cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
- Random random = new Random();
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
- for (int i = 0; i < sizeInKb; i++)
- {
- random.nextBytes(data);
- stream.write(data);
- }
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
}
protected void loadStream(HttpOutputStream stream, InputStream in) throws IOException
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-15 13:25:52 UTC (rev 1057)
@@ -27,20 +27,35 @@
* @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
* @version $Id$
*/
-public class WebdavAddNodeTest
- extends BaseClusteringFunctionalTest
+public class WebdavAddNodeTest extends BaseClusteringFunctionalTest
{
public void testAddNode() throws Exception
{
- // add
- connection.addNode(nodeName, "_data_".getBytes());
-
- // check
- HTTPResponse response = connection.getNode(nodeName);
-
+ // add node
+ connection1.addNode(nodeName, "_data_".getBytes());
+
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
assertEquals(response.getStatusCode(), 200);
- assertTrue("_data_".equals(new String(response.getData())));
+ assertTrue("_data_".equals(new String(response.getData())));
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(response2.getStatusCode(), 200);
+ assertTrue("_data_".equals(new String(response2.getData())));
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(response3.getStatusCode(), 200);
+ assertTrue("_data_".equals(new String(response3.getData())));
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(response4.getStatusCode(), 200);
+ assertTrue("_data_".equals(new String(response4.getData())));
+
}
-
+
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-15 12:31:47 UTC (rev 1056)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-15 13:25:52 UTC (rev 1057)
@@ -31,20 +31,41 @@
{
public void testRemoveNode() throws Exception
{
- // add
- connection.addNode(nodeName, "".getBytes());
+ // add test node
+ connection1.addNode(nodeName, "".getBytes());
- HTTPResponse response = connection.getNode(nodeName);
-
+ // check is exist cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
assertEquals(response.getStatusCode(), 200);
+ //cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
+ //cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
+ //cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 200);
- // remove
- connection.removeNode(nodeName);
+ // remove node on cluster-node2
+ connection2.removeNode(nodeName);
- // check
- response = connection.getNode(nodeName);
+ // check cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 404);
+ // cluster-node2
+ response = connection2.getNode(nodeName);
assertEquals(response.getStatusCode(), 404);
+
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 404);
+
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(response.getStatusCode(), 404);
+
}
}
16 years, 7 months
exo-jcr SVN: r1056 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core: src/test/resources/conf/test and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-15 07:31:47 -0500 (Tue, 15 Dec 2009)
New Revision: 1056
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/TCK.sh
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config-extended.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-usecase.xml
Log:
EXOJCR-300: remove unused Node Types
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/TCK.sh
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/TCK.sh 2009-12-15 12:00:57 UTC (rev 1055)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/TCK.sh 2009-12-15 12:31:47 UTC (rev 1056)
@@ -1,2 +1,2 @@
MAVEN_OPTS="-Duser.language=en -Duser.region=us -Dmaven.test.skip=false -DforkMode=never -Dorg.exoplatform.jcr.monitor.jdbcMonitor $MAVEN_OPTS "
-mvn $MAVEN_OPTS clean test -Prun-tck
+mvn clean test -Prun-tck
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config-extended.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config-extended.xml 2009-12-15 12:00:57 UTC (rev 1055)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config-extended.xml 2009-12-15 12:31:47 UTC (rev 1056)
@@ -151,50 +151,6 @@
</childNodeDefinitions>
</nodeType>
- <nodeType name="exo:relationable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:relation" requiredType="Reference" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="true">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
- <nodeType name="exo:rss-enable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:title" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:summary" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
- <nodeType name="exo:article" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
- <supertypes>
- <supertype>nt:base</supertype>
- <supertype>mix:referenceable</supertype>
- <supertype>exo:rss-enable</supertype>
- </supertypes>
- <propertyDefinitions>
- <propertyDefinition name="exo:text" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- <childNodeDefinitions>
- <childNodeDefinition name="*" defaultPrimaryType="nt:file" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- sameNameSiblings="true">
- <requiredPrimaryTypes>
- <requiredPrimaryType>nt:file</requiredPrimaryType>
- </requiredPrimaryTypes>
- </childNodeDefinition>
- </childNodeDefinitions>
- </nodeType>
-
<nodeType name="exo:tab" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
@@ -231,28 +187,6 @@
</childNodeDefinitions>
</nodeType>
- <nodeType name="exo:published" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:startPublication" requiredType="Date" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:endPublication" requiredType="Date" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
- <nodeType name="exo:categorized" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:category" requiredType="Reference" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="true">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
<nodeType name="exo:template" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
@@ -457,52 +391,6 @@
</childNodeDefinitions> -->
</nodeType>
- <nodeType name="exo:sample" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
- <supertypes>
- <supertype>nt:base</supertype>
- <supertype>exo:rss-enable</supertype>
- </supertypes>
- <propertyDefinitions>
- <propertyDefinition name="exo:title" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:description" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:date" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:datetime" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:summary" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:content" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- <childNodeDefinitions>
- <childNodeDefinition name="*" defaultPrimaryType="nt:file" autoCreated="false" mandatory="false" onParentVersion="VERSION"
- protected="false" sameNameSiblings="true">
- <requiredPrimaryTypes>
- <requiredPrimaryType>nt:file</requiredPrimaryType>
- </requiredPrimaryTypes>
- </childNodeDefinition>
- <childNodeDefinition name="exo:image" defaultPrimaryType="nt:resource" autoCreated="false" mandatory="false" onParentVersion="VERSION"
- protected="false" sameNameSiblings="true">
- <requiredPrimaryTypes>
- <requiredPrimaryType>nt:resource</requiredPrimaryType>
- </requiredPrimaryTypes>
- </childNodeDefinition>
- </childNodeDefinitions>
- </nodeType>
<nodeType name="exo:watchable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
@@ -634,71 +522,6 @@
</propertyDefinitions>
</nodeType>
- <nodeType name="exo:folksonomized" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:folksonomy" requiredType="Reference" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="true">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
- <nodeType name="exo:schedulableInfo" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:scheduledInitiator" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:jobName" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:jobGroup" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:jobClass" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:jobDescription" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:scheduleType" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:startTime" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:endTime" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:repeatCount" requiredType="Long" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:timeInterval" requiredType="Long" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:cronExpression" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:counter" requiredType="Long" autoCreated="true" mandatory="true" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- <defaultValues>
- <defaultValue>0</defaultValue>
- </defaultValues>
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
<nodeType name="mix:i18n" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
<propertyDefinitions>
<propertyDefinition name="exo:language" requiredType="String" autoCreated="true" mandatory="false" onParentVersion="COPY" protected="false"
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config.xml 2009-12-15 12:00:57 UTC (rev 1055)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-config.xml 2009-12-15 12:31:47 UTC (rev 1056)
@@ -102,41 +102,6 @@
</childNodeDefinitions>
</nodeType>
- <!-- exo:actions property will be used to store all actions that reference to this node -->
- <nodeType name="exo:actionable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:actions" requiredType="Reference" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- <childNodeDefinitions>
- <childNodeDefinition name="*" defaultPrimaryType="" autoCreated="false" mandatory="false" onParentVersion="VERSION" protected="false"
- sameNameSiblings="true">
- <requiredPrimaryTypes>
- <requiredPrimaryType>exo:actionStorage</requiredPrimaryType>
- </requiredPrimaryTypes>
- </childNodeDefinition>
- </childNodeDefinitions>
- </nodeType>
-
- <nodeType name="exo:move" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:repository" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:destWorkspace" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:destPath" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
<nodeType name="mix:title" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
<propertyDefinitions>
<propertyDefinition name="jcr:title" requiredType="String" autoCreated="false" mandatory="false"
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-usecase.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-usecase.xml 2009-12-15 12:00:57 UTC (rev 1055)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/test/nodetypes-usecase.xml 2009-12-15 12:31:47 UTC (rev 1056)
@@ -33,102 +33,7 @@
</propertyDefinitions>
</nodeType>
- <nodeType name="rma:record" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <supertypes>
- <supertype>mix:referenceable</supertype>
- <supertype>exo:metadata</supertype>
- </supertypes>
- <propertyDefinitions>
- <propertyDefinition name="rma:recordIdentifier" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:subject" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:format" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:mediaFormat" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:dateFiled" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:publicationDate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:dateReceived" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:originator" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:originatingOrganization" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:addressees" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:otherAddressees" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:supplementalMArkingList" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="rma:isObsolete" requiredType="Boolean" autoCreated="true" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- <defaultValues>
- <defaultValue>false</defaultValue>
- </defaultValues>
- </propertyDefinition>
- <propertyDefinition name="rma:superseded" requiredType="Reference" autoCreated="true" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- <defaultValues>
- <defaultValue>false</defaultValue>
- </defaultValues>
- </propertyDefinition>
- <propertyDefinition name="rma:recordNote" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:internalUse" requiredType="Boolean" autoCreated="true" mandatory="false" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- <defaultValues>
- <defaultValue>true</defaultValue>
- </defaultValues>
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
<!-- audit nodetypes -->
-
- <nodeType name="exo:auditable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <supertypes>
- <supertype>mix:referenceable</supertype>
- </supertypes>
- <propertyDefinitions>
- <propertyDefinition name="exo:auditHistory" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="true" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
<nodeType name="exo:auditRecord" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
@@ -232,25 +137,4 @@
</propertyDefinitions>
</nodeType>
- <nodeType name="exo:archiveable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:restorePath" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
- <nodeType name="exo:rss-enable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
- <propertyDefinitions>
- <propertyDefinition name="exo:title" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- <propertyDefinition name="exo:summary" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false"
- multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
- </nodeType>
-
</nodeTypes>
16 years, 7 months
exo-jcr SVN: r1055 - in kernel/branches/config-branch/exo.kernel.container/src: main/resources/org/exoplatform/container/configuration and 3 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-12-15 07:00:57 -0500 (Tue, 15 Dec 2009)
New Revision: 1055
Modified:
kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ProfileDOMFilter.java
kernel/branches/config-branch/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_1.xsd
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/collection-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-plugin-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/field-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/import-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/init-param-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator-with-profile-configuration.xml
kernel/branches/config-branch/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml
Log:
rename profile -> profiles
Modified: kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ProfileDOMFilter.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ProfileDOMFilter.java 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ProfileDOMFilter.java 2009-12-15 12:00:57 UTC (rev 1055)
@@ -39,7 +39,7 @@
{
/** . */
- private static final String PROFILE_ATTRIBUTE = "profile";
+ private static final String PROFILE_ATTRIBUTE = "profiles";
/** . */
private static final Set<String> kernelURIs = Tools.set(KERNEL_1_0_URI, KERNEL_1_1_URI);
Modified: kernel/branches/config-branch/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_1.xsd
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_1.xsd 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_1.xsd 2009-12-15 12:00:57 UTC (rev 1055)
@@ -9,8 +9,8 @@
<xsd:element name="configuration" type="configurationType"/>
- <xsd:complexType abstract="true" name="profiledElementType">
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:complexType abstract="true" name="profilesdElementType">
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType abstract="true" name="baseObjectType">
@@ -48,7 +48,7 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="baseObjectType">
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
@@ -83,7 +83,7 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="fieldType">
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
@@ -102,7 +102,7 @@
<xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="valueParamType">
@@ -163,7 +163,7 @@
<xsd:element name="priority" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="init-params" type="initParamsType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="externalComponentPluginType">
@@ -211,7 +211,7 @@
</xsd:element>
<xsd:element name="init-params" type="initParamsType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="configurationType">
@@ -228,7 +228,7 @@
<xsd:complexType name="importType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
- <xsd:attribute name="profile" type="xsd:string"/>
+ <xsd:attribute name="profiles" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/collection-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/collection-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/collection-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -34,8 +34,8 @@
<field name="role">
<collection type="java.util.ArrayList">
<value><string>manager</string></value>
- <value profile="foo"><string>foo_manager</string></value>
- <value profile="foo,bar"><string>foo_bar_manager</string></value>
+ <value profiles="foo"><string>foo_manager</string></value>
+ <value profiles="foo,bar"><string>foo_bar_manager</string></value>
</collection>
</field>
</object>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -24,12 +24,12 @@
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
- <component profile="bar">
+ <component profiles="bar">
<key>Component</key>
<type>ComponentImpl</type>
</component>
- <component profile="foo">
+ <component profiles="foo">
<key>Component</key>
<type>FooComponent</type>
</component>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-plugin-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-plugin-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/component-plugin-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -33,7 +33,7 @@
<set-method>set_method</set-method>
<type>PluginA</type>
</component-plugin>
- <component-plugin profile="foo">
+ <component-plugin profiles="foo">
<name>Plugin</name>
<set-method>set_method</set-method>
<type>PluginA</type>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/field-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/field-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/field-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -36,12 +36,12 @@
<value><string>manager</string></value>
</collection>
</field>
- <field name="role" profile="foo,bar">
+ <field name="role" profiles="foo,bar">
<collection type="java.util.ArrayList">
<value><string>foo_bar_manager</string></value>
</collection>
</field>
- <field name="role" profile="foo">
+ <field name="role" profiles="foo">
<collection type="java.util.ArrayList">
<value><string>foo_manager</string></value>
</collection>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/import-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/import-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/import-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -25,7 +25,7 @@
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
<import>empty</import>
- <import profile="foo">foo</import>
- <import profile="bar">bar</import>
+ <import profiles="foo">foo</import>
+ <import profiles="bar">bar</import>
</configuration>
\ No newline at end of file
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/init-param-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/init-param-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/init-param-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -32,11 +32,11 @@
<name>param</name>
<value>empty</value>
</value-param>
- <value-param profile="foo">
+ <value-param profiles="foo">
<name>param</name>
<value>foo</value>
</value-param>
- <value-param profile="bar">
+ <value-param profiles="bar">
<name>param</name>
<value>bar</value>
</value-param>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator-with-profile-configuration.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator-with-profile-configuration.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator-with-profile-configuration.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -30,7 +30,7 @@
<name>properties</name>
<property name="property_1" value="property_value_1"/>
</properties-param>
- <properties-param profile="foo">
+ <properties-param profiles="foo">
<name>properties</name>
<property name="property_1" value="property_value_1_foo"/>
</properties-param>
Modified: kernel/branches/config-branch/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml 2009-12-15 10:44:57 UTC (rev 1054)
+++ kernel/branches/config-branch/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml 2009-12-15 12:00:57 UTC (rev 1055)
@@ -29,12 +29,12 @@
<type>org.exoplatform.services.naming.InitialContextInitializer</type>
</component>
- <component profile="a">
+ <component profiles="a">
<key>org.exoplatform.services.naming.InitialContextInitializer</key>
<type>org.exoplatform.services.naming.InitialContextInitializer</type>
</component>
- <component profile="a,b">
+ <component profiles="a,b">
<key>org.exoplatform.services.naming.InitialContextInitializer</key>
<type>org.exoplatform.services.naming.InitialContextInitializer</type>
</component>
@@ -47,49 +47,49 @@
<name>object</name>
<object type="object"></object>
</object-param>
- <object-param profile="a">
+ <object-param profiles="a">
<name>object</name>
<object type="object"></object>
</object-param>
- <object-param profile="a,b">
+ <object-param profiles="a,b">
<name>object</name>
<object type="object"></object>
</object-param>
<properties-param>
<name>properties</name>
</properties-param>
- <properties-param profile="a">
+ <properties-param profiles="a">
<name>properties</name>
</properties-param>
- <properties-param profile="a,b">
+ <properties-param profiles="a,b">
<name>properties</name>
</properties-param>
<value-param>
<name>value</name>
<value>value</value>
</value-param>
- <value-param profile="a">
+ <value-param profiles="a">
<name>value</name>
<value>value</value>
</value-param>
- <value-param profile="a,b">
+ <value-param profiles="a,b">
<name>value</name>
<value>value</value>
</value-param>
<values-param>
<name>values</name>
</values-param>
- <values-param profile="a">
+ <values-param profiles="a">
<name>values</name>
</values-param>
- <values-param profile="a,b">
+ <values-param profiles="a,b">
<name>values</name>
</values-param>
</init-params>
</component>
<import>import_1</import>
- <import profile="a">import_1</import>
- <import profile="a,b">import_1</import>
+ <import profiles="a">import_1</import>
+ <import profiles="a,b">import_1</import>
</configuration>
\ No newline at end of file
16 years, 7 months
exo-jcr SVN: r1054 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-15 05:44:57 -0500 (Tue, 15 Dec 2009)
New Revision: 1054
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-199: Nicolas suggestion applied in getItemData(String uuid) method. Direct cache access
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-15 09:27:30 UTC (rev 1053)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-15 10:44:57 UTC (rev 1054)
@@ -78,7 +78,7 @@
private final Cache<Serializable, Object> cache;
private final WorkspaceDataContainer dataContainer;
-
+
/**
* Start batching flag. 'true' if batching was started, 'false' if batching is not start.
*/
@@ -104,8 +104,9 @@
* @param cache Cache<Serializable, Object>
* @param refs
*/
- public JBossCacheStorageConnection(WorkspaceDataContainer dataContainer, Cache<Serializable, Object> cache, Node<Serializable, Object> nodesRoot,
- Node<Serializable, Object> propsRoot, Node<Serializable, Object> locksRoot, Node<Serializable, Object> refsRoot)
+ public JBossCacheStorageConnection(WorkspaceDataContainer dataContainer, Cache<Serializable, Object> cache,
+ Node<Serializable, Object> nodesRoot, Node<Serializable, Object> propsRoot, Node<Serializable, Object> locksRoot,
+ Node<Serializable, Object> refsRoot)
{
super(nodesRoot, propsRoot, locksRoot, refsRoot);
@@ -220,7 +221,7 @@
throw new InvalidItemStateException("Property's parent doesn't exist or removed by another Session "
+ data.getQPath().getAsString());
}
-
+
String propName = data.getQPath().getName().getAsString();
Object value =
cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES), makeNodeFqn(data
@@ -242,7 +243,8 @@
}
// REFERENCEs hadnling
- if (data.getType() == PropertyType.REFERENCE) {
+ if (data.getType() == PropertyType.REFERENCE)
+ {
addReferences(data);
}
}
@@ -543,39 +545,14 @@
public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
{
- Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(identifier));
- if (node != null)
+ ItemData object =
+ (ItemData)cache.get(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES), makeNodeFqn(identifier)),
+ ITEM_DATA);
+ if (object != null && !object.isNode())
{
- NodeData itemData = (NodeData)node.get(ITEM_DATA);
- if (itemData != null)
- {
- return itemData;
- }
- else
- {
- throw new RepositoryException("FATAL NodeData empty " + identifier);
- }
+ throw new RepositoryException("FATAL NodeData empty " + identifier);
}
-
- // TODO only Nodes by Id
- // else
- // {
- // Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(identifier));
- // if (prop != null)
- // {
- // Object itemData = prop.get(ITEM_DATA);
- // if (itemData != null)
- // {
- // return (PropertyData)itemData;
- // }
- // else
- // {
- // throw new RepositoryException("FATAL PropertyData empty " + identifier);
- // }
- // }
- // }
-
- return null;
+ return object;
}
/**
16 years, 7 months
exo-jcr SVN: r1053 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr: impl/core/query and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-15 04:27:30 -0500 (Tue, 15 Dec 2009)
New Revision: 1053
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
Log:
EXOJCR-291: Added parameter "max-volatile-size" to QueryHandler configuration
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2009-12-15 08:37:26 UTC (rev 1052)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2009-12-15 09:27:30 UTC (rev 1053)
@@ -92,6 +92,8 @@
public static final String PARAM_USE_COMPOUNDFILE = "use-compoundfile";
public static final String PARAM_VOLATILE_IDLE_TIME = "volatile-idle-time";
+
+ public static final String PARAM_MAX_VOLATILE_SIZE = "max-volatile-size";
//since https://jira.jboss.org/jira/browse/EXOJCR-17
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2009-12-15 08:37:26 UTC (rev 1052)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2009-12-15 09:27:30 UTC (rev 1053)
@@ -129,6 +129,8 @@
searchIndex.setUseCompoundFile(Boolean.parseBoolean(value));
else if (QueryHandlerParams.PARAM_VOLATILE_IDLE_TIME.equals(name))
searchIndex.setVolatileIdleTime(Integer.parseInt(value));
+ else if (QueryHandlerParams.PARAM_MAX_VOLATILE_SIZE.equals(name))
+ searchIndex.setMaxVolatileIndexSize(Integer.parseInt(value));
else if (QueryHandlerParams.PARAM_ANALYZER_CLASS.equals(name))
{
searchIndex.setAnalyzer(value);
16 years, 7 months