Search in sources :

Example 1 with CleaningThread

use of com.axway.ats.agentapp.standalone.utils.CleaningThread in project ats-framework by Axway.

the class ContainerStarter method startCleanerThread.

/**
     * Method for starting the thread that will wait for all non daemon threads
     * to finish except the threads of the server and stop the server and JVM.
     * <i>This method is needed only when the server is started from a javaagent</i>
     * @param server
     */
private static void startCleanerThread(Server server) {
    // Wait for the server to start.
    // Make more attempts in short interval in order to stop this check
    // as soon as possible.
    int maxAttempts = 100;
    while (!server.isRunning()) {
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            log.error("Interrupted while waiting for the agent to start.", e);
        }
        if (maxAttempts == 0) {
            throw new AgentException("Jetty server not running.");
        }
        --maxAttempts;
    }
    CleaningThread cleanerThread = new CleaningThread(server, ThreadUtils.getInstance().getAllThreadIDsExceptMain());
    cleanerThread.start();
}
Also used : AgentException(com.axway.ats.agentapp.standalone.exceptions.AgentException) CleaningThread(com.axway.ats.agentapp.standalone.utils.CleaningThread)

Aggregations

AgentException (com.axway.ats.agentapp.standalone.exceptions.AgentException)1 CleaningThread (com.axway.ats.agentapp.standalone.utils.CleaningThread)1