Results 1 to 2 of 2

Thread: ApplicationDescriptor

  1. #1

    Default ApplicationDescriptor

    Hi everybody,
    as we needed for our project, I created another version of ApplicationDescriptor, which will read in a properties file to configure the version.

    I will post the code here:
    Code:
    package de.hr.ec.fsm.service;
    
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Properties;
    
    import org.springframework.richclient.application.ApplicationDescriptor;
    import org.springframework.richclient.core.LabeledObjectSupport;
    import org.springframework.richclient.util.Assert;
    
    public class PropertiesApplicationDescriptor extends LabeledObjectSupport implements ApplicationDescriptor {
    	/** The version of the application */
    	private String version;
    
    	/** The build identifier associated with this build of the application */
    	private String buildId;
    
    	public PropertiesApplicationDescriptor(String propertiesFile) {
    		Assert.notNull(propertiesFile);
    		Properties properties = new Properties();
    		try {
    			properties.load(PropertiesApplicationDescriptor.class.getResourceAsStream(propertiesFile));
    			setBuildId(properties.getProperty("buildId", "localBuild"));
    			setVersion(properties.getProperty("version", "localBuild"));
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    
    	}
    
    	public String getBuildId() {
    		return buildId;
    	}
    
    	public void setBuildId(String buildId) {
    		this.buildId = buildId;
    	}
    
    	public String getVersion() {
    		return version;
    	}
    
    	public void setVersion(String version) {
    		this.version = version;
    	}
    
    }
    We use this code to write a buildNumber (which is actually passed via CruiseContol to ant) with ant as the following example shows:

    Code:
    <target name="writeBuildNumber">
    		<propertyfile file="build/version.properties">
    			<entry key="buildId" value="${label}" />
    		</propertyfile>
    </target>

  2. #2

    Default

    Have you tried to use the PropertyPlaceholderConfigurer of spring? This makes it possible to read in property files and use these as variables within your context. So you could use the DefaultApplicationDescriptor and set the properties using ${version} etc.

    Kind Regards,
    Jan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •