exo-jcr SVN: r908 - 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: nzamosenchuk
Date: 2009-11-30 11:41:43 -0500 (Mon, 30 Nov 2009)
New Revision: 908
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-243: reimplemented addLockData() method using Node.putIfAbent() to prevent concurrency race situation.
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-11-30 11:57:21 UTC (rev 907)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-30 16:41:43 UTC (rev 908)
@@ -300,7 +300,7 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
-
+
// check if parent is cached
Node<Serializable, Object> parent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
if (parent == null)
@@ -1339,33 +1339,31 @@
{
throw new RepositoryException("Lock data to write can't be null!");
}
- // check that there is no lock data for given node
- Node<Serializable, Object> node = locksRoot.getChild(makeNodeFqn(lockData.getNodeIdentifier()));
- // node is not null: check if lockData exists
- if (node != null)
+ // addChild will add if absent or return old if present
+ Node<Serializable, Object> node = locksRoot.addChild(makeNodeFqn(lockData.getNodeIdentifier()));
+ // this will prevent from deleting by eviction.
+ node.setResident(true);
+
+ // this will return null if success. And old data if something exists...
+ LockData oldLockData = (LockData)node.putIfAbsent(JBossCacheStorage.LOCK_DATA, lockData);
+ // if oldLockData is present (not null):
+ // 1. this is Lock.refresh(): oldLockData and lockData will have the same tokens
+ // 2. this node is already locked: data-s will have different tokens
+
+ if (oldLockData != null)
{
- LockData oldLockData = (LockData)node.get(JBossCacheStorage.LOCK_DATA);
- // if old data exists and hash differs, then it was newly locked! Exception, can't lock
- // already locked node.
- if (oldLockData != null && oldLockData.getTokenHash() != lockData.getTokenHash())
+ // if LockData already present with different lock token, then node has already been locked!
+ if (oldLockData.getTokenHash() != lockData.getTokenHash())
{
throw new LockException("Unable to write lock data. Node [" + lockData.getNodeIdentifier()
+ "] already has LockData!");
}
+ else
+ {
+ // token is the same, then Lock is just refreshed. Putting new LockData.
+ node.put(JBossCacheStorage.LOCK_DATA, lockData);
+ }
}
- else
- {
- // JBoss node doesn't exists, create it
- node = locksRoot.addChild(makeNodeFqn(lockData.getNodeIdentifier()));
- node.setResident(true);
- }
- // try to write LockData
- if (node == null)
- {
- throw new RepositoryException("Unable to write to cache!");
- }
- // this will prevent from deleting it by eviction.
- node.put(JBossCacheStorage.LOCK_DATA, lockData);
}
/**
14 years, 5 months
exo-jcr SVN: r907 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage: jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-30 06:57:21 -0500 (Mon, 30 Nov 2009)
New Revision: 907
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/JDBCCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
Log:
EXOJCR-201: Fqn.ROOT handling fix for exists(); comments; delete deprecated in JDBC conn
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-11-30 10:36:38 UTC (rev 906)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-30 11:57:21 UTC (rev 907)
@@ -109,7 +109,13 @@
this.cache = cache;
}
- // helpers
+ /**
+ * Made for read of ItemData with cache invalidation.
+ * NOT USED!
+ *
+ * @param node Node
+ * @return ItemData
+ */
@Deprecated
protected ItemData readItemData(Node<Serializable, Object> node)
{
@@ -923,7 +929,6 @@
updateChildsACL(childNode, newACL);
}
}
-
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-30 10:36:38 UTC (rev 906)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-30 11:57:21 UTC (rev 907)
@@ -560,7 +560,7 @@
}
}
}
- else if (name.get(0).equals(Fqn.ROOT) || name.get(0).equals(JBossCacheStorage.PROPS)
+ else if (name.equals(Fqn.ROOT) || name.get(0).equals(JBossCacheStorage.PROPS)
|| name.get(0).equals(JBossCacheStorage.NODES) || name.get(0).equals(JBossCacheStorage.LOCKS)
|| name.get(0).equals(JBossCacheStorage.REFS))
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-30 10:36:38 UTC (rev 906)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-30 11:57:21 UTC (rev 907)
@@ -418,6 +418,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
@@ -449,6 +450,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
14 years, 5 months
exo-jcr SVN: r906 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core and 14 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-30 05:36:38 -0500 (Mon, 30 Nov 2009)
New Revision: 906
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/UpperLowerCaseQueryTest.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java
jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/BaseStandaloneTest.java
Log:
EXOJCR-280: Merge OPT branch
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -28,48 +28,72 @@
import javax.jcr.RepositoryException;
/**
- * Created by The eXo Platform SAS.
+ * Created by The eXo Platform SAS.<br/>
*
- * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
- * @version $Id: ItemDataConsumer.java 11907 2008-03-13 15:36:21Z ksm $
+ * Basic (Level 1) data flow inmemory operations<br/>
*
- * Basic (Level 1) data flow inmemory operations
- *
* Common Rule for Read : If there is some storage in this manager � try to get the data
* from here first, if not found � call super.someMethod
+ *
+ * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
+ * @version $Id$
*/
public interface ItemDataConsumer
{
/**
- * @param parent
- * @param name
- * @return data by parent and name
+ * Find Item by parent (id) and name (with path index).
+ *
+ * @param parent NodeData
+ * @param name QPathEntry
+ * @return ItemData, data by parent and name
* @throws RepositoryException
*/
ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException;
/**
- * @param identifier
- * @return data by identifier
+ * Find Item by identifier.
+ *
+ * @param String identifier
+ * @return ItemData, data by identifier
*/
ItemData getItemData(String identifier) throws RepositoryException;
/**
- * @param parentIdentifier
- * @return children data
+ * Get child Nodes of the parent node.
+ *
+ * @param parent NodeData
+ * @return List of children Nodes
*/
List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException;
/**
- * @param parentIdentifier
- * @return children data
+ * Get children nodes count of the parent node.
+ * @param parent NodeData
+ * @return int, child nodes count
*/
+ int getChildNodesCount(NodeData parent) throws RepositoryException;
+
+ /**
+ * Get child Properties of the parent node.
+ *
+ * @param parent NodeData
+ * @return List of children Properties
+ */
List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException;
- List<PropertyData> listChildPropertiesData(final NodeData nodeData) throws RepositoryException;
+ /**
+ * List child Properties, returned list will contains Properties without actual Values.
+ *
+ * @param parent NodeData
+ * @return List of PropertyData
+ * @throws RepositoryException
+ */
+ List<PropertyData> listChildPropertiesData(final NodeData parent) throws RepositoryException;
/**
+ * Get Referenced properties.
+ *
* @param identifier
* - referenceable id
* @param skipVersionStorage
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -199,7 +199,6 @@
in.readFully(buf);
sessionId = new String(buf, DEFAULT_ENCODING);
- items = new ArrayList<ItemState>();
int listSize = in.readInt();
for (int i = 0; i < listSize; i++)
add((ItemState)in.readObject());
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.access.AccessManager;
import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
@@ -97,6 +98,11 @@
*/
protected JCRPath location;
+ /**
+ * Item QPath.
+ */
+ protected QPath qpath;
+
protected SessionDataManager dataManager;
protected LocationFactory locationFactory;
@@ -104,32 +110,24 @@
protected ValueFactoryImpl valueFactory;
/**
- * Hashcode.
- */
- protected final int itemHashCode;
-
- /**
- * ItemImpl constructor.
- *
- * @param data
- * ItemData object
- * @param session
- * Session object
- * @throws RepositoryException
- * if any Exception is occurred
- */
+ * ItemImpl constructor.
+ *
+ * @param data
+ * ItemData object
+ * @param session
+ * Session object
+ * @throws RepositoryException
+ * if any Exception is occurred
+ */
ItemImpl(ItemData data, SessionImpl session) throws RepositoryException
{
this.session = session;
this.data = data;
- this.location = session.getLocationFactory().createJCRPath(data.getQPath());
this.dataManager = session.getTransientNodesManager();
this.locationFactory = session.getLocationFactory();
this.valueFactory = session.getValueFactory();
-
- itemHashCode = (session.getWorkspace().getName() + data.getIdentifier()).hashCode();
}
protected void invalidate()
@@ -165,7 +163,7 @@
/**
* {@inheritDoc}
*/
- public String getPath()
+ public String getPath() throws RepositoryException
{
return getLocation().getAsString(false);
}
@@ -173,7 +171,7 @@
/**
* {@inheritDoc}
*/
- public String getName()
+ public String getName() throws RepositoryException
{
return getLocation().getName().getAsString();
}
@@ -239,7 +237,7 @@
*/
public int getDepth()
{
- return getLocation().getDepth();
+ return qpath.getDepth();
}
/**
@@ -749,8 +747,11 @@
*
* @return item JCRPath
*/
- public JCRPath getLocation()
+ public JCRPath getLocation() throws RepositoryException
{
+ if (this.location == null)
+ this.location = session.getLocationFactory().createJCRPath(qpath);
+
return this.location;
}
@@ -764,8 +765,35 @@
return data.getIdentifier().equals(Constants.ROOT_UUID);
}
+ /**
+ * Loads data
+ *
+ * @param data
+ * source item data
+ * @throws RepositoryException
+ * if errors occurs
+ */
abstract void loadData(ItemData data) throws RepositoryException;
+ /**
+ * Loads data.
+ *
+ * @param data
+ * source item data
+ * @param itemDefinitionData
+ * source item definition data
+ * @throws RepositoryException
+ * if errors occurs
+ */
+ abstract void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException;
+
+ /**
+ * Returns Item definition data.
+ *
+ * @return
+ */
+ abstract ItemDefinitionData getItemDefinitionData();
+
public boolean hasPermission(String action) throws RepositoryException
{
NodeData ndata;
@@ -804,15 +832,6 @@
return false;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- return itemHashCode;
- }
-
private ValueData valueData(Value value, int type) throws RepositoryException, ValueFormatException
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.core.ExtendedNode;
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
@@ -137,7 +138,7 @@
*
* @param data
* Node data
- * @param session
+ * @param session
* Session
* @throws RepositoryException
* if error occurs during the Node data loading
@@ -150,6 +151,25 @@
}
/**
+ * NodeImpl constructor.
+ *
+ * @param data
+ * Node data
+ * @param parent
+ * parent node data is used for simple calculation item definition
+ * @param session
+ * Session
+ * @throws RepositoryException
+ * if error occurs during the Node data loading
+ */
+ public NodeImpl(NodeData data, NodeData parent, SessionImpl session) throws RepositoryException
+ {
+ super(data, session);
+ this.sysLocFactory = session.getSystemLocationFactory();
+ loadData(data, parent);
+ }
+
+ /**
* {@inheritDoc}
*/
public void accept(ItemVisitor visitor) throws RepositoryException
@@ -585,7 +605,7 @@
dataManager.update(state, false);
NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
- ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager);
+ ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager, false);
PlainChangesLog changes =
itemAutocreator.makeAutoCreatedItems(nodeData(), type.getName(), dataManager, session.getUserID());
@@ -956,7 +976,7 @@
+ itemPath.getAsString(false));
return (NodeImpl)node;
}
-
+
/**
* {@inheritDoc}
*/
@@ -1234,7 +1254,7 @@
checkValid();
- return dataManager.getChildNodesData(nodeData()).size() > 0;
+ return dataManager.getChildNodesCount(nodeData()) > 0;
}
/**
@@ -1357,14 +1377,100 @@
throw new RepositoryException("ACL is NULL " + nodeData.getQPath().getAsString());
this.data = nodeData;
- this.location = session.getLocationFactory().createJCRPath(getData().getQPath());
+ this.qpath = nodeData.getQPath();
+ this.location = null;
initDefinition();
}
/**
+ * Loads data.
+ *
+ * @param data
+ * source item data for load
+ * @param parent
+ * parent node data is used for simple calculation item definition
+ * @throws RepositoryException
+ * if error occurs
+ */
+ private void loadData(ItemData data, NodeData parent) throws RepositoryException, InvalidItemStateException,
+ ConstraintViolationException
+ {
+
+ if (data == null)
+ throw new InvalidItemStateException("Data is null for " + this.getPath()
+ + " Probably was deleted by another session and can not be loaded from container ");
+
+ if (!data.isNode())
+ throw new RepositoryException("Load data failed: Node expected");
+
+ NodeData nodeData = (NodeData)data;
+
+ // TODO do we need this three checks here?
+ if (nodeData.getPrimaryTypeName() == null)
+ throw new RepositoryException("Load data: NodeData has no primaryTypeName. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]") + " " + nodeData);
+
+ if (nodeData.getMixinTypeNames() == null)
+ throw new RepositoryException("Load data: NodeData has no mixinTypeNames. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]"));
+
+ if (nodeData.getACL() == null)
+ throw new RepositoryException("ACL is NULL " + nodeData.getQPath().getAsString());
+
+ this.data = nodeData;
+ this.qpath = nodeData.getQPath();
+ this.location = null;
+
+ initDefinition(parent);
+ }
+
+ /**
* {@inheritDoc}
*/
+ @Override
+ public void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException,
+ InvalidItemStateException, ConstraintViolationException
+ {
+
+ if (data == null)
+ throw new InvalidItemStateException("Data is null for " + this.getPath()
+ + " Probably was deleted by another session and can not be loaded from container ");
+
+ if (!data.isNode())
+ throw new RepositoryException("Load data failed: Node expected");
+
+ NodeData nodeData = (NodeData)data;
+
+ // TODO do we need this three checks here?
+ if (nodeData.getPrimaryTypeName() == null)
+ throw new RepositoryException("Load data: NodeData has no primaryTypeName. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]") + " " + nodeData);
+
+ if (nodeData.getMixinTypeNames() == null)
+ throw new RepositoryException("Load data: NodeData has no mixinTypeNames. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]"));
+
+ if (nodeData.getACL() == null)
+ throw new RepositoryException("ACL is NULL " + nodeData.getQPath().getAsString());
+
+ this.data = nodeData;
+ this.location = null;
+ this.qpath = nodeData.getQPath();
+ this.definition = (NodeDefinitionData)itemDefinitionData;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemDefinitionData getItemDefinitionData()
+ {
+ return definition;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException,
LockException, AccessDeniedException, RepositoryException
{
@@ -2488,16 +2594,92 @@
// ----------------------------- ExtendedNode -----------------------------
- private int getNextChildOrderNum(List<NodeData> siblings)
+ private int getNextChildOrderNum() throws RepositoryException
{
- int max = -1;
+ // int max = -1;
+ // for (NodeData sibling : siblings)
+ // {
+ // int cur = sibling.getOrderNumber();
+ // if (cur > max)
+ // max = cur;
+ // }
+ // return ++max;
+
+ //return siblings.size();
+
+ return dataManager.getChildNodesCount(nodeData());
+ }
+
+ private int getNextChildIndex(InternalQName nameToAdd, NodeData parentNode) throws RepositoryException,
+ ItemExistsException
+ {
+
+ NodeDefinitionData def =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd, parentNode.getPrimaryTypeName(),
+ parentNode.getMixinTypeNames());
+
+ boolean allowSns = def.isAllowsSameNameSiblings();
+
+ int ind = 1;
+
+ NodeData sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ while (sibling != null)
+ {
+ if (allowSns)
+ {
+ ind++;
+ sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ }
+ else
+ {
+ throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ + " and same name sibling is not allowed ");
+ }
+ };
+
+ return ind;
+
+ // int ind = 0;
+ // for (NodeData sibling : siblings)
+ // {
+ // if (sibling.getQPath().getName().equals(nameToAdd))
+ // {
+ // if (allowSns)
+ // ind++;
+ // else
+ // throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ // + " and same name sibling is not allowed ");
+ // }
+ // }
+ // return ind + 1;
+
+ }
+
+ // old impl
+ @Deprecated
+ private int getNextChildIndex(InternalQName nameToAdd, List<NodeData> siblings, NodeData parentNode)
+ throws RepositoryException, ItemExistsException
+ {
+
+ int ind = 0;
for (NodeData sibling : siblings)
{
- int cur = sibling.getOrderNumber();
- if (cur > max)
- max = cur;
+ if (sibling.getQPath().getName().equals(nameToAdd))
+ {
+ NodeDefinitionData def =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd,
+ parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
+ if (LOG.isDebugEnabled())
+ LOG.debug("Calculate index for " + nameToAdd + " " + sibling.getQPath().getAsString());
+
+ if (def.isAllowsSameNameSiblings())
+ ind++;
+ else
+ throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
+ + " and same name sibling is not allowed ");
+ }
}
- return ++max;
+ return ind + 1;
}
private NodeImpl doAddNode(NodeImpl parentNode, InternalQName name, InternalQName primaryTypeName)
@@ -2510,9 +2692,9 @@
InternalQName[] mixinTypeNames = new InternalQName[0];
String identifier = IdGenerator.generate();
- List<NodeData> siblings = dataManager.getChildNodesData(parentNode.nodeData());
- int orderNum = parentNode.getNextChildOrderNum(siblings);
- int index = parentNode.getNextChildIndex(name, siblings, parentNode.nodeData());
+ //List<NodeData> siblings = dataManager.getChildNodesData(parentNode.nodeData());
+ int orderNum = parentNode.getNextChildOrderNum();
+ int index = parentNode.getNextChildIndex(name, parentNode.nodeData());
QPath path = QPath.makeChildPath(parentNode.getInternalPath(), name, index);
@@ -2528,7 +2710,7 @@
NodeImpl node = (NodeImpl)dataManager.update(state, true);
NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
- ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager);
+ ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager, true);
PlainChangesLog changes =
itemAutocreator.makeAutoCreatedItems(node.nodeData(), primaryTypeName, dataManager, session.getUserID());
@@ -2546,35 +2728,8 @@
session.getActionHandler().postAddNode(node);
return node;
-
}
- private int getNextChildIndex(InternalQName nameToAdd, List<NodeData> siblings, NodeData parentNode)
- throws RepositoryException, ItemExistsException
- {
-
- int ind = 0;
- for (NodeData sibling : siblings)
- {
- if (sibling.getQPath().getName().equals(nameToAdd))
- {
- NodeDefinitionData def =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd,
- parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
- if (LOG.isDebugEnabled())
- LOG.debug("Calculate index for " + nameToAdd + " " + sibling.getQPath().getAsString());
-
- if (def.isAllowsSameNameSiblings())
- ind++;
- else
- throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
- + " and same name sibling is not allowed ");
- }
- }
- return ind + 1;
-
- }
-
private int getOrderNumber()
{
return nodeData().getOrderNumber();
@@ -2636,6 +2791,33 @@
throw new ConstraintViolationException("Node definition not found for " + getPath());
}
+ /**
+ * Init NodeDefinition.
+ *
+ * @throws RepositoryException
+ * if error occurs
+ * @throws ConstraintViolationException
+ * if definition not found
+ */
+ private void initDefinition(NodeData parent) throws RepositoryException, ConstraintViolationException
+ {
+
+ if (this.isRoot())
+ { // root - no parent
+ this.definition =
+ new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, true,
+ new InternalQName[]{Constants.NT_BASE}, null, false);
+ return;
+ }
+
+ this.definition =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
+ parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+
+ if (definition == null)
+ throw new ConstraintViolationException("Node definition not found for " + getPath());
+ }
+
private void removeMergeFailed(Version version, PlainChangesLog changesLog) throws RepositoryException
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core;
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
import org.exoplatform.services.jcr.datamodel.InternalQName;
@@ -93,14 +94,42 @@
this.propertyData = (TransientPropertyData)data;
this.type = propertyData.getType();
- this.location = session.getLocationFactory().createJCRPath(getData().getQPath());
- this.propertyDef = null;
+ this.qpath = data.getQPath();
+ this.location = null;
+
initDefinitions(this.propertyData.isMultiValued());
}
/**
* {@inheritDoc}
*/
+ void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException,
+ ConstraintViolationException
+ {
+
+ if (!(data instanceof TransientPropertyData))
+ throw new RepositoryException("Load data: TransientPropertyData is expected, but have " + data);
+
+ this.data = data;
+ this.propertyData = (TransientPropertyData)data;
+ this.type = propertyData.getType();
+
+ this.location = null;
+ this.qpath = data.getQPath();
+ this.propertyDef = (PropertyDefinitionData)itemDefinitionData;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemDefinitionData getItemDefinitionData()
+ {
+ return propertyDef;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Value getValue() throws ValueFormatException, RepositoryException
{
@@ -526,9 +555,10 @@
*/
public String dump()
{
- String vals = "Property " + getPath() + " values: ";
+ String vals = "Property ";
try
{
+ vals = getPath() + " values: ";
for (int i = 0; i < getValueArray().length; i++)
{
vals += new String(((BaseValue)getValueArray()[i]).getInternalData().getAsByteArray()) + ";";
@@ -564,19 +594,4 @@
return false;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- try
- {
- return getLocation().getAsString(false).hashCode();
- }
- catch (Exception e)
- {
- return super.hashCode();
- }
- }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -466,18 +466,12 @@
public boolean isNew(String identifier)
{
- List<ItemState> states = changesLog.getItemStates(identifier);
- ItemState lastState = states.size() > 0 ? states.get(states.size() - 1) : null;
+ ItemState lastState = changesLog.getItemState(identifier);
if (lastState == null || lastState.isDeleted())
return false;
- for (ItemState state : states)
- {
- if (state.isAdded())
- return true;
- }
- return false;
+ return changesLog.getItemState(identifier, ItemState.ADDED) != null;
}
/**
@@ -534,7 +528,8 @@
// [PN] 21.12.07 use item data
NodeData parent = (NodeData)getItemData(data.getParentIdentifier());
// skip not permitted
- if (accessManager.hasPermission(parent.getACL(), PermissionType.READ, session.getUserState().getIdentity()))
+ if (accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.READ}, session.getUserState()
+ .getIdentity()))
{
PropertyImpl item = null;
ItemState state = changesLog.getItemState(identifier);
@@ -583,11 +578,12 @@
for (NodeData data : nodeDatas)
{
- NodeImpl item = itemFactory.createNode(data);
+ NodeImpl item = itemFactory.createNode(data, parent);
session.getActionHandler().postRead(item);
- if (accessManager.hasPermission(data.getACL(), PermissionType.READ, session.getUserState().getIdentity()))
+ if (accessManager.hasPermission(data.getACL(), new String[]{PermissionType.READ}, session.getUserState()
+ .getIdentity()))
{
if (pool)
item = (NodeImpl)itemsPool.get(item);
@@ -633,7 +629,8 @@
{
ItemImpl item = itemFactory.createItem(data);
session.getActionHandler().postRead(item);
- if (accessManager.hasPermission(parent.getACL(), PermissionType.READ, session.getUserState().getIdentity()))
+ if (accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.READ}, session.getUserState()
+ .getIdentity()))
{
if (pool)
item = itemsPool.get(item);
@@ -674,6 +671,22 @@
/**
* {@inheritDoc}
*/
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ int childsCount =
+ changesLog.getChildNodesCount(parent.getIdentifier()) + transactionableManager.getChildNodesCount(parent);
+ if (childsCount < 0)
+ {
+ throw new InvalidItemStateException("Node's child nodes were changed in another Session "
+ + parent.getQPath().getAsString());
+ }
+
+ return childsCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
long start = 0;
@@ -1264,8 +1277,8 @@
// Remove propery or node
if (changedItem.isDeleted())
{
- if (!accessManager.hasPermission(parent.getACL(), PermissionType.REMOVE, session.getUserState()
- .getIdentity()))
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.REMOVE}, session
+ .getUserState().getIdentity()))
throw new AccessDeniedException("Access denied: REMOVE "
+ changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ parent.getACL().getOwner());
@@ -1275,8 +1288,8 @@
// add node
if (changedItem.isAdded())
{
- if (!accessManager.hasPermission(parent.getACL(), PermissionType.ADD_NODE, session.getUserState()
- .getIdentity()))
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE}, session
+ .getUserState().getIdentity()))
{
throw new AccessDeniedException("Access denied: ADD_NODE "
+ changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
@@ -1287,8 +1300,8 @@
else if (changedItem.isAdded() || changedItem.isUpdated())
{
// add or update property
- if (!accessManager.hasPermission(parent.getACL(), PermissionType.SET_PROPERTY, session.getUserState()
- .getIdentity()))
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.SET_PROPERTY}, session
+ .getUserState().getIdentity()))
throw new AccessDeniedException("Access denied: SET_PROPERTY "
+ changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ parent.getACL().getOwner());
@@ -1647,10 +1660,6 @@
{
ret.add(childNode);
- if (log.isDebugEnabled())
- log.debug("Traverse transient (N) " + childNode.getData().getQPath().getAsString() + " "
- + ItemState.nameFromValue(childNode.getState()));
-
if (deep)
traverseTransientDescendants(childNode.getData(), deep, action, ret);
}
@@ -1661,17 +1670,14 @@
for (ItemState childProp : childProps)
{
ret.add(childProp);
-
- if (log.isDebugEnabled())
- log.debug("Traverse transient (P) " + childProp.getData().getQPath().getAsString());
}
}
}
}
/**
- * Pool for touched items.
- */
+ * Pool for touched items.
+ */
protected final class ItemReferencePool
{
@@ -1723,7 +1729,7 @@
}
else
{
- item.loadData(newItem.getData());
+ item.loadData(newItem.getData(), newItem.getItemDefinitionData());
return item;
}
}
@@ -1833,12 +1839,19 @@
String dump()
{
String str = "Items Pool: \n";
- for (ItemImpl item : items.values())
+ try
{
- str +=
- (item.isNode() ? "Node\t\t" : "Property\t") + "\t" + item.isValid() + "\t" + item.isNew() + "\t"
- + item.getInternalIdentifier() + "\t" + item.getPath() + "\n";
+ for (ItemImpl item : items.values())
+ {
+ str +=
+ (item.isNode() ? "Node\t\t" : "Property\t") + "\t" + item.isValid() + "\t" + item.isNew() + "\t"
+ + item.getInternalIdentifier() + "\t" + item.getPath() + "\n";
+ }
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
return str;
}
@@ -1874,10 +1887,26 @@
return node;
}
+ private NodeImpl createNode(NodeData data, NodeData parent) throws RepositoryException
+ {
+ NodeImpl node = new NodeImpl(data, parent, session);
+ if (data.getPrimaryTypeName().equals(Constants.NT_VERSION))
+ {
+ return new VersionImpl(data, session);
+ }
+ else if (data.getPrimaryTypeName().equals(Constants.NT_VERSIONHISTORY))
+ {
+ return new VersionHistoryImpl(data, session);
+ }
+ else
+ return node;
+ }
+
private PropertyImpl createProperty(ItemData data) throws RepositoryException
{
return new PropertyImpl(data, session);
}
+
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -69,16 +69,19 @@
private final ValueFactory valueFactory;
+ private final boolean avoidCheckExistedChildItems;
+
/**
* @param nodeTypeDataManager
*/
public ItemAutocreator(NodeTypeDataManager nodeTypeDataManager, ValueFactory valueFactory,
- ItemDataConsumer dataConsumer)
+ ItemDataConsumer dataConsumer, boolean avoidCheckExistedChildItems)
{
super();
this.nodeTypeDataManager = nodeTypeDataManager;
this.valueFactory = valueFactory;
this.dataConsumer = dataConsumer;
+ this.avoidCheckExistedChildItems = avoidCheckExistedChildItems;
}
public PlainChangesLog makeAutoCreatedItems(final NodeData parent, final InternalQName nodeTypeName,
@@ -113,7 +116,9 @@
{
if (ndef.isAutoCreated())
{
- final ItemData pdata = targetDataManager.getItemData(parent, new QPathEntry(ndef.getName(), 0));
+ final ItemData pdata =
+ avoidCheckExistedChildItems ? null : targetDataManager.getItemData(parent, new QPathEntry(
+ ndef.getName(), 0));
if (pdata == null && !addedNodes.contains(ndef.getName()) || pdata != null && !pdata.isNode())
{
@@ -156,7 +161,9 @@
if (pdef.isAutoCreated())
{
- final ItemData pdata = targetDataManager.getItemData(parent, new QPathEntry(pdef.getName(), 0));
+ final ItemData pdata =
+ avoidCheckExistedChildItems ? null : targetDataManager.getItemData(parent, new QPathEntry(
+ pdef.getName(), 0));
if (pdata == null && !addedProperties.contains(pdef.getName()) || pdata != null && pdata.isNode())
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -638,7 +638,7 @@
final boolean recipientsMixVersionable = isNodeType(Constants.MIX_VERSIONABLE, recipienAllNodeTypeNames);
final boolean ancestorIsMixVersionable = isNodeType(Constants.MIX_VERSIONABLE, ancestorAllNodeTypeNames);
- ItemAutocreator itemAutocreator = new ItemAutocreator(this, valueFactory, dataManager);
+ ItemAutocreator itemAutocreator = new ItemAutocreator(this, valueFactory, dataManager, false);
if (recipientsMixVersionable && !ancestorIsMixVersionable)
{
@@ -838,7 +838,8 @@
volatileNodeTypeDataManager.registerVolatileNodeTypes(volatileNodeTypes);
- ItemAutocreator itemAutocreator = new ItemAutocreator(volatileNodeTypeDataManager, valueFactory, dataManager);
+ ItemAutocreator itemAutocreator =
+ new ItemAutocreator(volatileNodeTypeDataManager, valueFactory, dataManager, false);
final Set<String> nodes = this.indexSearcherHolder.getNodesByNodeType(recipientDefinition.getName());
// check add mix:versionable super
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -16,7 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query;
-
import java.text.NumberFormat;
import javax.jcr.ItemExistsException;
@@ -56,298 +55,302 @@
/**
* Provides the default implementation for a JCR query.
*/
-public class QueryImpl extends AbstractQueryImpl {
+public class QueryImpl extends AbstractQueryImpl
+{
- /**
- * The logger instance for this class
- */
- private static final Logger log = LoggerFactory.getLogger(QueryImpl.class);
+ /**
+ * The logger instance for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger(QueryImpl.class);
- /**
- * A string constant representing the JCR-SQL2 query language.
- *
- * @since JCR 2.0
- * TODO: REMOVE WHEN JSR 283 IS FINAL!!
- */
- public static final String JCR_SQL2 = "JCR-SQL2";
+ /**
+ * A string constant representing the JCR-SQL2 query language.
+ *
+ * @since JCR 2.0
+ * TODO: REMOVE WHEN JSR 283 IS FINAL!!
+ */
+ public static final String JCR_SQL2 = "JCR-SQL2";
- /**
- * A string constant representing the JCR-JQOM query language.
- *
- * @since JCR 2.0
- * TODO: REMOVE WHEN JSR 283 IS FINAL!!
- */
- public static final String JCR_JQOM = "JCR-JQOM";
+ /**
+ * A string constant representing the JCR-JQOM query language.
+ *
+ * @since JCR 2.0
+ * TODO: REMOVE WHEN JSR 283 IS FINAL!!
+ */
+ public static final String JCR_JQOM = "JCR-JQOM";
- /**
- * The session of the user executing this query
- */
- protected SessionImpl session;
+ /**
+ * The session of the user executing this query
+ */
+ protected SessionImpl session;
- /**
- * The query statement
- */
- protected String statement;
+ /**
+ * The query statement
+ */
+ protected String statement;
- /**
- * The syntax of the query statement
- */
- protected String language;
+ /**
+ * The syntax of the query statement
+ */
+ protected String language;
- /**
- * The actual query implementation that can be executed
- */
- protected ExecutableQuery query;
+ /**
+ * The actual query implementation that can be executed
+ */
+ protected ExecutableQuery query;
- /**
- * The node where this query is persisted. Only set when this is a persisted
- * query.
- */
- protected Node node;
+ /**
+ * The node where this query is persisted. Only set when this is a persisted
+ * query.
+ */
+ protected Node node;
- /**
- * The query handler for this query.
- */
- protected QueryHandler handler;
+ /**
+ * The query handler for this query.
+ */
+ protected QueryHandler handler;
- /**
- * Flag indicating whether this query is initialized.
- */
- private boolean initialized = false;
+ /**
+ * Flag indicating whether this query is initialized.
+ */
+ private boolean initialized = false;
- /**
- * The maximum result size
- */
- private long limit;
+ /**
+ * The maximum result size
+ */
+ private long limit;
- /**
- * The offset in the total result set
- */
- private long offset;
+ /**
+ * The offset in the total result set
+ */
+ private long offset;
- /**
- * @inheritDoc
- */
- public void init(SessionImpl session,
- SessionDataManager itemMgr,
- QueryHandler handler,
- String statement,
- String language) throws InvalidQueryException {
- checkNotInitialized();
- this.session = session;
- this.statement = statement;
- this.language = language;
- this.handler = handler;
- this.query = handler.createExecutableQuery(session, itemMgr, statement, language);
- setInitialized();
- }
+ /**
+ * @inheritDoc
+ */
+ public void init(SessionImpl session, SessionDataManager itemMgr, QueryHandler handler, String statement,
+ String language) throws InvalidQueryException
+ {
+ checkNotInitialized();
+ this.session = session;
+ this.statement = statement;
+ this.language = language;
+ this.handler = handler;
+ this.query = handler.createExecutableQuery(session, itemMgr, statement, language);
+ setInitialized();
+ }
- /**
- * @inheritDoc
- */
- public void init(SessionImpl session,
- SessionDataManager itemMgr,
- QueryHandler handler,
- Node node)
- throws InvalidQueryException, RepositoryException {
- checkNotInitialized();
- this.session = session;
- this.node = node;
- this.handler = handler;
+ /**
+ * @inheritDoc
+ */
+ public void init(SessionImpl session, SessionDataManager itemMgr, QueryHandler handler, Node node)
+ throws InvalidQueryException, RepositoryException
+ {
+ checkNotInitialized();
+ this.session = session;
+ this.node = node;
+ this.handler = handler;
- if (!((ExtendedNode)node).isNodeType(Constants.NT_QUERY)){
- throw new InvalidQueryException("node is not of type nt:query");
- }
- statement = node.getProperty("jcr:statement").getString();
- language = node.getProperty("jcr:language").getString();
- query = handler.createExecutableQuery(session, itemMgr, statement, language);
- setInitialized();
- }
+ if (!((ExtendedNode)node).isNodeType(Constants.NT_QUERY))
+ {
+ throw new InvalidQueryException("node is not of type nt:query");
+ }
+ statement = node.getProperty("jcr:statement").getString();
+ language = node.getProperty("jcr:language").getString();
+ query = handler.createExecutableQuery(session, itemMgr, statement, language);
+ setInitialized();
+ }
-// /**
-// * @inheritDoc
-// * <p/>
-// * Throws an {@link UnsupportedOperationException}.
-// */
-// public void init(SessionImpl session,
-// Sess itemMgr,
-// QueryHandler handler,
-// QueryObjectModelTree qomTree,
-// String language)
-// throws InvalidQueryException, RepositoryException {
-// throw new UnsupportedOperationException("not a prepared query");
-// }
+ // /**
+ // * @inheritDoc
+ // * <p/>
+ // * Throws an {@link UnsupportedOperationException}.
+ // */
+ // public void init(SessionImpl session,
+ // Sess itemMgr,
+ // QueryHandler handler,
+ // QueryObjectModelTree qomTree,
+ // String language)
+ // throws InvalidQueryException, RepositoryException {
+ // throw new UnsupportedOperationException("not a prepared query");
+ // }
- /**
- * This method simply forwards the <code>execute</code> call to the
- * {@link ExecutableQuery} object returned by
- * {@link QueryHandler#createExecutableQuery}.
- * {@inheritDoc}
- */
- public QueryResult execute() throws RepositoryException {
- checkInitialized();
- long time = System.currentTimeMillis();
- QueryResult result = query.execute(offset, limit);
- if (log.isDebugEnabled()) {
- time = System.currentTimeMillis() - time;
- NumberFormat format = NumberFormat.getNumberInstance();
- format.setMinimumFractionDigits(2);
- format.setMaximumFractionDigits(2);
- String seconds = format.format((double) time / 1000);
- log.debug("executed in " + seconds + " s. (" + statement + ")");
- }
- return result;
- }
+ /**
+ * This method simply forwards the <code>execute</code> call to the
+ * {@link ExecutableQuery} object returned by
+ * {@link QueryHandler#createExecutableQuery}.
+ * {@inheritDoc}
+ */
+ public QueryResult execute() throws RepositoryException
+ {
+ checkInitialized();
+ long time = System.currentTimeMillis();
+ QueryResult result = query.execute(offset, limit);
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ NumberFormat format = NumberFormat.getNumberInstance();
+ format.setMinimumFractionDigits(2);
+ format.setMaximumFractionDigits(2);
+ String seconds = format.format((double)time / 1000);
+ log.debug("executed in " + seconds + " s. (" + statement + ")");
+ }
+ return result;
+ }
- /**
- * {@inheritDoc}
- */
- public String getStatement() {
- checkInitialized();
- return statement;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getStatement()
+ {
+ checkInitialized();
+ return statement;
+ }
- /**
- * {@inheritDoc}
- */
- public String getLanguage() {
- checkInitialized();
- return language;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getLanguage()
+ {
+ checkInitialized();
+ return language;
+ }
- /**
- * {@inheritDoc}
- */
- public String getStoredQueryPath()
- throws ItemNotFoundException, RepositoryException {
- checkInitialized();
- if (node == null) {
- throw new ItemNotFoundException("not a persistent query");
- }
- return node.getPath();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getStoredQueryPath() throws ItemNotFoundException, RepositoryException
+ {
+ checkInitialized();
+ if (node == null)
+ {
+ throw new ItemNotFoundException("not a persistent query");
+ }
+ return node.getPath();
+ }
- /**
- * {@inheritDoc}
- */
- public Node storeAsNode(String absPath)
- throws ItemExistsException,
- PathNotFoundException,
- VersionException,
- ConstraintViolationException,
- LockException,
- UnsupportedRepositoryOperationException,
- RepositoryException {
+ /**
+ * {@inheritDoc}
+ */
+ public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException,
+ ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException
+ {
- checkInitialized();
- JCRPath path = session.getLocationFactory().parseAbsPath(absPath);
- QPath qpath = path.getInternalPath();
- NodeImpl parent = (NodeImpl)session.getTransientNodesManager().getItem(qpath.makeParentPath(), false);
- if (parent == null)
- throw new PathNotFoundException("Parent not found for " + path.getAsString(false));
+ checkInitialized();
+ JCRPath path = session.getLocationFactory().parseAbsPath(absPath);
+ QPath qpath = path.getInternalPath();
+ NodeImpl parent = (NodeImpl)session.getTransientNodesManager().getItem(qpath.makeParentPath(), false);
+ if (parent == null)
+ throw new PathNotFoundException("Parent not found for " + path.getAsString(false));
- // validate as on parent child node
- parent.validateChildNode(qpath.getName(), Constants.NT_QUERY);
+ // validate as on parent child node
+ parent.validateChildNode(qpath.getName(), Constants.NT_QUERY);
- NodeData queryData =
- TransientNodeData.createNodeData((NodeData)parent.getData(), qpath.getName(), Constants.NT_QUERY);
- NodeImpl queryNode =
- (NodeImpl)session.getTransientNodesManager().update(ItemState.createAddedState(queryData), false);
+ NodeData queryData =
+ TransientNodeData.createNodeData((NodeData)parent.getData(), qpath.getName(), Constants.NT_QUERY);
+ NodeImpl queryNode =
+ (NodeImpl)session.getTransientNodesManager().update(ItemState.createAddedState(queryData), false);
- NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
+ NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
- ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, session.getValueFactory(),session.getTransientNodesManager());
+ ItemAutocreator itemAutocreator =
+ new ItemAutocreator(ntmanager, session.getValueFactory(), session.getTransientNodesManager(), false);
- PlainChangesLog changes =
- itemAutocreator.makeAutoCreatedItems((NodeData)queryNode.getData(), Constants.NT_QUERY, session
- .getTransientNodesManager(), session.getUserID());
+ PlainChangesLog changes =
+ itemAutocreator.makeAutoCreatedItems((NodeData)queryNode.getData(), Constants.NT_QUERY, session
+ .getTransientNodesManager(), session.getUserID());
- for (ItemState autoCreatedState : changes.getAllStates())
- {
- session.getTransientNodesManager().update(autoCreatedState, false);
- }
- // queryNode.addAutoCreatedItems(Constants.NT_QUERY);
- // set properties
- TransientValueData value = new TransientValueData(language);
- TransientPropertyData jcrLanguage =
- TransientPropertyData.createPropertyData(queryData, Constants.JCR_LANGUAGE, PropertyType.STRING, false, value);
- session.getTransientNodesManager().update(ItemState.createAddedState(jcrLanguage), false);
+ for (ItemState autoCreatedState : changes.getAllStates())
+ {
+ session.getTransientNodesManager().update(autoCreatedState, false);
+ }
+ // queryNode.addAutoCreatedItems(Constants.NT_QUERY);
+ // set properties
+ TransientValueData value = new TransientValueData(language);
+ TransientPropertyData jcrLanguage =
+ TransientPropertyData.createPropertyData(queryData, Constants.JCR_LANGUAGE, PropertyType.STRING, false, value);
+ session.getTransientNodesManager().update(ItemState.createAddedState(jcrLanguage), false);
- value = new TransientValueData(statement);
- TransientPropertyData jcrStatement =
- TransientPropertyData
- .createPropertyData(queryData, Constants.JCR_STATEMENT, PropertyType.STRING, false, value);
- session.getTransientNodesManager().update(ItemState.createAddedState(jcrStatement), false);
+ value = new TransientValueData(statement);
+ TransientPropertyData jcrStatement =
+ TransientPropertyData
+ .createPropertyData(queryData, Constants.JCR_STATEMENT, PropertyType.STRING, false, value);
+ session.getTransientNodesManager().update(ItemState.createAddedState(jcrStatement), false);
- // NOTE: for save stored node need save() on parent or on session (6.6.10
- // The Query Object)
- node = queryNode;
- return node;
- }
+ // NOTE: for save stored node need save() on parent or on session (6.6.10
+ // The Query Object)
+ node = queryNode;
+ return node;
+ }
- /**
- * Binds the given <code>value</code> to the variable named
- * <code>varName</code>.
- *
- * @param varName name of variable in query
- * @param value value to bind
- * @throws IllegalArgumentException if <code>varName</code> is not a
- * valid variable in this query.
- * @throws javax.jcr.RepositoryException if an error occurs.
- */
- public void bindValue(String varName, Value value)
- throws IllegalArgumentException, RepositoryException {
- checkInitialized();
- query.bindValue(session.getLocationFactory().parseJCRName(varName).getInternalName(), value);
- }
+ /**
+ * Binds the given <code>value</code> to the variable named
+ * <code>varName</code>.
+ *
+ * @param varName name of variable in query
+ * @param value value to bind
+ * @throws IllegalArgumentException if <code>varName</code> is not a
+ * valid variable in this query.
+ * @throws javax.jcr.RepositoryException if an error occurs.
+ */
+ public void bindValue(String varName, Value value) throws IllegalArgumentException, RepositoryException
+ {
+ checkInitialized();
+ query.bindValue(session.getLocationFactory().parseJCRName(varName).getInternalName(), value);
+ }
- /**
- * Sets the maximum size of the result set.
- *
- * @param limit new maximum size of the result set
- */
- public void setLimit(long limit) {
- this.limit = limit;
- }
+ /**
+ * Sets the maximum size of the result set.
+ *
+ * @param limit new maximum size of the result set
+ */
+ public void setLimit(long limit)
+ {
+ this.limit = limit;
+ }
- /**
- * Sets the start offset of the result set.
- *
- * @param offset new start offset of the result set
- */
- public void setOffset(long offset) {
- this.offset = offset;
- }
+ /**
+ * Sets the start offset of the result set.
+ *
+ * @param offset new start offset of the result set
+ */
+ public void setOffset(long offset)
+ {
+ this.offset = offset;
+ }
- //-----------------------------< internal >---------------------------------
+ //-----------------------------< internal >---------------------------------
- /**
- * Sets the initialized flag.
- */
- protected void setInitialized() {
- initialized = true;
- }
+ /**
+ * Sets the initialized flag.
+ */
+ protected void setInitialized()
+ {
+ initialized = true;
+ }
- /**
- * Checks if this query is not yet initialized and throws an
- * <code>IllegalStateException</code> if it is already initialized.
- */
- protected void checkNotInitialized() {
- if (initialized) {
- throw new IllegalStateException("already initialized");
- }
- }
+ /**
+ * Checks if this query is not yet initialized and throws an
+ * <code>IllegalStateException</code> if it is already initialized.
+ */
+ protected void checkNotInitialized()
+ {
+ if (initialized)
+ {
+ throw new IllegalStateException("already initialized");
+ }
+ }
- /**
- * Checks if this query is initialized and throws an
- * <code>IllegalStateException</code> if it is not yet initialized.
- */
- protected void checkInitialized() {
- if (!initialized) {
- throw new IllegalStateException("not initialized");
- }
- }
+ /**
+ * Checks if this query is initialized and throws an
+ * <code>IllegalStateException</code> if it is not yet initialized.
+ */
+ protected void checkInitialized()
+ {
+ if (!initialized)
+ {
+ throw new IllegalStateException("not initialized");
+ }
+ }
-
}
-
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -629,7 +629,7 @@
}
- public boolean isVersionBelongToThis(Version version)
+ public boolean isVersionBelongToThis(Version version) throws RepositoryException
{
return ((VersionImpl)version).getLocation().isDescendantOf(getLocation(), false);
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -18,6 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
@@ -28,12 +34,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.util.Calendar;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS. Data Manager supported ACL Inheritance
*
@@ -124,6 +124,9 @@
return node;
}
+ /**
+ * {@inheritDoc}
+ */
// ------------ ItemDataConsumer impl ------------
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException
@@ -133,29 +136,52 @@
initACL(parent, node);
return nodes;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ return persistentManager.getChildNodesCount(parent);
+ }
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
{
final ItemData item = persistentManager.getItemData(parent, name);
return item != null && item.isNode() ? initACL(parent, (NodeData)item) : item;
}
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(String identifier) throws RepositoryException
{
final ItemData item = persistentManager.getItemData(identifier);
return item != null && item.isNode() ? initACL(null, (NodeData)item) : item;
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
return persistentManager.getChildPropertiesData(parent);
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException
{
return persistentManager.listChildPropertiesData(parent);
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
throws RepositoryException
{
@@ -164,12 +190,18 @@
// ------------ SharedDataManager ----------------------
+ /**
+ * {@inheritDoc}
+ */
public void save(ItemStateChangesLog changes) throws InvalidItemStateException, UnsupportedOperationException,
RepositoryException
{
persistentManager.save(changes);
}
+ /**
+ * {@inheritDoc}
+ */
public Calendar getCurrentTime()
{
return persistentManager.getCurrentTime();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -369,6 +369,18 @@
}
}
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ if (cache.isEnabled())
+ {
+ List<NodeData> childNodes = cache.getChildNodes(parent);
+ if (childNodes != null)
+ return childNodes.size();
+ }
+
+ return super.getChildNodesCount(parent);
+ }
+
/**
* Get child PropertyData.
*
@@ -453,7 +465,7 @@
}
return propertiesList;
}
-
+
/**
* {@inheritDoc}
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -18,6 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.DataManager;
@@ -36,12 +42,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS. Responsible for: *redirecting repository operations if item is
* descendant of /jcr:system/jcr:versionStorage *adding version history for newly added/assigned
@@ -72,11 +72,8 @@
this.versionDataManager = (ACLInheritanceSupportedWorkspaceDataManager)systemDataManager;
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildNodes(org.exoplatform.services
- * .jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<NodeData> getChildNodesData(final NodeData nodeData) throws RepositoryException
@@ -87,12 +84,22 @@
}
return super.getChildNodesData(nodeData);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ if (isSystemDescendant(parent.getQPath()) && !this.equals(versionDataManager))
+ {
+ return versionDataManager.getChildNodesCount(parent);
+ }
+ return super.getChildNodesCount(parent);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildProperties(org.exoplatform
- * .services.jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<PropertyData> getChildPropertiesData(final NodeData nodeData) throws RepositoryException
@@ -104,6 +111,10 @@
return super.getChildPropertiesData(nodeData);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<PropertyData> listChildPropertiesData(final NodeData nodeData) throws RepositoryException
{
if (isSystemDescendant(nodeData.getQPath()) && !this.equals(versionDataManager))
@@ -113,6 +124,10 @@
return super.listChildPropertiesData(nodeData);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
if (parentData != null)
@@ -127,8 +142,9 @@
}
/**
- * @see org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager#getItemData(java.lang.String)
+ * {@inheritDoc}
*/
+ @Override
public ItemData getItemData(String identifier) throws RepositoryException
{
// from cache at first
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -290,6 +290,22 @@
con.close();
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ final WorkspaceStorageConnection con = dataContainer.openConnection();
+ try
+ {
+ return con.getChildNodesCount(parent);
+ }
+ finally
+ {
+ con.close();
+ }
+ }
/**
* {@inheritDoc}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -97,6 +97,9 @@
storageDataManager.save(newLog);
}
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
return copyItemData(storageDataManager.getItemData(parentData, name));
@@ -117,6 +120,14 @@
{
return copyNodes(storageDataManager.getChildNodesData(parent));
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ return storageDataManager.getChildNodesCount(parent);
+ }
/**
* {@inheritDoc}
@@ -126,6 +137,9 @@
return copyProperties(storageDataManager.getChildPropertiesData(parent));
}
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException
{
return copyPropertiesWithoutValues(storageDataManager.listChildPropertiesData(parent));
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import java.util.ArrayList;
@@ -50,6 +51,22 @@
protected Map<Object, ItemState> index = new HashMap<Object, ItemState>();
/**
+ * ItemState index storage. Used to store last nodes states.
+ */
+ protected Map<String, Map<String, ItemState>> lastChildNodeStates = new HashMap<String, Map<String, ItemState>>();
+
+ /**
+ * ItemState index storage. Used to store last properties states.
+ */
+ protected Map<String, Map<String, ItemState>> lastChildPropertyStates =
+ new HashMap<String, Map<String, ItemState>>();
+
+ /**
+ * Stores persisted child nodes count.
+ */
+ protected Map<String, int[]> childNodesCount = new HashMap<String, int[]>();
+
+ /**
* Create empty ChangesLog.
*
* @param sessionId
@@ -70,52 +87,45 @@
super(items, sessionId);
for (ItemState change : items)
- {
- index.put(change.getData().getIdentifier(), change);
- index.put(change.getData().getQPath(), change);
- }
+ addItem(change);
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.dataflow.PlainChangesLog#add(org.exoplatform.services.jcr.dataflow
- * .ItemState)
+ /**
+ * {@inheritDoc}
*/
@Override
public PlainChangesLog add(ItemState change)
{
super.add(change);
- index.put(change.getData().getIdentifier(), change);
- index.put(change.getData().getQPath(), change);
+ addItem(change);
+
return this;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.dataflow.PlainChangesLog#addAll(java.util.List)
+ /**
+ * {@inheritDoc}
*/
@Override
public PlainChangesLog addAll(List<ItemState> changes)
{
super.addAll(changes);
for (ItemState change : changes)
- {
- index.put(change.getData().getIdentifier(), change);
- index.put(change.getData().getQPath(), change);
- }
+ addItem(change);
+
return this;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.dataflow.PlainChangesLog#clear()
+ /**
+ * {@inheritDoc}
*/
@Override
public void clear()
{
super.clear();
index.clear();
+ lastChildNodeStates.clear();
+ lastChildPropertyStates.clear();
+ childNodesCount.clear();
}
/**
@@ -126,24 +136,51 @@
*/
public void remove(QPath rootPath)
{
- List<ItemState> removedList = new ArrayList<ItemState>();
+ for (int i = items.size() - 1; i >= 0; i--)
+ {
+ ItemState item = items.get(i);
- for (ItemState item : items)
- {
QPath qPath = item.getData().getQPath();
if (qPath.isDescendantOf(rootPath) || item.getAncestorToSave().isDescendantOf(rootPath)
|| item.getAncestorToSave().equals(rootPath) || qPath.equals(rootPath))
{
- removedList.add(item);
+ items.remove(i);
+ index.remove(item.getData().getIdentifier());
+ index.remove(item.getData().getQPath());
+ index.remove(new ParentIDQPathBasedKey(item));
+ index.remove(new IDStateBasedKey(item.getData().getIdentifier(), item.getState()));
+ childNodesCount.remove(item.getData().getIdentifier());
+ lastChildNodeStates.remove(item.getData().getIdentifier());
+ lastChildPropertyStates.remove(item.getData().getIdentifier());
+
+ if (item.isNode() && item.isPersisted())
+ {
+ int childCount[] = childNodesCount.get(item.getData().getParentIdentifier());
+ if (childCount != null)
+ {
+ if (item.isDeleted())
+ ++childCount[0];
+ else if (item.isAdded())
+ --childCount[0];
+
+ childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+ }
+ }
+
+ if (item.getData().isNode())
+ {
+ Map<String, ItemState> children = lastChildNodeStates.get(item.getData().getParentIdentifier());
+ if (children != null)
+ children.remove(item.getData().getIdentifier());
+ }
+ else
+ {
+ Map<String, ItemState> children = lastChildPropertyStates.get(item.getData().getParentIdentifier());
+ if (children != null)
+ children.remove(item.getData().getIdentifier());
+ }
}
}
-
- for (ItemState item : removedList)
- {
- items.remove(item);
- index.remove(item.getData().getIdentifier());
- index.remove(item.getData().getQPath());
- }
}
/**
@@ -215,9 +252,11 @@
return list;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.dataflow.ItemDataChangesLog#getItemStates(java.lang.String)
+ /**
+ * Gets items by identifier.
+ *
+ * @param itemIdentifier
+ * @return
*/
public List<ItemState> getItemStates(String itemIdentifier)
{
@@ -242,8 +281,18 @@
public PlainChangesLog pushLog(QPath rootPath)
{
PlainChangesLog cLog = new PlainChangesLogImpl(sessionId);
- cLog.addAll(getDescendantsChanges(rootPath));
- remove(rootPath);
+
+ if (rootPath.equals(Constants.ROOT_PATH))
+ {
+ cLog.addAll(items);
+ clear();
+ }
+ else
+ {
+ cLog.addAll(getDescendantsChanges(rootPath));
+ remove(rootPath);
+ }
+
return cLog;
}
@@ -257,15 +306,7 @@
*/
public ItemState getItemState(NodeData parentData, QPathEntry name) throws IllegalPathException
{
- List<ItemState> allStates = getAllStates();
- for (int i = allStates.size() - 1; i >= 0; i--)
- {
- ItemState state = allStates.get(i);
- if (state.getData().getParentIdentifier().equals(parentData.getIdentifier())
- && state.getData().getQPath().getEntries()[state.getData().getQPath().getEntries().length - 1].isSame(name))
- return state;
- }
- return null;
+ return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name));
}
/**
@@ -295,6 +336,20 @@
}
/**
+ * Get ItemState by identifier and state.
+ *
+ * NOTE: Uses index HashMap.
+ *
+ * @param itemIdentifier
+ * @param sate
+ * @return
+ */
+ public ItemState getItemState(String itemIdentifier, int state)
+ {
+ return index.get(new IDStateBasedKey(itemIdentifier, state));
+ }
+
+ /**
* Collect changes of all item direct childs (only). Including the item itself.
*
* @param rootIdentifier
@@ -312,6 +367,12 @@
return list;
}
+ public int getChildNodesCount(String rootIdentifier)
+ {
+ int[] childCount = childNodesCount.get(rootIdentifier);
+ return childCount == null ? 0 : childCount[0];
+ }
+
/**
* Collect last in ChangesLog order item child changes.
*
@@ -323,17 +384,11 @@
*/
public Collection<ItemState> getLastChildrenStates(ItemData rootData, boolean forNodes)
{
- HashMap<String, ItemState> children = new HashMap<String, ItemState>();
- List<ItemState> changes = getChildrenChanges(rootData.getIdentifier());
- for (ItemState child : changes)
- {
- ItemData data = child.getData();
- // add state to result
- if (data.isNode() == forNodes && !data.equals(rootData))
- children.put(data.getIdentifier(), child);
+ Map<String, ItemState> children =
+ forNodes ? lastChildNodeStates.get(rootData.getIdentifier()) : lastChildPropertyStates.get(rootData
+ .getIdentifier());
- }
- return children.values();
+ return children == null ? new ArrayList<ItemState>() : children.values();
}
/**
@@ -528,4 +583,214 @@
}
return null;
}
+
+ /**
+ * Adds item to the changes log.
+ *
+ * @param item
+ * the item
+ */
+ private void addItem(ItemState item)
+ {
+ index.put(item.getData().getIdentifier(), item);
+ index.put(item.getData().getQPath(), item);
+ index.put(new ParentIDQPathBasedKey(item), item);
+ index.put(new IDStateBasedKey(item.getData().getIdentifier(), item.getState()), item);
+
+ if (item.getData().isNode())
+ {
+ Map<String, ItemState> children = lastChildNodeStates.get(item.getData().getParentIdentifier());
+ if (children == null)
+ {
+ children = new HashMap<String, ItemState>();
+ lastChildNodeStates.put(item.getData().getParentIdentifier(), children);
+ }
+ children.put(item.getData().getIdentifier(), item);
+ }
+ else
+ {
+ Map<String, ItemState> children = lastChildPropertyStates.get(item.getData().getParentIdentifier());
+ if (children == null)
+ {
+ children = new HashMap<String, ItemState>();
+ lastChildPropertyStates.put(item.getData().getParentIdentifier(), children);
+ }
+ children.put(item.getData().getIdentifier(), item);
+ }
+
+ if (item.isNode() && item.isPersisted())
+ {
+ int[] childCount = childNodesCount.get(item.getData().getParentIdentifier());
+ if (childCount == null)
+ childCount = new int[1];
+
+ if (item.isDeleted())
+ --childCount[0];
+ else if (item.isAdded())
+ ++childCount[0];
+
+ childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+ }
+ }
+
+ /**
+ * This class is used as a key for index map.
+ */
+ private class IDStateBasedKey
+ {
+
+ /**
+ * Item identifier.
+ */
+ private final String identifier;
+
+ /**
+ * Item state.
+ */
+ private final int state;
+
+ /**
+ * KeyUUIDState constructor.
+ *
+ * @param identifier
+ * item identifier
+ * @param state
+ * item state
+ */
+ IDStateBasedKey(String identifier, int state)
+ {
+ this.identifier = identifier;
+ this.state = state;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + identifier.hashCode();
+ result = prime * result + state;
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IDStateBasedKey other = (IDStateBasedKey)obj;
+
+ if (identifier == null)
+ {
+ if (other.identifier != null)
+ return false;
+ }
+ else if (!identifier.equals(other.identifier))
+ return false;
+ if (state != other.state)
+ return false;
+ return true;
+ }
+ }
+
+ /**
+ * This class is used as a key for index map.
+ */
+ private class ParentIDQPathBasedKey
+ {
+ /**
+ * Item name.
+ */
+ private final QPathEntry name;
+
+ /**
+ * Parent identifier.
+ */
+ private final String parentIdentifier;
+
+ /**
+ * KeyParentUUIDQPath constructor.
+ *
+ * @param item
+ * the item
+ */
+ ParentIDQPathBasedKey(ItemState item)
+ {
+ this.name = item.getData().getQPath().getEntries()[item.getData().getQPath().getEntries().length - 1];
+ this.parentIdentifier = item.getData().getParentIdentifier();
+ }
+
+ /**
+ * KeyParentUUIDQPath constructor.
+ *
+ * @param parentIdentifier
+ * the parent identifier
+ * @param name
+ * item name
+ */
+ ParentIDQPathBasedKey(String parentIdentifier, QPathEntry name)
+ {
+ this.name = name;
+ this.parentIdentifier = parentIdentifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + name.getName().hashCode();
+ result = prime * result + name.getNamespace().hashCode();
+ result = prime * result + name.getIndex();
+ result = prime * result + parentIdentifier.hashCode();
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ParentIDQPathBasedKey other = (ParentIDQPathBasedKey)obj;
+
+ if (name == null)
+ {
+ if (other.name != null)
+ return false;
+ }
+ else if (!name.getName().equals(other.name.getName())
+ || !name.getNamespace().equals(other.name.getNamespace()) || name.getIndex() != other.name.getIndex())
+ return false;
+ if (parentIdentifier == null)
+ {
+ if (other.parentIdentifier != null)
+ return false;
+ }
+ else if (!parentIdentifier.equals(other.parentIdentifier))
+ return false;
+ return true;
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -94,6 +94,45 @@
/**
* {@inheritDoc}
*/
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ {
+ if (txStarted())
+ {
+ int txChildsCount = 0;
+ for (ItemState change : transactionLog.getAllStates())
+ {
+ if (change.isNode() && change.isPersisted()
+ && change.getData().getParentIdentifier().equals(parent.getIdentifier()))
+ {
+ if (change.isDeleted())
+ {
+ txChildsCount--;
+ }
+ else if (change.isAdded())
+ {
+ txChildsCount++;
+ }
+ }
+ }
+
+ final int childsCount = storageDataManager.getChildNodesCount(parent) + txChildsCount;
+ if (childsCount < 0)
+ {
+ throw new InvalidItemStateException("Node's child nodes were changed in another Transaction "
+ + parent.getQPath().getAsString());
+ }
+
+ return childsCount;
+ }
+ else
+ {
+ return storageDataManager.getChildNodesCount(parent);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException
{
List<PropertyData> props = storageDataManager.getChildPropertiesData(parent);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -126,6 +126,11 @@
* FIND_NODES_BY_PARENTID.
*/
protected String FIND_NODES_BY_PARENTID;
+
+ /**
+ * FIND_NODES_COUNT_BY_PARENTID.
+ */
+ protected String FIND_NODES_COUNT_BY_PARENTID;
/**
* FIND_PROPERTIES_BY_PARENTID.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -600,6 +600,29 @@
throw new RepositoryException(e);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException {
+ checkIfOpened();
+ try
+ {
+ ResultSet count = findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for " + parent.getQPath().getAsString());
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
/**
* {@inheritDoc}
@@ -1871,6 +1894,8 @@
protected abstract ResultSet findItemByName(String parentId, String name, int index) throws SQLException;
protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException;
protected abstract ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -74,6 +74,7 @@
"select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2" + " order by ID";
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -81,6 +81,8 @@
+ " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?" + " order by N_ORDER_NUM";
+ FIND_NODES_COUNT_BY_PARENTID =
+ "select count(ID) from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?" + " order by ID";
}
@@ -135,7 +137,23 @@
findNodesByParentId.setString(2, containerName);
return findNodesByParentId.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+ findNodesCountByParentId.setString(1, parentCid);
+ findNodesCountByParentId.setString(2, containerName);
+ return findNodesCountByParentId.executeQuery();
+ }
+
/**
* {@inheritDoc}
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -77,6 +77,8 @@
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findNodesCountByParentId;
protected PreparedStatement findPropertiesByParentId;
@@ -185,6 +187,8 @@
FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
@@ -428,6 +432,21 @@
* {@inheritDoc}
*/
@Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, parentIdentifier);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
{
if (findPropertiesByParentId == null)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -75,6 +75,8 @@
protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement findNodesCountByParentId;
+
protected PreparedStatement findPropertiesByParentId;
protected PreparedStatement insertItem;
@@ -193,6 +195,9 @@
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+ FIND_NODES_COUNT_BY_PARENTID =
+ "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
@@ -339,6 +344,22 @@
* {@inheritDoc}
*/
@Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(2, parentCid);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
{
if (findPropertiesByParentId == null)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -93,6 +93,15 @@
* if connection is closed
*/
List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException;
+
+ /**
+ * Reads count of <code>parent<code/> child nodes.
+ *
+ * @param parent NodeData
+ * @return long, childs count
+ * @throws RepositoryException if error occurs
+ */
+ int getChildNodesCount(NodeData parent) throws RepositoryException;
/**
* Reads <code>List</code> of <code>PropertyData</code> from the storage using item's parent
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -387,7 +387,7 @@
return testFile;
}
- protected void checkMixins(String[] mixins, NodeImpl node)
+ protected void checkMixins(String[] mixins, NodeImpl node) throws RepositoryException
{
try
{
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/UpperLowerCaseQueryTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/UpperLowerCaseQueryTest.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/UpperLowerCaseQueryTest.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -16,9 +16,9 @@
*/
package org.exoplatform.services.jcr.api.core.query;
-
-
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Random;
import java.util.Set;
@@ -32,295 +32,276 @@
* fn:upper-case() in XPath, LOWER() and UPPER() in SQL and UpperCase and
* LowerCase in JQOM.
*/
-public class UpperLowerCaseQueryTest extends AbstractQueryTest {
+public class UpperLowerCaseQueryTest extends AbstractQueryTest
+{
-// /**
-// * Maps operator strings to QueryObjectModelConstants.
-// */
-// private static final Map OPERATORS = new HashMap();
-//
-// static {
-// OPERATORS.put("=", new Integer(OPERATOR_EQUAL_TO));
-// OPERATORS.put(">", new Integer(OPERATOR_GREATER_THAN));
-// OPERATORS.put(">=", new Integer(OPERATOR_GREATER_THAN_OR_EQUAL_TO));
-// OPERATORS.put("<", new Integer(OPERATOR_LESS_THAN));
-// OPERATORS.put("<=", new Integer(OPERATOR_LESS_THAN_OR_EQUAL_TO));
-// OPERATORS.put("like", new Integer(OPERATOR_LIKE));
-// OPERATORS.put("!=", new Integer(OPERATOR_NOT_EQUAL_TO));
-// }
+ // /**
+ // * Maps operator strings to QueryObjectModelConstants.
+ // */
+ // private static final Map OPERATORS = new HashMap();
+ //
+ // static {
+ // OPERATORS.put("=", new Integer(OPERATOR_EQUAL_TO));
+ // OPERATORS.put(">", new Integer(OPERATOR_GREATER_THAN));
+ // OPERATORS.put(">=", new Integer(OPERATOR_GREATER_THAN_OR_EQUAL_TO));
+ // OPERATORS.put("<", new Integer(OPERATOR_LESS_THAN));
+ // OPERATORS.put("<=", new Integer(OPERATOR_LESS_THAN_OR_EQUAL_TO));
+ // OPERATORS.put("like", new Integer(OPERATOR_LIKE));
+ // OPERATORS.put("!=", new Integer(OPERATOR_NOT_EQUAL_TO));
+ // }
- public void testEqualsGeneralComparison() throws RepositoryException {
- check(new String[]{"foo", "Foo", "fOO", "FOO", "fooBar", "fo", "fooo"},
- "=",
- "foo",
- new boolean[]{true, true, true, true, false, false, false});
- check(new String[]{"foo"}, "=", "", new boolean[]{false});
- check(new String[]{""}, "=", "", new boolean[]{true});
- }
+ public void testEqualsGeneralComparison() throws RepositoryException
+ {
+ check(new String[]{"foo", "Foo", "fOO", "FOO", "fooBar", "fo", "fooo"}, "=", "foo", new boolean[]{true, true,
+ true, true, false, false, false});
+ check(new String[]{"foo"}, "=", "", new boolean[]{false});
+ check(new String[]{""}, "=", "", new boolean[]{true});
+ }
- public void testGreaterThanGeneralComparison() throws RepositoryException {
- // check edges
- check(new String[]{"foo", "FOO", "FoO", "fOo", "FON", "fon", "fo", "FO"},
- ">",
- "foo",
- new boolean[]{false, false, false, false, false, false, false, false});
- check(new String[]{"foo ", "FOOa", "FoOO", "fOo1", "FOp", "foP", "fp", "g", "G"},
- ">",
- "foo",
- new boolean[]{true, true, true, true, true, true, true, true, true});
- // check combinations
- check(new String[]{"foo", "fooo", "FooO", "fo", "FON", "fon"},
- ">",
- "foo",
- new boolean[]{false, true, true, false, false, false});
- }
+ public void testGreaterThanGeneralComparison() throws RepositoryException
+ {
+ // check edges
+ check(new String[]{"foo", "FOO", "FoO", "fOo", "FON", "fon", "fo", "FO"}, ">", "foo", new boolean[]{false, false,
+ false, false, false, false, false, false});
+ check(new String[]{"foo ", "FOOa", "FoOO", "fOo1", "FOp", "foP", "fp", "g", "G"}, ">", "foo", new boolean[]{true,
+ true, true, true, true, true, true, true, true});
+ // check combinations
+ check(new String[]{"foo", "fooo", "FooO", "fo", "FON", "fon"}, ">", "foo", new boolean[]{false, true, true,
+ false, false, false});
+ }
- public void testLessThanGeneralComparison() throws RepositoryException {
- // check edges
- check(new String[]{"foo", "FOO", "FoO", "fOo", "foOo", "foo ", "fooa", "fop"},
- "<",
- "foo",
- new boolean[]{false, false, false, false, false, false, false, false});
- check(new String[]{"fo", "FOn", "FoN", "fO", "FO1", "fn", "fN", "E", "e"},
- "<",
- "foo",
- new boolean[]{true, true, true, true, true, true, true, true, true});
- // check combinations
- check(new String[]{"foo", "fooo", "FooO", "fo", "FON", "fon"},
- "<",
- "foo",
- new boolean[]{false, false, false, true, true, true});
- }
+ public void testLessThanGeneralComparison() throws RepositoryException
+ {
+ // check edges
+ check(new String[]{"foo", "FOO", "FoO", "fOo", "foOo", "foo ", "fooa", "fop"}, "<", "foo", new boolean[]{false,
+ false, false, false, false, false, false, false});
+ check(new String[]{"fo", "FOn", "FoN", "fO", "FO1", "fn", "fN", "E", "e"}, "<", "foo", new boolean[]{true, true,
+ true, true, true, true, true, true, true});
+ // check combinations
+ check(new String[]{"foo", "fooo", "FooO", "fo", "FON", "fon"}, "<", "foo", new boolean[]{false, false, false,
+ true, true, true});
+ }
- public void testGreaterEqualsGeneralComparison() throws RepositoryException {
- // check edges
- check(new String[]{"fo", "FO", "Fon", "fONo", "FON", "fO", "fo", "FO"},
- ">=",
- "foo",
- new boolean[]{false, false, false, false, false, false, false, false});
- check(new String[]{"foo", "FoO", "FoOO", "fOo1", "FOp", "foP", "fp", "g", "G"},
- ">=",
- "foo",
- new boolean[]{true, true, true, true, true, true, true, true, true});
- // check combinations
- check(new String[]{"foo", "fooo", "FOo", "fo", "FON", "fon"},
- ">=",
- "foo",
- new boolean[]{true, true, true, false, false, false});
- }
+ public void testGreaterEqualsGeneralComparison() throws RepositoryException
+ {
+ // check edges
+ check(new String[]{"fo", "FO", "Fon", "fONo", "FON", "fO", "fo", "FO"}, ">=", "foo", new boolean[]{false, false,
+ false, false, false, false, false, false});
+ check(new String[]{"foo", "FoO", "FoOO", "fOo1", "FOp", "foP", "fp", "g", "G"}, ">=", "foo", new boolean[]{true,
+ true, true, true, true, true, true, true, true});
+ // check combinations
+ check(new String[]{"foo", "fooo", "FOo", "fo", "FON", "fon"}, ">=", "foo", new boolean[]{true, true, true, false,
+ false, false});
+ }
- public void testLessEqualsGeneralComparison() throws RepositoryException {
- // check edges
- check(new String[]{"fooo", "FOoo", "Fop", "fOpo", "FOP", "fOo ", "fp", "G"},
- "<=",
- "foo",
- new boolean[]{false, false, false, false, false, false, false, false});
- check(new String[]{"foo", "FoO", "Foo", "fOn", "FO", "fo", "f", "E", "e"},
- "<=",
- "foo",
- new boolean[]{true, true, true, true, true, true, true, true, true});
- // check combinations
- check(new String[]{"foo", "fo", "FOo", "fop", "FOP", "fooo"},
- "<=",
- "foo",
- new boolean[]{true, true, true, false, false, false});
- }
+ public void testLessEqualsGeneralComparison() throws RepositoryException
+ {
+ // check edges
+ check(new String[]{"fooo", "FOoo", "Fop", "fOpo", "FOP", "fOo ", "fp", "G"}, "<=", "foo", new boolean[]{false,
+ false, false, false, false, false, false, false});
+ check(new String[]{"foo", "FoO", "Foo", "fOn", "FO", "fo", "f", "E", "e"}, "<=", "foo", new boolean[]{true, true,
+ true, true, true, true, true, true, true});
+ // check combinations
+ check(new String[]{"foo", "fo", "FOo", "fop", "FOP", "fooo"}, "<=", "foo", new boolean[]{true, true, true, false,
+ false, false});
+ }
- public void testNotEqualsGeneralComparison() throws RepositoryException {
- // check edges
- check(new String[]{"fooo", "FOoo", "Fop", "fOpo", "FOP", "fOo ", "fp", "G", ""},
- "!=",
- "foo",
- new boolean[]{true, true, true, true, true, true, true, true, true});
- check(new String[]{"foo", "FoO", "Foo", "foO", "FOO"},
- "!=",
- "foo",
- new boolean[]{false, false, false, false, false});
- // check combinations
- check(new String[]{"foo", "fo", "FOo", "fop", "FOP", "fooo"},
- "!=",
- "foo",
- new boolean[]{false, true, false, true, true, true});
- }
+ public void testNotEqualsGeneralComparison() throws RepositoryException
+ {
+ // check edges
+ check(new String[]{"fooo", "FOoo", "Fop", "fOpo", "FOP", "fOo ", "fp", "G", ""}, "!=", "foo", new boolean[]{true,
+ true, true, true, true, true, true, true, true});
+ check(new String[]{"foo", "FoO", "Foo", "foO", "FOO"}, "!=", "foo", new boolean[]{false, false, false, false,
+ false});
+ // check combinations
+ check(new String[]{"foo", "fo", "FOo", "fop", "FOP", "fooo"}, "!=", "foo", new boolean[]{false, true, false,
+ true, true, true});
+ }
- public void testLikeComparison() throws RepositoryException {
- check(new String[]{"foo", "Foo", "fOO", "FO "},
- "like",
- "fo_",
- new boolean[]{true, true, true, true});
- check(new String[]{"foo", "Foo", "fOO", "FOO"},
- "like",
- "f_o",
- new boolean[]{true, true, true, true});
- check(new String[]{"foo", "Foo", "fOO", " OO"},
- "like",
- "_oo",
- new boolean[]{true, true, true, true});
- check(new String[]{"foo", "Foa", "fOO", "FO", "foRm", "fPo", "fno", "FPo", "Fno"},
- "like",
- "fo%",
- new boolean[]{true, true, true, true, true, false, false, false, false});
- }
+ public void testLikeComparison() throws RepositoryException
+ {
+ check(new String[]{"foo", "Foo", "fOO", "FO "}, "like", "fo_", new boolean[]{true, true, true, true});
+ check(new String[]{"foo", "Foo", "fOO", "FOO"}, "like", "f_o", new boolean[]{true, true, true, true});
+ check(new String[]{"foo", "Foo", "fOO", " OO"}, "like", "_oo", new boolean[]{true, true, true, true});
+ check(new String[]{"foo", "Foa", "fOO", "FO", "foRm", "fPo", "fno", "FPo", "Fno"}, "like", "fo%", new boolean[]{
+ true, true, true, true, true, false, false, false, false});
+ }
- public void testLikeComparisonRandom() throws RepositoryException {
- String abcd = "abcd";
- Random random = new Random();
- for (int i = 0; i < 50; i++) {
- String pattern = "";
- pattern += getRandomChar(abcd, random);
- pattern += getRandomChar(abcd, random);
+ public void testLikeComparisonRandom() throws RepositoryException
+ {
+ String abcd = "abcd";
+ Random random = new Random();
+ for (int i = 0; i < 50; i++)
+ {
+ String pattern = "";
+ pattern += getRandomChar(abcd, random);
+ pattern += getRandomChar(abcd, random);
- // create 10 random values with 4 characters
- String[] values = new String[10];
- boolean[] matches = new boolean[10];
- for (int n = 0; n < 10; n++) {
- // at least the first character always matches
- String value = String.valueOf(pattern.charAt(0));
- for (int r = 1; r < 4; r++) {
- char c = getRandomChar(abcd, random);
- if (random.nextBoolean()) {
- c = Character.toUpperCase(c);
- }
- value += c;
- }
- matches[n] = value.toLowerCase().startsWith(pattern);
- values[n] = value;
+ // create 10 random values with 4 characters
+ String[] values = new String[10];
+ boolean[] matches = new boolean[10];
+ for (int n = 0; n < 10; n++)
+ {
+ // at least the first character always matches
+ String value = String.valueOf(pattern.charAt(0));
+ for (int r = 1; r < 4; r++)
+ {
+ char c = getRandomChar(abcd, random);
+ if (random.nextBoolean())
+ {
+ c = Character.toUpperCase(c);
+ }
+ value += c;
}
- pattern += "%";
- check(values, "like", pattern, matches);
- }
- }
+ matches[n] = value.toLowerCase().startsWith(pattern);
+ values[n] = value;
+ }
+ pattern += "%";
+ check(values, "like", pattern, matches);
+ }
+ }
- public void testRangeWithEmptyString() throws RepositoryException {
- check(new String[]{" ", "a", "A", "1", "3", "!", "@"},
- ">",
- "",
- new boolean[]{true, true, true, true, true, true, true});
- check(new String[]{"", "a", "A", "1", "3", "!", "@"},
- ">=",
- "",
- new boolean[]{true, true, true, true, true, true, true});
- check(new String[]{"", "a", "A", "1", "3", "!", "@"},
- "<",
- "",
- new boolean[]{false, false, false, false, false, false, false});
- check(new String[]{"", "a", "A", "1", "3", "!", "@"},
- "<=",
- "",
- new boolean[]{true, false, false, false, false, false, false});
- }
+ public void testRangeWithEmptyString() throws RepositoryException
+ {
+ check(new String[]{" ", "a", "A", "1", "3", "!", "@"}, ">", "", new boolean[]{true, true, true, true, true, true,
+ true});
+ check(new String[]{"", "a", "A", "1", "3", "!", "@"}, ">=", "", new boolean[]{true, true, true, true, true, true,
+ true});
+ check(new String[]{"", "a", "A", "1", "3", "!", "@"}, "<", "", new boolean[]{false, false, false, false, false,
+ false, false});
+ check(new String[]{"", "a", "A", "1", "3", "!", "@"}, "<=", "", new boolean[]{true, false, false, false, false,
+ false, false});
+ }
- public void testInvalidQuery() throws RepositoryException {
- try {
- executeXPathQuery("//*[fn:lower-case(@foo) = 123]", new Node[]{});
- fail("must throw InvalidQueryException");
- } catch (InvalidQueryException e) {
- // correct
- }
+ public void testInvalidQuery() throws RepositoryException
+ {
+ try
+ {
+ executeXPathQuery("//*[fn:lower-case(@foo) = 123]", new Node[]{});
+ fail("must throw InvalidQueryException");
+ }
+ catch (InvalidQueryException e)
+ {
+ // correct
+ }
- try {
- executeSQLQuery("select * from nt:base where LOWER(foo) = 123", new Node[]{});
- fail("must throw InvalidQueryException");
- } catch (InvalidQueryException e) {
- // correct
- }
- }
+ try
+ {
+ executeSQLQuery("select * from nt:base where LOWER(foo) = 123", new Node[]{});
+ fail("must throw InvalidQueryException");
+ }
+ catch (InvalidQueryException e)
+ {
+ // correct
+ }
+ }
- public void testWrongCaseNeverMatches() throws RepositoryException {
- Node n = testRootNode.addNode("node");
- n.setProperty("foo", "Bar");
- testRootNode.save();
- executeXPathQuery(testPath + "/*[jcr:like(fn:lower-case(@foo), 'BA%')]", new Node[]{});
- }
+ public void testWrongCaseNeverMatches() throws RepositoryException
+ {
+ Node n = testRootNode.addNode("node");
+ n.setProperty("foo", "Bar");
+ testRootNode.save();
+ executeXPathQuery(testPath + "/*[jcr:like(fn:lower-case(@foo), 'BA%')]", new Node[]{});
+ }
- //----------------------------< internal >----------------------------------
+ //----------------------------< internal >----------------------------------
- private void check(String[] values, String operation, String queryTerm, boolean[] matches)
- throws RepositoryException {
- if (values.length != matches.length) {
- throw new IllegalArgumentException("values and matches must have same length");
- }
- // create log message
- StringBuffer logMsg = new StringBuffer();
- logMsg.append("queryTerm: ").append(queryTerm);
- logMsg.append(" values: ");
- String separator = "";
- for (int i = 0; i < values.length; i++) {
- logMsg.append(separator);
- separator = ", ";
- if (matches[i]) {
- logMsg.append("+");
- } else {
- logMsg.append("-");
- }
- logMsg.append(values[i]);
- }
- log.println(logMsg.toString());
- for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
- it.nextNode().remove();
- }
- Set matchingNodes = new HashSet();
- for (int i = 0; i < values.length; i++) {
- Node n = testRootNode.addNode("node" + i);
- n.setProperty(propertyName1, values[i]);
- if (matches[i]) {
- matchingNodes.add(n);
- }
- }
- testRootNode.save();
+ private void check(String[] values, String operation, String queryTerm, boolean[] matches)
+ throws RepositoryException
+ {
+ if (values.length != matches.length)
+ {
+ throw new IllegalArgumentException("values and matches must have same length");
+ }
+ // create log message
+ StringBuffer logMsg = new StringBuffer();
+ logMsg.append("queryTerm: ").append(queryTerm);
+ logMsg.append(" values: ");
+ String separator = "";
+ for (int i = 0; i < values.length; i++)
+ {
+ logMsg.append(separator);
+ separator = ", ";
+ if (matches[i])
+ {
+ logMsg.append("+");
+ }
+ else
+ {
+ logMsg.append("-");
+ }
+ logMsg.append(values[i]);
+ }
+ log.println(logMsg.toString());
+ for (NodeIterator it = testRootNode.getNodes(); it.hasNext();)
+ {
+ it.nextNode().remove();
+ }
+ List matchingNodes = new ArrayList();
+ for (int i = 0; i < values.length; i++)
+ {
+ Node n = testRootNode.addNode("node" + i);
+ n.setProperty(propertyName1, values[i]);
+ if (matches[i])
+ {
+ matchingNodes.add(n);
+ }
+ }
+ testRootNode.save();
- Node[] nodes = (Node[]) matchingNodes.toArray(new Node[matchingNodes.size()]);
- String sqlOperation = operation;
- if (operation.equals("!=")) {
- sqlOperation = "<>";
- }
+ Node[] nodes = (Node[])matchingNodes.toArray(new Node[matchingNodes.size()]);
+ String sqlOperation = operation;
+ if (operation.equals("!="))
+ {
+ sqlOperation = "<>";
+ }
- // run queries with lower-case
- String xpath = testPath;
- if (operation.equals("like")) {
- xpath += "/*[jcr:like(fn:lower-case(@" + propertyName1 +
- "), '" + queryTerm.toLowerCase() + "')]";
- } else {
- xpath += "/*[fn:lower-case(@" + propertyName1 +
- ") " + operation + " '" + queryTerm.toLowerCase() + "']";
- }
- executeXPathQuery(xpath, nodes);
+ // run queries with lower-case
+ String xpath = testPath;
+ if (operation.equals("like"))
+ {
+ xpath += "/*[jcr:like(fn:lower-case(@" + propertyName1 + "), '" + queryTerm.toLowerCase() + "')]";
+ }
+ else
+ {
+ xpath += "/*[fn:lower-case(@" + propertyName1 + ") " + operation + " '" + queryTerm.toLowerCase() + "']";
+ }
+ executeXPathQuery(xpath, nodes);
- String sql = "select * from nt:base where jcr:path like '" +
- testRoot + "/%' and LOWER(" + propertyName1 + ") " +
- sqlOperation + " '" + queryTerm.toLowerCase() + "'";
- executeSQLQuery(sql, nodes);
+ String sql =
+ "select * from nt:base where jcr:path like '" + testRoot + "/%' and LOWER(" + propertyName1 + ") "
+ + sqlOperation + " '" + queryTerm.toLowerCase() + "'";
+ executeSQLQuery(sql, nodes);
+ // run queries with upper-case
+ xpath = testPath;
+ if (operation.equals("like"))
+ {
+ xpath += "/*[jcr:like(fn:upper-case(@" + propertyName1 + "), '" + queryTerm.toUpperCase() + "')]";
+ }
+ else
+ {
+ xpath += "/*[fn:upper-case(@" + propertyName1 + ") " + operation + " '" + queryTerm.toUpperCase() + "']";
+ }
+ executeXPathQuery(xpath, nodes);
+ sql =
+ "select * from nt:base where jcr:path like '" + testRoot + "/%' and UPPER(" + propertyName1 + ") "
+ + sqlOperation + " '" + queryTerm.toUpperCase() + "'";
+ executeSQLQuery(sql, nodes);
- // run queries with upper-case
- xpath = testPath;
- if (operation.equals("like")) {
- xpath += "/*[jcr:like(fn:upper-case(@" + propertyName1 +
- "), '" + queryTerm.toUpperCase() + "')]";
- } else {
- xpath += "/*[fn:upper-case(@" + propertyName1 +
- ") " + operation + " '" + queryTerm.toUpperCase() + "']";
- }
- executeXPathQuery(xpath, nodes);
+ }
- sql = "select * from nt:base where jcr:path like '" +
- testRoot + "/%' and UPPER(" + propertyName1 + ") " +
- sqlOperation + " '" + queryTerm.toUpperCase() + "'";
- executeSQLQuery(sql, nodes);
+ private char getRandomChar(String pool, Random random)
+ {
+ return pool.charAt(random.nextInt(pool.length()));
+ }
-
- }
-
- private char getRandomChar(String pool, Random random) {
- return pool.charAt(random.nextInt(pool.length()));
- }
-
-// protected static int getOperatorForString(String operator) {
-// Integer i = (Integer) OPERATORS.get(operator);
-// if (i == null) {
-// throw new IllegalArgumentException("unknown operator: " + operator);
-// }
-// return i.intValue();
-// }
+ // protected static int getOperatorForString(String operator) {
+ // Integer i = (Integer) OPERATORS.get(operator);
+ // if (i == null) {
+ // throw new IllegalArgumentException("unknown operator: " + operator);
+ // }
+ // return i.intValue();
+ // }
}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -0,0 +1,271 @@
+/*
+ * 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.
+ */
+/*
+ * 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.jcr.impl.core;
+
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 13.11.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class TestNodeOrder extends JcrImplBaseTest
+{
+
+ public void testOrder() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+ testNode.addNode("z");
+ session.save();
+ testNode.addNode("a");
+ session.save();
+ testNode.addNode("b");
+ session.save();
+ testNode.addNode("c");
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(4, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderInSession() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(4, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderCombined() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+ session.save();
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithRefreshDiscard() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+ root.refresh(false); // discard added a and y
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(6, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithInvalidation() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("y");
+
+ // add some in another session
+ Session another = repository.login(credentials, root.getSession().getWorkspace().getName());
+ Node anotherTest = another.getRootNode().getNode("testNode");
+ another.save();
+ anotherTest.addNode("a");
+ anotherTest.addNode("y");
+ another.save();
+ another.logout();
+
+ try
+ {
+ session.save();
+ fail("Nodes already added in another session, ItemExistsException should be thrown");
+ }
+ catch (ItemExistsException e)
+ {
+ // ok
+ root.refresh(false); // discard a and y
+ }
+
+ testNode.addNode("c");
+ testNode.addNode("a");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+ public void testOrderWithRefreshKeep() throws Exception
+ {
+ Node testNode = root.addNode("testNode");
+ session.save();
+
+ testNode.addNode("a");
+ testNode.addNode("a");
+ testNode.addNode("z");
+ testNode.addNode("a");
+ session.save();
+
+ // add some in another session
+ Session another = repository.login(credentials, root.getSession().getWorkspace().getName());
+ Node anotherTest = another.getRootNode().getNode("testNode");
+ another.save();
+ anotherTest.addNode("a");
+ anotherTest.addNode("y");
+ another.save();
+ another.logout();
+
+ //root.refresh(true); // refresh to see another Session
+ testNode.addNode("a");
+ testNode.addNode("y");
+ session.save();
+
+ // check
+ NodeIterator nodes = testNode.getNodes();
+ assertEquals(8, nodes.getSize());
+
+ int order = 0;
+ for (; nodes.hasNext();)
+ {
+ NodeImpl n = (NodeImpl)nodes.nextNode();
+ int orderNumb = ((NodeData)n.getData()).getOrderNumber();
+ log.info(orderNumb + ": " + n.getPath());
+
+ assertEquals(order++, orderNumb);
+ }
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestNodeOrder.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -0,0 +1,130 @@
+/*
+ * 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.load.perf;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TestGetNodesPerf extends JcrAPIBaseTest
+{
+ private static final String testName = "testRoot";
+
+ private static final int sessionCount = 10;
+
+ private static final int tryCount = 5;
+
+ private Session[] sessions = new Session[sessionCount];
+
+ private GetNodesThread[] threads = new GetNodesThread[sessionCount];
+
+ public void testGetNodes() throws Exception
+ {
+ for (int i = 0; i < sessionCount; i++)
+ {
+ sessions[i] = (SessionImpl)repository.login(credentials, "ws");
+ }
+
+ Node testRoot = session.getRootNode().addNode(testName);
+ session.save();
+
+ log.info("adding...");
+ int nodesCount = 50000;
+ for (int i = 0; i < nodesCount; i++)
+ {
+ testRoot.addNode("_" + i + "_node");
+ }
+ log.info("saving...");
+ session.save();
+
+ log.info("waiting for 10 seconds...");
+ Thread.sleep(10000);
+
+ System.gc();
+ Runtime rt = Runtime.getRuntime();
+ long usedMemory = rt.totalMemory() - rt.freeMemory();
+
+ log.info("getting nodes...");
+ for (int k = 0; k < tryCount; k++)
+ {
+ for (int i = 0; i < sessionCount; i++)
+ {
+ threads[i] = new GetNodesThread(sessions[i]);
+ threads[i].start();
+ }
+
+ outer : while (true)
+ {
+ for (int i = 0; i < sessionCount; i++)
+ {
+ if (threads[i].isAlive())
+ {
+ Thread.sleep(1000);
+ continue outer;
+ }
+ }
+
+ break;
+ }
+
+ log.info("waiting for 10 seconds...");
+ Thread.sleep(10000);
+ }
+ log.info("Memory used: " + (rt.totalMemory() - rt.freeMemory() - usedMemory) / 1024 / 1024 + "Mb");
+ }
+
+ private class GetNodesThread extends Thread
+ {
+ private final Session curSession;
+
+ private NodeIterator nodes;
+
+ GetNodesThread(Session session)
+ {
+ this.curSession = session;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ Node testRoot = curSession.getRootNode().getNode(testName);
+
+ long startTime = System.currentTimeMillis();
+ nodes = testRoot.getNodes();
+ log.info("Total time: " + (System.currentTimeMillis() - startTime) + "ms");
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -388,7 +388,7 @@
return testFile;
}
- protected void checkMixins(String[] mixins, NodeImpl node)
+ protected void checkMixins(String[] mixins, NodeImpl node) throws RepositoryException
{
try
{
Modified: jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/BaseStandaloneTest.java 2009-11-29 20:16:22 UTC (rev 905)
+++ jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/BaseStandaloneTest.java 2009-11-30 10:36:38 UTC (rev 906)
@@ -343,7 +343,7 @@
return testFile;
}
- protected void checkMixins(String[] mixins, NodeImpl node)
+ protected void checkMixins(String[] mixins, NodeImpl node) throws RepositoryException
{
try
{
14 years, 5 months
exo-jcr SVN: r905 - in kernel/branches/mc-int-branch: exo.kernel.demos/mc-injection/src/main/resources/conf and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2009-11-29 15:16:22 -0500 (Sun, 29 Nov 2009)
New Revision: 905
Modified:
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml
Log:
Log warn if mc-int not available + aop conf can't have leading and trailing whitespaces spaces in mc-int-beans.xml
Modified: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java 2009-11-28 21:33:31 UTC (rev 904)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java 2009-11-29 20:16:22 UTC (rev 905)
@@ -72,7 +72,7 @@
catch (ClassNotFoundException ignored)
{
permFailure = true;
- log.info("MC integration not available in this environment (missing class: "
+ log.warn("MC integration not available in this environment (missing class: "
+ ignored.getMessage() + ")");
return null;
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml 2009-11-28 21:33:31 UTC (rev 904)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml 2009-11-29 20:16:22 UTC (rev 905)
@@ -5,14 +5,10 @@
<annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true)</annotation>
</bean>
<bean name="InjectingBean2">
- <annotation>
- @org.exoplatform.container.mc.impl.InterceptMC(injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.STANDARD)
- </annotation>
+ <annotation>@org.exoplatform.container.mc.impl.InterceptMC(injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.STANDARD)</annotation>
</bean>
<bean name="InjectingBean3">
- <annotation>
- @org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true,injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.ALL)
- </annotation>
+ <annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true,injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.ALL)</annotation>
</bean>
<bean name="InjectingBean4">
<annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true)</annotation>
14 years, 5 months
exo-jcr SVN: r904 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-11-28 16:33:31 -0500 (Sat, 28 Nov 2009)
New Revision: 904
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
Log:
EXOJCR-241: fixed indexing of the jcr:system. Now all test pass
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-11-28 00:05:57 UTC (rev 903)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-11-28 21:33:31 UTC (rev 904)
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.jboss.cache.commands.WriteCommand;
import java.util.ArrayList;
import java.util.List;
@@ -61,12 +62,17 @@
*/
private List<ItemStateChangesLog> changesLogBuffer = new ArrayList<ItemStateChangesLog>();
+ /**
+ * ChangesLog Buffer (used for saves before start).
+ */
+ private List<List<WriteCommand>> writeCommandBuffer = new ArrayList<List<WriteCommand>>();
+
public static final String INDEX_DIR_SUFFIX = "system";
public SystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
WorkspacePersistentDataManager itemMgr, DocumentReaderService service, ConfigurationManager cfm,
- RepositoryIndexSearcherHolder indexSearcherHolder, IndexerInterceptor indexInterceptor) throws RepositoryException,
- RepositoryConfigurationException
+ RepositoryIndexSearcherHolder indexSearcherHolder, IndexerInterceptor indexInterceptor)
+ throws RepositoryException, RepositoryConfigurationException
{
super(config, nsReg, ntReg, itemMgr, null, service, cfm, indexSearcherHolder, indexInterceptor);
}
@@ -107,24 +113,50 @@
{
log.error(e.getLocalizedMessage());
handler = null;
- changesLogBuffer.clear();
- changesLogBuffer = null;
+ freeBuffers();
throw new RuntimeException(e);
}
catch (RepositoryConfigurationException e)
{
log.error(e.getLocalizedMessage());
handler = null;
- changesLogBuffer.clear();
- changesLogBuffer = null;
+ freeBuffers();
throw new RuntimeException(e);
}
- for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer)
+ if (changesLogBuffer.size() > 0)
{
- super.onSaveItems(bufferedChangesLog);
+ for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer)
+ {
+ super.onSaveItems(bufferedChangesLog);
+ }
+
}
+
+ if (writeCommandBuffer.size() > 0)
+ {
+ try
+ {
+ for (List<WriteCommand> bufferedWriteLog : writeCommandBuffer)
+ {
+ super.onSaveItems(bufferedWriteLog);
+ }
+ }
+ catch (RepositoryException e)
+ {
+ freeBuffers();
+ throw new RuntimeException(e);
+
+ }
+ }
+ freeBuffers();
+ }
+
+ private void freeBuffers()
+ {
changesLogBuffer.clear();
changesLogBuffer = null;
+ writeCommandBuffer.clear();
+ writeCommandBuffer = null;
}
@Override
@@ -133,7 +165,25 @@
{
QueryHandlerContext context =
new QueryHandlerContext(itemMgr, indexingTree, nodeTypeDataManager, nsReg, parentHandler, getIndexDir() + "_"
- + INDEX_DIR_SUFFIX, extractor, changesLogBuffer.size() > 0 && !isStarted, virtualTableResolver);
+ + INDEX_DIR_SUFFIX, extractor,
+ (changesLogBuffer.size() > 0 || writeCommandBuffer.size() > 0) && !isStarted, virtualTableResolver);
return context;
}
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.impl.core.query.SearchManager#onSaveItems(java.util.List)
+ */
+ @Override
+ public void onSaveItems(List<WriteCommand> modifications) throws RepositoryException
+ {
+ if (!isStarted)
+ {
+ writeCommandBuffer.add(modifications);
+ }
+ else
+ {
+ super.onSaveItems(modifications);
+ }
+
+ }
}
14 years, 5 months
exo-jcr SVN: r903 - in kernel/branches/mc-int-branch: exo.kernel.commons and 50 other directories.
by do-not-reply@jboss.org
Author: mstruk
Date: 2009-11-27 19:05:57 -0500 (Fri, 27 Nov 2009)
New Revision: 903
Added:
kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java
kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/helpers/
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/helpers/StatelessController.java
Removed:
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml
Modified:
kernel/branches/mc-int-branch/exo.kernel.commons/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.cache/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java
kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
kernel/branches/mc-int-branch/exo.kernel.component.command/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.common/pom.xml
kernel/branches/mc-int-branch/exo.kernel.component.remote/pom.xml
kernel/branches/mc-int-branch/exo.kernel.container/pom.xml
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml
kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml
kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml
kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml
kernel/branches/mc-int-branch/packaging/module/pom.xml
kernel/branches/mc-int-branch/pom.xml
Log:
Merged in changes from trunk up to rev. 902 + incremented mc-int modules versions to keep in sync
Modified: kernel/branches/mc-int-branch/exo.kernel.commons/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.commons/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.commons/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.commons</artifactId>
@@ -35,30 +35,21 @@
<dependencies>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
</dependency>
-
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
-
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
Modified: kernel/branches/mc-int-branch/exo.kernel.component.cache/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.cache</artifactId>
@@ -35,17 +35,16 @@
<dependencies>
<dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.remote</artifactId>
+ <artifactId>exo.kernel.container</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
+ <artifactId>exo.kernel.commons</artifactId>
</dependency>
</dependencies>
-</project>
-
+</project>
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java (from rev 902, kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheFactory.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java (from rev 902, kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCacheInitException.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.command/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.command/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.command/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.command</artifactId>
@@ -34,13 +34,15 @@
<description>exoplatform command services implementation</description>
<dependencies>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
+ <artifactId>exo.kernel.commons</artifactId>
</dependency>
-
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-chain</groupId>
<artifactId>commons-chain</artifactId>
<exclusions>
@@ -50,5 +52,13 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.common/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.common/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.common</artifactId>
@@ -35,15 +35,21 @@
<dependencies>
<dependency>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.container</artifactId>
</dependency>
-
<dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</dependency>
-
<dependency>
<groupId>jotm</groupId>
<artifactId>jotm</artifactId>
@@ -58,23 +64,23 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<scope>provided</scope>
</dependency>
-
<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
</dependency>
-
<dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</dependency>
-
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache (from rev 902, kernel/trunk/exo.kernel.component.ext.cache)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,36 +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</artifactId>
-
- <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>
-</project>
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/pom.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,36 @@
+<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</artifactId>
+
+ <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>
+</project>
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,573 +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.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
-
-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.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.notifications.annotation.NodeCreated;
-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;
-
-/**
- * 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 implements ExoCache
-{
-
- /**
- * Logger.
- */
- private static final Log LOG = ExoLogger.getLogger(AbstractExoCache.class);
-
- protected final AtomicInteger size = new AtomicInteger();
-
- private volatile int hits;
-
- private volatile int misses;
-
- private String label;
-
- private String name;
-
- private boolean distributed;
-
- private boolean replicated;
-
- private boolean logEnabled;
-
- private final CopyOnWriteArrayList<CacheListener> listeners;
-
- protected final Cache<Serializable, Object> cache;
-
- protected final boolean isCacheSPI;
-
- @SuppressWarnings("unchecked")
- public AbstractExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache)
- {
- this.cache = cache;
- this.isCacheSPI = cache instanceof CacheSPI;
- this.listeners = new CopyOnWriteArrayList<CacheListener>();
- if (!isCacheSPI)
- {
- LOG.warn("The cache is not an instance of CacheSPI, the cache size will be evaluated but won't be accurate");
- }
- setDistributed(config.isDistributed());
- setLabel(config.getLabel());
- setName(config.getName());
- setLogEnabled(config.isLogEnabled());
- setReplicated(config.isRepicated());
- cache.getConfiguration().setInvocationBatchingEnabled(true);
- cache.addCacheListener(new SizeManager());
- }
-
- /**
- * {@inheritDoc}
- */
- public void addCacheListener(CacheListener listener)
- {
- if (listener == null)
- {
- return;
- }
- listeners.add(listener);
- }
-
- /**
- * {@inheritDoc}
- */
- public void clearCache() throws Exception
- {
- final Node<Serializable, Object> rootNode = cache.getRoot();
- for (Node<Serializable, Object> node : rootNode.getChildren())
- {
- if (node == null)
- {
- continue;
- }
- remove(getKey(node));
- }
- onClearCache();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object get(Serializable name) throws Exception
- {
- final Object result = cache.get(Fqn.fromElements(name), name);
- if (result == null)
- {
- misses++;
- }
- else
- {
- hits++;
- }
- onGet(name, result);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheHit()
- {
- return hits;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheMiss()
- {
- return misses;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public int getCacheSize()
- {
- if (isCacheSPI)
- {
- return ((CacheSPI)cache).getNumberOfNodes();
- }
- return size.intValue();
- }
-
- /**
- * {@inheritDoc}
- */
- public List<Object> getCachedObjects()
- {
- final LinkedList<Object> list = new LinkedList<Object>();
- for (Node<Serializable, Object> node : cache.getRoot().getChildren())
- {
- if (node == null)
- {
- continue;
- }
- final Object 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(Serializable name, Object obj) throws Exception
- {
- putOnly(name, obj);
- onPut(name, obj);
- }
-
- /**
- * Only puts the data into the cache nothing more
- */
- private Object putOnly(Serializable name, Object obj) throws Exception
- {
- return cache.put(Fqn.fromElements(name), name, obj);
- }
-
- /**
- * {@inheritDoc}
- */
- public void putMap(Map<Serializable, Object> objs) throws Exception
- {
- cache.startBatch();
- int total = 0;
- try
- {
- // Start transaction
- for (Entry<Serializable, Object> entry : objs.entrySet())
- {
- Object value = putOnly(entry.getKey(), entry.getValue());
- if (value == null)
- {
- total++;
- }
- }
- cache.endBatch(true);
- // End transaction
- for (Entry<Serializable, Object> entry : objs.entrySet())
- {
- onPut(entry.getKey(), entry.getValue());
- }
- }
- catch (Exception e)
- {
- if (!isCacheSPI)
- size.addAndGet(-total);
- cache.endBatch(false);
- throw e;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Object remove(Serializable name) throws Exception
- {
- final Fqn<Serializable> fqn = Fqn.fromElements(name);
- final Node<Serializable, Object> node = cache.getNode(fqn);
- if (node != null)
- {
- final Object result = node.get(name);
- if (cache.removeNode(fqn))
- {
- onRemove(name, result);
- }
- return result;
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public List<Object> removeCachedObjects() throws Exception
- {
- final List<Object> list = getCachedObjects();
- clearCache();
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- public void select(CachedObjectSelector selector) throws Exception
- {
- for (Node<Serializable, Object> node : cache.getRoot().getChildren())
- {
- if (node == null)
- {
- continue;
- }
- final Serializable key = getKey(node);
- final Object value = node.get(key);
- ObjectCacheInfo info = new ObjectCacheInfo()
- {
- public Object 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 Serializable getKey(Node<Serializable, Object> node)
- {
- return getKey(node.getFqn());
- }
-
- /**
- * Returns the key related to the given Fqn
- */
- @SuppressWarnings("unchecked")
- private Serializable getKey(Fqn fqn)
- {
- return (Serializable)fqn.get(0);
- }
-
- void onExpire(Serializable key, Object obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener listener : listeners)
- {
- try
- {
- listener.onExpire(this, key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- void onRemove(Serializable key, Object obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener listener : listeners)
- {
- try
- {
- listener.onRemove(this, key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- void onPut(Serializable key, Object obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener listener : listeners)
- try
- {
- listener.onPut(this, key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- void onGet(Serializable key, Object obj)
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener listener : listeners)
- try
- {
- listener.onGet(this, key, obj);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- void onClearCache()
- {
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener listener : listeners)
- try
- {
- listener.onClearCache(this);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- @org.jboss.cache.notifications.annotation.CacheListener
- public class SizeManager
- {
-
- @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);
- }
- else if (!isCacheSPI)
- {
- size.decrementAndGet();
- }
- }
-
- @NodeRemoved
- public void nodeRemoved(NodeEvent ne)
- {
- if (ne.isPre())
- {
- if (!ne.isOriginLocal())
- {
- final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
- final Serializable key = getKey(ne.getFqn());
- onRemove(key, node.get(key));
- }
- }
- else if (!isCacheSPI)
- {
- size.decrementAndGet();
- }
- }
-
- @NodeCreated
- public void nodeCreated(NodeEvent ne)
- {
- if (!ne.isPre() && !isCacheSPI)
- {
- size.incrementAndGet();
- }
- }
-
- @SuppressWarnings("unchecked")
- @NodeModified
- public void nodeModified(NodeEvent ne)
- {
- if (!ne.isOriginLocal() && !ne.isPre())
- {
- final Serializable key = getKey(ne.getFqn());
- if (ne instanceof EventImpl)
- {
- EventImpl evt = (EventImpl)ne;
- Map<Serializable, Object> data = evt.getData();
- if (data != null)
- {
- onPut(key, data.get(key));
- return;
- }
- }
- final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
- onPut(key, node.get(key));
- }
- }
- }
-}
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,573 @@
+/*
+ * 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.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+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.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.notifications.annotation.NodeCreated;
+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;
+
+/**
+ * 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 implements ExoCache
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(AbstractExoCache.class);
+
+ protected final AtomicInteger size = new AtomicInteger();
+
+ private volatile int hits;
+
+ private volatile int misses;
+
+ private String label;
+
+ private String name;
+
+ private boolean distributed;
+
+ private boolean replicated;
+
+ private boolean logEnabled;
+
+ private final CopyOnWriteArrayList<CacheListener> listeners;
+
+ protected final Cache<Serializable, Object> cache;
+
+ protected final boolean isCacheSPI;
+
+ @SuppressWarnings("unchecked")
+ public AbstractExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache)
+ {
+ this.cache = cache;
+ this.isCacheSPI = cache instanceof CacheSPI;
+ this.listeners = new CopyOnWriteArrayList<CacheListener>();
+ if (!isCacheSPI)
+ {
+ LOG.warn("The cache is not an instance of CacheSPI, the cache size will be evaluated but won't be accurate");
+ }
+ setDistributed(config.isDistributed());
+ setLabel(config.getLabel());
+ setName(config.getName());
+ setLogEnabled(config.isLogEnabled());
+ setReplicated(config.isRepicated());
+ cache.getConfiguration().setInvocationBatchingEnabled(true);
+ cache.addCacheListener(new SizeManager());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCacheListener(CacheListener listener)
+ {
+ if (listener == null)
+ {
+ return;
+ }
+ listeners.add(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearCache() throws Exception
+ {
+ final Node<Serializable, Object> rootNode = cache.getRoot();
+ for (Node<Serializable, Object> node : rootNode.getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ remove(getKey(node));
+ }
+ onClearCache();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object get(Serializable name) throws Exception
+ {
+ final Object result = cache.get(Fqn.fromElements(name), name);
+ if (result == null)
+ {
+ misses++;
+ }
+ else
+ {
+ hits++;
+ }
+ onGet(name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheHit()
+ {
+ return hits;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheMiss()
+ {
+ return misses;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public int getCacheSize()
+ {
+ if (isCacheSPI)
+ {
+ return ((CacheSPI)cache).getNumberOfNodes();
+ }
+ return size.intValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Object> getCachedObjects()
+ {
+ final LinkedList<Object> list = new LinkedList<Object>();
+ for (Node<Serializable, Object> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final Object 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(Serializable name, Object obj) throws Exception
+ {
+ putOnly(name, obj);
+ onPut(name, obj);
+ }
+
+ /**
+ * Only puts the data into the cache nothing more
+ */
+ private Object putOnly(Serializable name, Object obj) throws Exception
+ {
+ return cache.put(Fqn.fromElements(name), name, obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putMap(Map<Serializable, Object> objs) throws Exception
+ {
+ cache.startBatch();
+ int total = 0;
+ try
+ {
+ // Start transaction
+ for (Entry<Serializable, Object> entry : objs.entrySet())
+ {
+ Object value = putOnly(entry.getKey(), entry.getValue());
+ if (value == null)
+ {
+ total++;
+ }
+ }
+ cache.endBatch(true);
+ // End transaction
+ for (Entry<Serializable, Object> entry : objs.entrySet())
+ {
+ onPut(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (Exception e)
+ {
+ if (!isCacheSPI)
+ size.addAndGet(-total);
+ cache.endBatch(false);
+ throw e;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Serializable name) throws Exception
+ {
+ final Fqn<Serializable> fqn = Fqn.fromElements(name);
+ final Node<Serializable, Object> node = cache.getNode(fqn);
+ if (node != null)
+ {
+ final Object result = node.get(name);
+ if (cache.removeNode(fqn))
+ {
+ onRemove(name, result);
+ }
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Object> removeCachedObjects() throws Exception
+ {
+ final List<Object> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void select(CachedObjectSelector selector) throws Exception
+ {
+ for (Node<Serializable, Object> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final Serializable key = getKey(node);
+ final Object value = node.get(key);
+ ObjectCacheInfo info = new ObjectCacheInfo()
+ {
+ public Object 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 Serializable getKey(Node<Serializable, Object> node)
+ {
+ return getKey(node.getFqn());
+ }
+
+ /**
+ * Returns the key related to the given Fqn
+ */
+ @SuppressWarnings("unchecked")
+ private Serializable getKey(Fqn fqn)
+ {
+ return (Serializable)fqn.get(0);
+ }
+
+ void onExpire(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ {
+ try
+ {
+ listener.onExpire(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onRemove(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ {
+ try
+ {
+ listener.onRemove(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onPut(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onPut(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onGet(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onGet(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onClearCache()
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onClearCache(this);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ @org.jboss.cache.notifications.annotation.CacheListener
+ public class SizeManager
+ {
+
+ @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);
+ }
+ else if (!isCacheSPI)
+ {
+ size.decrementAndGet();
+ }
+ }
+
+ @NodeRemoved
+ public void nodeRemoved(NodeEvent ne)
+ {
+ if (ne.isPre())
+ {
+ if (!ne.isOriginLocal())
+ {
+ final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
+ final Serializable key = getKey(ne.getFqn());
+ onRemove(key, node.get(key));
+ }
+ }
+ else if (!isCacheSPI)
+ {
+ size.decrementAndGet();
+ }
+ }
+
+ @NodeCreated
+ public void nodeCreated(NodeEvent ne)
+ {
+ if (!ne.isPre() && !isCacheSPI)
+ {
+ size.incrementAndGet();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
+ {
+ if (!ne.isOriginLocal() && !ne.isPre())
+ {
+ final Serializable key = getKey(ne.getFqn());
+ if (ne instanceof EventImpl)
+ {
+ EventImpl evt = (EventImpl)ne;
+ Map<Serializable, Object> data = evt.getData();
+ if (data != null)
+ {
+ onPut(key, data.get(key));
+ return;
+ }
+ }
+ final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
+ onPut(key, node.get(key));
+ }
+ }
+ }
+}
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
-
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.jboss.cache.Cache;
-
-/**
- * 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 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
+
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.jboss.cache.Cache;
+
+/**
+ * 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 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,242 +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.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-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;
-
-/**
- * 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 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 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
- final EvictionConfig evictionConfig = config.getEvictionConfig();
- 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,242 @@
+/*
+ * 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.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+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;
+
+/**
+ * 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 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 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
+ final EvictionConfig evictionConfig = config.getEvictionConfig();
+ 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
-
-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;
-
-/**
- * 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 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 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(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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
+
+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;
+
+/**
+ * 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 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 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(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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
-
-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;
-
-/**
- * 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 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 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
- {
-
- 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
+
+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;
+
+/**
+ * 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 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 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
+ {
+
+ 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
-
-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;
-
-/**
- * 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 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 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
- {
-
- 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
+
+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;
+
+/**
+ * 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 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 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
+ {
+
+ 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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
-
-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;
-
-/**
- * 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 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 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(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/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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 java.io.Serializable;
+
+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;
+
+/**
+ * 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 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 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(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/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/resources)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,33 +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>
- <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/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,33 @@
+<?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>
+ <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/mc-int-branch/exo.kernel.component.ext.cache/src/test (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,669 +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 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)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>()
- {
- 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");
- try
- {
- cache.putMap(values);
- assertTrue("An error was expected", false);
- }
- catch (Exception e)
- {
- }
- 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 selector = new CachedObjectSelector()
- {
-
- public void onSelect(ExoCache cache, Serializable key, ObjectCacheInfo 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 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);
- }
-
- public void testDistributedCache() throws Exception
- {
- 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 cache1 = (AbstractExoCache)factory.createCache(config);
- MyCacheListener listener1 = new MyCacheListener();
- cache1.addCacheListener(listener1);
- AbstractExoCache cache2 = (AbstractExoCache)factory.createCache(config);
- MyCacheListener listener2 = new MyCacheListener();
- cache2.addCacheListener(listener2);
- AbstractExoCache cache3 = (AbstractExoCache)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>()
- {
- 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");
- try
- {
- cache1.putMap(values);
- assertTrue("An error was expected", false);
- }
- catch (Exception e)
- {
- }
- 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
- {
- final ExoCache cache = service.getCacheInstance("test-multi-threading");
- final int totalElement = 100;
- final int totalTimes = 100;
- 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);
- }
- doneSignal.countDown();
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- }
- };
- 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);
- }
- doneSignal.countDown();
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- }
- };
- 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);
- }
- doneSignal.countDown();
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- }
- };
- 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);
- }
- doneSignal2.countDown();
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- }
- };
- 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();
- }
- doneSignal2.countDown();
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- }
- };
- thread.start();
- }
- cache.clearCache();
- assertEquals(0, cache.getCacheSize());
- if (!errors.isEmpty())
- {
- for (Exception e : errors)
- {
- e.printStackTrace();
- }
- throw errors.get(0);
- }
-
- }
-
- public static class MyCacheListener implements CacheListener
- {
-
- public int clearCache;
-
- public int expire;
-
- public int get;
-
- public int put;
-
- public int remove;
-
- public void onClearCache(ExoCache cache) throws Exception
- {
- clearCache++;
- }
-
- public void onExpire(ExoCache cache, Serializable key, Object obj) throws Exception
- {
- expire++;
- }
-
- public void onGet(ExoCache cache, Serializable key, Object obj) throws Exception
- {
- get++;
- }
-
- public void onPut(ExoCache cache, Serializable key, Object obj) throws Exception
- {
- put++;
- }
-
- public void onRemove(ExoCache 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
- {
- 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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,669 @@
+/*
+ * 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 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)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>()
+ {
+ 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");
+ try
+ {
+ cache.putMap(values);
+ assertTrue("An error was expected", false);
+ }
+ catch (Exception e)
+ {
+ }
+ 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 selector = new CachedObjectSelector()
+ {
+
+ public void onSelect(ExoCache cache, Serializable key, ObjectCacheInfo 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 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);
+ }
+
+ public void testDistributedCache() throws Exception
+ {
+ 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 cache1 = (AbstractExoCache)factory.createCache(config);
+ MyCacheListener listener1 = new MyCacheListener();
+ cache1.addCacheListener(listener1);
+ AbstractExoCache cache2 = (AbstractExoCache)factory.createCache(config);
+ MyCacheListener listener2 = new MyCacheListener();
+ cache2.addCacheListener(listener2);
+ AbstractExoCache cache3 = (AbstractExoCache)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>()
+ {
+ 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");
+ try
+ {
+ cache1.putMap(values);
+ assertTrue("An error was expected", false);
+ }
+ catch (Exception e)
+ {
+ }
+ 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
+ {
+ final ExoCache cache = service.getCacheInstance("test-multi-threading");
+ final int totalElement = 100;
+ final int totalTimes = 100;
+ 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);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ 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);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ 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);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ 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);
+ }
+ doneSignal2.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ 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();
+ }
+ doneSignal2.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ cache.clearCache();
+ assertEquals(0, cache.getCacheSize());
+ if (!errors.isEmpty())
+ {
+ for (Exception e : errors)
+ {
+ e.printStackTrace();
+ }
+ throw errors.get(0);
+ }
+
+ }
+
+ public static class MyCacheListener implements CacheListener
+ {
+
+ public int clearCache;
+
+ public int expire;
+
+ public int get;
+
+ public int put;
+
+ public int remove;
+
+ public void onClearCache(ExoCache cache) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(ExoCache 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
+ {
+ 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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf)
Copied: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal)
Deleted: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -1,180 +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>
-
- <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/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml (from rev 902, kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml)
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,180 @@
+<?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>
+
+ <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/mc-int-branch/exo.kernel.component.remote/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.remote/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.component.remote/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.remote</artifactId>
@@ -35,13 +35,20 @@
<dependencies>
<dependency>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
+ <artifactId>exo.kernel.commons</artifactId>
</dependency>
-
<dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- </dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: kernel/branches/mc-int-branch/exo.kernel.container/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.container/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.container</artifactId>
@@ -38,28 +38,23 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.commons</artifactId>
</dependency>
-
<dependency>
<groupId>org.exoplatform.tool</groupId>
<artifactId>exo.tool.framework.junit</artifactId>
<scope>compile</scope>
</dependency>
-
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
-
<dependency>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
</dependency>
-
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
-
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
@@ -70,7 +65,6 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-bind</artifactId>
@@ -81,12 +75,15 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-extras</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.4.O</version>
+ </dependency>
</dependencies>
<build>
@@ -120,4 +117,4 @@
-->
</plugins>
</build>
-</project>
+</project>
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel.demos</groupId>
<artifactId>demos-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.demos.mc-injection</artifactId>
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<groupId>org.exoplatform.kernel.demos</groupId>
Modified: kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.mc-int</artifactId>
@@ -19,51 +19,41 @@
<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>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
-
<dependency>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
</dependency>
-
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-kernel</artifactId>
</dependency>
-
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-aop-mc-int</artifactId>
</dependency>
-
<dependency>
<groupId>org.jboss.mc-int</groupId>
<artifactId>jboss-mc-int-common</artifactId>
</dependency>
-
<dependency>
<groupId>org.jboss.mc-int</groupId>
<artifactId>jboss-mc-int-servlet</artifactId>
</dependency>
-
<dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloader</artifactId>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.mc-kernel-extras</artifactId>
</dependency>
-
</dependencies>
</project>
Added: kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,23 @@
+
+<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.mc-kernel-extras</artifactId>
+
+ <name>eXo Kernel :: MC Kernel Extras</name>
+ <description>MC Kernel 2.2.0 classes that aren't available in mc-kernel 2.0.6.GA</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/helpers/StatelessController.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/helpers/StatelessController.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/main/java/org/jboss/dependency/plugins/helpers/StatelessController.java 2009-11-28 00:05:57 UTC (rev 903)
@@ -0,0 +1,167 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.dependency.plugins.helpers;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.event.KernelEventFilter;
+import org.jboss.kernel.spi.event.KernelEventListener;
+
+import java.util.Set;
+
+/**
+ * Stateless controller.
+ *
+ * @author <a href="ales.justin(a)jboss.com">Ales Justin</a>
+ */
+public class StatelessController extends AbstractController implements KernelController
+{
+ private KernelController controller;
+
+ public StatelessController(KernelController controller)
+ {
+ if (controller == null)
+ throw new IllegalArgumentException("Null controller");
+
+ this.controller = controller;
+ for (ControllerState state : controller.getStates())
+ addState(state, null);
+ }
+
+ public void enableOnDemand(ControllerContext context) throws Throwable
+ {
+ // ignore
+ }
+
+ @Override
+ protected void registerControllerContext(ControllerContext context)
+ {
+ // do nothing
+ }
+
+ @Override
+ public void install(ControllerContext context) throws Throwable
+ {
+ super.install(context);
+ }
+
+ public ControllerContext uninstall(Object name)
+ {
+ return null;
+ }
+
+ public ControllerContext getContext(Object name, ControllerState state)
+ {
+ return controller.getContext(name, state);
+ }
+
+ public ControllerContext getInstalledContext(Object name)
+ {
+ return controller.getInstalledContext(name);
+ }
+
+ public boolean isShutdown()
+ {
+ return controller.isShutdown();
+ }
+
+ public void shutdown()
+ {
+ }
+
+ public Kernel getKernel()
+ {
+ return controller.getKernel();
+ }
+
+ public void setKernel(Kernel kernel) throws Throwable
+ {
+ controller.setKernel(kernel);
+ }
+
+ public KernelControllerContext install(BeanMetaData metaData) throws Throwable
+ {
+ return controller.install(metaData);
+ }
+
+ public KernelControllerContext install(BeanMetaData metaData, Object target) throws Throwable
+ {
+ return controller.install(metaData, target);
+ }
+
+ public void addSupplies(KernelControllerContext context)
+ {
+ controller.addSupplies(context);
+ }
+
+ public void removeSupplies(KernelControllerContext context)
+ {
+ controller.removeSupplies(context);
+ }
+
+ public Set<KernelControllerContext> getInstantiatedContexts(Class<?> clazz)
+ {
+ return controller.getInstantiatedContexts(clazz);
+ }
+
+ public Set<KernelControllerContext> getContexts(Class<?> clazz, ControllerState state)
+ {
+ return controller.getContexts(clazz, state);
+ }
+
+ public KernelControllerContext getContextByClass(Class<?> clazz)
+ {
+ return controller.getContextByClass(clazz);
+ }
+
+ public void addInstantiatedContext(KernelControllerContext context)
+ {
+ controller.addInstantiatedContext(context);
+ }
+
+ public void removeInstantiatedContext(KernelControllerContext context)
+ {
+ controller.removeInstantiatedContext(context);
+ }
+
+ public void registerListener(KernelEventListener listener, KernelEventFilter filter, Object handback) throws Throwable
+ {
+ controller.registerListener(listener, filter, handback);
+ }
+
+ public void unregisterListener(KernelEventListener listener, KernelEventFilter filter, Object handback) throws Throwable
+ {
+ controller.unregisterListener(listener, filter, handback);
+ }
+
+ public void fireKernelEvent(KernelEvent event)
+ {
+ controller.fireKernelEvent(event);
+ }
+}
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel.tests</groupId>
<artifactId>tests-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.integration-tests</artifactId>
Modified: kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<groupId>org.exoplatform.kernel.tests</groupId>
Modified: kernel/branches/mc-int-branch/packaging/module/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/packaging/module/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/packaging/module/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: kernel/branches/mc-int-branch/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
+++ kernel/branches/mc-int-branch/pom.xml 2009-11-28 00:05:57 UTC (rev 903)
@@ -18,7 +18,8 @@
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<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">
+<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>
@@ -30,7 +31,7 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta04-SNAPSHOT</version>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
<packaging>pom</packaging>
<name>eXo Kernel</name>
@@ -56,222 +57,213 @@
<module>exo.kernel.component.common</module>
<module>exo.kernel.component.remote</module>
<module>exo.kernel.component.cache</module>
+ <!--module>exo.kernel.component.ext.cache</module-->
<module>exo.kernel.component.command</module>
<module>exo.kernel.mc-int</module>
<module>exo.kernel.mc-kernel-extras</module>
<module>exo.kernel.demos</module>
- <module>exo.kernel.tests</module>
+ <module>exo.kernel.tests</module>
<module>packaging/module</module>
</modules>
<dependencyManagement>
<dependencies>
-
<dependency>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.container</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.commons</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
+ <artifactId>exo.kernel.component.remote</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.remote</artifactId>
+ <artifactId>exo.kernel.component.cache</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.mc-int</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.mc-kernel-extras</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel.demos</groupId>
<artifactId>exo.kernel.demos.mc-injection</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.exoplatform.tool</groupId>
<artifactId>exo.tool.framework.junit</artifactId>
<version>1.2.0</version>
</dependency>
-
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
-
<dependency>
<groupId>commons-chain</groupId>
<artifactId>commons-chain</artifactId>
<version>1.0</version>
</dependency>
-
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.4.O</version>
</dependency>
-
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
-
<dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- <version>2.6.10.GA</version>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.6</version>
</dependency>
-
<dependency>
+ <groupId>commons-chain</groupId>
+ <artifactId>commons-chain</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.6</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
-
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
-
<dependency>
- <groupId>picocontainer</groupId>
- <artifactId>picocontainer</artifactId>
- <version>1.1</version>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>1.0.b2</version>
</dependency>
-
<dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.6</version>
+ <groupId>quartz</groupId>
+ <artifactId>quartz</artifactId>
+ <version>1.5.0-RC2</version>
</dependency>
-
<dependency>
- <groupId>org.jibx</groupId>
- <artifactId>jibx-run</artifactId>
- <version>${jibx.plugin.version}</version>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
</dependency>
-
<dependency>
- <groupId>org.jibx</groupId>
- <artifactId>jibx-bind</artifactId>
- <version>${jibx.plugin.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jibx</groupId>
- <artifactId>jibx-extras</artifactId>
- <version>${jibx.plugin.version}</version>
- </dependency>
-
- <dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
-
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<version>1.5</version>
</dependency>
-
<dependency>
- <groupId>jotm</groupId>
- <artifactId>jotm</artifactId>
- <version>2.0.10</version>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.0.1B</version>
</dependency>
-
<dependency>
- <groupId>quartz</groupId>
- <artifactId>quartz</artifactId>
- <version>1.5.0-RC2</version>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ <version>1.1</version>
</dependency>
-
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4</version>
- </dependency>
-
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
-
<dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <version>1.0.1B</version>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <version>2.6.12.GA</version>
</dependency>
-
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-dependency</artifactId>
<version>${org.jboss.mc}</version>
</dependency>
-
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-kernel</artifactId>
<version>${org.jboss.mc}</version>
</dependency>
-
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-aop-mc-int</artifactId>
<version>${org.jboss.mc}</version>
</dependency>
-
<dependency>
<groupId>org.jboss.mc-int</groupId>
<artifactId>jboss-mc-int-common</artifactId>
<version>${org.jboss.mc-int}</version>
</dependency>
-
<dependency>
<groupId>org.jboss.mc-int</groupId>
<artifactId>jboss-mc-int-servlet</artifactId>
<version>${org.jboss.mc-int}</version>
</dependency>
-
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloader</artifactId>
- <version>${version.jboss.classloader}</version>
- </dependency>
-
+ <dependency>
+ <groupId>org.jboss.cl</groupId>
+ <artifactId>jboss-classloader</artifactId>
+ <version>${version.jboss.classloader}</version>
+ </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>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-extras</artifactId>
+ <version>${jibx.plugin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-run</artifactId>
+ <version>${jibx.plugin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jotm</groupId>
+ <artifactId>jotm</artifactId>
+ <version>2.0.10</version>
+ </dependency>
</dependencies>
</dependencyManagement>
14 years, 5 months
exo-jcr SVN: r902 - in kernel/branches/mc-int-branch: exo.kernel.container and 35 other directories.
by do-not-reply@jboss.org
Author: mstruk
Date: 2009-11-27 18:21:52 -0500 (Fri, 27 Nov 2009)
New Revision: 902
Added:
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/AOPInterceptor.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/MissingNoArgsConstructorBean.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/PrivateNoArgsConstructorBean.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/ProtectedNoArgsConstructorBean.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-beans.xml
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml
kernel/branches/mc-int-branch/exo.kernel.mc-int/
kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/GenericWrapperUtil.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/InterceptMC.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/JavassistAOPClassLoader.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentAdapter.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentInfo.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInjectionMode.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntConfig.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntegrationImpl.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInterceptProxy.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/RootContainerVDFDecoratorInjector.java
kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/WrapperMethodComposer.java
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/
kernel/branches/mc-int-branch/exo.kernel.tests/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest2.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest3.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest4.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest5.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/JUnitInvokerServlet.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/LogOutputStream.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/TeeOutputStream.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/WEB-INF/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/WEB-INF/web.xml
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/CopiedException.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/FailuresParser.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/LineReader.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration2.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration3.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration4.java
kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration5.java
kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml
Removed:
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/GenericWrapperUtil.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/InterceptMC.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/JavassistAOPClassLoader.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentAdapter.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentInfo.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInjectionMode.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInterceptProxy.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/WrapperMethodComposer.java
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml
kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/src/
kernel/branches/mc-int-branch/org.jboss.mc-kernel-extras/
Modified:
kernel/branches/mc-int-branch/exo.kernel.container/pom.xml
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegration.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationContainer.java
kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/util/JBossEnv.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectedBean.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectingBean.java
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/META-INF/jboss-beans.xml
kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/configuration.xml
kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml
kernel/branches/mc-int-branch/pom.xml
Log:
Removed mc-kernel artifact dependencies from exo.kernel.container - moved integration impl code to exo.kernel.mc-int module, AOP demo, integration tests
Modified: kernel/branches/mc-int-branch/exo.kernel.container/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/pom.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -86,32 +86,7 @@
<groupId>org.jibx</groupId>
<artifactId>jibx-extras</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-aop-mc-int</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.mc-int</groupId>
- <artifactId>jboss-mc-int-common</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.mc-int</groupId>
- <artifactId>jboss-mc-int-servlet</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloader</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>mc-kernel-extras</artifactId>
- </dependency>
-
+
</dependencies>
<build>
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/GenericWrapperUtil.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/GenericWrapperUtil.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/GenericWrapperUtil.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,165 +0,0 @@
-package org.exoplatform.container.mc;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtMethod;
-import javassist.CtNewMethod;
-import javassist.LoaderClassPath;
-import javassist.Modifier;
-import javassist.NotFoundException;
-import javassist.bytecode.AnnotationsAttribute;
-import javassist.bytecode.ClassFile;
-import javassist.bytecode.ConstPool;
-import javassist.bytecode.MethodInfo;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.mc.common.ThreadLocalUtils;
-import org.jboss.virtual.MemoryFileFactory;
-import org.jboss.virtual.VirtualFile;
-
-import java.net.URL;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author <a href="mailto:ajustin@redhat.com">Ales Justin</a>
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-final class GenericWrapperUtil
-{
- private static AtomicInteger counter = new AtomicInteger(0);
-
- static MCComponentInfo generateAndInstallWrapper(Object instance) throws Exception
- {
- ClassPool pool = ClassPool.getDefault();
- pool.insertClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));
-
- CtClass cc = pool.get(MCInterceptProxy.class.getName());
- CtClass pc = pool.get(instance.getClass().getName());
-
- zeroArgConstructorCheck(pc, instance);
-
- cc.setSuperclass(pc);
- cc.setName(getPackage(cc.getName()) + ".MCInterceptProxy$" + counter.getAndIncrement());
- WrapperMethodComposer composer = new WrapperMethodComposer(MCInterceptProxy.DELEGATE, pc.getName());
-
- ClassFile cf = cc.getClassFile();
- AnnotationsAttribute attr = setAnnotations(pc.getClassFile().getAttributes(), cf.getConstPool());
- if (attr != null)
- cf.addAttribute(attr);
- cf.setVersionToJava5();
-
- for (CtMethod m : pc.getMethods())
- {
- if (isMethodOverridable(m))
- {
- CtMethod method = CtNewMethod.make(composer.composeMethod(m), cc);
- MethodInfo minf = method.getMethodInfo();
- attr = setAnnotations(m.getMethodInfo().getAttributes(), minf.getConstPool());
- if (attr != null)
- minf.addAttribute(attr);
- cc.addMethod(method);
- }
- }
-
- installWrapper(cc);
-
- MCComponentInfo mcinf = new MCComponentInfo(cc.getName(),
- new JavassistAOPClassLoader(Thread.currentThread().getContextClassLoader(), cc.getClassPool()));
- Thread.currentThread().setContextClassLoader(mcinf.getClassLoader()); // TODO: ensure symetry - reset old CL when done
- return mcinf;
- }
-
- private static AnnotationsAttribute setAnnotations(List attrs, ConstPool cpool)
- {
- AnnotationsAttribute attr = new AnnotationsAttribute(cpool, AnnotationsAttribute.visibleTag);
- for (Object a : attrs)
- {
- if (a instanceof AnnotationsAttribute)
- {
- AnnotationsAttribute aa = (AnnotationsAttribute) a;
- if (AnnotationsAttribute.visibleTag.equals(aa.getName()) == false)
- continue;
- attr.setAnnotations(aa.getAnnotations());
- return attr;
- }
- }
- return null;
- }
-
- private static String getPackage(String name)
- {
- return name.substring(0, name.lastIndexOf("."));
- }
-
- private static void installWrapper(CtClass cc) throws Exception
- {
- // This is to make classloading work with jboss-aop and mc-classloading
- // - third-party (Tomcat) can be enabled through context classloader
- DeploymentUnit unit = ThreadLocalUtils.getUnit();
- String host = getVFSMemoryHost(unit);
- if (host != null)
- {
- URL vfsUrl = new URL("vfsmemory://" + host + "/" + getResourcePath(cc.getName()));
- MemoryFileFactory.putFile(vfsUrl, cc.toBytecode());
- return;
- }
- }
-
- static void postInstallCleanup()
- {
- // TODO: symmetry not 100% assured here
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl instanceof JavassistAOPClassLoader)
- Thread.currentThread().setContextClassLoader(cl.getParent());
- }
-
- private static String getResourcePath(String name)
- {
- return name.replace(".", "/") + ".class";
- }
-
- private static String getVFSMemoryHost(DeploymentUnit unit) throws Exception
- {
- if (unit instanceof AbstractVFSDeploymentUnit)
- {
- List<VirtualFile> classPath = ((AbstractVFSDeploymentUnit) unit).getClassPath();
- for (VirtualFile vf : classPath)
- {
- URL url = vf.toURL();
- if ("vfsmemory".equals(url.getProtocol()))
- {
- return url.getHost();
- }
- }
- return getVFSMemoryHost(unit.getParent());
- }
-
- return null;
- }
-
- private static boolean isMethodOverridable(CtMethod m)
- {
- return (m.getModifiers() & Modifier.FINAL) == 0
- && !"clone".equals(m.getName())
- && !"finalize".equals(m.getName());
- }
-
- private static void zeroArgConstructorCheck(CtClass pc, Object c)
- throws NotFoundException
- {
- CtConstructor[] ctors = pc.getConstructors();
- boolean found = false;
- for (CtConstructor cons : ctors)
- {
- if (cons.getParameterTypes().length == 0)
- {
- found = true;
- break;
- }
- }
- if (!found)
- throw new RuntimeException("Class can not be AOP instrumented - it has no zero-arguments public constructor: " + c.getClass());
- }
-}
\ No newline at end of file
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/InterceptMC.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/InterceptMC.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/InterceptMC.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,31 +0,0 @@
-package org.exoplatform.container.mc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks Gatein MC enabled component.
- *
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- * @author <a href="mailto:ales.justin@redhat.com">Ales Justin</a>
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target({ElementType.TYPE})
-public @interface InterceptMC
-{
- /**
- * Do we enable AOP for this component.
- *
- * @return true if we should enable AOP, false otherwise
- */
- boolean enableAOP() default false;
-
- /**
- * Injection mode
- *
- * @return MCInjectionMode enumeration constant representing injection mode
- */
- MCInjectionMode injectionMode() default MCInjectionMode.STANDARD;
-}
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/JavassistAOPClassLoader.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/JavassistAOPClassLoader.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/JavassistAOPClassLoader.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,61 +0,0 @@
-package org.exoplatform.container.mc;
-
-import javassist.Loader;
-import javassist.ClassPool;
-
-/**
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class JavassistAOPClassLoader extends Loader
-{
- public JavassistAOPClassLoader()
- {
- }
-
- public JavassistAOPClassLoader(ClassPool cp)
- {
- super(cp);
- }
-
- public JavassistAOPClassLoader(ClassLoader parent, ClassPool cp)
- {
- super(parent, cp);
- }
-
- @Override
- protected Class loadClassByDelegation(String name) throws ClassNotFoundException
- {
- if (name.startsWith("org.jboss.aop."))
- return delegateToParent(name);
-
- return super.loadClassByDelegation(name);
- }
-
- protected Class loadClass(String name, boolean resolve)
- throws ClassFormatError, ClassNotFoundException
- {
- name = name.intern();
- synchronized (name)
- {
- Class c = findLoadedClass(name);
- if (c == null)
- {
- try
- {
- c = delegateToParent(name);
- }
- catch (ClassNotFoundException ignored)
- {
- }
- }
-
- if (c == null)
- c = findClass(name);
-
- if (resolve)
- resolveClass(c);
-
- return c;
- }
- }
-}
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentAdapter.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentAdapter.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentAdapter.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,142 +0,0 @@
-package org.exoplatform.container.mc;
-
-import java.lang.ref.WeakReference;
-
-import org.jboss.beans.info.spi.BeanAccessMode;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.dependency.plugins.helpers.StatelessController;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.picocontainer.ComponentAdapter;
-import org.picocontainer.PicoContainer;
-import org.picocontainer.PicoInitializationException;
-import org.picocontainer.PicoIntrospectionException;
-import org.picocontainer.PicoVisitor;
-
-/**
- * @author <a href="mailto:ajustin@redhat.com">Ales Justin</a>
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class MCComponentAdapter implements ComponentAdapter
-{
- private KernelController controller;
- private ComponentAdapter delegate;
- private InterceptMC interceptMC;
- private WeakReference<Object> lastComponentInstance;
-
- public MCComponentAdapter(KernelController controller, ComponentAdapter delegate, InterceptMC interceptMC)
- {
- if (controller == null)
- throw new IllegalArgumentException("Null controller");
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
-
- if (controller instanceof StatelessController)
- throw new IllegalArgumentException("controller is instanceof StatelessController");
-
- this.controller = controller;
- this.delegate = delegate;
- this.interceptMC = interceptMC;
- }
-
- public Object getComponentKey()
- {
- return delegate.getComponentKey();
- }
-
- public Class getComponentImplementation()
- {
- return delegate.getComponentImplementation();
- }
-
- public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException
- {
- Object target = getTargetFromRef();
- if (target != null)
- return target;
-
- try
- {
- String key = delegate.getComponentKey().toString();
- Object instance = delegate.getComponentInstance(container);
- BeanMetaDataBuilder builder;
- if (interceptMC != null && interceptMC.enableAOP())
- {
- MCComponentInfo mcinfo = GenericWrapperUtil.generateAndInstallWrapper(instance);
- builder = BeanMetaDataBuilder.createBuilder(key, mcinfo.getWrapperClassName());
- builder.addConstructorParameter(Object.class.getName(), instance);
- }
- else
- {
- builder = BeanMetaDataBuilder.createBuilder(key, instance.getClass().getName());
- builder.setConstructorValue(instance);
- }
- builder.ignoreCreate();
- builder.ignoreStart();
- builder.ignoreStop();
- builder.ignoreDestroy();
- builder.setAccessMode(getInjectionMode(interceptMC));
-
- KernelControllerContext ctx = new AbstractKernelControllerContext(null, builder.getBeanMetaData(), null);
- try
- {
- StatelessController ctrl = new StatelessController(controller);
- ctrl.install(ctx);
- if (ctx.getError() != null)
- throw ctx.getError();
- if (ctrl.getStates().isBeforeState(ctx.getState(), ControllerState.INSTALLED))
- throw new IllegalArgumentException("Missing some dependency: " + ctx.getDependencyInfo().getUnresolvedDependencies(null));
-
- target = ctx.getTarget();
- lastComponentInstance = new WeakReference<Object>(target);
- return target;
- }
- finally
- {
- GenericWrapperUtil.postInstallCleanup();
- }
- }
- catch (Throwable ex)
- {
- throw new RuntimeException("Failed to perform MC interception on component: " + delegate.getComponentImplementation(), ex);
- }
- }
-
- private BeanAccessMode getInjectionMode(InterceptMC interceptMC)
- {
- MCInjectionMode mode = interceptMC.injectionMode();
-
- switch(mode)
- {
- case ALL:
- return BeanAccessMode.ALL;
- case FIELDS:
- return BeanAccessMode.FIELDS;
- default:
- return BeanAccessMode.STANDARD;
- }
- }
-
- public void verify(PicoContainer container) throws PicoIntrospectionException
- {
- delegate.verify(container);
- }
-
- public void accept(PicoVisitor visitor)
- {
- delegate.accept(visitor);
- }
-
- private Object getTargetFromRef()
- {
- if (lastComponentInstance == null)
- return null;
-
- Object target = lastComponentInstance.get();
- if (target == null)
- return null;
- return target;
- }
-}
\ No newline at end of file
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentInfo.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentInfo.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCComponentInfo.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,26 +0,0 @@
-package org.exoplatform.container.mc;
-
-/**
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class MCComponentInfo
-{
- private String name;
- private ClassLoader classLoader;
-
- public MCComponentInfo(String wrapperClassName, ClassLoader classLoader)
- {
- this.name = wrapperClassName;
- this.classLoader = classLoader;
- }
-
- public String getWrapperClassName()
- {
- return name;
- }
-
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-}
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInjectionMode.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInjectionMode.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInjectionMode.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,16 +0,0 @@
-package org.exoplatform.container.mc;
-
-/**
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public enum MCInjectionMode
-{
- /** Field and method injections */
- ALL,
-
- /** Disable field injections (default) */
- FIELDS,
-
- /** Try setter injection first, if no setter found, fallback to field */
- STANDARD
-}
Modified: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegration.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegration.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegration.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,95 +1,16 @@
package org.exoplatform.container.mc;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.dependency.AbstractKernelController;
-import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.mc.common.ThreadLocalUtils;
import org.picocontainer.ComponentAdapter;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
+import javax.servlet.ServletContext;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
-public class MCIntegration
+public interface MCIntegration
{
- private static Log log = ExoLogger.getLogger(MCIntegration.class);
- private static MCIntegration mcint;
-
- private AbstractKernelController rootController;
- private List<KernelDeployment> deployments = new LinkedList<KernelDeployment>();
-
- public synchronized static MCIntegration getInstance()
- {
- if (mcint == null)
- mcint = new MCIntegration();
- return mcint;
- }
-
- public synchronized AbstractKernelController getRootController()
- {
- if (rootController == null)
- {
- Kernel kernel = ThreadLocalUtils.getKernel();
- if (kernel != null)
- {
- rootController = (AbstractKernelController) kernel.getController();
- }
- else
- {
- log.warn("GateIn - MC integration not available");
- return null;
- }
- processDeployments();
- }
- return rootController;
- }
-
- private void processDeployments()
- {
- // Now deploy any AOP configuration - instantiates lifecycle callbacks
- BasicXMLDeployer deployer = new BasicXMLDeployer(rootController.getKernel());
- Enumeration<URL> urls = null;
- try
- {
- urls = Thread.currentThread().getContextClassLoader().getResources("conf/mc-beans.xml");
- }
- catch (IOException e)
- {
- throw new RuntimeException("Failed to load resources: conf/mc-beans.xml", e);
- }
-
- while (urls.hasMoreElements())
- {
- URL confUrl = urls.nextElement();
- try
- {
- deployments.add(deployer.deploy(confUrl));
- }
- catch (Throwable ex)
- {
- throw new RuntimeException("Failed to deploy: " + confUrl, ex);
- }
- }
-
- if (deployments.size() == 0)
- {
- log.debug("No conf/mc-beans.xml found. MC integration disabled.");
- }
- }
-
- public ComponentAdapter getMCAdapter(ComponentAdapter adapter, InterceptMC interceptAnnotation)
- {
- AbstractKernelController controller = getRootController();
- if (controller != null)
- adapter = new MCComponentAdapter(controller, adapter, interceptAnnotation);
- return adapter;
- }
+ ComponentAdapter getMCAdapter(ComponentAdapter componentAdapter);
+ boolean hasMCKernel(ComponentAdapter adapter);
+ void initThreadCtx(ServletContext ctx);
+ void resetThreadCtx(ServletContext ctx);
}
Modified: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationContainer.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationContainer.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationContainer.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -7,9 +7,6 @@
import org.picocontainer.defaults.ComponentAdapterFactory;
import org.picocontainer.defaults.DefaultPicoContainer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
@@ -38,17 +35,20 @@
public ComponentAdapter registerComponent(ComponentAdapter componentAdapter)
{
- Class<?> clazz = componentAdapter.getComponentImplementation();
- InterceptMC interceptAnnotation = clazz.getAnnotation(InterceptMC.class);
-
ComponentAdapter adapter = componentAdapter;
- if (interceptAnnotation != null)
+ if (hasMCKernel(componentAdapter))
{
- if (hasMCKernel(componentAdapter))
+ try
{
- adapter = MCIntegration.getInstance().getMCAdapter(componentAdapter, interceptAnnotation);
+ adapter = MCIntegrationInvoker.getMCAdapter(componentAdapter);
}
+ catch(Exception ignored)
+ {
+ log.warn("MC integration failed - maybe not supported in this environment (component: "
+ + componentAdapter.getComponentKey() + ")", ignored);
+ }
}
+
super.registerComponent(adapter);
return adapter;
}
@@ -57,39 +57,13 @@
{
try
{
- Class tlu = null;
- String name = "org.jboss.mc.common.ThreadLocalUtils";
- try
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl != null)
- tlu = cl.loadClass(name);
- }
- catch (ClassNotFoundException ignored)
- {
- tlu = Class.forName(name);
- }
-
- Method m = tlu.getMethod("getKernel");
- Object ret = m.invoke(null);
- return ret != null;
+ return MCIntegrationInvoker.hasMCKernel(componentAdapter);
}
- catch (ClassNotFoundException ignored)
+ catch (Exception ignored)
{
- log.warn("@InterceptMC not supported in this environment (component: " + componentAdapter.getComponentKey() + ") - necessary classes are missing: " + ignored);
- return false;
+ log.warn("MC integration failed - maybe not supported in this environment (component: "
+ + componentAdapter.getComponentKey() + ")", ignored);
}
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException(e);
- }
- catch (InvocationTargetException e)
- {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException(e);
- }
+ return false;
}
}
Added: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCIntegrationInvoker.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,106 @@
+package org.exoplatform.container.mc;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.picocontainer.ComponentAdapter;
+
+import javax.servlet.ServletContext;
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCIntegrationInvoker
+{
+ private static Log log = ExoLogger.getLogger(MCIntegrationInvoker.class);
+
+ private static MCIntegration mcInt;
+ private static boolean permFailure;
+
+ public static synchronized ComponentAdapter getMCAdapter(ComponentAdapter componentAdapter)
+ {
+ MCIntegration mcInt = getMCIntegration();
+ if (mcInt == null)
+ {
+ return componentAdapter;
+ }
+
+ return mcInt.getMCAdapter(componentAdapter);
+ }
+
+ public static synchronized boolean hasMCKernel(ComponentAdapter adapter)
+ {
+ MCIntegration mcInt = getMCIntegration();
+ if (mcInt == null)
+ {
+ return false;
+ }
+ return mcInt.hasMCKernel(adapter);
+ }
+
+ public static synchronized void initThreadCtx(ServletContext ctx)
+ {
+ MCIntegration mcInt = getMCIntegration();
+ if (mcInt == null)
+ {
+ return;
+ }
+ mcInt.initThreadCtx(ctx);
+ }
+
+ public static synchronized void resetThreadCtx(ServletContext ctx)
+ {
+ MCIntegration mcInt = getMCIntegration();
+ if (mcInt == null)
+ {
+ return;
+ }
+ mcInt.resetThreadCtx(ctx);
+ }
+
+ private static MCIntegration getMCIntegration()
+ {
+ if (mcInt == null && permFailure == false)
+ {
+ Class clazz = null;
+ try
+ {
+ clazz = loadClass("org.exoplatform.container.mc.impl.MCIntegrationImpl");
+ Method m = clazz.getMethod("getInstance");
+ mcInt = (MCIntegration) m.invoke(null);
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ permFailure = true;
+ log.info("MC integration not available in this environment (missing class: "
+ + ignored.getMessage() + ")");
+
+ return null;
+ }
+ catch (Exception e)
+ {
+ permFailure = true;
+ throw new RuntimeException("MC Integration initialization error", e);
+ }
+ }
+ return mcInt;
+ }
+
+ static Class loadClass(String name) throws ClassNotFoundException
+ {
+ Class clazz = null;
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ {
+ clazz = cl.loadClass(name);
+ }
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ clazz = Class.forName(name);
+ }
+ return clazz;
+ }
+}
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInterceptProxy.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInterceptProxy.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/MCInterceptProxy.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,16 +0,0 @@
-package org.exoplatform.container.mc;
-
-/**
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class MCInterceptProxy
-{
- public static final String DELEGATE = "__delegate";
- private Object __delegate;
-
- public MCInterceptProxy(Object delegate)
- {
- this.__delegate = delegate;
- System.out.println("MCInterceptProxy<init> - CL: " + delegate.getClass().getClassLoader());
- }
-}
Deleted: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/WrapperMethodComposer.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/WrapperMethodComposer.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/mc/WrapperMethodComposer.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,126 +0,0 @@
-package org.exoplatform.container.mc;
-
-import javassist.CtClass;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-import javassist.bytecode.AccessFlag;
-
-/**
- * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
- */
-public class WrapperMethodComposer
-{
- private String delegate;
- private String type;
-
- public WrapperMethodComposer(String delegateFldName, String type)
- {
- delegate = delegateFldName;
- this.type = type;
- }
-
- public String composeMethod(CtMethod method) throws NotFoundException
- {
- StringBuilder sb = new StringBuilder();
-
- String next = addModifiers(method.getModifiers());
- sb.append(next);
- if (next.length() > 0)
- sb.append(" ");
-
- CtClass ret = method.getReturnType();
- next = addReturnType(ret);
- sb.append(next).append(" ");
-
- sb.append(method.getName()).append("(");
- next = addParams(method.getParameterTypes());
- sb.append(next);
- sb.append(") ");
-
- next = addExceptions(method.getExceptionTypes());
- sb.append(next);
- if (next.length() > 0)
- sb.append(" ");
-
- sb.append("{ ");
- sb.append(delegateCall(method.getName(), method.getParameterTypes(), method.getReturnType()));
- sb.append("}");
-
- return sb.toString();
- }
-
- private String delegateCall(String name, CtClass[] parameterTypes, CtClass returnType)
- {
- StringBuilder sb = new StringBuilder();
- if (returnType != null)
- sb.append("return ");
- sb.append("((").append(type).append(")");
- sb.append(delegate).append(")").append(".").append(name).append("(");
- for (int i = 0; i < parameterTypes.length; i++)
- {
- if (i > 0)
- sb.append(",");
- sb.append("a").append(i);
- }
- sb.append(");");
-
- if (returnType == null)
- sb.append("return;");
-
- return sb.toString();
- }
-
-
- private String addParams(CtClass[] parameterTypes)
- {
- if (parameterTypes == null || parameterTypes.length == 0)
- return "";
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < parameterTypes.length; i++)
- {
- if (i > 0)
- sb.append(",");
- sb.append(parameterTypes[i].getName()).append(" a").append(i);
- }
- return sb.toString();
- }
-
- private String addExceptions(CtClass[] exceptionTypes)
- {
- StringBuilder ret = new StringBuilder();
- if (exceptionTypes == null || exceptionTypes.length == 0)
- return "";
-
- ret.append("throws ");
- for (int i = 0; i < exceptionTypes.length; i++)
- {
- if (i > 0)
- ret.append(",");
- ret.append(exceptionTypes[i].getName());
- }
- return ret.toString();
- }
-
- private String addReturnType(CtClass ret)
- {
- if (ret == null)
- return "void";
- else
- return ret.getName();
- }
-
- private String addModifiers(int modifiers)
- {
- if (AccessFlag.isPackage(modifiers))
- return "";
- else if (AccessFlag.isPrivate(modifiers))
- return "private";
- else if (AccessFlag.isPublic(modifiers))
- return "public";
- else if (AccessFlag.isProtected(modifiers))
- return "protected";
- else
- throw new RuntimeException("Invalid modifiers: " + modifiers);
- }
-}
Modified: kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/util/JBossEnv.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/util/JBossEnv.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.container/src/main/java/org/exoplatform/container/util/JBossEnv.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,10 +1,8 @@
package org.exoplatform.container.util;
import javax.servlet.ServletContext;
+import org.exoplatform.container.mc.MCIntegrationInvoker;
-import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
-import org.jboss.mc.servlet.vdf.api.VDFThreadLocalUtils;
-
/**
* This class makes env specific thread context inits when GateIn runs inside JBossAS or MC
*
@@ -12,6 +10,9 @@
*/
public class JBossEnv
{
+ /** This value is equal to org.jboss.kernel.plugins.bootstrap.basic.KernelConstants.KERNEL_NAME */
+ private static final String MC_KERNEL_NAME = "jboss.kernel:service=Kernel";
+
/**
* Check if MC Kernel is available
*
@@ -20,7 +21,7 @@
*/
public static boolean isAvailable(ServletContext ctx)
{
- return ctx.getAttribute(KernelConstants.KERNEL_NAME) != null;
+ return ctx.getAttribute(MC_KERNEL_NAME) != null;
}
/**
@@ -30,7 +31,7 @@
*/
public static void initThreadEnv(ServletContext ctx)
{
- org.jboss.mc.servlet.vdf.api.VDFThreadLocalUtils.init(ctx);
+ MCIntegrationInvoker.initThreadCtx(ctx);
}
/**
@@ -40,6 +41,6 @@
*/
public static void cleanupThreadEnv(ServletContext ctx)
{
- org.jboss.mc.servlet.vdf.api.VDFThreadLocalUtils.reset();
+ MCIntegrationInvoker.resetThreadCtx(ctx);
}
}
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -4,19 +4,23 @@
<parent>
<groupId>org.exoplatform.kernel.demos</groupId>
- <artifactId>exo.kernel.demos</artifactId>
+ <artifactId>demos-parent</artifactId>
<version>2.2.0-Beta04-SNAPSHOT</version>
</parent>
- <artifactId>exo.mc-int.mc-injection</artifactId>
+ <artifactId>exo.kernel.demos.mc-injection</artifactId>
- <name>eXo Kernel Demo - MC Injection</name>
+ <name>eXo Kernel :: Demos :: MC Injection</name>
<description>MC Integration Demo - MC Injection</description>
<dependencies>
<dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
+ <artifactId>exo.kernel.mc-int</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/AOPInterceptor.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/AOPInterceptor.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/AOPInterceptor.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,52 @@
+package org.exoplatform.kernel.demos.mc;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.proxy.container.ContainerProxyMethodInvocation;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class AOPInterceptor implements Interceptor
+{
+ private static Log log = ExoLogger.getLogger(AOPInterceptor.class);
+ private static LinkedList<Invocation> invocations = new LinkedList<Invocation>();
+
+ public String getName()
+ {
+ return getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ StringBuilder sb = new StringBuilder();
+ if (invocation instanceof ContainerProxyMethodInvocation)
+ {
+ ContainerProxyMethodInvocation methodInvocation = (ContainerProxyMethodInvocation) invocation;
+ sb.append("Method: " + methodInvocation.getActualMethod().getName());
+ sb.append(", Args:\n");
+ Object[] args = methodInvocation.getArguments();
+ for (int i = 0; i < args.length; i++)
+ {
+ sb.append(" " + i + ") " + args[i] + "\n");
+ }
+ }
+ else
+ {
+ sb.append(invocation);
+ }
+ log.info("Interceptor: " + this + ", Target object: " + invocation.getTargetObject() + ", " + sb);
+ invocations.add(invocation);
+ return invocation.invokeNext();
+ }
+
+ public static List<Invocation> getInvocations()
+ {
+ return invocations;
+ }
+}
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectedBean.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectedBean.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectedBean.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,14 +1,17 @@
package org.exoplatform.kernel.demos.mc;
-import org.jboss.logging.Logger;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
public class InjectedBean
{
- private static final Logger log = Logger.getLogger(InjectedBean.class);
+ private static final Log log = ExoLogger.getLogger(InjectedBean.class);
+ public static final String SOME_PROPERTY_VALUE = "[This is some property value]";
+
//static
//{
// System.out.println("InjectedBean class loaded !!!");
@@ -21,7 +24,7 @@
public String getSomeString()
{
- return "[This is some property value]";
+ return SOME_PROPERTY_VALUE;
}
public void start()
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectingBean.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectingBean.java 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/InjectingBean.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,7 +1,9 @@
package org.exoplatform.kernel.demos.mc;
-import org.exoplatform.container.mc.InterceptMC;
-import org.exoplatform.container.mc.MCInjectionMode;
+import org.exoplatform.container.mc.impl.InterceptMC;
+import org.exoplatform.container.mc.impl.MCInjectionMode;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.jboss.beans.metadata.api.annotations.EntryValue;
import org.jboss.beans.metadata.api.annotations.Inject;
import org.jboss.beans.metadata.api.annotations.MapValue;
@@ -9,7 +11,6 @@
import org.jboss.beans.metadata.api.annotations.Value;
import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
import org.jboss.kernel.spi.config.KernelConfigurator;
-import org.jboss.logging.Logger;
import java.util.Map;
@@ -22,31 +23,44 @@
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
// Enable field injection by setting injectionMode
-@InterceptMC(injectionMode= MCInjectionMode.ALL)
+@InterceptMC(injectionMode = MCInjectionMode.ALL)
public class InjectingBean implements org.picocontainer.Startable
{
- private static final Logger log = Logger.getLogger(InjectingBean.class);
+ private static final Log log = ExoLogger.getLogger(InjectingBean.class);
- private InjectedBean bean1;
+ private InjectedBean bean;
private KernelConfigurator configurator;
// Avoid using field injection, it's an anti-pattern
@Inject(bean = "InjectedBean")
private InjectedBean injectedBean;
+ private Map bindingsMap;
+ private String stringValue;
+ private boolean started;
public InjectingBean()
{
log.info("Injecting bean instantiated");
}
+ public InjectedBean getBean()
+ {
+ return bean;
+ }
+
@Inject
public void setBean(InjectedBean bean)
{
- this.bean1 = bean;
+ this.bean = bean;
log.info("Received InjectedBean: " + bean);
}
+ public KernelConfigurator getConfigurator()
+ {
+ return configurator;
+ }
+
@Inject(bean = KernelConstants.KERNEL_CONFIGURATOR_NAME)
public void setConfigurator(KernelConfigurator configurator)
{
@@ -54,6 +68,11 @@
log.info("InjectingBean Received KernelConfigurator: " + configurator);
}
+ public Map getBindings()
+ {
+ return bindingsMap;
+ }
+
@MapValue(
value = {
@EntryValue(
@@ -85,21 +104,39 @@
public void setBindings(Map<Class<?>, Object> bindings)
{
log.info("Received a map with bindings: " + bindings);
+ this.bindingsMap = bindings;
}
+ public String getSomeStringProperty()
+ {
+ return stringValue;
+ }
+
@Inject(bean = "InjectedBean", property = "someString")
public void setSomeStringProperty(String value)
{
log.info("Received SomeStringProperty value: " + value);
+ this.stringValue = value;
}
public void start()
{
log.warn("start() called (injectedBean is set to: " + injectedBean + ")");
+ this.started = true;
}
public void stop()
{
log.info("stop() called");
}
+
+ public InjectedBean getInjectedBean()
+ {
+ return injectedBean;
+ }
+
+ public boolean isStarted()
+ {
+ return started;
+ }
}
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/MissingNoArgsConstructorBean.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/MissingNoArgsConstructorBean.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/MissingNoArgsConstructorBean.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,42 @@
+package org.exoplatform.kernel.demos.mc;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MissingNoArgsConstructorBean implements Startable
+{
+ private String name;
+ private boolean started;
+
+ public MissingNoArgsConstructorBean(InitParams params)
+ {
+ if (params == null)
+ {
+ return;
+ }
+ ValueParam val = params.getValueParam("name");
+ if (val != null)
+ {
+ name = val.getValue();
+ }
+ }
+
+ public String method01()
+ {
+ return "method01";
+ }
+
+ public void start()
+ {
+ started = true;
+ }
+
+ public void stop()
+ {
+ started = false;
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/PrivateNoArgsConstructorBean.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/PrivateNoArgsConstructorBean.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/PrivateNoArgsConstructorBean.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,38 @@
+package org.exoplatform.kernel.demos.mc;
+
+import org.exoplatform.container.xml.InitParams;
+import org.jboss.beans.metadata.api.annotations.Inject;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class PrivateNoArgsConstructorBean extends MissingNoArgsConstructorBean
+{
+ private InjectedBean injectedBean;
+
+ private PrivateNoArgsConstructorBean()
+ {
+ super(null);
+ }
+
+ public PrivateNoArgsConstructorBean(InitParams params)
+ {
+ super(params);
+ }
+
+ public String method12()
+ {
+ return "method12";
+ }
+
+ @Inject
+ public void setInjectedBean(InjectedBean bean)
+ {
+ this.injectedBean = bean;
+ }
+
+ public InjectedBean getInjectedBean()
+ {
+ return injectedBean;
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/ProtectedNoArgsConstructorBean.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/ProtectedNoArgsConstructorBean.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/java/org/exoplatform/kernel/demos/mc/ProtectedNoArgsConstructorBean.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,38 @@
+package org.exoplatform.kernel.demos.mc;
+
+import org.exoplatform.container.xml.InitParams;
+import org.jboss.beans.metadata.api.annotations.Inject;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class ProtectedNoArgsConstructorBean extends MissingNoArgsConstructorBean
+{
+ private InjectedBean injectedBean;
+
+ protected ProtectedNoArgsConstructorBean()
+ {
+ super(null);
+ }
+
+ public ProtectedNoArgsConstructorBean(InitParams params)
+ {
+ super(params);
+ }
+
+ public String method11()
+ {
+ return "method11";
+ }
+
+ @Inject
+ public void setInjectedBean(InjectedBean bean)
+ {
+ this.injectedBean = bean;
+ }
+
+ public InjectedBean getInjectedBean()
+ {
+ return injectedBean;
+ }
+}
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/META-INF/jboss-beans.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/META-INF/jboss-beans.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,3 +1,3 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="InjectedBean" class="org.exoplatform.kernel.demos.mc.InjectedBean" />
+ <bean name="InjectedBean" class="org.exoplatform.kernel.demos.mc.InjectedBean"/>
</deployment>
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/configuration.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/configuration.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/configuration.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,12 +1,37 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
+ 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>InjectingBean</key>
- <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
- </component>
-
+ <component>
+ <key>InjectingBean</key>
+ <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
+ </component>
+ <component>
+ <key>InjectingBean2</key>
+ <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
+ </component>
+ <component>
+ <key>InjectingBean3</key>
+ <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
+ </component>
+ <component>
+ <key>InjectingBean4</key>
+ <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
+ </component>
+ <component>
+ <key>InjectingBean5</key>
+ <type>org.exoplatform.kernel.demos.mc.InjectingBean</type>
+ </component>
+ <component>
+ <key>ProtectedNoArgsConstructorBean</key>
+ <type>org.exoplatform.kernel.demos.mc.ProtectedNoArgsConstructorBean</type>
+ <init-params>
+ <value-param>
+ <name>name</name>
+ <value>Some value</value>
+ </value-param>
+ </init-params>
+ </component>
</configuration>
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-beans.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-beans.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-beans.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <interceptor xmlns="urn:jboss:aop-beans:1.0" name="DemoAOPInterceptor"
+ class="org.exoplatform.kernel.demos.mc.AOPInterceptor"/>
+
+ <!-- Matching by exact type will not work, because of the mechanics of MC-integration AOP -->
+ <!-- Use $instanceof instead -->
+ <bind xmlns="urn:jboss:aop-beans:1.0"
+ pointcut="execution(* $instanceof{org.exoplatform.kernel.demos.mc.MissingNoArgsConstructorBean}->*(..))">
+ <interceptor-ref name="DemoAOPInterceptor"/>
+ </bind>
+
+ <bind xmlns="urn:jboss:aop-beans:1.0"
+ pointcut="execution(* $instanceof{org.exoplatform.kernel.demos.mc.InjectingBean}->*(..))">
+ <interceptor-ref name="DemoAOPInterceptor"/>
+ </bind>
+
+</deployment>
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/mc-injection/src/main/resources/conf/mc-int-beans.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean class="org.exoplatform.container.definition.PortalContainerConfig">
+ <annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true)</annotation>
+ </bean>
+ <bean name="InjectingBean2">
+ <annotation>
+ @org.exoplatform.container.mc.impl.InterceptMC(injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.STANDARD)
+ </annotation>
+ </bean>
+ <bean name="InjectingBean3">
+ <annotation>
+ @org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true,injectionMode=org.exoplatform.container.mc.impl.MCInjectionMode.ALL)
+ </annotation>
+ </bean>
+ <bean name="InjectingBean4">
+ <annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true)</annotation>
+ </bean>
+ <bean name="InjectingBean5" class="org.exoplatform.kernel.demos.mc.InjectingBean">
+ <!-- NO ANNOTATION -->
+ </bean>
+ <bean name="ProtectedNoArgsConstructorBean">
+ <annotation>@org.exoplatform.container.mc.impl.InterceptMC(enableAOP=true)</annotation>
+ </bean>
+
+</deployment>
\ No newline at end of file
Modified: kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.demos/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -9,10 +9,10 @@
</parent>
<groupId>org.exoplatform.kernel.demos</groupId>
- <artifactId>exo.kernel.demos</artifactId>
+ <artifactId>demos-parent</artifactId>
<packaging>pom</packaging>
- <name>eXo Kernel Demos</name>
+ <name>eXo Kernel :: Demos</name>
<modules>
<module>mc-injection</module>
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,69 @@
+
+<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-Beta04-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.kernel.mc-int</artifactId>
+
+ <name>eXo Kernel :: MC Kernel Integration</name>
+ <description>MC Kernel Integration</description>
+
+ <dependencies>
+ <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>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.mc-int</groupId>
+ <artifactId>jboss-mc-int-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.mc-int</groupId>
+ <artifactId>jboss-mc-int-servlet</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.cl</groupId>
+ <artifactId>jboss-classloader</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.mc-kernel-extras</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/GenericWrapperUtil.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/GenericWrapperUtil.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/GenericWrapperUtil.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,177 @@
+package org.exoplatform.container.mc.impl;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.LoaderClassPath;
+import javassist.Modifier;
+import javassist.NotFoundException;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
+import org.jboss.mc.common.ThreadLocalUtils;
+import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VirtualFile;
+
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author <a href="mailto:ajustin@redhat.com">Ales Justin</a>
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+final class GenericWrapperUtil
+{
+ private static AtomicInteger counter = new AtomicInteger(0);
+
+ static MCComponentInfo generateAndInstallWrapper(Object instance) throws Exception
+ {
+ ClassPool pool = ClassPool.getDefault();
+ pool.insertClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));
+
+ CtClass cc = pool.get(MCInterceptProxy.class.getName());
+ CtClass pc = pool.get(instance.getClass().getName());
+
+ zeroArgConstructorCheck(pc, instance);
+
+ cc.setSuperclass(pc);
+ cc.setName(getPackage(cc.getName()) + ".MCInterceptProxy$" + counter.getAndIncrement());
+ WrapperMethodComposer composer = new WrapperMethodComposer(MCInterceptProxy.DELEGATE, pc.getName());
+
+ ClassFile cf = cc.getClassFile();
+ AnnotationsAttribute attr = setAnnotations(pc.getClassFile().getAttributes(), cf.getConstPool());
+ if (attr != null)
+ {
+ cf.addAttribute(attr);
+ }
+ cf.setVersionToJava5();
+
+ for (CtMethod m : pc.getMethods())
+ {
+ if (isMethodOverridable(m))
+ {
+ CtMethod method = CtNewMethod.make(composer.composeMethod(m), cc);
+ MethodInfo minf = method.getMethodInfo();
+ attr = setAnnotations(m.getMethodInfo().getAttributes(), minf.getConstPool());
+ if (attr != null)
+ {
+ minf.addAttribute(attr);
+ }
+ cc.addMethod(method);
+ }
+ }
+
+ installWrapper(cc);
+
+ MCComponentInfo mcinf = new MCComponentInfo(cc.getName(),
+ new JavassistAOPClassLoader(Thread.currentThread().getContextClassLoader(), cc.getClassPool()));
+ Thread.currentThread().setContextClassLoader(mcinf.getClassLoader()); // TODO: ensure symetry - reset old CL when done
+ return mcinf;
+ }
+
+ private static AnnotationsAttribute setAnnotations(List attrs, ConstPool cpool)
+ {
+ //AnnotationsAttribute attr = new AnnotationsAttribute(cpool, AnnotationsAttribute.visibleTag);
+ for (Object a : attrs)
+ {
+ if (a instanceof AnnotationsAttribute)
+ {
+ AnnotationsAttribute aa = (AnnotationsAttribute) a;
+ if (AnnotationsAttribute.visibleTag.equals(aa.getName()) == false)
+ {
+ continue;
+ }
+ //attr.setAnnotations(aa.getAnnotations());
+ //return attr;
+ return (AnnotationsAttribute) aa.copy(cpool, null);
+ }
+ }
+ return null;
+ }
+
+ private static String getPackage(String name)
+ {
+ return name.substring(0, name.lastIndexOf("."));
+ }
+
+ private static void installWrapper(CtClass cc) throws Exception
+ {
+ // This is to make classloading work with jboss-aop and mc-classloading
+ // - third-party (Tomcat) can be enabled through context classloader
+ DeploymentUnit unit = ThreadLocalUtils.getUnit();
+ String host = getVFSMemoryHost(unit);
+ if (host != null)
+ {
+ URL vfsUrl = new URL("vfsmemory://" + host + "/" + getResourcePath(cc.getName()));
+ MemoryFileFactory.putFile(vfsUrl, cc.toBytecode());
+ return;
+ }
+ }
+
+ static void postInstallCleanup()
+ {
+ // TODO: symmetry not 100% assured here
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl instanceof JavassistAOPClassLoader)
+ {
+ Thread.currentThread().setContextClassLoader(cl.getParent());
+ }
+ }
+
+ private static String getResourcePath(String name)
+ {
+ return name.replace(".", "/") + ".class";
+ }
+
+ private static String getVFSMemoryHost(DeploymentUnit unit) throws Exception
+ {
+ if (unit instanceof AbstractVFSDeploymentUnit)
+ {
+ List<VirtualFile> classPath = ((AbstractVFSDeploymentUnit) unit).getClassPath();
+ for (VirtualFile vf : classPath)
+ {
+ URL url = vf.toURL();
+ if ("vfsmemory".equals(url.getProtocol()))
+ {
+ return url.getHost();
+ }
+ }
+ return getVFSMemoryHost(unit.getParent());
+ }
+
+ return null;
+ }
+
+ private static boolean isMethodOverridable(CtMethod m)
+ {
+ return (m.getModifiers() & Modifier.FINAL) == 0
+ && !"clone".equals(m.getName())
+ && !"finalize".equals(m.getName());
+ }
+
+ private static void zeroArgConstructorCheck(CtClass pc, Object c)
+ throws NotFoundException
+ {
+ CtConstructor[] ctors = pc.getDeclaredConstructors();
+ boolean found = false;
+ for (CtConstructor cons : ctors)
+ {
+ if (cons.getParameterTypes().length == 0
+ && (cons.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED)) > 0)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ throw new RuntimeException("Class can not be AOP instrumented - it has no zero-arguments public/protected constructor: " + c.getClass());
+ }
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/InterceptMC.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/InterceptMC.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/InterceptMC.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,31 @@
+package org.exoplatform.container.mc.impl;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks Gatein MC enabled component.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ * @author <a href="mailto:ales.justin@redhat.com">Ales Justin</a>
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface InterceptMC
+{
+ /**
+ * Do we enable AOP for this component.
+ *
+ * @return true if we should enable AOP, false otherwise
+ */
+ boolean enableAOP() default false;
+
+ /**
+ * Injection mode
+ *
+ * @return MCInjectionMode enumeration constant representing injection mode
+ */
+ MCInjectionMode injectionMode() default MCInjectionMode.STANDARD;
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/JavassistAOPClassLoader.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/JavassistAOPClassLoader.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/JavassistAOPClassLoader.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,67 @@
+package org.exoplatform.container.mc.impl;
+
+import javassist.ClassPool;
+import javassist.Loader;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class JavassistAOPClassLoader extends Loader
+{
+ public JavassistAOPClassLoader()
+ {
+ }
+
+ public JavassistAOPClassLoader(ClassPool cp)
+ {
+ super(cp);
+ }
+
+ public JavassistAOPClassLoader(ClassLoader parent, ClassPool cp)
+ {
+ super(parent, cp);
+ }
+
+ @Override
+ protected Class loadClassByDelegation(String name) throws ClassNotFoundException
+ {
+ if (name.startsWith("org.jboss.aop."))
+ {
+ return delegateToParent(name);
+ }
+
+ return super.loadClassByDelegation(name);
+ }
+
+ protected Class loadClass(String name, boolean resolve)
+ throws ClassFormatError, ClassNotFoundException
+ {
+ name = name.intern();
+ synchronized (name)
+ {
+ Class c = findLoadedClass(name);
+ if (c == null)
+ {
+ try
+ {
+ c = delegateToParent(name);
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ }
+ }
+
+ if (c == null)
+ {
+ c = findClass(name);
+ }
+
+ if (resolve)
+ {
+ resolveClass(c);
+ }
+
+ return c;
+ }
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentAdapter.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentAdapter.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentAdapter.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,141 @@
+package org.exoplatform.container.mc.impl;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.plugins.helpers.StatelessController;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.picocontainer.ComponentAdapter;
+import org.picocontainer.PicoContainer;
+import org.picocontainer.PicoInitializationException;
+import org.picocontainer.PicoIntrospectionException;
+import org.picocontainer.PicoVisitor;
+
+/**
+ * @author <a href="mailto:ajustin@redhat.com">Ales Justin</a>
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCComponentAdapter implements ComponentAdapter
+{
+ private KernelController controller;
+ private ComponentAdapter delegate;
+ private InterceptMC interceptMC;
+ private Object lastComponentInstance;
+
+ public MCComponentAdapter(KernelController controller, ComponentAdapter delegate, InterceptMC interceptMC)
+ {
+ if (controller == null)
+ {
+ throw new IllegalArgumentException("Null controller");
+ }
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("Null delegate");
+ }
+
+ if (controller instanceof StatelessController)
+ {
+ throw new IllegalArgumentException("controller is instanceof StatelessController");
+ }
+
+ this.controller = controller;
+ this.delegate = delegate;
+ this.interceptMC = interceptMC;
+ }
+
+ public Object getComponentKey()
+ {
+ return delegate.getComponentKey();
+ }
+
+ public Class getComponentImplementation()
+ {
+ return delegate.getComponentImplementation();
+ }
+
+ public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException
+ {
+ Object target = lastComponentInstance;
+ if (target != null)
+ {
+ return target;
+ }
+
+ String key = delegate.getComponentKey().toString();
+ Object instance = delegate.getComponentInstance(container);
+ try
+ {
+ BeanMetaDataBuilder builder;
+ if (interceptMC != null && interceptMC.enableAOP())
+ {
+ MCComponentInfo mcinfo = GenericWrapperUtil.generateAndInstallWrapper(instance);
+ builder = BeanMetaDataBuilder.createBuilder(key, mcinfo.getWrapperClassName());
+ builder.addConstructorParameter(Object.class.getName(), instance);
+ }
+ else
+ {
+ builder = BeanMetaDataBuilder.createBuilder(key, instance.getClass().getName());
+ builder.setConstructorValue(instance);
+ }
+ builder.ignoreCreate();
+ builder.ignoreStart();
+ builder.ignoreStop();
+ builder.ignoreDestroy();
+ builder.setAccessMode(getInjectionMode(interceptMC));
+
+ KernelControllerContext ctx = new AbstractKernelControllerContext(null, builder.getBeanMetaData(), null);
+ try
+ {
+ StatelessController ctrl = new StatelessController(controller);
+ ctrl.install(ctx);
+ if (ctx.getError() != null)
+ {
+ throw ctx.getError();
+ }
+ if (ctrl.getStates().isBeforeState(ctx.getState(), ControllerState.INSTALLED))
+ {
+ throw new IllegalArgumentException("Missing some dependency: " + ctx.getDependencyInfo().getUnresolvedDependencies(null));
+ }
+
+ target = ctx.getTarget();
+ lastComponentInstance = target;
+ return target;
+ }
+ finally
+ {
+ GenericWrapperUtil.postInstallCleanup();
+ }
+ }
+ catch (Throwable ex)
+ {
+ throw new RuntimeException("Failed to perform MC interception on component: " + delegate.getComponentImplementation(), ex);
+ }
+ }
+
+ private BeanAccessMode getInjectionMode(InterceptMC interceptMC)
+ {
+ MCInjectionMode mode = interceptMC.injectionMode();
+
+ switch (mode)
+ {
+ case ALL:
+ return BeanAccessMode.ALL;
+ case FIELDS:
+ return BeanAccessMode.FIELDS;
+ default:
+ return BeanAccessMode.STANDARD;
+ }
+ }
+
+ public void verify(PicoContainer container) throws PicoIntrospectionException
+ {
+ delegate.verify(container);
+ }
+
+ public void accept(PicoVisitor visitor)
+ {
+ delegate.accept(visitor);
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentInfo.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentInfo.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCComponentInfo.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,26 @@
+package org.exoplatform.container.mc.impl;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCComponentInfo
+{
+ private String name;
+ private ClassLoader classLoader;
+
+ public MCComponentInfo(String wrapperClassName, ClassLoader classLoader)
+ {
+ this.name = wrapperClassName;
+ this.classLoader = classLoader;
+ }
+
+ public String getWrapperClassName()
+ {
+ return name;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInjectionMode.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInjectionMode.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInjectionMode.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,22 @@
+package org.exoplatform.container.mc.impl;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public enum MCInjectionMode
+{
+ /**
+ * Field and method injections
+ */
+ ALL,
+
+ /**
+ * Disable field injections (default)
+ */
+ FIELDS,
+
+ /**
+ * Try setter injection first, if no setter found, fallback to field
+ */
+ STANDARD
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntConfig.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntConfig.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntConfig.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,171 @@
+package org.exoplatform.container.mc.impl;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+import org.picocontainer.ComponentAdapter;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCIntConfig
+{
+ private static final Log log = ExoLogger.getLogger(MCIntConfig.class);
+
+ private Map<String, DeploymentData> confByKey = new HashMap<String, DeploymentData>();
+
+ private Map<String, DeploymentData> confByBean = new HashMap<String, DeploymentData>();
+
+ MCIntConfig()
+ {
+ Enumeration<URL> urls = null;
+ try
+ {
+ urls = Thread.currentThread().getContextClassLoader().getResources("conf/mc-int-beans.xml");
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to get resources: conf/mc-int-beans.xml", e);
+ }
+
+ UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+ MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+
+ while (urls.hasMoreElements())
+ {
+ URL url = urls.nextElement();
+
+ KernelDeployment deployment = parseConfigURL(factory, resolver, url);
+
+ List<BeanMetaData> beans = deployment.getBeans();
+ for (BeanMetaData mdata : beans)
+ {
+ String name = mdata.getName();
+ DeploymentData data = confByKey.get(name);
+ if (data == null)
+ {
+ String bean = mdata.getBean();
+ data = confByBean.get(bean);
+ }
+ if (data != null)
+ {
+ log.warn("Overriding existing mc-int-beans configuration for bean: " + data.data
+ + " from " + data.deployment.getName() + " with one from " + deployment.getName());
+ }
+ addConf(new DeploymentData(deployment, mdata));
+ }
+ }
+ }
+
+ public BeanMetaData getByKey(String key)
+ {
+ DeploymentData dd = confByKey.get(key);
+ if (dd == null)
+ {
+ return null;
+ }
+ return dd.data;
+ }
+
+ public BeanMetaData getByBean(String bean)
+ {
+ DeploymentData dd = confByBean.get(bean);
+ if (dd == null)
+ {
+ return null;
+ }
+ return dd.data;
+ }
+
+ public BeanMetaData getByAdapter(ComponentAdapter adapter)
+ {
+ Object key = adapter.getComponentKey();
+ String strKey = key instanceof Class ? ((Class) key).getName() : String.valueOf(key);
+ BeanMetaData ret = getByKey(strKey);
+ if (ret != null)
+ {
+ return ret;
+ }
+
+ ret = getByBean(strKey);
+ return ret;
+ }
+
+ private void addConf(DeploymentData deploymentData)
+ {
+ String name = deploymentData.data.getName();
+ if (name != null)
+ {
+ confByKey.put(name, deploymentData);
+ }
+ String bean = deploymentData.data.getBean();
+ if (bean != null)
+ {
+ confByBean.put(bean, deploymentData);
+ }
+ if (name == null && bean == null)
+ {
+ throw new RuntimeException("Configuration error: bean found with no name and no class in "
+ + deploymentData.deployment.getName());
+ }
+ }
+
+ private KernelDeployment parseConfigURL(UnmarshallerFactory factory, MutableSchemaResolver resolver, URL url)
+ {
+ final boolean trace = log.isTraceEnabled();
+ if (trace)
+ {
+ log.trace("Parsing " + url);
+ }
+ long start = System.currentTimeMillis();
+
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ KernelDeployment deployment = null;
+ try
+ {
+ deployment = (KernelDeployment) unmarshaller.unmarshal(url.toString(), resolver);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse xml " + url, e);
+ }
+
+ if (deployment == null)
+ {
+ throw new RuntimeException("The xml " + url + " is not well formed!");
+ }
+ deployment.setName(url.toString());
+
+ if (trace)
+ {
+ long now = System.currentTimeMillis();
+ log.trace("Parsing " + url + " took " + (now - start) + " milliseconds");
+ }
+
+ return deployment;
+ }
+
+ static class DeploymentData
+ {
+ KernelDeployment deployment;
+ BeanMetaData data;
+
+ public DeploymentData(KernelDeployment deployment, BeanMetaData data)
+ {
+ this.deployment = deployment;
+ this.data = data;
+ }
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntegrationImpl.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntegrationImpl.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCIntegrationImpl.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,153 @@
+package org.exoplatform.container.mc.impl;
+
+import org.exoplatform.container.mc.MCIntegration;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.dependency.AbstractKernelController;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.mc.common.ThreadLocalUtils;
+import org.jboss.mc.servlet.vdf.api.VDFThreadLocalUtils;
+import org.picocontainer.ComponentAdapter;
+
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCIntegrationImpl implements MCIntegration
+{
+ private static Log log = ExoLogger.getLogger(MCIntegrationImpl.class);
+ private static MCIntegration mcint;
+
+ private AbstractKernelController rootController;
+ private List<KernelDeployment> deployments = new LinkedList<KernelDeployment>();
+ private MCIntConfig conf;
+
+ public synchronized static MCIntegration getInstance()
+ {
+ if (mcint == null)
+ {
+ mcint = new MCIntegrationImpl();
+ }
+ return mcint;
+ }
+
+ private MCIntegrationImpl()
+ {
+ // load mc-int-beans.xml
+ conf = new MCIntConfig();
+ }
+
+ public synchronized AbstractKernelController getRootController()
+ {
+ if (rootController == null)
+ {
+ Kernel kernel = ThreadLocalUtils.getKernel();
+ if (kernel != null)
+ {
+ rootController = (AbstractKernelController) kernel.getController();
+ }
+ else
+ {
+ log.warn("GateIn - MC integration not available");
+ return null;
+ }
+ processDeployments();
+ }
+ return rootController;
+ }
+
+ private void processDeployments()
+ {
+ // Now deploy any AOP configuration - instantiates lifecycle callbacks
+ BasicXMLDeployer deployer = new BasicXMLDeployer(rootController.getKernel());
+ Enumeration<URL> urls = null;
+ try
+ {
+ urls = Thread.currentThread().getContextClassLoader().getResources("conf/mc-beans.xml");
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to load resources: conf/mc-beans.xml", e);
+ }
+
+ while (urls.hasMoreElements())
+ {
+ URL confUrl = urls.nextElement();
+ try
+ {
+ deployments.add(deployer.deploy(confUrl));
+ log.debug("Deployed mc-kernel configuration: " + confUrl);
+ }
+ catch (Throwable ex)
+ {
+ throw new RuntimeException("Failed to deploy: " + confUrl, ex);
+ }
+ }
+ }
+
+ public ComponentAdapter getMCAdapter(ComponentAdapter adapter)
+ {
+ InterceptMC interceptAnnotation = null;
+
+ BeanMetaData data = conf.getByAdapter(adapter);
+ if (data != null)
+ {
+ Set<AnnotationMetaData> annotationMetaData = data.getAnnotations();
+ if (annotationMetaData != null)
+ {
+ for (AnnotationMetaData annMeta : annotationMetaData)
+ {
+ Annotation ann = annMeta.getAnnotationInstance();
+ if (ann.annotationType() == InterceptMC.class)
+ {
+ interceptAnnotation = (InterceptMC) ann;
+ }
+ }
+ }
+ }
+ else
+ {
+ Class<?> clazz = adapter.getComponentImplementation();
+ interceptAnnotation = clazz.getAnnotation(InterceptMC.class);
+ }
+
+ if (interceptAnnotation == null)
+ {
+ return adapter;
+ }
+
+ AbstractKernelController controller = getRootController();
+ if (controller != null)
+ {
+ adapter = new MCComponentAdapter(controller, adapter, interceptAnnotation);
+ }
+ return adapter;
+ }
+
+ public boolean hasMCKernel(ComponentAdapter adapter)
+ {
+ return ThreadLocalUtils.getKernel() != null;
+ }
+
+ public void initThreadCtx(ServletContext ctx)
+ {
+ VDFThreadLocalUtils.init(ctx);
+ }
+
+ public void resetThreadCtx(ServletContext ctx)
+ {
+ VDFThreadLocalUtils.reset();
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInterceptProxy.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInterceptProxy.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/MCInterceptProxy.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,23 @@
+package org.exoplatform.container.mc.impl;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInterceptProxy
+{
+ private static final Log __log = ExoLogger.getLogger(MCInterceptProxy.class);
+ public static final String DELEGATE = "__delegate";
+ private Object __delegate;
+
+ public MCInterceptProxy(Object delegate)
+ {
+ this.__delegate = delegate;
+ if (__log.isDebugEnabled())
+ {
+ __log.debug("MCInterceptProxy<init> - CL: " + delegate.getClass().getClassLoader());
+ }
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/RootContainerVDFDecoratorInjector.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/RootContainerVDFDecoratorInjector.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/RootContainerVDFDecoratorInjector.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,71 @@
+package org.exoplatform.container.mc.impl;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.LoaderClassPath;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.mc.common.ThreadLocalUtils;
+import org.jboss.util.loading.Translator;
+
+import java.security.ProtectionDomain;
+
+public class RootContainerVDFDecoratorInjector implements Translator
+{
+ @SuppressWarnings({"UnusedDeclaration"})
+ private Kernel kernel;
+ private ClassLoaderSystem system;
+
+ private static final String RC_CLASSNAME = "org.exoplatform.container.RootContainer";
+ private boolean found;
+
+ public void start()
+ {
+ system.addTranslator(this);
+ }
+
+ public void stop()
+ {
+ system.removeTranslator(this);
+ }
+
+ protected byte[] decorate(ClassLoader cl) throws Exception
+ {
+ ClassPool pool = ClassPool.getDefault();
+ pool.insertClassPath(new LoaderClassPath(cl));
+ CtClass cc = pool.get(RC_CLASSNAME);
+ CtMethod m = cc.getDeclaredMethod("getInstance");
+ m.insertBefore(ThreadLocalUtils.class.getName() + ".putKernel(kernel);\ntry {\n");
+ m.insertAfter("\n } finally { \n" + ThreadLocalUtils.class.getName() + ".removeKernel();\n }");
+ return cc.toBytecode();
+ }
+
+ public byte[] transform(ClassLoader classLoader, String s, Class<?> aClass, ProtectionDomain protectionDomain, byte[] bytes) throws Exception
+ {
+ if (found == false && RC_CLASSNAME.equals(s))
+ {
+ found = true;
+ return decorate(classLoader);
+ }
+ return bytes;
+ }
+
+ public void unregisterClassLoader(ClassLoader classLoader)
+ {
+ }
+
+ @Inject(bean = KernelConstants.KERNEL_NAME)
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ @Inject
+ public void setSystem(ClassLoaderSystem system)
+ {
+ this.system = system;
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/WrapperMethodComposer.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/WrapperMethodComposer.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-int/src/main/java/org/exoplatform/container/mc/impl/WrapperMethodComposer.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,158 @@
+package org.exoplatform.container.mc.impl;
+
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import javassist.bytecode.AccessFlag;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class WrapperMethodComposer
+{
+ private String delegate;
+ private String type;
+
+ public WrapperMethodComposer(String delegateFldName, String type)
+ {
+ delegate = delegateFldName;
+ this.type = type;
+ }
+
+ public String composeMethod(CtMethod method) throws NotFoundException
+ {
+ StringBuilder sb = new StringBuilder();
+
+ String next = addModifiers(method.getModifiers());
+ sb.append(next);
+ if (next.length() > 0)
+ {
+ sb.append(" ");
+ }
+
+ CtClass ret = method.getReturnType();
+ next = addReturnType(ret);
+ sb.append(next).append(" ");
+
+ sb.append(method.getName()).append("(");
+ next = addParams(method.getParameterTypes());
+ sb.append(next);
+ sb.append(") ");
+
+ next = addExceptions(method.getExceptionTypes());
+ sb.append(next);
+ if (next.length() > 0)
+ {
+ sb.append(" ");
+ }
+
+ sb.append("{ ");
+ sb.append(delegateCall(method.getName(), method.getParameterTypes(), method.getReturnType()));
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+ private String delegateCall(String name, CtClass[] parameterTypes, CtClass returnType)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (returnType != null)
+ {
+ sb.append("return ");
+ }
+ sb.append("((").append(type).append(")");
+ sb.append(delegate).append(")").append(".").append(name).append("(");
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (i > 0)
+ {
+ sb.append(",");
+ }
+ sb.append("a").append(i);
+ }
+ sb.append(");");
+
+ if (returnType == null)
+ {
+ sb.append("return;");
+ }
+
+ return sb.toString();
+ }
+
+
+ private String addParams(CtClass[] parameterTypes)
+ {
+ if (parameterTypes == null || parameterTypes.length == 0)
+ {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (i > 0)
+ {
+ sb.append(",");
+ }
+ sb.append(parameterTypes[i].getName()).append(" a").append(i);
+ }
+ return sb.toString();
+ }
+
+ private String addExceptions(CtClass[] exceptionTypes)
+ {
+ StringBuilder ret = new StringBuilder();
+ if (exceptionTypes == null || exceptionTypes.length == 0)
+ {
+ return "";
+ }
+
+ ret.append("throws ");
+ for (int i = 0; i < exceptionTypes.length; i++)
+ {
+ if (i > 0)
+ {
+ ret.append(",");
+ }
+ ret.append(exceptionTypes[i].getName());
+ }
+ return ret.toString();
+ }
+
+ private String addReturnType(CtClass ret)
+ {
+ if (ret == null)
+ {
+ return "void";
+ }
+ else
+ {
+ return ret.getName();
+ }
+ }
+
+ private String addModifiers(int modifiers)
+ {
+ if (AccessFlag.isPackage(modifiers))
+ {
+ return "";
+ }
+ else if (AccessFlag.isPrivate(modifiers))
+ {
+ return "private";
+ }
+ else if (AccessFlag.isPublic(modifiers))
+ {
+ return "public";
+ }
+ else if (AccessFlag.isProtected(modifiers))
+ {
+ return "protected";
+ }
+ else
+ {
+ throw new RuntimeException("Invalid modifiers: " + modifiers);
+ }
+ }
+}
Copied: kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras (from rev 901, kernel/branches/mc-int-branch/org.jboss.mc-kernel-extras)
Deleted: kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/org.jboss.mc-kernel-extras/pom.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/exo.kernel.mc-kernel-extras/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -1,57 +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-Beta04-SNAPSHOT</version>
- </parent>
-
- <artifactId>mc-kernel-extras</artifactId>
-
- <name>MC Kernel 2.2.0 Selected Classes</name>
- <description>MC integration classes that aren't available in mc-kernel 2.0.6.GA</description>
-
- <!--build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- <optimize>true</optimize>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- <inherited>true</inherited>
- <configuration>
- <includePom>true</includePom>
- </configuration>
- </plugin>
- </plugins>
- </build-->
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- </dependency>
- </dependencies>
-</project>
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,98 @@
+<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.tests</groupId>
+ <artifactId>tests-parent</artifactId>
+ <version>2.2.0-Beta04-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.kernel.integration-tests</artifactId>
+ <packaging>war</packaging>
+
+ <name>eXo Kernel :: Tests :: Integration Tests</name>
+ <description>MC Integration Tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel.demos</groupId>
+ <artifactId>exo.kernel.demos.mc-injection</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <!-- In version 2.1-alpha-1, this was incorrectly named warSourceExcludes -->
+ <!--packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes-->
+ <packagingIncludes>WEB-INF/lib/junit-*.jar,WEB-INF/classes/**</packagingIncludes>
+ <archive>
+ <manifest>
+ <addClasspath>false</addClasspath>
+ <!-- Doesn't seem to be working: -->
+ <!--classpathPrefix>gatein.ear/lib/</classpathPrefix-->
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>tests</id>
+ <build>
+ <finalName>eXo-kernel-integration-tests-${project.version}</finalName>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/it/Test*.java</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-tests</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <excludes>
+ <exclude>none</exclude>
+ </excludes>
+ <includes>
+ <include>**/it/Test*.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,247 @@
+package org.exoplatform.kernel.it;
+
+import org.exoplatform.commons.Environment;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.kernel.demos.mc.AOPInterceptor;
+import org.exoplatform.kernel.demos.mc.InjectedBean;
+import org.exoplatform.kernel.demos.mc.InjectingBean;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.proxy.container.ContainerProxyMethodInvocation;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.registry.KernelBus;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Presumption when running this test from within servlet container is that
+ * org.exoplatform.kernel.demos:exo.kernel.demos.mc-injection jar has been deployed
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInjectionTest
+{
+ protected Log log = ExoLogger.getLogger(getClass());
+
+ protected String beanName;
+ protected InjectingBean bean;
+ protected boolean inJboss;
+ protected boolean mcIntActive = true;
+ protected boolean aopIntActive = false;
+ protected Map<String, Integer> expectedAOPResults;
+
+ public MCInjectionTest()
+ {
+ beanName = "InjectingBean";
+ }
+
+ protected void init()
+ {
+ log.info("init() method called");
+ RootContainer rootContainer = RootContainer.getInstance();
+ bean = (InjectingBean) rootContainer.getComponentInstance(beanName);
+ log.info("Retrieved " + beanName + ": " + bean);
+ Assert.assertNotNull(beanName + " not installed", bean);
+ inJboss = Environment.getInstance().getPlatform() == Environment.JBOSS_PLATFORM;
+ log.info("Running inside JBoss? " + inJboss);
+ }
+
+ @Test
+ public void test()
+ {
+ init();
+ // AOP tests first
+ testAOP();
+ tests();
+ }
+
+ protected void testAOP()
+ {
+ String className;
+ Method m = null;
+ try
+ {
+ m = bean.getClass().getDeclaredMethod("getDelegate");
+ }
+ catch (Exception ignored)
+ {
+ }
+ catch (Error ignored)
+ {
+ }
+
+ if (inJboss == false || aopIntActive == false)
+ {
+ Assert.assertNull("AOP Proxy should not be present", m);
+ return;
+ }
+ Assert.assertNotNull("AOP Proxy should be present", m);
+ try
+ {
+ Object delegate = m.invoke(bean);
+ className = delegate.getClass().getName();
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("AOP Proxy getDelegate() filed");
+ }
+ CallCounter counter = new CallCounter();
+ List<Invocation> invocations = AOPInterceptor.getInvocations();
+ for (Invocation iv : invocations)
+ {
+ if (iv instanceof ContainerProxyMethodInvocation)
+ {
+ if (iv.getTargetObject().getClass().getName().startsWith(className))
+ {
+ counter.add(((ContainerProxyMethodInvocation) iv).getMethod().getName());
+ }
+ }
+ }
+
+ Map<String, Integer> called = counter.getCallMap();
+ if (expectedAOPResults == null)
+ {
+ throw new IllegalArgumentException("expectedAOPResults == null");
+ }
+ if (expectedAOPResults.size() == 0)
+ {
+ throw new IllegalArgumentException("expectedAOPResults.size() == 0");
+ }
+ for (Map.Entry<String, Integer> ent : expectedAOPResults.entrySet())
+ {
+ Integer callCount = called.get(ent.getKey());
+ if (callCount == null)
+ {
+ callCount = Integer.valueOf(0);
+ }
+ junit.framework.Assert.assertEquals(ent.getKey() + "() not called through AOP as expected",
+ ent.getValue(), callCount);
+ }
+ }
+
+ protected void tests()
+ {
+ testFieldInjection();
+ testTypeMatchingMethodInjection();
+ testNameLookupMethodInjection();
+ testNameLookupMapInjection();
+ testPropertyValueMethodInjection();
+ testStarted();
+ }
+
+ protected void testFieldInjection()
+ {
+ boolean found = bean.getInjectedBean() != null;
+ if (inJboss && mcIntActive)
+ {
+ Assert.assertTrue("Field injection not executed", found);
+ }
+ else
+ {
+ Assert.assertFalse("Field injection should not have worked", found);
+ }
+ log.info("testFieldInjection passed");
+ }
+
+ protected void testTypeMatchingMethodInjection()
+ {
+ boolean found = bean.getBean() != null;
+ if (inJboss && mcIntActive)
+ {
+ Assert.assertTrue("Method injection by type matching not executed", found);
+ }
+ else
+ {
+ Assert.assertFalse("Method injection by type matching should not have worked", found);
+ }
+ log.info("testTypeMatchingMethodInjection passed");
+ }
+
+ protected void testNameLookupMethodInjection()
+ {
+ boolean found = bean.getConfigurator() != null;
+ if (inJboss && mcIntActive)
+ {
+ Assert.assertTrue("Method injection by name lookup not executed", found);
+ }
+ else
+ {
+ Assert.assertFalse("Method injection by name lookup should not have worked", found);
+ }
+ log.info("testNameLookupMethodInjection passed");
+ }
+
+ protected void testNameLookupMapInjection()
+ {
+ Map bindings = bean.getBindings();
+ boolean found = bindings != null;
+ if (inJboss && mcIntActive)
+ {
+ Assert.assertTrue("Name lookup Map injection not executed", found);
+ Assert.assertEquals("Bindings size", bindings.size(), 6);
+ Assert.assertTrue("Controller not bound", bindings.get(Controller.class) instanceof Controller);
+ Assert.assertTrue("Kernel not bound", bindings.get(Kernel.class) instanceof Kernel);
+ Assert.assertTrue("KernelController not bound", bindings.get(KernelController.class) instanceof KernelController);
+ Assert.assertTrue("KernelBus not bound", bindings.get(KernelBus.class) instanceof KernelBus);
+ Assert.assertTrue("KernelRegistry not bound", bindings.get(KernelRegistry.class) instanceof KernelRegistry);
+ Assert.assertTrue("KernelConfigurator not bound", bindings.get(KernelConfigurator.class) instanceof KernelConfigurator);
+ }
+ else
+ {
+ Assert.assertFalse("Name lookup Map injection should not have worked", found);
+ }
+ log.info("testNameLookupMapInjection passed");
+ }
+
+ protected void testPropertyValueMethodInjection()
+ {
+ String propertyValue = bean.getSomeStringProperty();
+ boolean found = propertyValue != null;
+ if (inJboss && mcIntActive)
+ {
+ Assert.assertTrue("Property value method injection not executed", found);
+ Assert.assertEquals("Invalid injected value", propertyValue, InjectedBean.SOME_PROPERTY_VALUE);
+ }
+ else
+ {
+ Assert.assertFalse("Property value method injection should not have worked", found);
+ }
+ log.info("testPropertyValueMethodInjection passed");
+ }
+
+ protected void testStarted()
+ {
+ Assert.assertTrue("start() method not called", bean.isStarted());
+ log.info("testStarted passed");
+ }
+
+ static class CallCounter
+ {
+ private Map<String, Integer> called = new HashMap<String, Integer>();
+
+ public void add(String name)
+ {
+ Integer count = called.get(name);
+ if (count == null)
+ {
+ count = 0;
+ }
+ called.put(name, 1 + count);
+ }
+
+ public Map<String, Integer> getCallMap()
+ {
+ return called;
+ }
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest2.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest2.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest2.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,23 @@
+package org.exoplatform.kernel.it;
+
+import org.junit.Assert;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInjectionTest2 extends MCInjectionTest
+{
+ public MCInjectionTest2()
+ {
+ super();
+ beanName = "InjectingBean2";
+ }
+
+ @Override
+ protected void testFieldInjection()
+ {
+ boolean found = bean.getInjectedBean() != null;
+ Assert.assertFalse("Field injection should not have worked", found);
+ log.info("testFieldInjection passed");
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest3.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest3.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest3.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,22 @@
+package org.exoplatform.kernel.it;
+
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInjectionTest3 extends MCInjectionTest2
+{
+ public MCInjectionTest3()
+ {
+ super();
+ beanName = "InjectingBean3";
+ expectedAOPResults = new HashMap<String, Integer>();
+ expectedAOPResults.put("setBindings", 1);
+ expectedAOPResults.put("setSomeStringProperty", 1);
+ expectedAOPResults.put("setBean", 1);
+ expectedAOPResults.put("setConfigurator", 1);
+ expectedAOPResults.put("start", 1);
+ aopIntActive = true;
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest4.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest4.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest4.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,13 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInjectionTest4 extends MCInjectionTest3
+{
+ public MCInjectionTest4()
+ {
+ super();
+ beanName = "InjectingBean4";
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest5.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest5.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/kernel/it/MCInjectionTest5.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,14 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class MCInjectionTest5 extends MCInjectionTest
+{
+ public MCInjectionTest5()
+ {
+ super();
+ beanName = "InjectingBean5";
+ mcIntActive = false;
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/JUnitInvokerServlet.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/JUnitInvokerServlet.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/JUnitInvokerServlet.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,43 @@
+package org.exoplatform.tests;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.junit.internal.JUnitSystem;
+import org.junit.runner.JUnitCore;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+public class JUnitInvokerServlet extends HttpServlet
+{
+ private static final Log log = ExoLogger.getLogger(JUnitInvokerServlet.class);
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String className = request.getParameter("class");
+ response.setContentType("text/plain");
+ OutputStream out = response.getOutputStream();
+ final PrintStream fOut = new PrintStream(new TeeOutputStream(out, new LogOutputStream(log)));
+ //final PrintStream fOut = new PrintStream(out);
+ JUnitSystem sys = new JUnitSystem()
+ {
+ public PrintStream out()
+ {
+ return fOut;
+ }
+
+ public void exit(int arg)
+ {
+ }
+ };
+
+ new JUnitCore().runMain(sys, className);
+ out.close();
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/LogOutputStream.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/LogOutputStream.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/LogOutputStream.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,54 @@
+package org.exoplatform.tests;
+
+import org.exoplatform.services.log.Log;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+class LogOutputStream extends OutputStream
+{
+ private Log log;
+
+ private ByteArrayOutputStream buf = new ByteArrayOutputStream();
+
+ private boolean eol;
+
+ LogOutputStream(Log log)
+ {
+ this.log = log;
+ }
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ if (b == '\n' || b == '\r')
+ {
+ eol = true;
+ return;
+ }
+ flush();
+ if (b != -1)
+ {
+ buf.write(b);
+ }
+ }
+
+ public void flush()
+ {
+ if (eol)
+ {
+ eol = false;
+ log.info(new String(buf.toByteArray()));
+ buf.reset();
+ }
+ }
+
+ public void close()
+ {
+ flush();
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/TeeOutputStream.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/TeeOutputStream.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/java/org/exoplatform/tests/TeeOutputStream.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,53 @@
+package org.exoplatform.tests;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+class TeeOutputStream extends OutputStream
+{
+ private OutputStream out;
+ private OutputStream out2;
+
+ TeeOutputStream(OutputStream out, OutputStream out2)
+ {
+ this.out = out;
+ this.out2 = out2;
+ }
+
+ @Override
+ public void write(byte[] buf, int off, int len) throws IOException
+ {
+ out.write(buf, off, len);
+ out2.write(buf, off, len);
+ }
+
+ @Override
+ public void write(byte[] buf) throws IOException
+ {
+ write(buf, 0, buf.length);
+ }
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ out.write(b);
+ out2.write(b);
+ }
+
+ @Override
+ public void flush() throws IOException
+ {
+ out.flush();
+ out2.flush();
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ out.close();
+ out2.close();
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/WEB-INF/web.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/main/webapp/WEB-INF/web.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <servlet>
+ <servlet-name>JUnit Invoker Servlet</servlet-name>
+ <servlet-class>org.exoplatform.tests.JUnitInvokerServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JUnit Invoker Servlet</servlet-name>
+ <url-pattern>/integration-tests</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/CopiedException.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/CopiedException.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/CopiedException.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,70 @@
+package org.exoplatform.kernel.it;
+
+import java.io.BufferedReader;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class CopiedException extends RuntimeException
+{
+ private String msg;
+ private String trace;
+
+ public CopiedException(String trace)
+ {
+ this.trace = trace;
+ try
+ {
+ final String EOL = System.getProperty("line.separator");
+ StringBuilder sb = new StringBuilder();
+ BufferedReader lineReader = new BufferedReader(new StringReader(trace));
+ String line = null;
+ while ((line = lineReader.readLine()) != null)
+ {
+ if (line.trim().startsWith("at "))
+ {
+ break;
+ }
+ sb.append(line).append(EOL);
+ }
+ msg = sb.toString();
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Failed to initialize from stacktrace: ", ex);
+ }
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return msg;
+ }
+
+ @Override
+ public String toString()
+ {
+ return msg;
+ }
+
+ @Override
+ public void printStackTrace()
+ {
+ System.out.println(trace);
+ }
+
+ @Override
+ public void printStackTrace(PrintStream s)
+ {
+ s.println(trace);
+ }
+
+ @Override
+ public void printStackTrace(PrintWriter s)
+ {
+ s.println(trace);
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/FailuresParser.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/FailuresParser.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/FailuresParser.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,111 @@
+package org.exoplatform.kernel.it;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class FailuresParser
+{
+ private static final String END_OF_REPORT = "FAILURES!!!";
+ private Map<String, CopiedException> failures = new HashMap<String, CopiedException>();
+
+ FailuresParser(LineReader lineReader)
+ {
+ try
+ {
+ String line = null;
+ while ((line = lineReader.readLine()) != null)
+ {
+ String testMethodName = getNameIfStartOfFailure(line);
+
+ if (testMethodName == END_OF_REPORT)
+ {
+ break;
+ }
+
+ if (testMethodName != null)
+ {
+ failures.put(testMethodName, new CopiedException(readStackTrace(lineReader)));
+ lineReader.unreadLastLine();
+ }
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Failed to read response from server: ", ex);
+ }
+ }
+
+ public Map<String, CopiedException> getFailures()
+ {
+ return failures;
+ }
+
+ private String getNameIfStartOfFailure(String line)
+ {
+ // Number + ") " + methodName + "(" + className + ")"
+ // Number + ") " + className
+ if (END_OF_REPORT.equals(line))
+ {
+ return END_OF_REPORT;
+ }
+
+ int max = line.length() > 4 ? 4 : line.length();
+ int pos = line.substring(0, max).indexOf(")");
+ if (pos == -1)
+ {
+ return null;
+ }
+
+ try
+ {
+ Integer.valueOf(line.substring(0, pos));
+ }
+ catch (NumberFormatException ignored)
+ {
+ return null;
+ }
+
+ int endOfMethodPos = line.lastIndexOf("(", line.length() - 1);
+ if (endOfMethodPos == -1)
+ {
+ endOfMethodPos = line.length();
+ }
+
+ String ret = line.substring(pos + 2, endOfMethodPos);
+ // it should not contain any spaces, tabs, newlines, colons ...
+ String[] split = ret.split("(\\s|:)");
+ if (split.length > 1)
+ {
+ return null;
+ }
+ return ret;
+ }
+
+ private String readStackTrace(BufferedReader lineReader) throws IOException
+ {
+ final String EOL = System.getProperty("line.separator");
+ StringBuilder sb = new StringBuilder();
+
+ // Read for as long as lines don't look like beginning of another failure
+ String line = null;
+ while ((line = lineReader.readLine()) != null)
+ {
+ String testMethodName = getNameIfStartOfFailure(line);
+ if (testMethodName != null)
+ {
+ break;
+ }
+ sb.append(line).append(EOL);
+ }
+ return sb.toString();
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/LineReader.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/LineReader.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/LineReader.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,47 @@
+package org.exoplatform.kernel.it;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class LineReader extends BufferedReader
+{
+ private String lastLine;
+ private String unreadLine;
+
+ public LineReader(Reader reader)
+ {
+ super(reader);
+ }
+
+ public LineReader(Reader reader, int size)
+ {
+ super(reader, size);
+ }
+
+ public String readLine() throws IOException
+ {
+ if (unreadLine != null)
+ {
+ lastLine = unreadLine;
+ unreadLine = null;
+ }
+ else
+ {
+ lastLine = super.readLine();
+ }
+ return lastLine;
+ }
+
+ public void unreadLastLine()
+ {
+ if (unreadLine != null)
+ {
+ throw new RuntimeException("Can't unread multiple lines!");
+ }
+ unreadLine = lastLine;
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,79 @@
+package org.exoplatform.kernel.it;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This test needs to be executed in integration-test phase
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestMCInjectionIntegration
+{
+ protected String testClass;
+
+ protected Map<String, CopiedException> failures = new HashMap<String, CopiedException>();
+
+
+ public TestMCInjectionIntegration()
+ {
+ testClass = MCInjectionTest.class.getName();
+ }
+
+ @Before
+ public void init()
+ {
+ URL url = null;
+ try
+ {
+ String host = System.getProperty("server.host");
+ if (host == null)
+ {
+ host = "localhost";
+ }
+ String port = System.getProperty("server.port");
+ if (port == null)
+ {
+ port = "8080";
+ }
+ // invoke servlet
+ url = new URL("http://" + host + ":" + port + "/integration-tests/integration-tests?class=" + testClass);
+ System.out.println("Executing remote tests: " + url);
+ InputStream is = (InputStream) url.getContent();
+ LineReader lineReader = new LineReader(new InputStreamReader(is));
+ failures = new FailuresParser(lineReader).getFailures();
+ checkFailed(testClass);
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new RuntimeException("Buggy test case", ex);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to retrieve response for url: " + url, e);
+ }
+ }
+
+ private void checkFailed(String method)
+ {
+ RuntimeException ex = failures.get(method);
+ if (ex != null)
+ {
+ throw ex;
+ }
+ }
+
+ @Test
+ public void test()
+ {
+ checkFailed("test");
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration2.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration2.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration2.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,12 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestMCInjectionIntegration2 extends TestMCInjectionIntegration
+{
+ public TestMCInjectionIntegration2()
+ {
+ testClass = MCInjectionTest2.class.getName();
+ }
+}
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration3.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration3.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration3.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,12 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestMCInjectionIntegration3 extends TestMCInjectionIntegration
+{
+ public TestMCInjectionIntegration3()
+ {
+ testClass = MCInjectionTest3.class.getName();
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration4.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration4.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration4.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,12 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestMCInjectionIntegration4 extends TestMCInjectionIntegration
+{
+ public TestMCInjectionIntegration4()
+ {
+ testClass = MCInjectionTest4.class.getName();
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration5.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration5.java (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/integration-tests/src/test/java/org/exoplatform/kernel/it/TestMCInjectionIntegration5.java 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,12 @@
+package org.exoplatform.kernel.it;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestMCInjectionIntegration5 extends TestMCInjectionIntegration
+{
+ public TestMCInjectionIntegration5()
+ {
+ testClass = MCInjectionTest5.class.getName();
+ }
+}
\ No newline at end of file
Added: kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml (rev 0)
+++ kernel/branches/mc-int-branch/exo.kernel.tests/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -0,0 +1,21 @@
+<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-Beta04-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.exoplatform.kernel.tests</groupId>
+ <artifactId>tests-parent</artifactId>
+ <packaging>pom</packaging>
+
+ <name>eXo Kernel :: Tests</name>
+
+ <modules>
+ <module>integration-tests</module>
+ </modules>
+
+</project>
Modified: kernel/branches/mc-int-branch/pom.xml
===================================================================
--- kernel/branches/mc-int-branch/pom.xml 2009-11-27 11:53:44 UTC (rev 901)
+++ kernel/branches/mc-int-branch/pom.xml 2009-11-27 23:21:52 UTC (rev 902)
@@ -57,8 +57,10 @@
<module>exo.kernel.component.remote</module>
<module>exo.kernel.component.cache</module>
<module>exo.kernel.component.command</module>
+ <module>exo.kernel.mc-int</module>
+ <module>exo.kernel.mc-kernel-extras</module>
<module>exo.kernel.demos</module>
- <module>org.jboss.mc-kernel-extras</module>
+ <module>exo.kernel.tests</module>
<module>packaging/module</module>
</modules>
@@ -91,11 +93,23 @@
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>mc-kernel-extras</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <artifactId>exo.kernel.mc-int</artifactId>
+ <version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.mc-kernel-extras</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
+ <groupId>org.exoplatform.kernel.demos</groupId>
+ <artifactId>exo.kernel.demos.mc-injection</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.exoplatform.tool</groupId>
<artifactId>exo.tool.framework.junit</artifactId>
<version>1.2.0</version>
14 years, 5 months
exo-jcr SVN: r901 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-27 06:53:44 -0500 (Fri, 27 Nov 2009)
New Revision: 901
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestSearch.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/AbstractRestartTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestLockCleanup.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestVersionHistory.java
Log:
EXOJCR-199: restart tests added and refactored.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/AbstractRestartTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/AbstractRestartTest.java 2009-11-27 08:21:19 UTC (rev 900)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/AbstractRestartTest.java 2009-11-27 11:53:44 UTC (rev 901)
@@ -33,26 +33,41 @@
*/
public abstract class AbstractRestartTest extends JcrAPIBaseTest
{
- protected boolean firstRun = true;
+ protected static int run = 0;
+ protected static int testCasesCount = 0;
+
private final String runNodeName = "SecondRun";
+ /**
+ * Count of test cases in one test suite. After last test HSSQLDB "SHUTDOWN is called"
+ */
+ public AbstractRestartTest(int testCasesCount)
+ {
+ super();
+ this.testCasesCount = testCasesCount;
+ }
+
@Override
public void setUp() throws Exception
{
super.setUp();
- try
+ if (run == 0)
{
- root.getNode(runNodeName);
- // node exists, it means than this is second run
- firstRun = false;
+ try
+ {
+ root.getNode(runNodeName);
+ // node exists, it means than this is second run
+ run = 2;
+ }
+ catch (PathNotFoundException e)
+ {
+ root.addNode(runNodeName);
+ run = 1;
+ }
}
- catch (PathNotFoundException e)
- {
- root.addNode(runNodeName);
- }
session.save();
- if (firstRun)
+ if (run < 2)
{
log.info("/!\\ This is FIRST run");
}
@@ -64,7 +79,7 @@
public boolean isFirstRun()
{
- return firstRun;
+ return run < 2;
}
@Override
@@ -72,24 +87,28 @@
{
// super.tearDown in not invoked to prevent DB cleaning
// shutdown HSSQLDB :)
- if (firstRun)
+ testCasesCount--;
+ if (testCasesCount <= 0)
{
- for (Object uri : DatabaseManager.getDatabaseURIs())
+ if (isFirstRun())
{
- try
+ for (Object uri : DatabaseManager.getDatabaseURIs())
{
- Connection c = DriverManager.getConnection("jdbc:hsqldb:" + uri.toString(), "sa", "");
- c.createStatement().execute("SHUTDOWN");
+ try
+ {
+ Connection c = DriverManager.getConnection("jdbc:hsqldb:" + uri.toString(), "sa", "");
+ c.createStatement().execute("SHUTDOWN");
+ }
+ catch (Throwable e)
+ {
+ }
}
- catch (Throwable e)
- {
- }
}
+ else
+ {
+ super.tearDown();
+ }
}
- else
- {
- super.tearDown();
- }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestLockCleanup.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestLockCleanup.java 2009-11-27 08:21:19 UTC (rev 900)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestLockCleanup.java 2009-11-27 11:53:44 UTC (rev 901)
@@ -28,6 +28,14 @@
public class TestLockCleanup extends AbstractRestartTest
{
+ /**
+ *
+ */
+ public TestLockCleanup()
+ {
+ super(1);
+ }
+
/*
* This test should be performed manually because it requires JCR tearDown and startup without
* cleaning it's content.
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestSearch.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestSearch.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestSearch.java 2009-11-27 11:53:44 UTC (rev 901)
@@ -0,0 +1,169 @@
+/*
+ * 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.jcr.lab.restart;
+
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
+import java.io.ByteArrayInputStream;
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id$
+ *
+ */
+public class TestSearch extends AbstractRestartTest
+{
+ public TestSearch()
+ {
+ super(2);
+ }
+
+ public void testSearch() throws Exception
+ {
+ if (isFirstRun())
+ {
+ Node rootNode = session.getRootNode();
+ Node queryNode = rootNode.addNode("queryNode", "nt:unstructured");
+ if (!queryNode.canAddMixin("rma:record"))
+ throw new RepositoryException("Cannot add mixin node");
+ else
+ {
+ queryNode.addMixin("rma:record");
+ queryNode.setProperty("rma:recordIdentifier", "testIdentificator");
+ queryNode.setProperty("rma:originatingOrganization", "testProperty2");
+ }
+
+ Node node1 = queryNode.addNode("Test1", "nt:file");
+ Node content1 = node1.addNode("jcr:content", "nt:resource");
+ content1.setProperty("jcr:lastModified", Calendar.getInstance());
+ content1.setProperty("jcr:mimeType", "text/plain");
+ content1.setProperty("jcr:data", new ByteArrayInputStream("ABBA AAAA".getBytes()));
+ node1.addMixin("rma:record");
+ node1.setProperty("rma:recordIdentifier", "testIdentificator");
+ node1.setProperty("rma:originatingOrganization", "testProperty2");
+
+ Node node2 = queryNode.addNode("Test2", "nt:file");
+ Node content2 = node2.addNode("jcr:content", "nt:resource");
+ content2.setProperty("jcr:lastModified", Calendar.getInstance());
+ content2.setProperty("jcr:mimeType", "text/plain");
+ content2.setProperty("jcr:data", new ByteArrayInputStream("ACDC EEEE".getBytes()));
+ node2.addMixin("rma:record");
+ node2.setProperty("rma:recordIdentifier", "testIdentificator");
+ node2.setProperty("rma:originatingOrganization", "testProperty2");
+
+ session.save();
+ }
+ else
+ {
+ SessionImpl querySession = (SessionImpl)repository.login(credentials, "ws");
+ String sqlQuery = "SELECT * FROM rma:record WHERE jcr:path LIKE '/queryNode/%' ";
+ QueryManager manager = querySession.getWorkspace().getQueryManager();
+ Query query = manager.createQuery(sqlQuery, Query.SQL);
+
+ QueryResult queryResult = query.execute();
+ NodeIterator iter = queryResult.getNodes();
+
+ assertTrue(iter.getSize() == 2); // check target nodes for existanse
+ while (iter.hasNext())
+ {
+ assertNotNull(iter.nextNode());
+ }
+
+ sqlQuery = "//*[jcr:contains(., 'ABBA')]";
+ query = manager.createQuery(sqlQuery, Query.XPATH);
+
+ queryResult = query.execute();
+ iter = queryResult.getNodes();
+
+ while (iter.hasNext())
+ {
+ System.out.print(iter.nextNode().getPath());
+ }
+
+ assertEquals("Result nodes count is wrong", 1, iter.getSize());
+ while (iter.hasNext())
+ {
+ assertEquals("Content must be equals", "ABBA AAAA", iter.nextNode().getProperty("jcr:data").getString());
+ }
+ }
+ }
+
+ public void testSQLQuery() throws Exception
+ {
+ if (isFirstRun())
+ {
+ Node testRoot = root.addNode("testSqlQuery");
+ root.save();
+
+ String prefixPath = testRoot.getPath();
+
+ // files
+ Node subnode = testRoot.addNode("files");
+
+ Node sdata = subnode.addNode("draft");
+ sdata.addNode("content1");
+
+ Node file = subnode.addNode("myFile1", "nt:file");
+ Node cfile = file.addNode("jcr:content", "nt:unstructured").addNode("myFile1", "nt:file");
+ cfile.addNode("jcr:content", "nt:base");
+
+ file = subnode.addNode("myFile2", "nt:file");
+ cfile = file.addNode("jcr:content", "nt:unstructured").addNode("myFile1", "nt:file");
+ cfile.addNode("jcr:content", "nt:base");
+
+ // data
+ subnode = testRoot.addNode("data");
+
+ sdata = subnode.addNode("draft");
+ sdata.addNode("content1");
+ sdata.addNode("content2");
+
+ Node data = subnode.addNode("myData1", "nt:file");
+ data.addNode("jcr:content", "nt:unstructured");
+
+ data = subnode.addNode("myData2", "nt:file");
+ data.addNode("jcr:content", "nt:unstructured");
+
+ testRoot.save();
+ }
+ else
+ {
+
+ Query q =
+ session.getWorkspace().getQueryManager().createQuery(
+ "select * from nt:unstructured where jcr:path like '/testSqlQuery/%/draft/%'", Query.SQL);
+
+ QueryResult res = q.execute();
+ assertEquals("Wrong nodes count in result set", 3, res.getNodes().getSize());
+
+ for (NodeIterator nodes = res.getNodes(); nodes.hasNext();)
+ {
+ log.info(nodes.nextNode().getPath());
+ }
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestSearch.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestVersionHistory.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestVersionHistory.java 2009-11-27 08:21:19 UTC (rev 900)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/restart/TestVersionHistory.java 2009-11-27 11:53:44 UTC (rev 901)
@@ -46,6 +46,14 @@
* then (without clean!) :
* >mvn test -Dtest=org.exoplatform.services.jcr.lab.restart.TestVersionHistory
*/
+
+ /**
+ *
+ */
+ public TestVersionHistory()
+ {
+ super(1);
+ }
private Node testVersionable = null;
14 years, 5 months
exo-jcr SVN: r900 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-27 03:21:19 -0500 (Fri, 27 Nov 2009)
New Revision: 900
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
Log:
EXOJCR-271: test scalability
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java 2009-11-27 02:14:36 UTC (rev 899)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java 2009-11-27 08:21:19 UTC (rev 900)
@@ -19,12 +19,8 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.jcr.Node;
import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
import javax.jcr.Session;
/**
@@ -39,7 +35,7 @@
{
private static final String testName = "testRoot";
- private static final int sessionCount = 20;
+ private static final int sessionCount = 10;
private static final int tryCount = 5;
@@ -95,6 +91,9 @@
break;
}
+
+ log.info("waiting for 10 seconds...");
+ Thread.sleep(10000);
}
log.info("Memory used: " + (rt.totalMemory() - rt.freeMemory() - usedMemory) / 1024 / 1024 + "Mb");
}
14 years, 5 months
exo-jcr SVN: r899 - 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: pnedonosko
Date: 2009-11-26 21:14:36 -0500 (Thu, 26 Nov 2009)
New Revision: 899
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/JDBCCacheLoader.java
Log:
EXOJCR-270: skip transitive ACL updates on DB level; cleanups
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-11-27 02:12:58 UTC (rev 898)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-27 02:14:36 UTC (rev 899)
@@ -294,7 +294,7 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- // propsRoot.getChild(makePropFqn(data.getIdentifier()))
+
// check if parent is cached
Node<Serializable, Object> parent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
if (parent == null)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-27 02:12:58 UTC (rev 898)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-27 02:14:36 UTC (rev 899)
@@ -89,18 +89,14 @@
}
/**
- * Apply all Modifications to JDBC database, but don't commite them.
+ * Apply all Modifications on JDBC database, but don't commit them.
*
* @param modifications List if Modification
* @param conn JDBCStorageConnection
- * @throws RepositoryException if error
+ * @throws RepositoryException if error occurs
*/
protected void apply(List<Modification> modifications, JDBCStorageConnection conn) throws RepositoryException
{
- // TODO Prepare modifications list.
- // Will be added oldValueData to modification for UPDATE.
- //prepareModifications(modifications);
-
for (Modification m : modifications)
{
switch (m.getType())
@@ -271,9 +267,10 @@
// update if it's non transitive update
if (item.isNode())
{
- if ((item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0)
+ if ((item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0
+ && (item.getState() & TransientItemData.TRANSITIVE_ACL_UPDATED) == 0)
{
- // TODO do not handle mixin updates in db; it's a workaround - review logic in the connection
+ // TODO do not handle mixin or ACL updates in db; it's a workaround - review logic in the connection
// TODO conn.rename() is used to update all the fields in DB.
// Original conn.update() will be matched as deprecated,
@@ -801,56 +798,4 @@
throw new JDBCCacheLoaderException("The method 'removeData(Fqn fqn)' should not be called.");
}
- // etc.
-
- /**
- * Prepare list of modifications.
- *
- * Will be checked the UPDATE or ADD.
- *
- * @param modifications
- * @throws RepositoryException
- */
- @Deprecated
- private void prepareModifications(List<Modification> modifications) throws RepositoryException
- {
- WorkspaceStorageConnection conn = dataContainer.openConnection();
-
- try
- {
- for (int i = 0; i < modifications.size(); i++)
- {
- Modification m = modifications.get(i);
- if (m.getType() == ModificationType.PUT_KEY_VALUE)
- {
- ItemData itemData = null;
-
- //Check add or update node data.
- if (m.getValue() instanceof NodeData)
- {
- NodeData nodeData = (NodeData)m.getValue();
- itemData = conn.getItemData(nodeData.getIdentifier());
-
- // Set oldValueData for update node.
- if (itemData != null)
- modifications.get(i).setOldValue(itemData);
- }
- else if (m.getValue() instanceof PropertyData)
- {
- PropertyData propertyData = (PropertyData)m.getValue();
- itemData = conn.getItemData(propertyData.getIdentifier());
-
- // Set oldValueData for update property.
- if (itemData != null)
- modifications.get(i).setOldValue(itemData);
- }
- }
- }
- }
- finally
- {
- conn.close();
- }
- }
-
}
\ No newline at end of file
14 years, 5 months