cleaned up configuraiton management and startup scripts

This commit is contained in:
2014-04-30 07:00:25 +02:00
parent 9f4c6c0356
commit 88f4dd2b19
6 changed files with 8 additions and 262 deletions

View File

@@ -37,4 +37,4 @@ do
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ConversionMain $ARGUMENTS
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ui.ConversionMain $ARGUMENTS

View File

@@ -37,4 +37,4 @@ do
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ViewerMain $ARGUMENTS
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ui.VisualizationZMQMain $ARGUMENTS

View File

@@ -37,4 +37,4 @@ do
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.VisualizationMain $ARGUMENTS
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ui.VisualizationMain $ARGUMENTS

View File

@@ -1,251 +0,0 @@
/**
*
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class AcquisitionConfiguration {
private static final Logger logger = Logger.getLogger(AcquisitionConfiguration.class.getName());
public final static String FDA_CONFIG_FILE = "ch.psi.fda.config.file";
private String otfChannelPrefix;
private String otfNfsServer;
private String otfNfsShare;
private String otfSmbShare;
private String otfScalerPrefix;
private boolean otfUseCrlogic;
private String otfCrlogicPrefix;
private boolean otfCrlogicKeepTmpFiles;
/**
* Base directory for data. The directory may contain date macros. The string may contain any @see java.text.SimpleDateFormat
* patterns within ${ } brackets. The macros are resolved with the actual time while the get method
* of this property is called.
*/
private String dataBaseDirectory = System.getProperty("user.home");
/**
* Prefix of the data file. The prefix may contain date macros. The string may contain any @see java.text.SimpleDateFormat
* patterns within ${ } brackets. The macros are resolved with the actual time while the get method
* of this property is called.
*/
private String dataFilePrefix = "";
/**
* Maximum time for a actor move
*/
private Long actorMoveTimeout = 600000l; // 10 Minutes maximum move time
private String smptServer;
/**
* Default Constructor
* The constructor will read the configuration from the /fda.properties file (resource) located in the classpath.
*/
public AcquisitionConfiguration(){
loadConfiguration(System.getProperty(FDA_CONFIG_FILE));
}
/**
* Load configuration from properties file
*/
public void loadConfiguration(String file) {
Properties properties = new Properties();
File cfile = null;
// Only read in the property file if a file is specified
if(file != null){
cfile = new File(file);
try {
properties.load(new FileReader(cfile));
} catch (FileNotFoundException e) {
throw new RuntimeException("Configuration file "+file+" not found", e);
} catch (IOException e) {
throw new RuntimeException("Cannot read configuration file "+file, e);
}
}
else{
logger.warning("No configfile specified !");
}
// The defaults are set here
otfChannelPrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.channelPrefix", "");
otfScalerPrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.scalerPrefix", "");
otfNfsServer = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.nfsServer", "");
otfNfsShare = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.nfsShare", "");
otfSmbShare = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.smbShare", "");
otfUseCrlogic = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.useCrlogic", "false"));
otfCrlogicPrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicPrefix", "");
otfCrlogicKeepTmpFiles = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicKeepTmpFiles", "false"));
dataBaseDirectory = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.dir",".");
if(cfile!=null && dataBaseDirectory.matches("^\\.\\.?/.*")){ // if basedir starts with . or .. we assume the data directory to be relative to the directory of the configuration file
dataBaseDirectory = cfile.getParentFile().getAbsolutePath()+"/"+dataBaseDirectory;
}
dataFilePrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.filePrefix","");
actorMoveTimeout = new Long(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".actorMoveTimeout","600000"));
smptServer= properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".notification.host","mail.psi.ch");
}
/**
* Replace ${name} and ${date} macro given string
* @param string
* @param date
* @param name
* @return
*/
public String replaceMacros(String string, Date date, String name){
String newString = string;
// Replace scan name macros
newString = newString.replaceAll("\\$\\{name\\}", name);
// Replace date macros
Pattern pattern = Pattern.compile("\\$\\{[a-z,A-Z,-,_,:]*\\}");
Matcher matcher = pattern.matcher(newString);
while(matcher.find()){
String datePattern = matcher.group();
datePattern = datePattern.replaceAll("\\$\\{", "");
datePattern = datePattern.replaceAll("\\}", "");
SimpleDateFormat datef = new SimpleDateFormat(datePattern);
newString = matcher.replaceFirst(datef.format(date));
matcher = pattern.matcher(newString);
}
return newString;
}
// Getter and setter functions
public String getOtfChannelPrefix() {
return otfChannelPrefix;
}
public void setOtfChannelPrefix(String otfChannelPrefix) {
this.otfChannelPrefix = otfChannelPrefix;
}
public String getOtfNfsServer() {
return otfNfsServer;
}
public void setOtfNfsServer(String otfNfsServer) {
this.otfNfsServer = otfNfsServer;
}
public String getOtfNfsShare() {
return otfNfsShare;
}
public void setOtfNfsShare(String otfNfsShare) {
this.otfNfsShare = otfNfsShare;
}
public String getOtfSmbShare() {
return otfSmbShare;
}
public void setOtfSmbShare(String otfSmbShare) {
this.otfSmbShare = otfSmbShare;
}
public String getOtfScalerPrefix() {
return otfScalerPrefix;
}
public void setOtfScalerPrefix(String otfScalerPrefix) {
this.otfScalerPrefix = otfScalerPrefix;
}
public boolean isOtfUseCrlogic() {
return otfUseCrlogic;
}
public void setOtfUseCrlogic(boolean otfUseCrlogic) {
this.otfUseCrlogic = otfUseCrlogic;
}
public String getOtfCrlogicPrefix() {
return otfCrlogicPrefix;
}
public void setOtfCrlogicPrefix(String otfCrlogicPrefix) {
this.otfCrlogicPrefix = otfCrlogicPrefix;
}
public boolean isOtfCrlogicKeepTmpFiles() {
return otfCrlogicKeepTmpFiles;
}
public void setOtfCrlogicKeepTmpFiles(boolean otfCrlogicKeepTmpFiles) {
this.otfCrlogicKeepTmpFiles = otfCrlogicKeepTmpFiles;
}
public String getDataBaseDirectory() {
return dataBaseDirectory;
}
public void setDataBaseDirectory(String dataBaseDirectory) {
this.dataBaseDirectory = dataBaseDirectory;
}
public String getDataFilePrefix() {
return dataFilePrefix;
}
public void setDataFilePrefix(String dataFilePrefix) {
this.dataFilePrefix = dataFilePrefix;
}
public Long getActorMoveTimeout() {
return actorMoveTimeout;
}
public void setActorMoveTimeout(Long actorMoveTimeout) {
this.actorMoveTimeout = actorMoveTimeout;
}
public String getSmptServer() {
return smptServer;
}
public void setSmptServer(String smptServer) {
this.smptServer = smptServer;
}
}

