001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.deploy.auto;
016    
017    /**
018     * @author Ivica Cardic
019     * @author Brian Wing Shun Chan
020     */
021    public class AutoDeployScanner extends Thread {
022    
023            public AutoDeployScanner(
024                    ThreadGroup threadGroup, String name, AutoDeployDir autoDeployDir) {
025    
026                    super(threadGroup, name);
027    
028                    _autoDeployDir = autoDeployDir;
029    
030                    setContextClassLoader(getClass().getClassLoader());
031                    setDaemon(true);
032                    setPriority(MIN_PRIORITY);
033            }
034    
035            public void pause() {
036                    _started = false;
037            }
038    
039            @Override
040            public void run() {
041                    try {
042                            sleep(1000 * 10);
043                    }
044                    catch (InterruptedException ie) {
045                    }
046    
047                    while (_started) {
048                            try {
049                                    sleep(_autoDeployDir.getInterval());
050                            }
051                            catch (InterruptedException ie) {
052                            }
053    
054                            _autoDeployDir.scanDirectory();
055                    }
056            }
057    
058            private AutoDeployDir _autoDeployDir;
059            private boolean _started = true;
060    
061    }