public class SolrResourceLoader extends Object implements ResourceLoader, Closeable
Modifier and Type | Field and Description |
---|---|
protected URLClassLoader |
classLoader |
Constructor and Description |
---|
SolrResourceLoader() |
SolrResourceLoader(Path instanceDir) |
SolrResourceLoader(Path 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(Path instanceDir,
ClassLoader parent,
Properties coreProperties)
This loader will delegate to Solr's 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 |
---|---|
void |
close() |
<T> Class<? extends T> |
findClass(String cname,
Class<T> expectedType) |
<T> Class<? extends T> |
findClass(String cname,
Class<T> expectedType,
String... subpackages)
This method loads a class either with its FQN or a short-name (solr.class-simplename or class-simplename).
|
ClassLoader |
getClassLoader()
EXPERT
|
String |
getConfigDir() |
Properties |
getCoreProperties() |
String |
getDataDir() |
static List<URL> |
getFilteredURLs(Path libDir,
String regex)
Utility method to get the URLs of all paths under a given directory that match a regex
|
List<SolrInfoBean> |
getInfoMBeans() |
Path |
getInstancePath() |
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.
|
RestManager.Registry |
getManagedResourceRegistry() |
static List<URL> |
getURLs(Path libDir)
Utility method to get the URLs of all paths under a given directory
|
static List<URL> |
getURLs(Path libDir,
DirectoryStream.Filter<Path> filter)
Utility method to get the URLs of all paths under a given directory that match a filter
|
void |
inform(Map<String,SolrInfoBean> infoRegistry)
Register any
SolrInfoBean s |
void |
inform(ResourceLoader loader)
Tell all
ResourceLoaderAware instances about the loader |
void |
inform(SolrCore core)
Tell all
SolrCoreAware instances about the SolrCore |
String[] |
listConfigDir() |
static Path |
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.
|
CoreAdminHandler |
newAdminHandlerInstance(CoreContainer coreContainer,
String cname,
String... subpackages) |
<T> T |
newInstance(String name,
Class<T> expectedType) |
<T> T |
newInstance(String cname,
Class<T> expectedType,
String... subpackages) |
<T> T |
newInstance(String cName,
Class<T> expectedType,
String[] subPackages,
Class[] params,
Object[] args) |
static String |
normalizeDir(String path)
Ensures a directory name always 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.
|
static void |
persistConfLocally(SolrResourceLoader loader,
String resourceName,
byte[] content) |
String |
resourceLocation(String resource)
Report the location of a resource found by the resource loader
|
protected URLClassLoader classLoader
public SolrResourceLoader()
public SolrResourceLoader(Path 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.
public SolrResourceLoader(Path instanceDir)
public SolrResourceLoader(Path instanceDir, ClassLoader parent, Properties coreProperties)
This loader will delegate to Solr's 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 RestManager.Registry getManagedResourceRegistry()
public static List<URL> getURLs(Path libDir, DirectoryStream.Filter<Path> filter) throws IOException
libDir
- the root directoryfilter
- the filterIOException
- on errorpublic static List<URL> getURLs(Path libDir) throws IOException
libDir
- the root directoryIOException
- on errorpublic static List<URL> getFilteredURLs(Path libDir, String regex) throws IOException
libDir
- the root directoryregex
- the regex as a StringIOException
- on errorpublic static String normalizeDir(String path)
public String[] listConfigDir()
public String getConfigDir()
public String getDataDir()
public Properties getCoreProperties()
public ClassLoader getClassLoader()
The underlying class loader. Most applications will not need to use this.
ClassLoader
public InputStream openSchema(String name) throws IOException
IOException
public InputStream openConfig(String name) throws IOException
IOException
public InputStream openResource(String resource) throws IOException
openResource
in interface ResourceLoader
IOException
public String resourceLocation(String resource)
public List<String> getLines(String resource) throws IOException
A comment line is any line that starts with the character "#"
IOException
- If there is a low-level I/O error.public List<String> getLines(String resource, String encoding) throws IOException
A comment line is any line that starts with the character "#"
resource
- the file to be readIOException
- If there is a low-level I/O error.public List<String> getLines(String resource, Charset charset) throws IOException
IOException
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
findClass
in interface ResourceLoader
public <T> Class<? extends T> findClass(String cname, Class<T> expectedType, String... subpackages)
cname
- The name or the short name of the class.subpackages
- the packages to be tried if the cname starts with solr.public <T> T newInstance(String name, Class<T> expectedType)
newInstance
in interface ResourceLoader
public CoreAdminHandler newAdminHandlerInstance(CoreContainer coreContainer, String cname, String... subpackages)
public <T> T newInstance(String cName, Class<T> expectedType, String[] subPackages, Class[] params, Object[] args)
public void inform(SolrCore core)
SolrCoreAware
instances about the SolrCorepublic void inform(ResourceLoader loader) throws IOException
ResourceLoaderAware
instances about the loaderIOException
public void inform(Map<String,SolrInfoBean> infoRegistry)
SolrInfoBean
sinfoRegistry
- The Info Registrypublic static Path locateSolrHome()
normalizeDir(String)
public Path getInstancePath()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public List<SolrInfoBean> getInfoMBeans()
public static void persistConfLocally(SolrResourceLoader loader, String resourceName, byte[] content)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.