1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.deploy.auto;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  /**
21   * <a href="AutoDeployUtil.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Ivica Cardic
24   * @author Brian Wing Shun Chan
25   */
26  public class AutoDeployUtil {
27  
28      public static AutoDeployDir getDir(String name) {
29          return _instance._getDir(name);
30      }
31  
32      public static void registerDir(AutoDeployDir autoDeployDir) {
33          _instance._registerDir(autoDeployDir);
34      }
35  
36      public static void unregisterDir(String name) {
37          _instance._unregisterDir(name);
38      }
39  
40      private AutoDeployUtil() {
41          _autoDeployDirs = new HashMap<String, AutoDeployDir>();
42      }
43  
44      private AutoDeployDir _getDir(String name) {
45          return _autoDeployDirs.get(name);
46      }
47  
48      private void _registerDir(AutoDeployDir autoDeployDir) {
49          _autoDeployDirs.put(autoDeployDir.getName(), autoDeployDir);
50  
51          autoDeployDir.start();
52      }
53  
54      private void _unregisterDir(String name) {
55          AutoDeployDir autoDeployDir = _autoDeployDirs.remove(name);
56  
57          if (autoDeployDir != null) {
58              autoDeployDir.stop();
59          }
60      }
61  
62      private static AutoDeployUtil _instance = new AutoDeployUtil();
63  
64      private Map<String, AutoDeployDir> _autoDeployDirs;
65  
66  }