1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.deploy.auto;
16  
17  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
18  import com.liferay.portal.kernel.deploy.auto.BaseAutoDeployListener;
19  import com.liferay.portal.kernel.log.Log;
20  import com.liferay.portal.kernel.log.LogFactoryUtil;
21  
22  import java.io.File;
23  
24  /**
25   * <a href="HookAutoDeployListener.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class HookAutoDeployListener extends BaseAutoDeployListener {
30  
31      public HookAutoDeployListener() {
32          _deployer = new HookAutoDeployer();
33      }
34  
35      public void deploy(File file) throws AutoDeployException {
36          if (_log.isDebugEnabled()) {
37              _log.debug("Invoking deploy for " + file.getPath());
38          }
39  
40          if (!isHookPlugin(file)) {
41              return;
42          }
43  
44          if (_log.isInfoEnabled()) {
45              _log.info("Copying web plugin for " + file.getPath());
46          }
47  
48          _deployer.autoDeploy(file.getName());
49  
50          if (_log.isInfoEnabled()) {
51              _log.info(
52                  "Hook for " +  file.getPath() + " copied successfully. " +
53                      "Deployment will start in a few seconds.");
54          }
55      }
56  
57      private static Log _log = LogFactoryUtil.getLog(
58          HookAutoDeployListener.class);
59  
60      private AutoDeployer _deployer;
61  
62  }