move default configuration dir from ./conf to ./solrconf

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@386349 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-03-16 14:56:45 +00:00
parent 3cf1cfb107
commit 0f9bcba8ad
12 changed files with 28 additions and 16 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<!-- The Solr schema file. This file should be named "schema.xml" and
should be in the conf directory or located where the classloader
should be in the solrconf directory or located where the classloader
for the Solr webapp can find it.
For more information, on how to customize this file, please see...

View File

@ -218,6 +218,18 @@ public class Config {
}
}
// The directory where solr will look for config files by default.
// defaults to "./solrconf/"
private static final String configDir;
static {
String str = System.getProperty("solr.configdir");
if (str==null) {
str="solrconf/";
} else if ( !(str.endsWith("/") || str.endsWith("\\")) ) {
str+='/';
}
configDir = str;
}
public static InputStream openResource(String resource) {
InputStream is=null;
@ -225,8 +237,8 @@ public class Config {
try {
File f = new File(resource);
if (!f.isAbsolute()) {
// try $CWD/conf/
f = new File("conf/" + resource);
// try $CWD/solrconf/
f = new File(configDir + resource);
}
if (f.isFile() && f.canRead()) {
return new FileInputStream(f);

View File

@ -26,28 +26,28 @@ import java.io.InputStream;
public class SolrConfig {
public static Config config;
static {
Exception e=null;
RuntimeException e=null;
String file="solrconfig.xml";
InputStream is=null;
try {
is = Config.openResource(file);
} catch (Exception ee) {
} catch (RuntimeException ee) {
e=ee;
file = "solarconfig.xml"; // backward compat
try {
is = Config.openResource(file);
} catch (Exception eee) {}
}
if (is!=null) {
try {
config=new Config(file, is, "/config/");
is.close();
} catch (Exception ee) {
throw new RuntimeException(ee);
} catch (Exception eee) {
throw e;
}
Config.log.info("Loaded Config solrconfig.xml");
} else {
throw new RuntimeException("Can't find Solr config file ./conf/solrconfig.xml",e);
}
try {
config=new Config(file, is, "/config/");
is.close();
} catch (Exception ee) {
throw new RuntimeException("Error in solrconfig.xml", ee);
}
Config.log.info("Loaded Config solrconfig.xml");
}
}