View File

@@ -75,10 +75,12 @@ public class ApplicationConfigurator {
createApplicationHome();
createDefaultConfigurationFiles();
// Set FDA configuration argument -Dch.psi.fda.config.file=...
String property = System.getProperty(AcquisitionConfiguration.FDA_CONFIG_FILE);
// Set FDA configuration argument -Dch.psi.fda.config.file=...
final String configFile = "ch.psi.fda.xscan.config.file";
String property = System.getProperty(configFile);
if(property==null){
System.setProperty(AcquisitionConfiguration.FDA_CONFIG_FILE, fdaProperties.getAbsolutePath());
System.setProperty(configFile, fdaProperties.getAbsolutePath());
}
// Set jcae.properties file

View File

@@ -6,8 +6,6 @@ import javax.inject.Singleton;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import ch.psi.fda.AcquisitionConfiguration;
//import ch.psi.fda.cdump.CdumpConfiguration;
import ch.psi.jcae.ChannelService;
import ch.psi.jcae.impl.DefaultChannelService;
@@ -19,10 +17,7 @@ public class ResourceBinder extends AbstractBinder {
@Override
protected void configure() {
bind(channelService).to(ChannelService.class);
bind(AcquisitionConfiguration.class).to(AcquisitionConfiguration.class).in(Singleton.class);
bind(ExecutionEngine.class).to(ExecutionEngine.class).in(Singleton.class);
bind(zmqService).to(ZMQDataService.class);
}