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.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 dir) {
33          _instance._registerDir(dir);
34      }
35  
36      public static void unregisterDir(String name) {
37          _instance._unregisterDir(name);
38      }
39  
40      private AutoDeployUtil() {
41          _dirs = new HashMap<String, AutoDeployDir>();
42      }
43  
44      private AutoDeployDir _getDir(String name) {
45          return _dirs.get(name);
46      }
47  
48      private void _registerDir(AutoDeployDir dir) {
49          _dirs.put(dir.getName(), dir);
50  
51          dir.start();
52      }
53  
54      private void _unregisterDir(String name) {
55          AutoDeployDir dir = _dirs.remove(name);
56  
57          if (dir != null) {
58              dir.stop();
59          }
60      }
61  
62      private static AutoDeployUtil _instance = new AutoDeployUtil();
63  
64      private Map<String, AutoDeployDir> _dirs;
65  
66  }