001    /**
002     * Copyright (c) 2000-2011 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.sandbox;
016    
017    /**
018     * @author Igor Spasic
019     * @author Brian Wing Shun Chan
020     */
021    public class SandboxDeployScanner extends Thread {
022    
023            public SandboxDeployScanner(
024                    ThreadGroup threadGroup, String name,
025                    SandboxDeployDir sandboxDeployDir) {
026    
027                    super(threadGroup, name);
028    
029                    _sandboxDeployDir = sandboxDeployDir;
030    
031                    setContextClassLoader(getClass().getClassLoader());
032                    setDaemon(true);
033                    setPriority(MIN_PRIORITY);
034            }
035    
036            @Override
037            public void run() {
038                    try {
039                            sleep(1000 * 10);
040                    }
041                    catch (InterruptedException ie) {
042                    }
043    
044                    while (_started) {
045                            try {
046                                    sleep(_sandboxDeployDir.getInterval());
047                            }
048                            catch (InterruptedException ie) {
049                            }
050    
051                            _sandboxDeployDir.scanDirectory();
052                    }
053            }
054    
055            public void pause() {
056                    _started = false;
057            }
058    
059            private SandboxDeployDir _sandboxDeployDir;
060            private boolean _started = true;
061    
062    }