diff --git a/nucleus/deployment/autodeploy/pom.xml b/nucleus/deployment/autodeploy/pom.xml index 94f6a2e0d4c..b810ebd3219 100755 --- a/nucleus/deployment/autodeploy/pom.xml +++ b/nucleus/deployment/autodeploy/pom.xml @@ -117,6 +117,12 @@ org.glassfish.annotations logging-annotation-processor true - - + + + fish.payara.payara-modules + payara-executor-service + ${project.version} + jar + + diff --git a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java index 67e54dcccb5..84c420ee758 100644 --- a/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java +++ b/nucleus/deployment/autodeploy/src/main/java/org/glassfish/deployment/autodeploy/AutoDeployService.java @@ -42,13 +42,14 @@ package org.glassfish.deployment.autodeploy; import com.sun.enterprise.config.serverbeans.DasConfig; +import fish.payara.nucleus.executorservice.PayaraExecutorService; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.LogRecord; @@ -95,12 +96,13 @@ public class AutoDeployService implements PostConstruct, PreDestroy, ConfigListe @Inject ServerEnvironment env; + + @Inject + private PayaraExecutorService executor; private AutoDeployer autoDeployer = null; - private Timer autoDeployerTimer; - - private TimerTask autoDeployerTimerTask; + private ScheduledFuture autoDeployerTimerTask; private String target; @@ -222,11 +224,9 @@ private int getPollingIntervalInSeconds() throws NumberFormatException { } private void startAutoDeployer(int pollingIntervalInSeconds) { - long pollingInterval = pollingIntervalInSeconds * 1000L; autoDeployer.init(); - autoDeployerTimer = new Timer("AutoDeployer", true); - autoDeployerTimer.schedule( - autoDeployerTimerTask = new TimerTask() { + autoDeployerTimerTask = executor.scheduleAtFixedRate( + new Runnable() { @Override public void run() { try { @@ -236,9 +236,10 @@ public void run() { AutoDeployer.deplLogger.log(Level.FINE, ex.getMessage(), ex); } } - }, - pollingInterval, - pollingInterval); + }, + 0L, + pollingIntervalInSeconds, + TimeUnit.SECONDS); logConfig( "Started", isAutoDeployEnabled(), @@ -252,12 +253,11 @@ private void stopAutoDeployer() { * and the timer. */ deplLogger.fine("[AutoDeploy] Stopping"); - if (autoDeployer!=null) + if (autoDeployer!=null) { autoDeployer.cancel(true); - if (autoDeployerTimerTask!=null) - autoDeployerTimerTask.cancel(); - if (autoDeployerTimer != null) { - autoDeployerTimer.cancel(); + } + if (autoDeployerTimerTask!=null) { + autoDeployerTimerTask.cancel(false); } }