[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-dev
Subject:    svn commit: r543166 - in
From:       hlship () apache ! org
Date:       2007-05-31 15:38:59
Message-ID: 20070531153859.38EC91A981A () eris ! apache ! org
[Download RAW message or body]

Author: hlship
Date: Thu May 31 08:38:58 2007
New Revision: 543166

URL: http://svn.apache.org/viewvc?view=rev&rev=543166
Log:
TAPESTRY-1528: No way to cleanup the thread without access to the Registry

Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
  tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ThreadCleanupHub.java


Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
                
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/ \
org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java?view=diff&rev=543166&r1=543165&r2=543166
 ==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java \
                (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java \
Thu May 31 08:38:58 2007 @@ -12,70 +12,67 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal.services;
-
+package org.apache.tapestry.ioc.internal.services;
+
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.services.ThreadCleanupHub;
-import org.apache.tapestry.ioc.services.ThreadCleanupListener;
-
-/**
- * 
- */
-public class ThreadCleanupHubImpl implements ThreadCleanupHub
-{
-    private static class ListHolder extends ThreadLocal<List<ThreadCleanupListener>>
-    {
-        @Override
-        protected List<ThreadCleanupListener> initialValue()
-        {
-            return newList();
-        }
-    }
-
-    private final Log _log;
-
-    private final ListHolder _holder = new ListHolder();
-
-    public ThreadCleanupHubImpl(Log log)
-    {
-        _log = log;
-    }
-
-    public void addThreadCleanupListener(ThreadCleanupListener listener)
-    {
-        _holder.get().add(listener);
-    }
-
-    /**
-     * Instructs the hub to notify all its listeners (for the current thread). It \
                also discards its
-     * list of listeners.
-     */
-    public void cleanup()
-    {
-        List<ThreadCleanupListener> listeners = _holder.get();
-
-        // Discard the listeners. In a perfect world, we would set a per-thread flag \
                that prevented
-        // more listeners from being added, until a new thread begins. But we don't \
                have a concept
-        // of thread start, just thread complete.
-
-        _holder.remove();
-
-        for (ThreadCleanupListener listener : listeners)
-        {
-            try
-            {
-                listener.threadDidCleanup();
-            }
-            catch (Exception ex)
-            {
-                _log.warn(ServiceMessages.threadCleanupError(listener, ex), ex);
-            }
-        }
-
-    }
-
-}
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.services.ThreadCleanupHub;
+import org.apache.tapestry.ioc.services.ThreadCleanupListener;
+
+public class ThreadCleanupHubImpl implements ThreadCleanupHub
+{
+    private static class ListHolder extends ThreadLocal<List<ThreadCleanupListener>>
+    {
+        @Override
+        protected List<ThreadCleanupListener> initialValue()
+        {
+            return newList();
+        }
+    }
+
+    private final Log _log;
+
+    private final ListHolder _holder = new ListHolder();
+
+    public ThreadCleanupHubImpl(Log log)
+    {
+        _log = log;
+    }
+
+    public void addThreadCleanupListener(ThreadCleanupListener listener)
+    {
+        _holder.get().add(listener);
+    }
+
+    /**
+     * Instructs the hub to notify all its listeners (for the current thread). It \
also discards its +     * list of listeners.
+     */
+    public void cleanup()
+    {
+        List<ThreadCleanupListener> listeners = _holder.get();
+
+        // Discard the listeners. In a perfect world, we would set a per-thread flag \
that prevented +        // more listeners from being added, until a new thread \
begins. But we don't have a concept +        // of thread start, just thread \
complete. +
+        _holder.remove();
+
+        for (ThreadCleanupListener listener : listeners)
+        {
+            try
+            {
+                listener.threadDidCleanup();
+            }
+            catch (Exception ex)
+            {
+                _log.warn(ServiceMessages.threadCleanupError(listener, ex), ex);
+            }
+        }
+
+    }
+
+}

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ThreadCleanupHub.java
                
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/ \
org/apache/tapestry/ioc/services/ThreadCleanupHub.java?view=diff&rev=543166&r1=543165&r2=543166
 ==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ThreadCleanupHub.java \
                (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ThreadCleanupHub.java \
Thu May 31 08:38:58 2007 @@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,24 +12,27 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.services;
-
-/**
- * Event hub used to identify when the end of thread cleanup (i.e., end of request \
                cleanup in a
- * typical web application) should occur. Tapestry IoC has any number of objects \
                that need to know
- * when this event occurs, so that they can clean up any per-thread/per-request \
                state.
- * 
- * 
- */
-public interface ThreadCleanupHub
-{
-    /**
-     * Adds a listener to the hub. The hub maintains a seperate list of listeners \
                for each thread
-     * (i.e., using a ThreadLocal). Further, the listener list is discarded at the \
                end of the
-     * request.
-     * 
-     * @param listener
-     *            to add
-     */
-    void addThreadCleanupListener(ThreadCleanupListener listener);
-}
+package org.apache.tapestry.ioc.services;
+
+/**
+ * Event hub used to identify when the end of thread cleanup (i.e., end of request \
cleanup in a + * typical web application) should occur. Tapestry IoC has any number \
of objects that need to know + * when this event occurs, so that they can clean up \
any per-thread/per-request state. + */
+public interface ThreadCleanupHub
+{
+    /**
+     * Adds a listener to the hub. The hub maintains a seperate list of listeners \
for each thread +     * (i.e., using a ThreadLocal). Further, the listener list is \
discarded at the end of the +     * request.
+     * 
+     * @param listener
+     *            to add
+     */
+    void addThreadCleanupListener(ThreadCleanupListener listener);
+
+    /**
+     * Immediately performs a cleanup of the thread, notifying all listeners.
+     */
+    void cleanup();
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic