001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.deploy.auto;
016    
017    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018    import com.liferay.portal.kernel.deploy.auto.BaseAutoDeployListener;
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    
022    import java.io.File;
023    
024    /**
025     * @author Jorge Ferrer
026     */
027    public class WebAutoDeployListener extends BaseAutoDeployListener {
028    
029            public WebAutoDeployListener() {
030                    _deployer = new WebAutoDeployer();
031            }
032    
033            public void deploy(File file) throws AutoDeployException {
034                    if (_log.isDebugEnabled()) {
035                            _log.debug("Invoking deploy for " + file.getPath());
036                    }
037    
038                    if (!isWebPlugin(file)) {
039                            return;
040                    }
041    
042                    if (_log.isInfoEnabled()) {
043                            _log.info("Copying web plugin for " + file.getPath());
044                    }
045    
046                    _deployer.autoDeploy(file.getName());
047    
048                    if (_log.isInfoEnabled()) {
049                            _log.info(
050                                    "Web plugin for " +  file.getPath() + " copied successfully. " +
051                                            "Deployment will start in a few seconds.");
052                    }
053            }
054    
055            private static Log _log = LogFactoryUtil.getLog(
056                    WebAutoDeployListener.class);
057    
058            private AutoDeployer _deployer;
059    
060    }