local properties override for ./config/kustvakt.conf, ./config/jdbc.properties, ./config/log4j.properties
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 1564e77..20d5813 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -7,6 +7,7 @@
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -26,7 +27,7 @@
public class KustvaktConfiguration {
private static final Logger jlog = KustvaktLogger
- .initiate(KustvaktConfiguration.class);
+ .getLogger(KustvaktConfiguration.class);
private String indexDir;
private int port;
// todo: make exclusive so that the containg languages can really only be used then
@@ -77,9 +78,11 @@
* @return
*/
protected Properties load(Properties properties) {
- String log4jconfig = properties
- .getProperty("log4jconfig", "log4j.properties");
- loadLog4jLogger(log4jconfig);
+ properties.list(System.out);
+
+ // if not present, uses classpath log4j.properties
+ String log4jconfig = properties.getProperty("log4jconfig", "");
+ loadLog4jLogger();
maxhits = new Integer(properties.getProperty("maxhits", "50000"));
returnhits = new Integer(properties.getProperty("returnhits", "50000"));
indexDir = properties.getProperty("lucene.indexDir", "");
@@ -156,6 +159,7 @@
*/
public void setPropertiesAsStream(InputStream stream) {
try {
+
Properties p = new Properties();
p.load(stream);
this.load(p);
@@ -172,16 +176,17 @@
return Enum.valueOf(BACKENDS.class, value.toUpperCase());
}
- private void loadLog4jLogger(String log4jconfig) {
+ private void loadLog4jLogger() {
/** loadSubTypes log4j configuration file programmatically */
Properties log4j = new Properties();
try {
- if (!log4jconfig.equals("")) {
- log4j.load(new FileInputStream(log4jconfig));
+ File f = new File("./config/log4j.properties");
+ if (f.exists()) {
+ log4j.load(new FileInputStream(f));
PropertyConfigurator.configure(log4j);
- jlog.info(
+ jlog.warn(
"using local logging properties file ({}) to configure logging system",
- log4jconfig);
+ "./config/log4j.properties");
return;
}
}catch (Exception e) {
diff --git a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 8686d73..e371f45 100644
--- a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -14,8 +14,6 @@
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-import java.io.FileInputStream;
-
/**
* @author hanl
* @date 01/06/2015
@@ -30,9 +28,6 @@
else
BeanConfiguration.loadClasspathContext();
- BeanConfiguration.getBeans().getConfiguration().setPropertiesAsStream(
- new FileInputStream(kargs.getProperties()));
-
kargs.setRootPackages(
new String[] { "de.ids_mannheim.korap.web.service.light" });
startServer(kargs);
@@ -58,9 +53,9 @@
StringBuffer b = new StringBuffer();
b.append("Parameter description: \n")
- .append("--config <Path to spring configuration file> : Configuration file\n")
- .append("--port <Server port> : Port under which the server is accessible \n")
- .append("--props <Path to kustvakt properties> : list of configuration properties\n")
+ .append("--config <Path to spring configuration file> : Configuration file\n").append(
+ "--port <Server port> : Port under which the server is accessible \n")
+ // .append("--props <Path to kustvakt properties> : list of configuration properties\n")
.append("--help : This help menu\n");
System.out.println(b.toString());
System.out.println();
@@ -124,6 +119,7 @@
@Getter
private String config;
@Getter
+ @Deprecated
private String properties;
private int port;
private SslContextFactory sslContext;
@@ -134,6 +130,7 @@
this.sslContext = null;
this.debug = false;
this.config = null;
+ this.properties = null;
}
}
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index 983a69c..7d21bdd 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -10,6 +10,8 @@
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+
+
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/cache
@@ -20,11 +22,27 @@
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<cache:annotation-driven/>
- <util:properties id="props" location="classpath:kustvakt.conf"/>
+
+ <bean id="props"
+ class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="ignoreResourceNotFound" value="true"/>
+ <property name="locations">
+ <array>
+ <value>classpath:kustvakt.conf</value>
+ <value>file:./config/kustvakt.conf</value>
+ </array>
+ </property>
+ </bean>
<bean id="jdbc_props"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations" value="classpath:jdbc.properties"/>
+ <property name="ignoreResourceNotFound" value="true"/>
+ <property name="locations">
+ <array>
+ <value>classpath:jdbc.properties</value>
+ <value>file:./config/jdbc.properties</value>
+ </array>
+ </property>
</bean>
<bean id='cacheManager'
@@ -51,7 +69,7 @@
<property name="password" value="${jdbc.password}"/>
<!-- relevant for single connection datasource and sqlite -->
<!--<property name="suppressClose">-->
- <!--<value>true</value>-->
+ <!--<value>true</value>-->
<!--</property>-->
<property name="initialSize" value="1"/>
<property name="maxIdle" value="1"/>
diff --git a/src/main/resources/light-config.xml b/src/main/resources/light-config.xml
index 12dce87..5548189 100644
--- a/src/main/resources/light-config.xml
+++ b/src/main/resources/light-config.xml
@@ -8,7 +8,18 @@
http://www.springframework.org/schema/util/spring-util-4.0.xsd">
- <util:properties id="props" location="classpath:kustvakt.conf"/>
+ <!--<util:properties id="props" location="classpath:kustvakt.conf"/>-->
+
+ <bean id="props"
+ class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="ignoreResourceNotFound" value="true"/>
+ <property name="locations">
+ <array>
+ <value>classpath:kustvakt.conf</value>
+ <value>file:./config/kustvakt.conf</value>
+ </array>
+ </property>
+ </bean>
<bean id="kustvakt_auditing"
class="de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing">