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