Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: leinfelder $'
10
 *     '$Date: 2011-11-02 20:40:12 -0700 (Wed, 02 Nov 2011) $'
11
 * '$Revision: 6595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.index;
28

    
29
import java.util.List;
30

    
31
import org.apache.commons.logging.Log;
32
import org.apache.commons.logging.LogFactory;
33
import org.springframework.context.ApplicationContext;
34
import org.springframework.context.support.ClassPathXmlApplicationContext;
35
import org.springframework.context.support.FileSystemXmlApplicationContext;
36

    
37
/**
38
 * The start class of the index.
39
 * @author tao
40
 *
41
 */
42
public class ApplicationController {
43
    
44
    private static String SOLRINDEXES = "solrIndexes";
45
    private List<SolrIndex> solrIndexes = null;
46
    private static ApplicationContext context = null;
47
    private String springConfigFile = "src/main/resources/index-processor-context.xml";
48
    Log log = LogFactory.getLog(ApplicationController.class);
49
    
50
    /**
51
     * Constructor
52
     */
53
    public ApplicationController () {
54
        init();
55
    }
56
    
57
    /*
58
     * Init the list of the SolrIndex objects from the configuration file.
59
     */
60
    private void init() {
61
        context = getContext();
62
        solrIndexes = (List<SolrIndex>) context.getBean(SOLRINDEXES);
63
        
64
    }
65
    
66
    /*
67
     * Get the ApplicaionContext of Spring.
68
     */
69
    private ApplicationContext getContext() {
70
        if (context == null) {
71
            context = new FileSystemXmlApplicationContext(springConfigFile);
72
        }
73
        return context;
74
    }
75

    
76
    /**
77
     * Set the Spring configuration file.
78
     * @param springConfigFile  the path of the Spring configuration file
79
     */
80
    public void setSpringConfigFile(String springConfigFile) {
81
        this.springConfigFile = springConfigFile;
82
    }
83
    
84
    /**
85
     * Get the path of the Spring configuration file.
86
     * @return the path of the Spring configuration file.
87
     */
88
    public String getSpringConfigFile() {
89
        return this.springConfigFile;
90
    }
91
    
92
    /**
93
     * Get the list of the solr index.
94
     * @return the list of the solr index.
95
     */
96
    public List<SolrIndex> getSolrIndexes() {
97
        return this.solrIndexes;
98
    }
99
}
(1-1/3)