Revision 38809 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/Version.java
Version.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.util.StringTokenizer; |
25 | 25 |
|
26 |
import org.gvsig.andami.PluginsLocator; |
|
26 | 27 |
import org.gvsig.app.ApplicationLocator; |
27 | 28 |
import org.gvsig.installer.lib.api.InstallerLocator; |
28 | 29 |
import org.gvsig.installer.lib.api.PackageInfo; |
... | ... | |
41 | 42 |
private static final Logger LOG = LoggerFactory.getLogger(Version.class); |
42 | 43 |
private static final String APP_PACKAGE_CODE = "org.gvsig.app"; |
43 | 44 |
|
44 |
private int majorVersionNumber; |
|
45 |
private int minorVersionNumber; |
|
46 |
private int releaseNumber; |
|
45 |
private org.gvsig.installer.lib.api.Version version; |
|
47 | 46 |
|
48 |
private String buildNumber = "unknown"; |
|
49 |
|
|
50 | 47 |
@Deprecated |
51 | 48 |
public static String format() { |
52 | 49 |
return ApplicationLocator.getManager().getVersion().getFormat(); |
... | ... | |
67 | 64 |
* Loads version information from the application installation information. |
68 | 65 |
*/ |
69 | 66 |
public Version() { |
70 |
String[] versions = new String[] { "2", "0", "0" }; |
|
71 |
try { |
|
72 |
MakePluginPackageService packageService = |
|
73 |
InstallerLocator.getInstallerManager() |
|
74 |
.getMakePluginPackageService(); |
|
75 |
|
|
76 |
PackageInfo info = |
|
77 |
packageService.getPluginPackageInfo(APP_PACKAGE_CODE); |
|
78 |
|
|
79 |
String version = info.getGvSIGVersion(); |
|
80 |
|
|
81 |
StringTokenizer tokens = new StringTokenizer(version, "."); |
|
82 |
int i = 0; |
|
83 |
while (tokens.hasMoreTokens() && i < 3) { |
|
84 |
versions[i] = tokens.nextToken(); |
|
85 |
i++; |
|
86 |
} |
|
87 |
this.buildNumber = Integer.toString(info.getBuild()); |
|
88 |
|
|
89 |
} catch (Exception e) { |
|
90 |
LOG.error("Error getting version information through " |
|
91 |
+ "the InstallManager", e); |
|
92 |
} |
|
93 |
|
|
94 |
this.majorVersionNumber = Integer.parseInt(versions[0]); |
|
95 |
this.minorVersionNumber = Integer.parseInt(versions[1]); |
|
96 |
this.releaseNumber = Integer.parseInt(versions[2]); |
|
97 | 67 |
|
68 |
PackageInfo pinfo = PluginsLocator.getManager().getPackageInfo(InitializeApplicationExtension.class); |
|
69 |
this.version = pinfo.getVersion(); |
|
98 | 70 |
LOG.debug("Loaded version information: {}", getLongFormat()); |
99 | 71 |
} |
100 | 72 |
|
101 | 73 |
public int getMinor() { |
102 |
return minorVersionNumber;
|
|
74 |
return this.version.getMinor();
|
|
103 | 75 |
} |
104 | 76 |
|
105 | 77 |
public int getMajor() { |
106 |
return majorVersionNumber;
|
|
78 |
return this.version.getMajor();
|
|
107 | 79 |
} |
108 | 80 |
|
109 | 81 |
public int getRelease() { |
110 |
return releaseNumber;
|
|
82 |
return this.version.getRevision();
|
|
111 | 83 |
} |
112 | 84 |
|
113 | 85 |
public String getBuildId() { |
114 |
return buildNumber;
|
|
86 |
return Integer.toString(this.version.getBuild());
|
|
115 | 87 |
} |
116 | 88 |
|
117 | 89 |
public String toString() { |
... | ... | |
125 | 97 |
public String getLongFormat() { |
126 | 98 |
return getFormat() + " (Build " + getBuildId() + ")"; |
127 | 99 |
} |
100 |
|
|
101 |
public org.gvsig.installer.lib.api.Version asInstallerVersion() { |
|
102 |
return version; |
|
103 |
} |
|
128 | 104 |
} |
Also available in: Unified diff