[exo-jcr-commits] exo-jcr SVN: r1050 - kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Dec 14 19:36:18 EST 2009
Author: julien_viet
Date: 2009-12-14 19:36:17 -0500 (Mon, 14 Dec 2009)
New Revision: 1050
Modified:
kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java
kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycleStack.java
Log:
minor thing that helps to write better unit test for clients
Modified: kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java 2009-12-14 17:14:40 UTC (rev 1049)
+++ kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java 2009-12-15 00:36:17 UTC (rev 1050)
@@ -17,9 +17,10 @@
package org.exoplatform.container.component;
import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.component.ComponentRequestLifecycle;
+import java.util.IdentityHashMap;
import java.util.List;
+import java.util.Map;
/**
* <p>The request life cycle object allows a client to demarcate the life cycle of the various components
@@ -55,22 +56,30 @@
}
}
- List<ComponentRequestLifecycle> doEnd()
+ IdentityHashMap<Object, Throwable> doEnd()
{
+ IdentityHashMap<Object, Throwable> result = new IdentityHashMap<Object, Throwable>();
+
+ //
for (ComponentRequestLifecycle componentRLF : components)
{
+ Throwable t = null;
try
{
componentRLF.endRequest(container);
}
- catch (Exception e)
+ catch (Throwable throwable)
{
- // Swallow and log
+ t = throwable;
}
+ finally
+ {
+ result.put(componentRLF, t);
+ }
}
//
- return components;
+ return result;
}
/**
@@ -131,23 +140,29 @@
}
/**
- * Ends the life cycle of the most recent container started.
- * Only the components of the container that have not been previously enrolled in a life cycle
- * are ended.
+ * <p>Ends the life cycle of the most recent container started. Only the components of the container that
+ * have not been previously enrolled in a life cycle are ended.</p>
*
+ * <p>The result map returned has for keys the components whose the life cycle ended during this method call
+ * and the associated value are the potential throwable that were thrown by those components. It is usefull
+ * when writing unit test to be aware of the throwable of the various components involved in a request
+ * life cycle.</p>
+ *
* @throws IllegalStateException if no container life cycle is associated with this thread
+ * @return the result map
*/
- public static void end() throws IllegalStateException
+ public static Map<Object, Throwable> end() throws IllegalStateException
{
RequestLifeCycleStack lf = current.get();
if (lf == null)
{
throw new IllegalStateException();
}
- lf.end();
+ Map<Object, Throwable> result = lf.end();
if (lf.isEmpty())
{
current.set(null);
}
+ return result;
}
}
Modified: kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycleStack.java
===================================================================
--- kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycleStack.java 2009-12-14 17:14:40 UTC (rev 1049)
+++ kernel/branches/config-branch/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycleStack.java 2009-12-15 00:36:17 UTC (rev 1050)
@@ -23,8 +23,10 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -87,14 +89,17 @@
lifeCycle.doBegin();
}
- void end()
+ Map<Object, Throwable> end()
{
RequestLifeCycle lifeCycle = removeLast();
//
- List<ComponentRequestLifecycle> components = lifeCycle.doEnd();
+ IdentityHashMap<Object, Throwable> result = lifeCycle.doEnd();
//
- allComponents.removeAll(components);
+ allComponents.removeAll(result.keySet());
+
+ //
+ return result;
}
}
More information about the exo-jcr-commits
mailing list