donaldp 02/04/27 21:52:51
Modified: aut/src/java/org/apache/aut/jprocess
JavaProcessContextPolicy.java
Log:
Incorporate per thread redirector for policy objects
Revision Changes Path
1.3 +49 -11
jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/JavaProcessContextPolicy.java
Index: JavaProcessContextPolicy.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/JavaProcessContextPolicy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JavaProcessContextPolicy.java 26 Apr 2002 07:55:53 -0000 1.2
+++ JavaProcessContextPolicy.java 28 Apr 2002 04:52:51 -0000 1.3
@@ -12,6 +12,7 @@
import java.net.URLStreamHandlerFactory;
import java.util.Map;
import java.util.Properties;
+import java.security.Policy;
import javax.naming.spi.InitialContextFactory;
import org.apache.excalibur.threadcontext.ThreadContextAccessor;
import org.apache.excalibur.threadcontext.impl.DefaultThreadContextPolicy;
@@ -20,8 +21,26 @@
* This is a basic extension of ThreadContextPolicy that
* just defines new constants that will be handled.
*
+ * <p>Some more things to think about.</p>
+ *
+ * <ul>
+ * <li>Register a DemuxSecurityManager that redirects as
+ * appropriate to thread specific SecurityManager.</p>
+ * <li>Register a SecurityManager that noticies permission
+ * checks for top level windows and records all the
+ * windows in a WeakHashMap. Then when context is
+ * deactivated will dispose any still visible/non-disposed
+ * windows.</p>
+ * <li>When a System.exit() call is made throw a ThreadDeath
+ * exception rather than exiting.</p>
+ * <li>Force all threads to be created in a specific
+ * ThreadGroup.</p>
+ * </ul>
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/04/26 07:55:53 $
+ * @version $Revision: 1.3 $ $Date: 2002/04/28 04:52:51 $
+ * @todo Implement a Redirector for [EMAIL PROTECTED]
URLStreamHandlerFactory}
+ * and [EMAIL PROTECTED] InitialContextFactory}
*/
public class JavaProcessContextPolicy
extends DefaultThreadContextPolicy
@@ -33,6 +52,7 @@
public static final String URL_FACTORY =
URLStreamHandlerFactory.class.getName();
public static final String JNDI_FACTORY =
InitialContextFactory.class.getName();
public static final String THREAD_NAME = Thread.class.getName();
+ public static final String POLICY = Policy.class.getName();
/**
* Construct the policy object and register the types
@@ -47,6 +67,7 @@
addEntry( URL_FACTORY, URLStreamHandlerFactory.class, true );
addEntry( JNDI_FACTORY, InitialContextFactory.class, true );
addEntry( THREAD_NAME, String.class, false );
+ addEntry( POLICY, Policy.class, false );
}
/**
@@ -61,6 +82,16 @@
{
super.activate( accessor, store );
+ if( accessor.containsKey( POLICY ) )
+ {
+ final Policy newPolicy =
+ (Policy)get( accessor, POLICY, null );
+
+ final Policy oldPolicy =
+ PolicyRedirector.bindPolicy( newPolicy );
+ store.put( POLICY, oldPolicy );
+ }
+
if( accessor.containsKey( THREAD_NAME ) )
{
final String newName =
@@ -125,39 +156,46 @@
{
super.deactivate( accessor, store );
+ if( accessor.containsKey( POLICY ) )
+ {
+ final Policy policy =
+ (Policy)store.get( POLICY );
+ PolicyRedirector.bindPolicy( policy );
+ }
+
if( accessor.containsKey( THREAD_NAME ) )
{
- final String oldName =
+ final String name =
(String)store.get( THREAD_NAME );
- Thread.currentThread().setName( oldName );
+ Thread.currentThread().setName( name );
}
if( accessor.containsKey( INPUT ) )
{
- final InputStream oldStream =
+ final InputStream stream =
(InputStream)store.get( INPUT );
- StdioRedirector.bindInput( oldStream );
+ StdioRedirector.bindInput( stream );
}
if( accessor.containsKey( OUTPUT ) )
{
- final OutputStream oldStream =
+ final OutputStream stream =
(OutputStream)store.get( OUTPUT );
- StdioRedirector.bindOutput( oldStream );
+ StdioRedirector.bindOutput( stream );
}
if( accessor.containsKey( ERROR ) )
{
- final OutputStream oldStream =
+ final OutputStream stream =
(OutputStream)store.get( ERROR );
- StdioRedirector.bindError( oldStream );
+ StdioRedirector.bindError( stream );
}
if( accessor.containsKey( PROPERTIES ) )
{
- final Properties oldProperties =
+ final Properties properties =
(Properties)store.get( PROPERTIES );
- SysPropertiesRedirector.bindProperties( oldProperties );
+ SysPropertiesRedirector.bindProperties( properties );
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>