001    /**
002     * Copyright (c) 2000-2012 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.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.deploy.auto.context.AutoDeploymentContext;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    
023    import java.io.File;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class ExtAutoDeployListener extends BaseAutoDeployListener {
029    
030            public ExtAutoDeployListener() {
031                    _autoDeployer = new ExtAutoDeployer();
032            }
033    
034            public void deploy(AutoDeploymentContext autoDeploymentContext)
035                    throws AutoDeployException {
036    
037                    File file = autoDeploymentContext.getFile();
038    
039                    if (_log.isDebugEnabled()) {
040                            _log.debug("Invoking deploy for " + file.getPath());
041                    }
042    
043                    if (!isExtPlugin(file)) {
044                            return;
045                    }
046    
047                    if (_log.isInfoEnabled()) {
048                            _log.info(
049                                    "Copying extension environment plugin for " + file.getPath());
050                    }
051    
052                    int code = _autoDeployer.autoDeploy(autoDeploymentContext);
053    
054                    if ((code == AutoDeployer.CODE_DEFAULT) && _log.isInfoEnabled()) {
055                            _log.info(
056                                    "Extension environment for " + file.getPath() +
057                                            " copied successfully. Deployment will start in a few " +
058                                                    "seconds.");
059                    }
060            }
061    
062            private static Log _log = LogFactoryUtil.getLog(
063                    ExtAutoDeployListener.class);
064    
065            private AutoDeployer _autoDeployer;
066    
067    }