From: <tho...@us...> - 2014-06-30 13:03:23
|
Revision: 8509 http://sourceforge.net/p/bigdata/code/8509 Author: thompsonbry Date: 2014-06-30 13:03:14 +0000 (Mon, 30 Jun 2014) Log Message: ----------- Modified the Banner class to provide more transparent access to the BuildInfo metadata. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java 2014-06-30 11:32:23 UTC (rev 8508) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java 2014-06-30 13:03:14 UTC (rev 8509) @@ -249,23 +249,52 @@ } /** - * Use reflection to discover and report on the bigdata build information. A - * <code>com.bigdata.BuildInfo</code> is built when the JAR is created. - * However, it may not be present when running under an IDE from the source - * code and, therefore, there MUST NOT be any compile time references to the - * <code>com.bigdata.BuildInfo</code> class. This method uses reflection to - * avoid a compile time dependency. + * An interface which declares the keys for the map returned by + * {@link Banner#getBuildInfo()} . + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + */ + public interface BuildInfoMeta { + /** The bigdata release version. */ + String buildVersion = "buildVersion"; + /** The source code revision. */ + String svnRevision = "svnRevision"; + /** The source code repository URL for the branch. */ + String svnURL = "svnURL"; + /** The timestamp of the build. */ + String buildTimestamp = "buildTimestamp"; + /** The username that performed the build. */ + String buildUser = "buildUser"; + /** The hostname on which the build was performed. */ + String buildHost = "buildHost"; + /** The OS architecture on which the build was performed. */ + String osArch = "osArch"; + /** The OS name on which the build was performed. */ + String osName = "osName"; + /** The OS version on which the build was performed. */ + String osVersion = "osVersion"; + } + + /** + * Method used to discover and report on the bigdata build information. A + * <code>com.bigdata.BuildInfo</code> class is built when the JAR is + * created. However, it may not be present when running under an IDE from + * the source code and, therefore, there MUST NOT be any compile time + * references to the <code>com.bigdata.BuildInfo</code> class. This method + * uses reflection to avoid a compile time dependency. * <p> - * Note: This method works fine. However, the problem with exposing the - * information is that people running from an IDE can observe <em>stale</em> - * data from old <code>com.bigdata.BuildInfo</code> class files left from a - * previous build of a JAR. This makes the information good for deployed - * versions of the JAR but potentially misleading when people are running - * under an IDE. + * Note: This method works fine. However, people running from an IDE will + * observe <em>stale</em> data from old <code>com.bigdata.BuildInfo</code> + * class files left from a previous build of a JAR. This makes the + * information good for deployed versions of the JAR but potentially + * misleading when people are running under an IDE. * * @return Build info metadata iff available. + * + * @see BuildInfoMeta */ - private synchronized static Map<String,String> getBuildInfo() { + public synchronized static Map<String,String> getBuildInfo() { if (buildInfoRef.get() == null) { @@ -341,7 +370,7 @@ final StringBuilder s = new StringBuilder(); - s.append("\nbuildVersion=" + getBuildInfo().get("buildVersion")); + s.append("\nbuildVersion=" + getBuildInfo().get(BuildInfoMeta.buildVersion)); // s.append("\nsvnRevision =" + getBuildInfo().get("svnRevision")); @@ -350,16 +379,25 @@ } /** - * Attempts to return build version. + * Attempts to return the build version (aka the release version) from the + * <code>com.bigdata.BuildInfo</code> class. This class is generated by + * <code>build.xml</code> and is NOT available from the IDE. It is correct + * discovered using reflection. * - * @return Build version if available + * @return Build version if available and <code>unknown</code> otherwise. + * + * @see #getBuildInfo() */ public final static String getVersion() { - if (getBuildInfo().isEmpty()) { - return "unknown"; - } - - return getBuildInfo().get("buildVersion"); + + if (getBuildInfo().isEmpty()) { + + return "unknown"; + + } + + return getBuildInfo().get(BuildInfoMeta.buildVersion); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |