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 setContextClassLoader(getClass().getClassLoader());
034 setDaemon(true);
035 setPriority(MIN_PRIORITY);
036 }
037
038 public void pause() {
039 _started = false;
040 }
041
042 @Override
043 public void run() {
044 try {
045 sleep(1000 * 10);
046 }
047 catch (InterruptedException ie) {
048 }
049
050 while (_started) {
051 try {
052 sleep(_autoDeployDir.getInterval());
053 }
054 catch (InterruptedException ie) {
055 }
056
057 try {
058 _autoDeployDir.scanDirectory();
059 }
060 catch (Exception e) {
061 if (_log.isWarnEnabled()) {
062 _log.warn("Unable to scan the auto deploy directory", e);
063 }
064 }
065 }
066 }
067
068 private static Log _log = LogFactoryUtil.getLog(AutoDeployScanner.class);
069
070 private AutoDeployDir _autoDeployDir;
071 private boolean _started = true;
072
073 }