1 | /* |
2 | |
3 | Derby - Class org.apache.derby.tools.sysinfo |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.tools; |
22 | |
23 | import org.apache.derby.iapi.services.info.ProductVersionHolder; |
24 | import org.apache.derby.iapi.services.info.JVMInfo; |
25 | import org.apache.derby.impl.tools.sysinfo.Main; |
26 | |
27 | /** |
28 | |
29 | This class displays system information to system out. |
30 | |
31 | To run from the command-line, enter the following: |
32 | <p> |
33 | <code>java org.apache.derby.tools.sysinfo</code> |
34 | <p> |
35 | <p> |
36 | Also available on this class are methods which allow you to determine |
37 | the version of the code for the system without actually booting a database. |
38 | Please note that this is the Derby version of the .jar files, not of your databases. |
39 | <p> |
40 | The numbering scheme for released Derby products is <b><code>m1.m2.m3 </code></b> |
41 | where <b><code>m1</code></b> is the major release version, <b><code>m2</code></b> is the minor release version, |
42 | and <b><code>m3</code></b> is the maintenance level. Versions of the product with the same |
43 | major and minor version numbers are considered feature compatible. |
44 | <p>Valid major and minor versions are always greater than zero. Valid maintenance |
45 | versions are greater than or equal to zero. |
46 | |
47 | |
48 | */ |
49 | public class sysinfo { |
50 | |
51 | static public void main(String[] args) { |
52 | Main.main(args); |
53 | } |
54 | |
55 | private sysinfo() { // no instances allowed |
56 | } |
57 | |
58 | /** |
59 | The genus name for the Apache Derby code. Use this to determine the version of the |
60 | Apache Derby embedded code in cs.jar. |
61 | */ |
62 | public static final String DBMS="DBMS"; |
63 | |
64 | /** |
65 | * The genus name for the tools code. Use this to determine the version of |
66 | code in cstools.jar |
67 | */ |
68 | public static final String TOOLS="tools"; |
69 | |
70 | |
71 | /** |
72 | gets the major version of the Apache Derby embedded code. |
73 | @return the major version. Returns -1 if not found. |
74 | */ |
75 | static public int getMajorVersion() |
76 | { |
77 | return getMajorVersion(DBMS); |
78 | } |
79 | |
80 | |
81 | /** |
82 | gets the major version of the specified code library. |
83 | @param genus which library to get the version of. Valid inputs include |
84 | DBMS, TOOLS |
85 | @return the major version. Return -1 if the information is not found. |
86 | */ |
87 | static public int getMajorVersion(String genus) |
88 | { |
89 | ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus); |
90 | if (pvh == null) |
91 | { |
92 | return -1; |
93 | } |
94 | |
95 | return pvh.getMajorVersion(); |
96 | } |
97 | |
98 | |
99 | /** |
100 | gets the minor version of the Apache Derby embedded code. |
101 | @return the minor version. Returns -1 if not found. |
102 | */ |
103 | static public int getMinorVersion() |
104 | { |
105 | return getMinorVersion(DBMS); |
106 | } |
107 | |
108 | /** |
109 | gets the minor version of the specified code library. |
110 | @param genus which library to get the version of. Valid inputs include |
111 | DBMS, TOOLS. |
112 | @return the minor version. Return -1 if the information is not found. |
113 | */ |
114 | static public int getMinorVersion(String genus) |
115 | { |
116 | ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus); |
117 | if (pvh == null) |
118 | { |
119 | return -1; |
120 | } |
121 | |
122 | return pvh.getMinorVersion(); |
123 | } |
124 | |
125 | /** |
126 | gets the build number for the Apache Derby embedded library |
127 | @return the build number, or -1 if the information is not found. |
128 | */ |
129 | static public String getBuildNumber() |
130 | { |
131 | return getBuildNumber("DBMS"); |
132 | } |
133 | |
134 | /** |
135 | gets the build number for the specified library |
136 | @param genus which library to get the build number for. Valid inputs are |
137 | DBMS, TOOLS |
138 | @return the build number, or ???? if the information is not found. |
139 | */ |
140 | static public String getBuildNumber(String genus) |
141 | { |
142 | ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus); |
143 | if (pvh == null) |
144 | { |
145 | return "????"; |
146 | } |
147 | |
148 | return pvh.getBuildNumber(); |
149 | } |
150 | |
151 | |
152 | /** |
153 | gets the product name for the Apache Derby embedded library |
154 | @return the name |
155 | */ |
156 | static public String getProductName() |
157 | { |
158 | return getProductName("DBMS"); |
159 | } |
160 | |
161 | /** |
162 | gets the external name for the specified code library. |
163 | @param genus which library to get the name for |
164 | @return the name. |
165 | */ |
166 | |
167 | static public String getProductName(String genus) |
168 | { |
169 | ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus); |
170 | if (pvh == null) |
171 | { |
172 | return Main.getTextMessage ("SIF01.K"); |
173 | } |
174 | |
175 | return pvh.getProductName(); |
176 | } |
177 | |
178 | /** |
179 | Return the version information string for the specified library including alpha or beta indicators. |
180 | */ |
181 | static public String getVersionString() { |
182 | return getVersionString(DBMS); |
183 | } |
184 | |
185 | /** |
186 | Return the version information string for the Apache Derby embedded library including alpha or beta indicators. |
187 | */ |
188 | static public String getVersionString(String genus) { |
189 | |
190 | ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus); |
191 | if (pvh == null) |
192 | { |
193 | return Main.getTextMessage ("SIF01.K"); |
194 | } |
195 | |
196 | return pvh.getVersionBuildString(false); |
197 | } |
198 | |
199 | public static void getInfo (java.io.PrintWriter out) { |
200 | Main.getMainInfo(out, false); |
201 | } |
202 | } |