001: /*
002:
003: Derby - Class org.apache.derby.tools.sysinfo
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.tools;
023:
024: import org.apache.derby.iapi.services.info.ProductVersionHolder;
025: import org.apache.derby.iapi.services.info.JVMInfo;
026: import org.apache.derby.impl.tools.sysinfo.Main;
027:
028: /**
029:
030: This class displays system information to system out.
031:
032: To run from the command-line, enter the following:
033: <p>
034: <code>java org.apache.derby.tools.sysinfo</code>
035: <p>
036: <p>
037: Also available on this class are methods which allow you to determine
038: the version of the code for the system without actually booting a database.
039: Please note that this is the Derby version of the .jar files, not of your databases.
040: <p>
041: The numbering scheme for released Derby products is <b><code>m1.m2.m3 </code></b>
042: where <b><code>m1</code></b> is the major release version, <b><code>m2</code></b> is the minor release version,
043: and <b><code>m3</code></b> is the maintenance level. Versions of the product with the same
044: major and minor version numbers are considered feature compatible.
045: <p>Valid major and minor versions are always greater than zero. Valid maintenance
046: versions are greater than or equal to zero.
047:
048:
049: */
050: public class sysinfo {
051:
052: static public void main(String[] args) {
053: Main.main(args);
054: }
055:
056: private sysinfo() { // no instances allowed
057: }
058:
059: /**
060: The genus name for the Apache Derby code. Use this to determine the version of the
061: Apache Derby embedded code in derby.jar.
062: */
063: public static final String DBMS = "DBMS";
064:
065: /**
066: * The genus name for the tools code. Use this to determine the version of
067: code in derbytools.jar
068: */
069: public static final String TOOLS = "tools";
070:
071: /**
072: * The genus name for the network server code. Use this to determine the version of
073: code in derbynet.jar
074: */
075: public static final String NET = "net";
076:
077: /**
078: * The genus name for the client code. Use this to determine the version of
079: code in derbyclient.jar
080: */
081: public static final String CLIENT = "dnc";
082:
083: /**
084: gets the major version of the Apache Derby embedded code.
085: @return the major version. Returns -1 if not found.
086: */
087: static public int getMajorVersion() {
088: return getMajorVersion(DBMS);
089: }
090:
091: /**
092: gets the major version of the specified code library.
093: @param genus which library to get the version of. Valid inputs include
094: DBMS, TOOLS, NET, CLIENT
095: @return the major version. Return -1 if the information is not found.
096: */
097: static public int getMajorVersion(String genus) {
098: ProductVersionHolder pvh = ProductVersionHolder
099: .getProductVersionHolderFromMyEnv(genus);
100: if (pvh == null) {
101: return -1;
102: }
103:
104: return pvh.getMajorVersion();
105: }
106:
107: /**
108: gets the minor version of the Apache Derby embedded code.
109: @return the minor version. Returns -1 if not found.
110: */
111: static public int getMinorVersion() {
112: return getMinorVersion(DBMS);
113: }
114:
115: /**
116: gets the minor version of the specified code library.
117: @param genus which library to get the version of. Valid inputs include
118: DBMS, TOOLS, NET, CLIENT.
119: @return the minor version. Return -1 if the information is not found.
120: */
121: static public int getMinorVersion(String genus) {
122: ProductVersionHolder pvh = ProductVersionHolder
123: .getProductVersionHolderFromMyEnv(genus);
124: if (pvh == null) {
125: return -1;
126: }
127:
128: return pvh.getMinorVersion();
129: }
130:
131: /**
132: gets the build number for the Apache Derby embedded library
133: @return the build number, or -1 if the information is not found.
134: */
135: static public String getBuildNumber() {
136: return getBuildNumber("DBMS");
137: }
138:
139: /**
140: gets the build number for the specified library
141: @param genus which library to get the build number for. Valid inputs are
142: DBMS, TOOLS, NET, CLIENT.
143: @return the build number, or ???? if the information is not found.
144: */
145: static public String getBuildNumber(String genus) {
146: ProductVersionHolder pvh = ProductVersionHolder
147: .getProductVersionHolderFromMyEnv(genus);
148: if (pvh == null) {
149: return "????";
150: }
151:
152: return pvh.getBuildNumber();
153: }
154:
155: /**
156: gets the product name for the Apache Derby embedded library
157: @return the name
158: */
159: static public String getProductName() {
160: return getProductName("DBMS");
161: }
162:
163: /**
164: gets the external name for the specified code library.
165: @param genus which library to get the name for
166: @return the name.
167: */
168:
169: static public String getProductName(String genus) {
170: ProductVersionHolder pvh = ProductVersionHolder
171: .getProductVersionHolderFromMyEnv(genus);
172: if (pvh == null) {
173: return Main.getTextMessage("SIF01.K");
174: }
175:
176: return pvh.getProductName();
177: }
178:
179: /**
180: Return the version information string for the specified library including alpha or beta indicators.
181: */
182: static public String getVersionString() {
183: return getVersionString(DBMS);
184: }
185:
186: /**
187: Return the version information string for the Apache Derby embedded library including alpha or beta indicators.
188: */
189: static public String getVersionString(String genus) {
190:
191: ProductVersionHolder pvh = ProductVersionHolder
192: .getProductVersionHolderFromMyEnv(genus);
193: if (pvh == null) {
194: return Main.getTextMessage("SIF01.K");
195: }
196:
197: return pvh.getVersionBuildString(false);
198: }
199:
200: public static void getInfo(java.io.PrintWriter out) {
201: Main.getMainInfo(out, false);
202: }
203: }
|