make json response writers available by default

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@423629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-07-19 22:00:28 +00:00
parent e6f9c04807
commit e24147b019
2 changed files with 21 additions and 15 deletions

View File

@ -223,15 +223,17 @@
writer.
The "standard" writer is the default and will be used if 'wt' is not specified
in the request. XMLResponseWriter will be used if nothing specified here.
The json, python, and ruby writers are also available by default.
<queryResponseWriter name="standard" class="org.apache.solr.request.XMLResponseWriter"/>
<queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
-->
<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter"/>
<queryResponseWriter name="python" class="org.apache.solr.request.PythonResponseWriter"/>
<queryResponseWriter name="ruby" class="org.apache.solr.request.RubyResponseWriter"/>
<queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
-->
<!-- config for the admin interface -->
<admin>

View File

@ -16,17 +16,11 @@
package org.apache.solr.core;
import java.util.Map;
import java.util.TreeMap;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.solr.request.QueryResponseWriter;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.request.XMLResponseWriter;
import org.apache.solr.request.*;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.SolrIndexSearcher;
@ -47,8 +41,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -956,8 +949,7 @@ public final class SolrCore {
private QueryResponseWriter defaultResponseWriter;
private Map<String, QueryResponseWriter> responseWriters
= new TreeMap<String, QueryResponseWriter>();
private final Map<String, QueryResponseWriter> responseWriters = new HashMap<String, QueryResponseWriter>();
/** Configure the query response writers. There will always be a default writer; additional
* writers may also be configured. */
@ -988,6 +980,18 @@ public final class SolrCore {
if (defaultResponseWriter == null) {
defaultResponseWriter = new XMLResponseWriter();
}
// make JSON response writers available by default
if (responseWriters.get("json")==null) {
responseWriters.put("json", new JSONResponseWriter());
}
if (responseWriters.get("python")==null) {
responseWriters.put("python", new PythonResponseWriter());
}
if (responseWriters.get("ruby")==null) {
responseWriters.put("ruby", new RubyResponseWriter());
}
}
/** Finds a writer by name, or returns the default writer if not found. */