exo-jcr SVN: r4597 - in jcr/trunk: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 07:51:45 -0400 (Tue, 05 Jul 2011)
New Revision: 4597
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
Log:
EXOJCR-1396: added possibility to control sessions closing before repository removing
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 09:24:54 UTC (rev 4596)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 11:51:45 UTC (rev 4597)
@@ -101,8 +101,10 @@
* Remove previously created repository.
*
* @param repositoryName - the repository name to delete
+ * @param forceCloseSessions - indicates if need to close sessions before repository removing, if
+ * sessions are opened is it not possbile to remove repository and exception will be thrown
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occurred
*/
- void removeRepository(String repositoryName) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 09:24:54 UTC (rev 4596)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 11:51:45 UTC (rev 4597)
@@ -231,8 +231,10 @@
public Serializable execute(Serializable[] args) throws Throwable
{
String repositoryName = (String)args[0];
- removeRepositoryLocally(repositoryName);
+ boolean forceCloseSessions = (Boolean)args[1];
+ removeRepositoryLocally(repositoryName, forceCloseSessions);
+
return null;
}
});
@@ -733,13 +735,14 @@
/**
* {@inheritDoc}
*/
- public void removeRepository(String repositoryName) throws RepositoryCreationException
+ public void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException
{
if (rpcService != null)
{
try
{
- List<Object> results = rpcService.executeCommandOnAllNodes(removeRepository, true, repositoryName);
+ List<Object> results =
+ rpcService.executeCommandOnAllNodes(removeRepository, true, repositoryName, forceCloseSessions);
for (Object result : results)
{
@@ -764,7 +767,7 @@
}
else
{
- removeRepositoryLocally(repositoryName);
+ removeRepositoryLocally(repositoryName, forceCloseSessions);
}
}
@@ -773,9 +776,12 @@
*
* @param repositoryName
* the repository name
+ * @param forceCloseSessions - indicates if need to close session before repository removing, if
+ * sessions are opened is it not possbile to remove repository and exception will be throw
* @throws RepositoryCreationException
*/
- protected void removeRepositoryLocally(String repositoryName) throws RepositoryCreationException
+ protected void removeRepositoryLocally(String repositoryName, boolean forceCloseSessions)
+ throws RepositoryCreationException
{
try
{
@@ -783,13 +789,16 @@
ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
Set<String> datasources = extractDataSourceNames(repositorty.getConfiguration(), false);
- // close all opened sessions
- for (String workspaceName : repositorty.getWorkspaceNames())
+ if (forceCloseSessions)
{
- WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
- SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
+ // close all opened sessions
+ for (String workspaceName : repositorty.getWorkspaceNames())
+ {
+ WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
+ SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
- sessionRegistry.closeSessions(workspaceName);
+ sessionRegistry.closeSessions(workspaceName);
+ }
}
// remove repository from configuration
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 09:24:54 UTC (rev 4596)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 11:51:45 UTC (rev 4597)
@@ -220,10 +220,12 @@
* Remove previously created repository.
*
* @param repositoryName - the repository name to delete
+ * @param forceCloseSessions - indicates if need to close session before repository removing, if
+ * sessions are opened is it not possbile to remove repository and exception will be thrown
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occurred
*/
- void removeRepository(String repositoryName) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException;
}</programlisting>
</section>
14 years, 10 months
exo-jcr SVN: r4596 - in jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules: kernel and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 05:24:54 -0400 (Tue, 05 Jul 2011)
New Revision: 4596
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/initialcontext-binder-service.xml
Log:
EXOJCR-1396: docbook updated
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 09:18:02 UTC (rev 4595)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 09:24:54 UTC (rev 4596)
@@ -215,6 +215,15 @@
*/
void createRepository(String backupId, RepositoryEntry rEntry, String rToken)
throws RepositoryConfigurationException, RepositoryCreationException;
+
+ /**
+ * Remove previously created repository.
+ *
+ * @param repositoryName - the repository name to delete
+ * @throws RepositoryCreationServiceException
+ * if some exception occurred during repository removing occurred
+ */
+ void removeRepository(String repositoryName) throws RepositoryCreationException;
}</programlisting>
</section>
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/initialcontext-binder-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/initialcontext-binder-service.xml 2011-07-05 09:18:02 UTC (rev 4595)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/initialcontext-binder-service.xml 2011-07-05 09:24:54 UTC (rev 4596)
@@ -49,5 +49,9 @@
<para>Returns reference associated with defined name:</para>
<programlisting language="java">public Reference getReference(String bindName)</programlisting>
+
+ <para>Unbind the Reference with defined name:</para>
+
+ <programlisting language="java">public void unbind(String bindName) throws NamingException, FileNotFoundException, XMLStreamException</programlisting>
</section>
</chapter>
14 years, 10 months
exo-jcr SVN: r4595 - kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 05:18:02 -0400 (Tue, 05 Jul 2011)
New Revision: 4595
Modified:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java
Log:
EXOJCR-1418: remove violations
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java 2011-07-05 09:11:58 UTC (rev 4594)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java 2011-07-05 09:18:02 UTC (rev 4595)
@@ -56,7 +56,8 @@
* @version $Id$
*
*/
-public class InvalidationExoCache<K extends Serializable, V> implements ExoCache<K, V>, CacheListener<K, InvalidationExoCache.HashCode<V>>
+public class InvalidationExoCache<K extends Serializable, V> implements ExoCache<K, V>,
+ CacheListener<K, InvalidationExoCache.HashCode<V>>
{
/**
* Logger.
@@ -333,7 +334,7 @@
}
/**
- * @see org.exoplatform.services.cache.CacheListener#onExpire(org.exoplatform.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Object)
+ * {@inheritDoc}
*/
public void onExpire(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
{
@@ -357,7 +358,7 @@
}
/**
- * @see org.exoplatform.services.cache.CacheListener#onRemove(org.exoplatform.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Object)
+ * {@inheritDoc}
*/
public void onRemove(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
{
@@ -381,7 +382,7 @@
}
/**
- * @see org.exoplatform.services.cache.CacheListener#onPut(org.exoplatform.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Object)
+ * {@inheritDoc}
*/
public void onPut(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
{
@@ -424,7 +425,7 @@
}
/**
- * @see org.exoplatform.services.cache.CacheListener#onGet(org.exoplatform.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Object)
+ * {@inheritDoc}
*/
public void onGet(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
{
14 years, 10 months
exo-jcr SVN: r4594 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 05:11:58 -0400 (Tue, 05 Jul 2011)
New Revision: 4594
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
Log:
EXOJCR-1423: Remove reference from InitialContextBinder
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 09:11:22 UTC (rev 4593)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 09:11:58 UTC (rev 4594)
@@ -779,8 +779,11 @@
{
try
{
+ // extract list of all datasources
+ ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
+ Set<String> datasources = extractDataSourceNames(repositorty.getConfiguration(), false);
+
// close all opened sessions
- ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
for (String workspaceName : repositorty.getWorkspaceNames())
{
WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
@@ -792,6 +795,12 @@
// remove repository from configuration
repositoryService.removeRepository(repositoryName);
repositoryService.getConfig().retain();
+
+ // unbind datasource
+ for (String ds : datasources)
+ {
+ initialContextInitializer.getInitialContextBinder().unbind(ds);
+ }
}
catch (RepositoryException e)
{
@@ -801,6 +810,18 @@
{
throw new RepositoryCreationException("Can't remove repository", e);
}
+ catch (FileNotFoundException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", e);
+ }
+ catch (NamingException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", e);
+ }
}
private DBCreator getDBCreator(DBCreationProperties creationProps) throws ConfigurationException
14 years, 10 months
exo-jcr SVN: r4593 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 05:11:22 -0400 (Tue, 05 Jul 2011)
New Revision: 4593
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
Log:
EXOJCR-1423: Remove reference from InitialContextBinder
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2011-07-05 08:49:25 UTC (rev 4592)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2011-07-05 09:11:22 UTC (rev 4593)
@@ -177,6 +177,25 @@
}
/**
+ * Unbind the Reference with defined name, remove from the bindings list and persists the rest of references
+ * into the file.
+ *
+ * @param bindName
+ * the Reference's bind name
+ * @throws NamingException
+ * @throws FileNotFoundException
+ * @throws XMLStreamException
+ */
+ public void unbind(String bindName) throws NamingException, FileNotFoundException,
+ XMLStreamException
+ {
+ initialContextInitializer.getInitialContext().unbind(bindName);
+ bindings.remove(bindName);
+
+ saveBindings();
+ }
+
+ /**
* Returns reference associated with defined name.
*
* @param bindName the name on which the reference was binded.
14 years, 10 months
exo-jcr SVN: r4592 - in jcr/trunk/exo.jcr.component.ext/src: test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 04:49:25 -0400 (Tue, 05 Jul 2011)
New Revision: 4592
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode2.java
Log:
EXOJCR-1422: Remove repository in cluster mode
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 07:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 08:49:25 UTC (rev 4592)
@@ -122,6 +122,8 @@
private RemoteCommand startRepository;
+ private RemoteCommand removeRepository;
+
/**
* Constructor RepositoryCreationServiceImpl.
*/
@@ -218,6 +220,22 @@
return null;
}
});
+
+ removeRepository = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-removeRepository";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ String repositoryName = (String)args[0];
+ removeRepositoryLocally(repositoryName);
+
+ return null;
+ }
+ });
}
else
{
@@ -308,7 +326,15 @@
if (result != null)
{
- throw new RepositoryCreationException("CreateRepository command must not return any results.");
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't create repository " + rEntry.getName(),
+ (Throwable)result);
+ }
+ else
+ {
+ throw new RepositoryCreationException("createRepository command returned uknown result type.");
+ }
}
}
catch (RPCException e)
@@ -336,22 +362,18 @@
for (Object result : results)
{
- if (result instanceof RPCException)
+ if (result != null)
{
- Throwable cause = ((RPCException)result).getCause();
- if (cause instanceof RepositoryCreationException)
+ if (result instanceof Throwable)
{
throw new RepositoryCreationException("Repository " + rEntry.getName()
- + " created on coordinator, but can not be started at other cluster nodes: "
- + cause.getMessage(), cause);
+ + " created on coordinator, but can not be started at other cluster nodes", ((Throwable)result));
}
+ else
+ {
+ throw new RepositoryCreationException("startRepository command returns uknown result type");
+ }
}
- if (result instanceof Throwable)
- {
- throw new RepositoryCreationException("Repository " + rEntry.getName()
- + " created on coordinator, but can not be started at other cluster nodes: "
- + ((Throwable)result).getMessage(), ((Throwable)result));
- }
}
}
catch (RPCException e)
@@ -389,6 +411,10 @@
{
return (String)result;
}
+ else if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't reserve repository " + repositoryName, (Throwable)result);
+ }
else
{
throw new RepositoryCreationException("ReserveRepositoryName command returns unknown type result.");
@@ -700,6 +726,7 @@
this.rpcService.unregisterCommand(reserveRepositoryName);
this.rpcService.unregisterCommand(createRepository);
this.rpcService.unregisterCommand(startRepository);
+ this.rpcService.unregisterCommand(removeRepository);
}
}
@@ -708,7 +735,37 @@
*/
public void removeRepository(String repositoryName) throws RepositoryCreationException
{
- removeRepositoryLocally(repositoryName);
+ if (rpcService != null)
+ {
+ try
+ {
+ List<Object> results = rpcService.executeCommandOnAllNodes(removeRepository, true, repositoryName);
+
+ for (Object result : results)
+ {
+ if (result != null)
+ {
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't remove repository " + repositoryName,
+ (Throwable)result);
+ }
+ else
+ {
+ throw new RepositoryCreationException("removeRepository command returned uknown result type");
+ }
+ }
+ }
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository " + repositoryName, e);
+ }
+ }
+ else
+ {
+ removeRepositoryLocally(repositoryName);
+ }
}
/**
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 07:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 08:49:25 UTC (rev 4592)
@@ -32,6 +32,8 @@
import java.util.HashMap;
import java.util.Map;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -53,8 +55,8 @@
connProps.put("password", "24635457");
DBCreationProperties creationProps =
- new DBCreationProperties("jdbc:mysql://localhost/", connProps,
- "src/test/resources/test-mysql.sql", "user1", "pass1");
+ new DBCreationProperties("jdbc:mysql://localhost/", connProps, "src/test/resources/test-mysql.sql", "user3",
+ "pass3");
// prepare
String dsName = helper.createDatasource();
@@ -81,7 +83,7 @@
(RepositoryCreationService)container.getComponentInstanceOfType(RepositoryCreationService.class);
assertNotNull(creatorService);
- String tenantName = "tenant_2";
+ String tenantName = "tenant_4";
String repoToken = creatorService.reserveRepositoryName(tenantName);
// restore
@@ -106,7 +108,22 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
log.info("Node1: Repository has been created");
- Thread.sleep(100000);
+ Thread.sleep(60000);
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing
+ }
+
+ log.info("Node1: Repository removed");
}
@Override
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode2.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode2.java 2011-07-05 07:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode2.java 2011-07-05 08:49:25 UTC (rev 4592)
@@ -16,11 +16,14 @@
*/
package org.exoplatform.services.jcr.ext.repository.creation.cluster;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.backup.AbstractBackupTestCase;
import org.exoplatform.services.jcr.ext.backup.ExtendedBackupManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -36,7 +39,7 @@
log.info("Node2: Waits for the repository creation");
Thread.sleep(60000);
- String tenantName = "tenant_2";
+ String tenantName = "tenant_4";
// check
ManageableRepository restoredRepository = repositoryService.getRepository(tenantName);
@@ -48,7 +51,21 @@
session.getRootNode();
log.info("Node2: test passed. I have root node");
- Thread.sleep(100000);
+ Thread.sleep(120000);
+
+ RepositoryService repoService = (RepositoryService)this.container.getComponentInstance(RepositoryService.class);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing
+ }
+
+ log.info("Node2: Repository removed");
}
@Override
14 years, 10 months
exo-jcr SVN: r4591 - in jcr/trunk: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl and 4 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 03:42:37 -0400 (Tue, 05 Jul 2011)
New Revision: 4591
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositoryRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
Log:
EXOJCR-1420: Remove repository in Standalone mode
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -46,8 +46,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.StringTokenizer;
import java.util.Map.Entry;
+import java.util.StringTokenizer;
import javax.jcr.RepositoryException;
@@ -119,14 +119,6 @@
}
/**
- * {@inheritDoc}
- */
- public boolean canRemoveRepository(String name) throws RepositoryException
- {
- return canRemoveRepository(name, false);
- }
-
- /**
* Create repository. <br>
* Init worksapces for initial start or them load from persistence. <br>
* Add namespaces and nodetypes from service plugins.
@@ -232,14 +224,6 @@
return (ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
}
- /**
- * {@inheritDoc}
- */
- public void removeRepository(String name) throws RepositoryException
- {
- removeRepository(name, false);
- }
-
public void setCurrentRepositoryName(String repositoryName) throws RepositoryConfigurationException
{
// Need privileges to manage repository.
@@ -312,17 +296,6 @@
managerStartChanges.cleanup();
}
- /**
- * Remove default repository.
- *
- * @throws RepositoryException
- * if any Exception occurred during removing
- */
- public void removeDefaultRepository() throws RepositoryException
- {
- removeRepository(config.getDefaultRepositoryName(), true);
- }
-
private void init(ExoContainer container) throws RepositoryConfigurationException, RepositoryException
{
this.parentContainer = container;
@@ -396,16 +369,9 @@
}
/**
- * Remove repository with specific name.
- *
- * @param name
- * repository name
- * @param allowRemoveDefaultRepository
- * allow to remove default repository
- * @throws RepositoryException
- * if any Exception occurred
+ * {@inheritDoc}
*/
- private void removeRepository(String name, boolean allowRemoveDefaultRepository) throws RepositoryException
+ public void removeRepository(String name) throws RepositoryException
{
// Need privileges to manage repository.
SecurityManager security = System.getSecurityManager();
@@ -414,7 +380,7 @@
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
- if (!canRemoveRepository(name, allowRemoveDefaultRepository))
+ if (!canRemoveRepository(name))
throw new RepositoryException("Repository " + name + " in use. If you want to "
+ " remove repository close all open sessions");
@@ -458,24 +424,10 @@
}
/**
- * Indicates if repository with specific name can be removed.
- *
- * @param name
- * repository name
- * @param allowRemoveDefaultRepository
- * allow to remove default repository
- * @return
- * true if repository can be removed or false in other case
- * @throws RepositoryException
- * if any Exception occurred
+ * {@inheritDoc}
*/
- private boolean canRemoveRepository(String name, boolean allowRemoveDefaultRepository) throws RepositoryException
+ public boolean canRemoveRepository(String name) throws RepositoryException
{
- if (!allowRemoveDefaultRepository && name.equals(config.getDefaultRepositoryName()))
- {
- return false;
- }
-
RepositoryImpl repo = (RepositoryImpl)getRepository(name);
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositoryRestore.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositoryRestore.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryRestoreExeption;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
import org.exoplatform.services.jcr.impl.backup.Backupable;
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
@@ -101,14 +100,7 @@
}
//remove repository
- if (isDefault)
- {
- ((RepositoryServiceImpl)repositoryService).removeDefaultRepository();
- }
- else
- {
- repositoryService.removeRepository(repositoryEntry.getName());
- }
+ repositoryService.removeRepository(repositoryEntry.getName());
// clean
for (Backupable component : backupable)
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -18,6 +18,19 @@
*/
package org.exoplatform.services.jcr.ext.repository;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -34,23 +47,9 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
-import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.ManageableRepository;
-import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.exoplatform.services.jcr.impl.core.SessionRegistry;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-
/**
* Created by The eXo Platform SAS.
*
@@ -390,14 +389,7 @@
}
}
- if (repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryName))
- {
- ((RepositoryServiceImpl) repositoryService).removeDefaultRepository();
- }
- else
- {
- repositoryService.removeRepository(repositoryName);
- }
+ repositoryService.removeRepository(repositoryName);
repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
return Response.ok().build();
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -96,4 +96,13 @@
*/
void createRepository(String backupId, RepositoryEntry rEntry, String rToken)
throws RepositoryConfigurationException, RepositoryCreationException;
+
+ /**
+ * Remove previously created repository.
+ *
+ * @param repositoryName - the repository name to delete
+ * @throws RepositoryCreationServiceException
+ * if some exception occurred during repository removing occurred
+ */
+ void removeRepository(String repositoryName) throws RepositoryCreationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -27,11 +27,14 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.ext.backup.BackupConfigurationException;
import org.exoplatform.services.jcr.ext.backup.BackupManager;
import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
@@ -377,24 +380,6 @@
{
if (rpcService != null)
{
- // check does repository already created
- try
- {
- if (repositoryService.getRepository(repositoryName) != null)
- {
- throw new RepositoryCreationException("Repository " + repositoryName + " already exists.");
- }
- }
- catch (RepositoryConfigurationException e)
- {
- throw new RepositoryCreationException("Can not check does repository " + repositoryName + " exists: "
- + e.getMessage(), e);
- }
- catch (RepositoryException e)
- {
- //ok - repository does not exists
- }
-
// reserve RepositoryName at coordinator-node
try
{
@@ -718,6 +703,49 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
+ public void removeRepository(String repositoryName) throws RepositoryCreationException
+ {
+ removeRepositoryLocally(repositoryName);
+ }
+
+ /**
+ * Remove repository locally.
+ *
+ * @param repositoryName
+ * the repository name
+ * @throws RepositoryCreationException
+ */
+ protected void removeRepositoryLocally(String repositoryName) throws RepositoryCreationException
+ {
+ try
+ {
+ // close all opened sessions
+ ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
+ for (String workspaceName : repositorty.getWorkspaceNames())
+ {
+ WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
+ SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
+
+ sessionRegistry.closeSessions(workspaceName);
+ }
+
+ // remove repository from configuration
+ repositoryService.removeRepository(repositoryName);
+ repositoryService.getConfig().retain();
+ }
+ catch (RepositoryException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", e);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", e);
+ }
+ }
+
private DBCreator getDBCreator(DBCreationProperties creationProps) throws ConfigurationException
{
if (creationProps == null)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -35,7 +35,6 @@
import org.exoplatform.services.jcr.ext.backup.impl.BackupManagerImpl;
import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanService;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -557,9 +556,6 @@
throw new RepositoryRestoreExeption("Current repository configuration " + repositoryName + " did not found");
}
- boolean isDefault =
- repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryEntry.getName());
-
//Create local copy of WorkspaceEntry for all workspaces
ArrayList<WorkspaceEntry> workspaceList = new ArrayList<WorkspaceEntry>();
workspaceList.addAll(repositoryEntry.getWorkspaceEntries());
@@ -574,14 +570,7 @@
repositoryService.getRepository(repositoryName).getConfiguration().getSystemWorkspaceName();
//remove repository
- if (isDefault)
- {
- ((RepositoryServiceImpl)repositoryService).removeDefaultRepository();
- }
- else
- {
- repositoryService.removeRepository(repositoryEntry.getName());
- }
+ repositoryService.removeRepository(repositoryEntry.getName());
// clean data
for (WorkspaceEntry wEntry : workspaceList)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -32,6 +32,8 @@
import java.util.HashMap;
import java.util.Map;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -93,6 +95,19 @@
//check repositoryConfiguration
RepositoryService repoService = (RepositoryService)this.container.getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing
+ }
}
public void testCreateRepositorySingleDB() throws Exception
@@ -147,6 +162,19 @@
//check repositoryConfiguration
RepositoryService repoService = (RepositoryService)this.container.getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing
+ }
}
public void testCreateRepositorySingleDBWithSpecificCreationProps() throws Exception
@@ -210,6 +238,19 @@
//check repositoryConfiguration
RepositoryService repoService = (RepositoryService)this.container.getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing
+ }
}
public void testReserveRepositoryNameException() throws Exception
14 years, 10 months
exo-jcr SVN: r4590 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-07-05 02:23:08 -0400 (Tue, 05 Jul 2011)
New Revision: 4590
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/AuditPropertyImpl.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
Log:
EXOJCR-1408: added AuditPropertyImpl which extends PropertyImpl to avoid redundant operations not used during trail audit
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/AuditPropertyImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/AuditPropertyImpl.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/AuditPropertyImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
@@ -0,0 +1,56 @@
+package org.exoplatform.services.jcr.impl.core;
+
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.PropertyDefinition;
+
+/**
+ * Created to avoid huge operations on PropertyImpl instance initialization,
+ * as they are not needed for trail audit.
+ *
+ * @author <a href="mailto:dmi3.kuleshov@gmail.com">Dmitry Kuleshov</a>
+ * @version $Id: $
+ */
+public class AuditPropertyImpl extends PropertyImpl
+{
+
+ AuditPropertyImpl(ItemData data, SessionImpl session) throws RepositoryException, ConstraintViolationException
+ {
+ super(data, session);
+ }
+
+ /**
+ * The most expensive method. In parent class it fulfills useless operations
+ * in context of trail audit.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ void loadData(ItemData data) throws RepositoryException
+ {
+ this.qpath = data.getQPath();
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ItemDefinitionData getItemDefinitionData()
+ {
+ throw new UnsupportedOperationException("getItemDefinitionData method is not supported by this class");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PropertyDefinition getDefinition()
+ {
+ throw new UnsupportedOperationException("getItemDefinitionData method is not supported by this class");
+ }
+
+}
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 2011-07-04 17:19:31 UTC (rev 4589)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
@@ -478,7 +478,7 @@
{
// update of the property
prevProp = (PropertyImpl)prevItem;
- prevProperty = new PropertyImpl(prevProp.getData(), prevProp.parentData(), prevProp.getSession());
+ prevProperty = new AuditPropertyImpl(prevProp.getData(), prevProp.getSession());
isMultiValue = prevProp.isMultiValued();
defs =
ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
14 years, 10 months
exo-jcr SVN: r4589 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-07-04 13:19:31 -0400 (Mon, 04 Jul 2011)
New Revision: 4589
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
Log:
EXOJCR-1419: Complete the doc
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-04 17:12:39 UTC (rev 4588)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-04 17:19:31 UTC (rev 4589)
@@ -236,12 +236,12 @@
<title>FutureExoCache</title>
<para>If the data that you want to store into your eXo Cache instance
- and/or you would like to prevent multiple concurrent loading of the same
- data at the same time, you can use
+ takes a lot of time to load and/or you would like to prevent multiple
+ concurrent loading of the same data at the same time, you can use
<emphasis>org.exoplatform.services.cache.future.FutureExoCache</emphasis>
on top of your eXo Cache instance in order to delegate the loading of
your data to a loader that will be called only once whatever the total
- amount of concurrent thread looking for it. See below an example of how
+ amount of concurrent threads looking for it. See below an example of how
the FutureExoCache can be used:</para>
<programlisting language="java">import org.exoplatform.services.cache.future.Loader;
14 years, 10 months
exo-jcr SVN: r4588 - kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache and 3 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-07-04 13:12:39 -0400 (Mon, 04 Jul 2011)
New Revision: 4588
Added:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureCache.java
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureExoCache.java
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/Loader.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/ConcurrentGetWhenPutTestCase.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/FutureMap.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/GetTestCase.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/StringLoader.java
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
Log:
EXOJCR-1419: Move FutureExoCache from GateIn commons to eXo kernel
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-04 12:56:27 UTC (rev 4587)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-04 17:12:39 UTC (rev 4588)
@@ -133,7 +133,7 @@
<entry>replicated</entry>
<entry>Indicates if the cache is replicated. This field is
- optional. </entry>
+ optional.</entry>
</row>
<row>
@@ -231,6 +231,36 @@
the infinite loop described above will still be effective.</para>
</note>
</section>
+
+ <section>
+ <title>FutureExoCache</title>
+
+ <para>If the data that you want to store into your eXo Cache instance
+ and/or you would like to prevent multiple concurrent loading of the same
+ data at the same time, you can use
+ <emphasis>org.exoplatform.services.cache.future.FutureExoCache</emphasis>
+ on top of your eXo Cache instance in order to delegate the loading of
+ your data to a loader that will be called only once whatever the total
+ amount of concurrent thread looking for it. See below an example of how
+ the FutureExoCache can be used:</para>
+
+ <programlisting language="java">import org.exoplatform.services.cache.future.Loader;
+import org.exoplatform.services.cache.future.FutureExoCache;
+...
+ // Define first your loader and choose properly your context object in order
+ // to be able to reuse the same loader for different FutureExoCache instances
+ Loader<String, String, String> loader = new Loader<String, String, String>()
+ {
+ public String retrieve(String context, String key) throws Exception
+ {
+ return "Value loaded thanks to the key = '" + key + "' and the context = '" + context + "'";
+ }
+ };
+ // Create your FutureExoCache from your eXo cache instance and your loader
+ FutureExoCache<String, String, String> myFutureExoCache = new FutureExoCache<String, String, String>(loader, myExoCache);
+ // Get your data from your future cache instance
+ System.out.println(myFutureExoCache.get("my context", "foo"));</programlisting>
+ </section>
</section>
<section>
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureCache.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+/**
+ * A future cache that prevents the loading of the same resource twice. This should be used when the resource
+ * to load is very expensive or cannot be concurrently retrieved (like a classloading).
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
+ */
+public abstract class FutureCache<K, V, C>
+{
+
+ /** . */
+ private final Loader<K, V, C> loader;
+
+ /** . */
+ private final ConcurrentMap<K, FutureTask<V>> futureEntries;
+
+ /** . */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.component.cache.FutureCache");
+
+
+ public FutureCache(Loader<K, V, C> loader)
+ {
+ this.loader = loader;
+ this.futureEntries = new ConcurrentHashMap<K, FutureTask<V>>();
+ }
+
+ protected abstract V get(K key);
+
+ protected abstract void put(K key, V value);
+
+ /**
+ * Perform a cache lookup for the specified key within the specified context.
+ * When the value cannot be loaded (because it does not exist or it failed or anything else that
+ * does not come to my mind), the value null is returned.
+ *
+ * @param context the context in which the resource is accessed
+ * @param key the key identifying the resource
+ * @return the value
+ */
+ public final V get(final C context, final K key)
+ {
+ // First we try a simple cache get
+ V value = get(key);
+
+ // If it does not succeed then we go through a process that will avoid to load
+ // the same resource concurrently
+ if (value == null)
+ {
+ // Create our future
+ FutureTask<V> future = new FutureTask<V>(new Callable<V>()
+ {
+ public V call() throws Exception
+ {
+ // Retrieve the value from the loader
+ V value = loader.retrieve(context, key);
+
+ //
+ if (value != null)
+ {
+ // Cache it, it is made available to other threads (unless someone removes it)
+ put(key, value);
+
+ // Return value
+ return value;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ });
+
+ // This boolean means we inserted in the local
+ boolean inserted = true;
+
+ //
+ try
+ {
+ FutureTask<V> phantom = futureEntries.putIfAbsent(key, future);
+
+ // Use the value that could have been inserted by another thread
+ if (phantom != null)
+ {
+ future = phantom;
+ inserted = false;
+ }
+ else
+ {
+ future.run();
+ }
+
+ // Returns the value
+ value = future.get();
+ }
+ catch (ExecutionException e)
+ {
+ log.error("Computing of resource " + key + " threw an exception", e.getCause());
+ }
+ catch (Exception e)
+ {
+ log.error("Retrieval of resource " + key + " threw an exception", e);
+ }
+ finally
+ {
+ // Clean up the per key map but only if our insertion succeeded and with our future
+ if (inserted)
+ {
+ futureEntries.remove(key, future);
+ }
+ }
+ }
+
+ //
+ return value;
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/FutureExoCache.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import org.exoplatform.services.cache.ExoCache;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class FutureExoCache<K extends Serializable, V, C> extends FutureCache<K, V, C>
+{
+
+ /** . */
+ private final ExoCache<K, V> cache;
+
+ public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, V> cache)
+ {
+ super(loader);
+
+ //
+ this.cache = cache;
+ }
+
+ @Override
+ protected V get(K key)
+ {
+ return cache.get(key);
+ }
+
+ @Override
+ protected void put(K key, V entry)
+ {
+ cache.put(key, entry);
+ }
+}
+
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/Loader.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/Loader.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/future/Loader.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+/**
+ * The loader interface is used by the future cache to retrieves the value from the key when it does not exist.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
+ */
+public interface Loader<K, V, C>
+{
+
+ /**
+ * Retrieves the value from the key within the specified context. If the resource is not found then the value
+ * null must be returned.
+ *
+ * @param context the context
+ * @param key the key
+ * @return the value
+ * @throws Exception any exception that would prevent the value to be loaded
+ */
+ V retrieve(C context, K key) throws Exception;
+
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/ConcurrentGetWhenPutTestCase.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/ConcurrentGetWhenPutTestCase.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/ConcurrentGetWhenPutTestCase.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ConcurrentGetWhenPutTestCase extends TestCase
+{
+
+ /** . */
+ private AssertionFailedError failure;
+
+ /** . */
+ private List<String> events = Collections.synchronizedList(new LinkedList<String>());
+
+ FutureCache<String, String, Callable<String>> futureCache = new FutureCache<String, String, Callable<String>>(new StringLoader()) {
+
+
+ @Override
+ protected String get(String key)
+ {
+ if (key == key1)
+ {
+ if (Thread.currentThread() != thread1)
+ {
+ failure = new AssertionFailedError();
+ }
+ events.add("get/key1");
+ }
+ else if (key == key2)
+ {
+ if (Thread.currentThread() != thread2)
+ {
+ failure = new AssertionFailedError();
+ }
+ events.add("get/key2");
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ return null;
+ }
+
+ @Override
+ protected void put(String key, String value)
+ {
+ if (key == key1)
+ {
+ if (Thread.currentThread() == thread1)
+ {
+ events.add("begin_put/key1/" + value);
+
+ //
+ thread2.start();
+
+ //
+ while (thread2.getState() != Thread.State.WAITING)
+ {
+ // Wait until thread 2 is blocked
+ }
+
+ //
+ events.add("end_put/key1");
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ }
+ };
+
+ /** . */
+ private final String key1 = new String("foo");
+
+ /** . */
+ private final String key2 = new String("foo");
+
+ Thread thread1 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v = futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ events.add("call/key1");
+ return "foo_value_1";
+ }
+ }, key1);
+ events.add("retrieved/key1/" + v);
+ }
+ };
+
+ Thread thread2 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v = futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ failure = new AssertionFailedError();
+ return "foo_value_2";
+ }
+ }, key2);
+ events.add("retrieved/key2/" + v);
+ }
+ };
+
+ public void testMain() throws Exception
+ {
+ thread1.start();
+
+ //
+ thread1.join();
+ thread2.join();
+
+ //
+ if (failure != null)
+ {
+ throw failure;
+ }
+
+ //
+ List<String> expectedEvents = Arrays.asList(
+ "get/key1",
+ "call/key1",
+ "begin_put/key1/foo_value_1",
+ "get/key2",
+ "end_put/key1"
+ );
+
+ //
+ assertEquals(expectedEvents, events.subList(0, expectedEvents.size()));
+
+ //
+ Set<String> expectedEndEvents = new HashSet<String>(Arrays.asList("retrieved/key1/foo_value_1", "retrieved/key2/foo_value_1"));
+ assertEquals(expectedEndEvents, new HashSet<String>(events.subList(expectedEvents.size(), events.size())));
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/FutureMap.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/FutureMap.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/FutureMap.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class FutureMap<C> extends FutureCache<String, String, C>
+{
+
+ /** . */
+ final Map<String, String> data;
+
+ public FutureMap(Loader<String, String, C> loader)
+ {
+ super(loader);
+
+ //
+ this.data = Collections.synchronizedMap(new HashMap<String, String>());
+ }
+
+ @Override
+ protected String get(String key)
+ {
+ return data.get(key);
+ }
+
+ @Override
+ protected void put(String key, String value)
+ {
+ data.put(key, value);
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/GetTestCase.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/GetTestCase.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/GetTestCase.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GetTestCase extends TestCase
+{
+ public void testGet()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals("foo_value", futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ return "foo_value";
+ }
+ }, "foo"));
+ Assert.assertEquals("foo_value", futureCache.data.get("foo"));
+ }
+
+ public void testNullValue()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ return null;
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+
+ public void testThrowException()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ throw new Exception("DON'T FREAK OUT");
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/StringLoader.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/StringLoader.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/services/cache/future/StringLoader.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 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.future;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StringLoader implements Loader<String, String, Callable<String>>
+{
+ public String retrieve(Callable<String> context, String key) throws Exception
+ {
+ return context.call();
+ }
+}
14 years, 10 months