001
014
015 package com.liferay.portal.kernel.deploy.auto;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019
020
024 public class AutoDeployScanner extends Thread {
025
026 public AutoDeployScanner(
027 ThreadGroup threadGroup, String name, AutoDeployDir autoDeployDir) {
028
029 super(threadGroup, name);
030
031 _autoDeployDir = autoDeployDir;
032
033 Class<?> clazz = getClass();
034
035 setContextClassLoader(clazz.getClassLoader());
036
037 setDaemon(true);
038 setPriority(MIN_PRIORITY);
039 }
040
041 public void pause() {
042 _started = false;
043 }
044
045 @Override
046 public void run() {
047 try {
048 sleep(1000 * 10);
049 }
050 catch (InterruptedException ie) {
051 }
052
053 while (_started) {
054 try {
055 sleep(_autoDeployDir.getInterval());
056 }
057 catch (InterruptedException ie) {
058 }
059
060 try {
061 _autoDeployDir.scanDirectory();
062 }
063 catch (Exception e) {
064 if (_log.isWarnEnabled()) {
065 _log.warn("Unable to scan the auto deploy directory", e);
066 }
067 }
068 }
069 }
070
071 private static final Log _log = LogFactoryUtil.getLog(
072 AutoDeployScanner.class);
073
074 private final AutoDeployDir _autoDeployDir;
075 private boolean _started = true;
076
077 }