Author: ehatcher
Date: Sat Dec 8 02:42:31 2007
New Revision: 602443
URL: http://svn.apache.org/viewvc?rev=602443&view=rev
Log:
SOLR-427: Allow IndexSchema to be loadable from an InputStream.
Modified:
lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java?rev=602443&r1=602442&r2=602443&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java Sat Dec
8 02:42:31 2007
@@ -55,6 +55,8 @@
* @version $Id$
*/
public final class IndexSchema {
+ public static final String DEFAULT_SCHEMA_FILE = "schema.xml";
+
final static Logger log = Logger.getLogger(IndexSchema.class.getName());
private final SolrConfig solrConfig;
private final String schemaFile;
@@ -67,10 +69,16 @@
*
* @see Config#openResource
*/
+ @Deprecated
public IndexSchema(SolrConfig solrConfig, String schemaFile) {
+ this(solrConfig, solrConfig.getResourceLoader().openResource(schemaFile));
+ }
+
+ public IndexSchema(SolrConfig solrConfig, InputStream is) {
this.solrConfig = solrConfig;
- this.schemaFile=schemaFile;
- readSchema(solrConfig);
+ this.schemaFile = DEFAULT_SCHEMA_FILE;
+
+ readSchema(is);
SolrResourceLoader loader = solrConfig.getResourceLoader();
loader.inform( loader );
@@ -79,11 +87,13 @@
public SolrConfig getSolrConfig() {
return solrConfig;
}
+
/**
* Direct access to the InputStream for the schemaFile used by this instance.
*
* @see Config#openResource
*/
+ @Deprecated
public InputStream getInputStream() {
return solrConfig.getResourceLoader().openResource(schemaFile);
}
@@ -295,8 +305,7 @@
}
}
-
- private void readSchema(final SolrConfig solrConfig) {
+ private void readSchema(InputStream is) {
log.info("Reading Solr Schema");
try {
@@ -305,7 +314,7 @@
Document document = builder.parse(getInputStream());
***/
- Config schemaConf = new Config("schema", getInputStream(), "/schema/");
+ Config schemaConf = new Config("schema", is, "/schema/");
Document document = schemaConf.getDocument();
final XPath xpath = schemaConf.getXPath();