public class SolrResourceLoader extends java.lang.Object implements ResourceLoader
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Class,java.lang.Class[]> |
awareCompatibility
Keep a list of classes that are allowed to implement each 'Aware' interface
|
(package private) static java.lang.String |
base |
private java.net.URLClassLoader |
classLoader |
private static java.util.Map<java.lang.String,java.lang.String> |
classNameCache |
private java.util.Properties |
coreProperties |
private java.lang.String |
dataDir |
private java.util.List<SolrInfoMBean> |
infoMBeans |
private java.lang.String |
instanceDir |
private boolean |
live |
static org.slf4j.Logger |
log |
(package private) static java.lang.String[] |
packages |
(package private) static java.lang.String |
project |
private static java.nio.charset.Charset |
UTF_8 |
private java.util.List<SolrCoreAware> |
waitingForCore |
private java.util.List<ResourceLoaderAware> |
waitingForResources |
Constructor and Description |
---|
SolrResourceLoader(java.lang.String instanceDir) |
SolrResourceLoader(java.lang.String instanceDir,
java.lang.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(java.lang.String instanceDir,
java.lang.ClassLoader parent,
java.util.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.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addToClassLoader(java.lang.String path)
Adds the specific file/dir specified to the ClassLoader used by this
ResourceLoader.
|
(package private) void |
addToClassLoader(java.lang.String baseDir,
java.io.FileFilter filter)
Adds every file/dir found in the baseDir which passes the specified Filter
to the ClassLoader used by this ResourceLoader.
|
(package private) void |
assertAwareCompatibility(java.lang.Class aware,
java.lang.Object obj)
Utility function to throw an exception if the class is invalid
|
(package private) static java.net.URLClassLoader |
createClassLoader(java.io.File libDir,
java.lang.ClassLoader parent)
Convenience method for getting a new ClassLoader using all files found
in the specified lib directory.
|
java.lang.Class |
findClass(java.lang.String cname,
java.lang.String... subpackages)
This method loads a class either with it's FQN or a short-name (solr.class-simplename or class-simplename).
|
java.lang.ClassLoader |
getClassLoader()
+ * EXPERT
+ *
+ * The underlying class loader.
|
java.lang.String |
getConfigDir() |
java.util.Properties |
getCoreProperties() |
java.lang.String |
getDataDir() |
java.lang.String |
getInstanceDir() |
java.util.List<java.lang.String> |
getLines(java.lang.String resource)
Accesses a resource by name and returns the (non comment) lines
containing data.
|
java.util.List<java.lang.String> |
getLines(java.lang.String resource,
java.nio.charset.Charset charset) |
java.util.List<java.lang.String> |
getLines(java.lang.String resource,
java.lang.String encoding)
Accesses a resource by name and returns the (non comment) lines containing
data using the given character encoding.
|
void |
inform(java.util.Map<java.lang.String,SolrInfoMBean> infoRegistry)
Register any
SolrInfoMBean s |
void |
inform(ResourceLoader loader)
Tell all
ResourceLoaderAware instances about the loader |
void |
inform(SolrCore core)
Tell all
SolrCoreAware instances about the SolrCore |
static java.lang.String |
locateInstanceDir()
Deprecated.
|
static java.lang.String |
locateSolrHome()
Finds the solrhome 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.
|
java.lang.Object |
newAdminHandlerInstance(CoreContainer coreContainer,
java.lang.String cname,
java.lang.String... subpackages) |
java.lang.Object |
newInstance(java.lang.String cname,
java.lang.String... subpackages) |
java.lang.Object |
newInstance(java.lang.String cName,
java.lang.String[] subPackages,
java.lang.Class[] params,
java.lang.Object[] args) |
static java.lang.String |
normalizeDir(java.lang.String path)
Ensures a directory name always ends with a '/'.
|
java.io.InputStream |
openConfig(java.lang.String name)
Opens a config resource by its name.
|
java.io.InputStream |
openResource(java.lang.String resource)
Opens any resource by its name.
|
java.io.InputStream |
openSchema(java.lang.String name)
Opens a schema resource by its name.
|
private static java.net.URLClassLoader |
replaceClassLoader(java.net.URLClassLoader oldLoader,
java.io.File base,
java.io.FileFilter filter) |
public static final org.slf4j.Logger log
static final java.lang.String project
static final java.lang.String base
static final java.lang.String[] packages
private java.net.URLClassLoader classLoader
private final java.lang.String instanceDir
private java.lang.String dataDir
private final java.util.List<SolrCoreAware> waitingForCore
private final java.util.List<SolrInfoMBean> infoMBeans
private final java.util.List<ResourceLoaderAware> waitingForResources
private static final java.nio.charset.Charset UTF_8
private final java.util.Properties coreProperties
private volatile boolean live
private static java.util.Map<java.lang.String,java.lang.String> classNameCache
private static final java.util.Map<java.lang.Class,java.lang.Class[]> awareCompatibility
public SolrResourceLoader(java.lang.String instanceDir, java.lang.ClassLoader parent, java.util.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.
instanceDir
- - base directory for this resource loader, if null locateSolrHome() will be used.locateSolrHome()
public SolrResourceLoader(java.lang.String instanceDir, java.lang.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.
public SolrResourceLoader(java.lang.String instanceDir)
void addToClassLoader(java.lang.String baseDir, java.io.FileFilter filter)
baseDir
- base directory whose children (either jars or directories of
classes) will be in the classpath, will be resolved relative
the instance dir.filter
- The filter files must satisfy, if null all files will be accepted.void addToClassLoader(java.lang.String path)
path
- A jar file (or directory of classes) to be added to the classpath,
will be resolved relative the instance dir.private static java.net.URLClassLoader replaceClassLoader(java.net.URLClassLoader oldLoader, java.io.File base, java.io.FileFilter filter)
static java.net.URLClassLoader createClassLoader(java.io.File libDir, java.lang.ClassLoader parent)
public static java.lang.String normalizeDir(java.lang.String path)
public java.lang.String getConfigDir()
public java.lang.String getDataDir()
public java.util.Properties getCoreProperties()
public java.io.InputStream openSchema(java.lang.String name)
public java.io.InputStream openConfig(java.lang.String name)
public java.io.InputStream openResource(java.lang.String resource)
openResource
in interface ResourceLoader
public java.util.List<java.lang.String> getLines(java.lang.String resource) throws java.io.IOException
A comment line is any line that starts with the character "#"
getLines
in interface ResourceLoader
resource
- java.io.IOException
public java.util.List<java.lang.String> getLines(java.lang.String resource, java.lang.String encoding) throws java.io.IOException
A comment line is any line that starts with the character "#"
resource
- the file to be readencoding
- java.io.IOException
public java.util.List<java.lang.String> getLines(java.lang.String resource, java.nio.charset.Charset charset) throws java.io.IOException
java.io.IOException
public java.lang.Class findClass(java.lang.String cname, java.lang.String... subpackages)
cname
- The name or the short name of the class.subpackages
- the packages to be tried if the cnams starts with solr.public java.lang.Object newInstance(java.lang.String cname, java.lang.String... subpackages)
newInstance
in interface ResourceLoader
public java.lang.Object newAdminHandlerInstance(CoreContainer coreContainer, java.lang.String cname, java.lang.String... subpackages)
public java.lang.Object newInstance(java.lang.String cName, java.lang.String[] subPackages, java.lang.Class[] params, java.lang.Object[] args)
public void inform(SolrCore core)
SolrCoreAware
instances about the SolrCorepublic void inform(ResourceLoader loader)
ResourceLoaderAware
instances about the loaderpublic void inform(java.util.Map<java.lang.String,SolrInfoMBean> infoRegistry)
SolrInfoMBean
sinfoRegistry
- The Info Registrypublic static java.lang.String locateSolrHome()
normalizeDir(String)
@Deprecated public static java.lang.String locateInstanceDir()
public java.lang.String getInstanceDir()
void assertAwareCompatibility(java.lang.Class aware, java.lang.Object obj)
public java.lang.ClassLoader getClassLoader()
ClassLoader
+