Skip to content

Commit

Permalink
Merge pull request #77 from epics-base/Issue_72
Browse files Browse the repository at this point in the history
#72 simplify the jca versioning support
  • Loading branch information
shroffk authored Apr 5, 2024
2 parents 669385d + 506efc8 commit 38cfdbd
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 64 deletions.
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,25 @@
<directory>src/core/gov/aps/jca</directory>
<includes>
<include>JCALibrary.properties</include>
<include>version.properties</include>
</includes>
</resource>
<resource>
<targetPath>gov/aps/jca</targetPath>
<directory>src/core/gov/aps/jca</directory>
<filtering>true</filtering>
<includes>
<include>version.properties</include>
</includes>
</resource>
<resource>
<targetPath>gov/aps/jca</targetPath>
<directory>src/core/gov/aps/jca</directory>
<filtering>false</filtering>
<excludes>
<exclude>version.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Includes the OSGi manifest -->
Expand Down
23 changes: 1 addition & 22 deletions src/core/com/cosylab/epics/caj/CAJContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,12 @@
*/
public class CAJContext extends Context implements CAContext, CAJConstants, Configurable {

/**
* Major version.
*/
private static final int CAJ_VERSION_MAJOR = 1;

/**
* Minor version.
*/
private static final int CAJ_VERSION_MINOR = 1;

/**
* Maintenance version.
*/
private static final int CAJ_VERSION_MAINTENANCE = 16;

/**
* Development version.
*/
private static final int CAJ_VERSION_DEVELOPMENT = 1;

/**
* Version.
*/
public static final Version VERSION = new Version(
"Channel Access in Java", "Java",
CAJ_VERSION_MAJOR, CAJ_VERSION_MINOR,
CAJ_VERSION_MAINTENANCE, CAJ_VERSION_DEVELOPMENT);
JCALibrary.getInstance().getVersion());

/**
* String value of the JVM property key to turn on single threaded model.
Expand Down
22 changes: 1 addition & 21 deletions src/core/com/cosylab/epics/caj/cas/CAJServerContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,13 @@ public class CAJServerContext extends ServerContext implements CAContext, Config
System.setProperty("java.net.preferIPv4Stack", "true");
}

/**
* Major version.
*/
private static final int CAS_VERSION_MAJOR = 1;

/**
* Minor version.
*/
private static final int CAS_VERSION_MINOR = 1;

/**
* Maintenance version.
*/
private static final int CAS_VERSION_MAINTENANCE = 16;

/**
* Development version.
*/
private static final int CAS_VERSION_DEVELOPMENT = 1;

/**
* Version.
*/
public static final Version VERSION = new Version(
"Channel Access Server in Java", "Java",
CAS_VERSION_MAJOR, CAS_VERSION_MINOR,
CAS_VERSION_MAINTENANCE, CAS_VERSION_DEVELOPMENT);
JCALibrary.getInstance().getVersion());


