svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / PluginsLocator.java @ 40637
History | View | Annotate | Download (3.63 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.andami; |
25 |
|
26 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
27 |
import org.gvsig.tools.locator.AbstractLocator; |
28 |
import org.gvsig.tools.locator.Locator; |
29 |
import org.gvsig.tools.locator.LocatorException; |
30 |
|
31 |
|
32 |
public class PluginsLocator extends AbstractLocator { |
33 |
|
34 |
private static final String LOCATOR_NAME = "PluginsLocator"; |
35 |
|
36 |
/**
|
37 |
* PluginsManager name used by the locator to access the instance
|
38 |
*/
|
39 |
public static final String PLUGINS_MANAGER_NAME = "PluginsManager"; |
40 |
public static final String PLUGINS_ACTIONINFO_MANAGER_NAME = "PluginsActionInfoManager"; |
41 |
|
42 |
private static final String PLUGINS_MANAGER_DESCRIPTION = "PluginsManager of Andami framework"; |
43 |
private static final String PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION = "PluginsActionInfoManager"; |
44 |
|
45 |
/**
|
46 |
* Unique instance.
|
47 |
*/
|
48 |
private static final PluginsLocator instance = new PluginsLocator(); |
49 |
|
50 |
/**
|
51 |
* Return the singleton instance.
|
52 |
*
|
53 |
* @return the singleton instance
|
54 |
*/
|
55 |
public static PluginsLocator getInstance() { |
56 |
return instance;
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* Returns the Locator name.
|
61 |
*
|
62 |
* @return String containing the locator name.
|
63 |
*/
|
64 |
public String getLocatorName() { |
65 |
return LOCATOR_NAME;
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* Return a reference to DataManager.
|
70 |
*
|
71 |
* @return a reference to DataManager
|
72 |
* @throws LocatorException
|
73 |
* if there is no access to the class or the class cannot be
|
74 |
* instantiated
|
75 |
* @see Locator#get(String)
|
76 |
*/
|
77 |
public static PluginsManager getManager() throws LocatorException { |
78 |
return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Registers the Class implementing the DataManager interface.
|
83 |
*
|
84 |
* @param clazz
|
85 |
* implementing the DataManager interface
|
86 |
*/
|
87 |
public static void registerManager(Class clazz) { |
88 |
getInstance().register(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
89 |
clazz); |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Registers a class as the default DataManager.
|
94 |
*
|
95 |
* @param clazz
|
96 |
* implementing the DataManager interface
|
97 |
*/
|
98 |
public static void registerDefaultManager(Class clazz) { |
99 |
getInstance().registerDefault(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
100 |
clazz); |
101 |
} |
102 |
|
103 |
|
104 |
public static ActionInfoManager getActionInfoManager() throws LocatorException { |
105 |
return (ActionInfoManager) getInstance().get(PLUGINS_ACTIONINFO_MANAGER_NAME);
|
106 |
} |
107 |
|
108 |
public static void registerActionInfoManager(Class clazz) { |
109 |
getInstance().register(PLUGINS_ACTIONINFO_MANAGER_NAME, PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION, |
110 |
clazz); |
111 |
} |
112 |
|
113 |
} |