Index: metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/SolrIndexIT.java
===================================================================
--- metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/SolrIndexIT.java	(revision 7590)
+++ metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/SolrIndexIT.java	(revision 7591)
@@ -1,31 +1,21 @@
 package edu.ucsb.nceas.metacat.index;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 
-import javax.xml.parsers.ParserConfigurationException;
-
-
-
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.core.CoreContainer;
 import org.apache.solr.servlet.SolrRequestParsers;
-import org.dataone.configuration.Settings;
 import org.dataone.service.types.v1.SystemMetadata;
 import org.dataone.service.util.TypeMarshaller;
 import org.junit.Before;
 import org.junit.Test;
-import org.xml.sax.SAXException;
 
 public class SolrIndexIT  {
     
@@ -35,24 +25,32 @@
     private static final String EMLUPDATEFILEPATH = "src/test/resources/eml-updating-example.xml";
     private static final String id = "urn:uuid:606a19dd-b531-4bf4-b5a5-6d06c3d39098";
     private static final String newId = "urn:uuid:606a19dd-b531-4bf4-b5a5-6d06c3d39099";
-    private static String SOLRTESTHOMEPATH = null;
     
-    /**
-     * 
-     */
+	private SolrIndex solrIndex = null;
+    
+    
     @Before
-    public void setUp() {
-    	SOLRTESTHOMEPATH = Settings.getConfiguration().getString("solr.homeDir");
+    public void setUp() throws Exception {
+            solrIndex  = generateSolrIndex();
     }
     
+    private SolrIndex generateSolrIndex() throws Exception {
+        ApplicationController controller = new ApplicationController();
+        List<SolrIndex> list = controller.getSolrIndexes();
+        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
+        SolrIndex index = solrIndexesarray[0];
+        SolrServer solrServer = SolrServerFactory.createSolrServer();
+        index.setSolrServer(solrServer);
+        return index;
+    }
+    
     /**
      * Test building index for an insert.
      */
     @Test
     public void testInsert() throws Exception {
-    	try {
-        SolrIndex solrIndex = generateSolrIndex();
     	
+    	
        //InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH));
        SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH);
        InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH));    
@@ -59,9 +57,7 @@
        solrIndex.insert(id, systemMetadata, emlInputStream);
        String result = doQuery(solrIndex.getSolrServer());
        assertTrue(result.contains("version1"));
-    	} catch (Exception e) {
-    		e.printStackTrace();
-    	}
+    	
     }
     
     /**
@@ -69,7 +65,6 @@
      */
     @Test
     public void testUpdate() throws Exception {
-        SolrIndex solrIndex = generateSolrIndex();
        //InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH));
        SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAUPDATEFILEPATH);
        InputStream emlInputStream = new FileInputStream(new File(EMLUPDATEFILEPATH));    
@@ -90,7 +85,6 @@
        //assertTrue(!result.contains("version2"));
     }*/
     
-   
     
     /*
      * Do query
@@ -125,26 +119,6 @@
         }
     }*/
     
-    private SolrIndex generateSolrIndex() throws Exception {
-        ApplicationController controller = new ApplicationController();
-        List<SolrIndex> list = controller.getSolrIndexes();
-        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
-        SolrIndex index = solrIndexesarray[0];
-        index.setSolrServer(generateSolrServer());
-        return index;
-    }
     
-    /*
-     * Generate a test solr server
-     */
-    private SolrServer generateSolrServer() throws IOException, ParserConfigurationException, SAXException {
-        //createSolrHome();
-        File configFile = new File(SOLRTESTHOMEPATH, "solr.xml");
-        CoreContainer c = new CoreContainer(SOLRTESTHOMEPATH, configFile);
-        c.load(SOLRTESTHOMEPATH, configFile);
-        SolrServer solrServer = new EmbeddedSolrServer(c, "collection1");
-        return solrServer;
-    }
-    
 }
 
Index: metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/ApplicationController.java
===================================================================
--- metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/ApplicationController.java	(revision 7590)
+++ metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/ApplicationController.java	(revision 7591)
@@ -73,8 +73,13 @@
         context = getContext();
         solrIndexes = (List<SolrIndex>) context.getBean(SOLRINDEXES);
         
-        // TODO: use factory to create the correct impl
+        // use factory to create the correct impl
     	SolrServer solrServer = null;
