svn-gvsig-desktop / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / impl / DefaultPluginsManager.java @ 34114
History | View | Annotate | Download (2.07 KB)
1 |
package org.gvsig.andami.impl; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
5 |
import java.util.Enumeration; |
6 |
import java.util.Iterator; |
7 |
import java.util.List; |
8 |
|
9 |
import org.gvsig.andami.Launcher; |
10 |
import org.gvsig.andami.PluginServices; |
11 |
import org.gvsig.andami.PluginsManager; |
12 |
import org.gvsig.andami.config.generate.AndamiConfig; |
13 |
import org.gvsig.andami.config.generate.Plugin; |
14 |
import org.gvsig.andami.plugins.ExclusiveUIExtension; |
15 |
import org.gvsig.andami.plugins.Extension; |
16 |
import org.gvsig.andami.plugins.IExtension; |
17 |
import org.gvsig.andami.plugins.PluginClassLoader; |
18 |
|
19 |
public class DefaultPluginsManager implements PluginsManager{ |
20 |
|
21 |
public ExclusiveUIExtension getExclusiveUIExtension() {
|
22 |
return PluginServices.getExclusiveUIExtension();
|
23 |
} |
24 |
|
25 |
public IExtension getExtension(Class<IExtension> extension) { |
26 |
return PluginServices.getExtension(extension);
|
27 |
} |
28 |
|
29 |
@SuppressWarnings("unchecked") |
30 |
public Iterator<IExtension> getExtensions() { |
31 |
return PluginServices.getExtensions();
|
32 |
} |
33 |
|
34 |
@SuppressWarnings("rawtypes") |
35 |
/**
|
36 |
* Return the associated pluginServices to the extension class passed as parameter.
|
37 |
*
|
38 |
*/
|
39 |
public PluginServices getPlugin(Class<?> extension) { |
40 |
String pluginName = ((PluginClassLoader)extension.getClassLoader()).getPluginName();
|
41 |
return this.getPlugin(pluginName); |
42 |
} |
43 |
|
44 |
public PluginServices getPlugin(String pluginName) { |
45 |
return Launcher.getPluginServices(pluginName);
|
46 |
} |
47 |
|
48 |
@SuppressWarnings("unchecked") |
49 |
public List<PluginServices> getPlugins() { |
50 |
List<PluginServices> pluginServices = new ArrayList<PluginServices>(); |
51 |
|
52 |
AndamiConfig config = Launcher.getAndamiConfig(); |
53 |
Enumeration<Plugin> plugins = config.enumeratePlugin();
|
54 |
while( plugins.hasMoreElements()) {
|
55 |
Plugin plugin = plugins.nextElement(); |
56 |
pluginServices.add(PluginServices.getPluginServices(plugin.getName())); |
57 |
} |
58 |
return pluginServices;
|
59 |
} |
60 |
|
61 |
public void setExclusiveUIExtension(ExclusiveUIExtension extension) { |
62 |
PluginServices.setExclusiveUIExtension(extension); |
63 |
} |
64 |
|
65 |
public File getPluginsDirectory() { |
66 |
return new File(Launcher.getAndamiConfig().getPluginsDirectory()); |
67 |
} |
68 |
|
69 |
} |