Browse Source

MOve ProcessDestroyer into myrmidon hierarchy

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270349 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
8447568c3d
4 changed files with 3 additions and 92 deletions
  1. +1
    -1
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ProcessDestroyer.java
  2. +1
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute.java
  3. +1
    -0
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/Execute.java
  4. +0
    -91
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ProcessDestroyer.java

proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ProcessDestroyer.java → proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/ProcessDestroyer.java View File

@@ -5,7 +5,7 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.exec;
package org.apache.myrmidon.framework.exec;

import java.lang.reflect.Method;
import java.util.ArrayList;

+ 1
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute.java View File

@@ -19,6 +19,7 @@ import org.apache.myrmidon.framework.exec.Environment;
import org.apache.myrmidon.framework.exec.ExecException;
import org.apache.myrmidon.framework.exec.ExecMetaData;
import org.apache.myrmidon.framework.exec.ExecuteWatchdog;
import org.apache.myrmidon.framework.exec.ProcessDestroyer;
import org.apache.myrmidon.framework.exec.launchers.DefaultCommandLauncher;
import org.apache.myrmidon.framework.exec.launchers.MacCommandLauncher;
import org.apache.myrmidon.framework.exec.launchers.ScriptCommandLauncher;


+ 1
- 0
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/Execute.java View File

@@ -19,6 +19,7 @@ import org.apache.myrmidon.framework.exec.Environment;
import org.apache.myrmidon.framework.exec.ExecException;
import org.apache.myrmidon.framework.exec.ExecMetaData;
import org.apache.myrmidon.framework.exec.ExecuteWatchdog;
import org.apache.myrmidon.framework.exec.ProcessDestroyer;
import org.apache.myrmidon.framework.exec.launchers.DefaultCommandLauncher;
import org.apache.myrmidon.framework.exec.launchers.MacCommandLauncher;
import org.apache.myrmidon.framework.exec.launchers.ScriptCommandLauncher;


+ 0
- 91
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ProcessDestroyer.java View File

@@ -1,91 +0,0 @@
/*
* 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.tools.ant.taskdefs.exec;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;

/**
* Destroys all registered <code>Process</code>es when
* the VM exits (if in JDK1.3) or when requested.
*
* @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @version $Revision$ $Date$
*/
public class ProcessDestroyer
extends Thread
{
private ArrayList m_processes = new ArrayList();

/**
* Constructs a <code>ProcessDestroyer</code> and registers it as a shutdown
* hook.
*/
public ProcessDestroyer()
{
try
{
// check to see if the method exists (support pre-JDK 1.3 VMs)
//
final Class[] paramTypes = {Thread.class};
final Method addShutdownHook =
Runtime.class.getMethod( "addShutdownHook", paramTypes );

// add the hook
Object[] args = {this};
addShutdownHook.invoke( Runtime.getRuntime(), args );
}
catch( final Exception e )
{
// it just won't be added as a shutdown hook... :(
}
}

/**
* Add process to list of processes to be shutdown.
*
* @param process the process to add
*/
public synchronized void add( final Process process )
{
if( !m_processes.contains( process ) )
{
m_processes.add( process );
}
}

/**
* Remove process from list of processes to be shutdown.
*
* @param process the process to remove
*/
public synchronized void remove( final Process process )
{
m_processes.remove( process );
}

/**
* Invoked by the VM when it is exiting.
*/
public void run()
{
destroyProcesses();
}

protected synchronized void destroyProcesses()
{
final Iterator processes = m_processes.iterator();
while( processes.hasNext() )
{
( (Process)processes.next() ).destroy();
processes.remove();
}
}
}

Loading…
Cancel
Save