org.apache.solr.core
Class SolrResourceLoader

java.lang.Object
  extended by org.apache.solr.core.SolrResourceLoader
All Implemented Interfaces:
org.apache.solr.common.ResourceLoader

public class SolrResourceLoader
extends Object
implements org.apache.solr.common.ResourceLoader

Since:
solr 1.3

Field Summary
static Logger log
           
 
Constructor Summary
SolrResourceLoader(String instanceDir)
           
SolrResourceLoader(String instanceDir, ClassLoader parent)
           This loader will delegate to the context classloader when possible, otherwise it will attempt to resolve resources using any jar files found in the "lib/" directory in the specified instance directory.
SolrResourceLoader(String instanceDir, ClassLoader parent, Properties coreProperties)
           This loader will delegate to the context classloader when possible, otherwise it will attempt to resolve resources using any jar files found in the "lib/" directory in the specified instance directory.
 
Method Summary
 Class findClass(String cname, String... subpackages)
           
 String getConfigDir()
           
 Properties getCoreProperties()
           
 String getDataDir()
           
 String getInstanceDir()
           
 List<String> getLines(String resource)
          Accesses a resource by name and returns the (non comment) lines containing data.
 List<String> getLines(String resource, Charset charset)
           
 List<String> getLines(String resource, String encoding)
          Accesses a resource by name and returns the (non comment) lines containing data using the given character encoding.
 void inform(org.apache.solr.common.ResourceLoader loader)
          Tell all ResourceLoaderAware instances about the loader
 void inform(SolrCore core)
          Tell all SolrCoreAware instances about the SolrCore
static String locateInstanceDir()
          Finds the instanceDir based on looking up the value in one of three places: JNDI: via java:comp/env/solr/home The system property solr.solr.home Look in the current working directory for a solr/ directory The return value is normalized.
 Object newInstance(String cname, String... subpackages)
           
static String normalizeDir(String path)
          Ensures a directory name allways ends with a '/'.
 InputStream openConfig(String name)
          Opens a config resource by its name.
 InputStream openResource(String resource)
          Opens any resource by its name.
 InputStream openSchema(String name)
          Opens a schema resource by its name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final Logger log
Constructor Detail

SolrResourceLoader

public SolrResourceLoader(String instanceDir,
                          ClassLoader parent,
                          Properties coreProperties)

This loader will delegate to the context classloader when possible, otherwise it will attempt to resolve resources using any jar files found in the "lib/" directory in the specified instance directory. If the instance directory is not specified (=null), SolrResourceLoader#locateInstanceDir will provide one.


SolrResourceLoader

public SolrResourceLoader(String instanceDir,
                          ClassLoader parent)

This loader will delegate to the context classloader when possible, otherwise it will attempt to resolve resources using any jar files found in the "lib/" directory in the specified instance directory. If the instance directory is not specified (=null), SolrResourceLoader#locateInstanceDir will provide one.


SolrResourceLoader

public SolrResourceLoader(String instanceDir)
Method Detail

normalizeDir

public static String normalizeDir(String path)
Ensures a directory name allways ends with a '/'.


getConfigDir

public String getConfigDir()

getDataDir

public String getDataDir()

getCoreProperties

public Properties getCoreProperties()

openSchema

public InputStream openSchema(String name)
Opens a schema resource by its name. Override this method to customize loading schema resources.

Returns:
the stream for the named schema

openConfig

public InputStream openConfig(String name)
Opens a config resource by its name. Override this method to customize loading config resources.

Returns:
the stream for the named configuration

openResource

public InputStream openResource(String resource)
Opens any resource by its name. By default, this will look in multiple locations to load the resource: $configDir/$resource (if resource is not absolute) $CWD/$resource otherwise, it will look for it in any jar accessible through the class loader. Override this method to customize loading resources.

Specified by:
openResource in interface org.apache.solr.common.ResourceLoader
Returns:
the stream for the named resource

getLines

public List<String> getLines(String resource)
                      throws IOException
Accesses a resource by name and returns the (non comment) lines containing data.

A comment line is any line that starts with the character "#"

Specified by:
getLines in interface org.apache.solr.common.ResourceLoader
Parameters:
resource -
Returns:
a list of non-blank non-comment lines with whitespace trimmed from front and back.
Throws:
IOException

getLines

public List<String> getLines(String resource,
                             String encoding)
                      throws IOException
Accesses a resource by name and returns the (non comment) lines containing data using the given character encoding.

A comment line is any line that starts with the character "#"

Parameters:
resource - the file to be read
encoding -
Returns:
a list of non-blank non-comment lines with whitespace trimmed
Throws:
IOException

getLines

public List<String> getLines(String resource,
                             Charset charset)
                      throws IOException
Throws:
IOException

findClass

public Class findClass(String cname,
                       String... subpackages)

newInstance

public Object newInstance(String cname,
                          String... subpackages)
Specified by:
newInstance in interface org.apache.solr.common.ResourceLoader

inform

public void inform(SolrCore core)
Tell all SolrCoreAware instances about the SolrCore


inform

public void inform(org.apache.solr.common.ResourceLoader loader)
Tell all ResourceLoaderAware instances about the loader


locateInstanceDir

public static String locateInstanceDir()
Finds the instanceDir based on looking up the value in one of three places:
  1. JNDI: via java:comp/env/solr/home
  2. The system property solr.solr.home
  3. Look in the current working directory for a solr/ directory
The return value is normalized. Normalization essentially means it ends in a trailing slash.

Returns:
A normalized instanceDir
See Also:
normalizeDir(String)

getInstanceDir

public String getInstanceDir()


Copyright © 2008 Apache Software Foundation. All Rights Reserved.