You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by do...@apache.org on 2001/04/02 02:12:01 UTC
cvs commit: jakarta-avalon/src/java/org/apache/avalon/util/thread ThreadContext.java
donaldp 01/04/01 17:12:00
Modified: src/java/org/apache/avalon/util/thread ThreadContext.java
Log:
Added in javadocs and security permission check
(Requires ThreadContext.setCurrentThreadContext RuntimePermission)
Revision Changes Path
1.3 +23 -6 jakarta-avalon/src/java/org/apache/avalon/util/thread/ThreadContext.java
Index: ThreadContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/thread/ThreadContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ThreadContext.java 2001/03/05 18:56:40 1.2
+++ ThreadContext.java 2001/04/02 00:12:00 1.3
@@ -7,10 +7,6 @@
*/
package org.apache.avalon.util.thread;
-import org.apache.avalon.Poolable;
-import org.apache.avalon.util.pool.ObjectFactory;
-import org.apache.avalon.util.pool.SoftResourceLimitingPool;
-
/**
* To deal with *current* ThreadContext.
*
@@ -18,16 +14,37 @@
*/
public final class ThreadContext
{
- protected final static InheritableThreadLocal c_context = new InheritableThreadLocal();
+ private final static RuntimePermission c_permission =
+ new RuntimePermission( "ThreadContext.setCurrentThreadPool" );
+ private final static InheritableThreadLocal c_context = new InheritableThreadLocal();
+ /**
+ * Retrieve thread pool associated with current thread
+ *
+ * @return a thread pool
+ */
public static ThreadPool getCurrentThreadPool()
{
return (ThreadPool)c_context.get();
}
+ /**
+ * Set the thread pool that will be returned by getCurrentThreadPool() in this thread
+ * and decendent threads.
+ *
+ * @param threadPool the new thread pool
+ * @exception SecurityException if the caller does not have permission to set thread pool
+ */
public static void setCurrentThreadPool( final ThreadPool threadPool )
+ throws SecurityException
{
- //TODO: protect by a permission guard
+ final SecurityManager securityManager = System.getSecurityManager();
+
+ if( null != securityManager )
+ {
+ securityManager.checkPermission( c_permission );
+ }
+
c_context.set( threadPool );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org