+		try {
+			solrServer = SolrServerFactory.createSolrServer();
+		} catch (Exception e) {
+			log.error("Could not create SolrServer form factory", e);
+		}
 
         // start the SystemMetadata listener[s] (only expect there to be one)
         for (SolrIndex solrIndex: solrIndexes) {
Index: metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java
===================================================================
--- metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java	(revision 7590)
+++ metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java	(revision 7591)
@@ -27,7 +27,6 @@
 package edu.ucsb.nceas.metacat.index;
 
 import java.io.ByteArrayInputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -50,19 +49,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
-//import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.core.CoreContainer;
 import org.dataone.cn.indexer.XMLNamespaceConfig;
-import org.dataone.cn.indexer.XPathDocumentParser;
 import org.dataone.cn.indexer.parser.IDocumentSubprocessor;
 import org.dataone.cn.indexer.parser.SolrField;
 import org.dataone.cn.indexer.solrhttp.SolrDoc;
-import org.dataone.cn.indexer.solrhttp.SolrElementAdd;
 import org.dataone.cn.indexer.solrhttp.SolrElementField;
-import org.dataone.configuration.Settings;
 import org.dataone.service.types.v1.Identifier;
 import org.dataone.service.types.v1.SystemMetadata;
 import org.dataone.service.util.TypeMarshaller;
@@ -76,11 +69,7 @@
  *
  */
 public class SolrIndex {
-    
-    public static final String SOLRHOMEPROPERTYNAME = "solr.homeDir";
-    
-    //private static final String DEFAULTSOLRHOMEPATH = "/Users/tao/Downloads/apache-solr-3.4.0/example/solr";
-    
+            
     private List<IDocumentSubprocessor> subprocessors = null;
     private SolrServer solrServer = null;
     private XMLNamespaceConfig xmlNamespaceConfig = null;
@@ -114,20 +103,9 @@
                     throws XPathExpressionException, ParserConfigurationException, IOException, SAXException {
          this.xmlNamespaceConfig = xmlNamespaceConfig;
          this.sysmetaSolrFields = sysmetaSolrFields;
-         initSolrServer();
          init();
     }
     
-    private void initSolrServer() throws IOException, ParserConfigurationException, SAXException {
-        String solrHomeDir = null;
-        solrHomeDir = Settings.getConfiguration().getString(SOLRHOMEPROPERTYNAME);
-        log.info("========================= the solr home from the metacat.properties is "+solrHomeDir);
-        File configFile = new File(solrHomeDir, "solr.xml");
-        CoreContainer c = new CoreContainer(solrHomeDir, configFile);
-        c.load(solrHomeDir, configFile);
-        solrServer = new EmbeddedSolrServer(c, "collection1");
-    }
-    
     private void init() throws ParserConfigurationException, XPathExpressionException {
         xpath.setNamespaceContext(xmlNamespaceConfig);
         initExpressions();
Index: metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrServerFactory.java
===================================================================
--- metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrServerFactory.java	(nonexistent)
+++ metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrServerFactory.java	(revision 7591)
@@ -0,0 +1,72 @@
+/**
+ *  '$RCSfile$'
+ *    Purpose: A class that gets Accession Number, check for uniqueness
+ *             and register it into db
+ *  Copyright: 2000 Regents of the University of California and the
+ *             National Center for Ecological Analysis and Synthesis
+ *    Authors: Jivka Bojilova, Matt Jones
+ *
+ *   '$Author$'
+ *     '$Date$'
+ * '$Revision$'
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+package edu.ucsb.nceas.metacat.index;
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.core.CoreContainer;
+import org.dataone.configuration.Settings;
+
+/**
+ * A factory for creating SolrServer implementations based on
+ * configuration in Settings.java
+ * Options are as follows.
+ * 
+ * Embedded (default):
+ * solr.server.classname=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
+ * solr.homeDir=/path/to/solr/home
+ * 
+ * HTTP:
+ * solr.server.classname=org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
+ * solr.endpoint=http://endpoint/to/solr/service
+ * 
+ * @author leinfelder + tao
+ *
+ */
+public class SolrServerFactory {
+	
+    public static final String SOLR_HOME_PROPERTY_NAME = "solr.homeDir";
+
+	public static Log log = LogFactory.getLog(SolrServerFactory.class);
+
+	public static SolrServer createSolrServer() throws Exception {
+		SolrServer solrServer = null;
+		
+		String solrHomeDir = Settings.getConfiguration().getString(SOLR_HOME_PROPERTY_NAME);
+        log.info("The configured solr home from properties is " + solrHomeDir);
+        File configFile = new File(solrHomeDir, "solr.xml");
+        CoreContainer c = new CoreContainer(solrHomeDir, configFile);
+        c.load(solrHomeDir, configFile);
+        solrServer = new EmbeddedSolrServer(c, "collection1");
+        
+        return solrServer;
+	}
+}
\ No newline at end of file

Property changes on: metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrServerFactory.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
