donaldp 02/04/26 00:52:16 Added: aut/src/java/org/apache/aut/jprocess JavaProcess.java Log: Add in JavaProcess abstraction Revision Changes Path 1.1 jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/JavaProcess.java Index: JavaProcess.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.aut.jprocess; import java.io.IOException; import org.apache.excalibur.threadcontext.ThreadContext; /** * A JavaProcess is an abstraction that allows you to * partially isolate java applications from one another * and thus run more tasks in memory rather than in forked * mode. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/04/26 07:52:16 $ */ public class JavaProcess extends Thread { /** * Flag indicating whether or not all the correct * redirectors have been installed correctly. */ private static boolean c_installed; /** * ThreadContext object to be associated with thread. */ private final ThreadContext m_threadContext; /** * Create a thread to run specific target. * * @param target the target to run * @param threadContext the thread context to associate with thread */ public JavaProcess( final Runnable target, final ThreadContext threadContext ) { super( target ); m_threadContext = threadContext; } /** * Create a thread in specified ThreadGroup, * to run specific target. * * @param group the ThreadGroup to run in * @param target the target to run * @param threadContext the thread context to associate with thread */ public JavaProcess( final ThreadGroup group, final Runnable target, final ThreadContext threadContext ) { super( group, target ); m_threadContext = threadContext; } /** * Install redirectors if they need installing. */ private synchronized static final void install() { if( !c_installed ) { try { StdioRedirector.install(); SysPropertiesRedirector.install(); c_installed = true; } catch( final IOException ioe ) { ioe.printStackTrace(); } } } /** * Execute the associated code makign sure * that all of the context variables are setup correctly. */ public final void run() { install(); try { ThreadContext.setThreadContext( m_threadContext ); super.run(); } finally { ThreadContext.setThreadContext( null ); } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