/**
Expand Down
32 changes: 25 additions & 7 deletions src/core/gov/aps/jca/JCALibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@
*/
public final class JCALibrary {

@Deprecated
static private final int VERSION=2;
@Deprecated
static private final int REVISION=4;
// TODO version to be incremented - do not forget
@Deprecated
static private final int MODIFICATION=6;
@Deprecated
static private final String VERSION_STRING=""+VERSION+"."+REVISION+"."+MODIFICATION;

static private JCALibrary _instance=null;
Expand All @@ -94,9 +98,18 @@ protected JCALibrary() {
String fileSep=System.getProperty( "file.separator" );
String path=null;

// Read the version
try (InputStream input = JCALibrary.class.getResourceAsStream("version.properties")) {
// load a properties file
if (input == null)
throw new RuntimeException("resource not found.");
versionProperties.load(input);
} catch (IOException ex) {
System.out.println( "Unable to load default configuration located in 'version.properties' resource: " + ex.getMessage() );
}

// Read Configuration
try {
InputStream is = JCALibrary.class.getResourceAsStream( "JCALibrary.properties" );
try (InputStream is = JCALibrary.class.getResourceAsStream( "JCALibrary.properties" );) {
if (is == null)
throw new RuntimeException("resource not found.");
_builtinProperties.load( is );
Expand Down Expand Up @@ -125,12 +138,16 @@ protected JCALibrary() {

}

public String getVersion() {
return versionProperties.getProperty("jca.version");
}

/**Getter method for the version number.
* @return the JCALibrary version number.
*/
public int getVersion() {
return VERSION;
}
// public int getVersion() {
// return VERSION;
// }

/**Getter method for the revision number.
* @return the JCALibrary revision number.
Expand All @@ -150,7 +167,7 @@ public int getModification() {
* @return the JCALibrary version string.
*/
public String getVersionString() {
return VERSION_STRING;
return getVersion();
}

/** Print some basic info about the JCALibrary to the standard output stream.
Expand All @@ -167,10 +184,11 @@ public void printInfo( PrintStream out ) {
}

public String toString() {
return JCALibrary.class.getName()+"["+getVersionString()+"]";
return JCALibrary.class.getName()+"["+getVersion()+"]";
}

// PROPERTIES
Properties versionProperties=new Properties();
Properties _builtinProperties=new Properties();
Properties _defaultProperties=new Properties( _builtinProperties );
Properties _properties=new Properties( _defaultProperties );
Expand Down
56 changes: 42 additions & 14 deletions src/core/gov/aps/jca/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,33 @@ public class Version {
*/
private String implementationLanguage;

/**
*
*/
private String version;

/**
* @see Version#getMajorVersion()
*/
@Deprecated
private int majorVersion;

/**
* @see Version#getMinorVersion()
*/
@Deprecated
private int minorVersion;

/**
* @see Version#getMaintenanceVersion()
*/
@Deprecated
private int maintenanceVersion;

/**
* @see Version#getDevelopmentVersion()
*/
@Deprecated
private int developmentVersion;

/**
Expand All @@ -66,6 +75,7 @@ public class Version {
* @param maintenanceVersion maintenance version.
* @param developmentVersion development version.
*/
@Deprecated
public Version(String productName, String implementationLangugage,
int majorVersion, int minorVersion, int maintenanceVersion,
int developmentVersion)
Expand All @@ -81,6 +91,21 @@ public Version(String productName, String implementationLangugage,
this.developmentVersion = developmentVersion;
}

/**
* Version consturctor.
* @param productName product name.
* @param implementationLangugage impementation language.
* @param version a string representing the version number.
*/
public Version(String productName, String implementationLangugage, String version)
{

this.productName = productName;
this.implementationLanguage = implementationLangugage;
this.version = version;
}


/**
* Get the long version string. Version String formatted like <BR><CODE>
* "<B>ProductName </B> \[<B>ImplementationLanguage</B>\] 'v'v.r[.dd|<B>D</B>nn]"
Expand All @@ -95,16 +120,12 @@ public String getLongVersionString()
+ " ["
+ getImplementationLanguage()
+ "] v"
+ getMajorVersion()
+ "."
+ getMinorVersion()
+ "."
+ ((getDevelopmentVersion() > 0) ? ("D" + getDevelopmentVersion())
: ("" + getMaintenanceVersion()));
+ getVersion();
}

/**
* Get the basic version string. Version String formatted like <BR><CODE>

/**
* Get the basic version string. Vesion String formatted like <BR><CODE>
* "<B>ProductName </B> 'v'v.r[.dd|<B>D</B>nn]"
* </CODE> <BR>e.g. <BR><CODE>"<B>CAJ </B> v1.0.1"</CODE>
* <BR>
Expand All @@ -115,12 +136,7 @@ public String getVersionString()
{
return getProductName()
+ " v"
+ getMajorVersion()
+ "."
+ getMinorVersion()
+ "."
+ ((getDevelopmentVersion() > 0) ? ("D" + getDevelopmentVersion())
: ("" + getMaintenanceVersion()));
+ getVersion();
}

/**
Expand All @@ -139,6 +155,14 @@ public String getImplementationLanguage()
return implementationLanguage;
}

/**
*
* @return version number
*/
private String getVersion()
{
return version;
}
/**
* Major version number. This changes only when there is a
* significant, externally apparent enhancement from the previous release.
Expand All @@ -147,6 +171,7 @@ public String getImplementationLanguage()
* Clients should carefully consider the implications of new versions as
* external interfaces and behaviour may have changed.
*/
@Deprecated
public int getMajorVersion()
{
return majorVersion;
Expand All @@ -161,6 +186,7 @@ public int getMajorVersion()
* <li>its designated as a reference release</li>
* </ul>
*/
@Deprecated
public int getMinorVersion()
{
return minorVersion;
Expand All @@ -173,6 +199,7 @@ public int getMinorVersion()
* contains no API changes. When missing, it designates the final and
* complete development drop for a release.
*/
@Deprecated
public int getMaintenanceVersion()
{
return maintenanceVersion;
Expand All @@ -192,6 +219,7 @@ public int getMaintenanceVersion()
* Each 'D' drops can contain functional enhancements as well as defect
* fixes. 'D' drops may not be as stable as the final releases.
*/
@Deprecated
public int getDevelopmentVersion()
{
return developmentVersion;
Expand Down
1 change: 1 addition & 0 deletions src/core/gov/aps/jca/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jca.version=${project.version}

0 comments on commit 38cfdbd

Please sign in to comment.