svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / IntializeApplicationExtension.java @ 9295
History | View | Annotate | Download (3.84 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.IOException; |
5 |
import java.io.StringWriter; |
6 |
import java.security.KeyException; |
7 |
import java.util.Properties; |
8 |
|
9 |
import org.apache.log4j.Logger; |
10 |
|
11 |
import com.iver.andami.Launcher; |
12 |
import com.iver.andami.plugins.Extension; |
13 |
import com.iver.cit.gvsig.fmap.layers.FLayerFileVectorial; |
14 |
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
17 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
18 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
19 |
|
20 |
public class IntializeApplicationExtension extends Extension { |
21 |
private ExtensionPoints extensionPoints =
|
22 |
ExtensionPointsSingleton.getInstance(); |
23 |
private static Logger logger = Logger.getLogger("gvSIG"); |
24 |
|
25 |
public void initialize() { |
26 |
|
27 |
addToLogInfo(); |
28 |
//this.extensionPoints.add("Layers","FileVectorial", FLayerFileVectorial.class);
|
29 |
this.extensionPoints.add("Layers",FLayerFileVectorial.class.getName(), FLayerFileVectorial.class); |
30 |
|
31 |
//this.extensionPoints.add("Layers","GenericVectorial", FLayerGenericVectorial.class);
|
32 |
this.extensionPoints.add("Layers",FLayerGenericVectorial.class.getName(), FLayerGenericVectorial.class); |
33 |
try {
|
34 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerFileVectorial.class.getName(), "FileVectorial"); |
35 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerGenericVectorial.class.getName(), "GenericVectorial"); |
36 |
} catch (KeyException e) { |
37 |
// TODO Auto-generated catch block
|
38 |
e.printStackTrace(); |
39 |
} |
40 |
} |
41 |
|
42 |
public void execute(String actionCommand) { |
43 |
|
44 |
} |
45 |
|
46 |
public boolean isEnabled() { |
47 |
return false; |
48 |
} |
49 |
|
50 |
public boolean isVisible() { |
51 |
return false; |
52 |
} |
53 |
|
54 |
private void addToLogInfo() { |
55 |
String info[] = this.getStringInfo().split("\n"); |
56 |
for (int i=0;i< info.length;i++) { |
57 |
logger.info(info[i]); |
58 |
} |
59 |
} |
60 |
|
61 |
public String getStringInfo() { |
62 |
StringWriter writer = new StringWriter(); |
63 |
String andamiPath;
|
64 |
String extensionsPath;
|
65 |
String jaiVersion;
|
66 |
|
67 |
Properties props = System.getProperties(); |
68 |
|
69 |
try {
|
70 |
try {
|
71 |
andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getCanonicalPath(); |
72 |
} catch (IOException e) { |
73 |
andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getAbsolutePath(); |
74 |
} |
75 |
} catch (Exception e1) { |
76 |
andamiPath = (String)props.get("user.dir"); |
77 |
} |
78 |
try {
|
79 |
try {
|
80 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getCanonicalPath(); |
81 |
} catch (IOException e) { |
82 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getAbsolutePath(); |
83 |
} |
84 |
} catch (Exception e1) { |
85 |
extensionsPath = "???";
|
86 |
} |
87 |
|
88 |
|
89 |
|
90 |
writer.write("gvSIG version: " + Version.longFormat() + "\n"); |
91 |
writer.write(" gvSIG app exec path: " + andamiPath + "\n"); |
92 |
writer.write(" gvSIG user app home: " + Launcher.getAppHomeDir() + "\n"); |
93 |
writer.write(" gvSIG extension path: " + extensionsPath + "\n"); |
94 |
writer.write(" gvSIG locale language: " + Launcher.getAndamiConfig().getLocaleLanguage() + "\n"); |
95 |
writer.write("OS name: " + props.get("os.name") + "\n"); |
96 |
writer.write(" arch:" + props.get("os.arch") + "\n"); |
97 |
writer.write(" version:"+ props.get("os.version") + "\n"); |
98 |
writer.write("JAVA vendor: " + props.get("java.vendor") + "\n"); |
99 |
writer.write(" version:" +props.get("java.version")+ "\n"); |
100 |
writer.write(" home: " + props.get("java.home") + "\n"); |
101 |
//if (props.get("os.name").toLowerCase().equals("linux"))
|
102 |
return writer.toString();
|
103 |
} |
104 |
|
105 |
public void terminate() { |
106 |
|
107 |
super.terminate();
|
108 |
try {
|
109 |
LayerFactory.getDataSourceFactory().finalizeThis(); |
110 |
} catch (Exception e) { |
111 |
//e.printStackTrace();
|
112 |
} |
113 |
|
114 |
} |
115 |
} |