public class SolrResourceLoader extends Object implements ResourceLoader, Closeable, SolrClassLoader, SolrCoreAware
| Modifier and Type | Field and Description |
|---|---|
protected URLClassLoader |
classLoader |
static String |
USER_FILES_DIRECTORY
Deprecated.
|
| Constructor and Description |
|---|
SolrResourceLoader()
Deprecated.
Use
new SolrResourceLoader(Path) |
SolrResourceLoader(Path instanceDir)
Creates a loader.
|
SolrResourceLoader(Path instanceDir,
ClassLoader parent) |
SolrResourceLoader(Path instanceDir,
ClassLoader parent,
Properties properties)
Deprecated.
|
SolrResourceLoader(String name,
List<Path> classpath,
Path instanceDir,
ClassLoader parent)
Creates a loader.
|
| Modifier and Type | Method and Description |
|---|---|
<T> boolean |
addToCoreAware(T obj)
the inform() callback should be invoked on the listener.
|
<T> void |
addToInfoBeans(T obj) |
<T> boolean |
addToResourceLoaderAware(T obj) |
static Class |
assertAwareCompatibility(Class aware,
Object obj)
Utility function to throw an exception if the class is invalid
|
void |
close() |
<T> Class<? extends T> |
findClass(PluginInfo info,
Class<T> type,
boolean registerCoreReloadListener)
Load a class using an appropriate
SolrResourceLoader depending of the package on that class |
<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() |
CoreContainer |
getCoreContainer() |
Properties |
getCoreProperties()
Deprecated.
|
String |
getDataDir()
Deprecated.
|
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() |
SolrClassLoader |
getSchemaLoader() |
SolrConfig |
getSolrConfig() |
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
SolrInfoBeans |
void |
inform(ResourceLoader loader)
Tell all
ResourceLoaderAware instances about the loader |
void |
inform(SolrCore core)
Tell all
SolrCoreAware instances about the SolrCore |
static void |
informAware(ResourceLoader loader,
ResourceLoaderAware aware)
Set the current
ResourceLoaderAware object in thread local so that appropriate classloader can be used for package loaded classes |
String[] |
listConfigDir()
Deprecated.
|
static Path |
locateSolrHome()
Deprecated.
|
<T> T |
newInstance(PluginInfo info,
Class<T> type,
boolean registerCoreReloadListener)
Create a n instance of a class using an appropriate
SolrResourceLoader depending on the package of that class |
<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)
Deprecated.
|
InputStream |
openConfig(String name)
Deprecated.
|
InputStream |
openResource(String resource)
Opens any resource by its name.
|
InputStream |
openSchema(String name)
Deprecated.
|
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
@Deprecated public static final String USER_FILES_DIRECTORY
@Deprecated public SolrResourceLoader()
new SolrResourceLoader(Path)CoreContainer.getSolrHome()public SolrResourceLoader(String name, List<Path> classpath, Path instanceDir, ClassLoader parent)
reloadLuceneSPI().
(Behavior when instanceDir is null is un-specified, in future versions this will fail due to NPE)public SolrResourceLoader(Path instanceDir)
instanceDir is null is un-specified, in future versions this will fail due to NPE)public SolrResourceLoader(Path instanceDir, ClassLoader parent)
@Deprecated public SolrResourceLoader(Path instanceDir, ClassLoader parent, Properties properties)
instanceDir - - base directory for this resource loader, if null locateSolrHome() will be used. (in future versions this will fail due to NPE)SolrPaths.locateSolrHome()public RestManager.Registry getManagedResourceRegistry()
public SolrClassLoader getSchemaLoader()
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 error@Deprecated public static String normalizeDir(String path)
@Deprecated public String[] listConfigDir()
public String getConfigDir()
@Deprecated public String getDataDir()
@Deprecated public Properties getCoreProperties()
public ClassLoader getClassLoader()
The underlying class loader. Most applications will not need to use this.
ClassLoader@Deprecated public InputStream openSchema(String name) throws IOException
IOException@Deprecated public InputStream openConfig(String name) throws IOException
IOExceptionpublic InputStream openResource(String resource) throws IOException
openResource in interface ResourceLoaderIOExceptionpublic 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
IOExceptionpublic <T> Class<? extends T> findClass(String cname, Class<T> expectedType)
findClass in interface ResourceLoaderfindClass in interface SolrClassLoaderpublic <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 ResourceLoaderpublic <T> T newInstance(String cname, Class<T> expectedType, String... subpackages)
newInstance in interface SolrClassLoaderpublic <T> T newInstance(String cName, Class<T> expectedType, String[] subPackages, Class[] params, Object[] args)
newInstance in interface SolrClassLoaderpublic <T> void addToInfoBeans(T obj)
public <T> boolean addToResourceLoaderAware(T obj)
public <T> boolean addToCoreAware(T obj)
public void inform(SolrCore core)
SolrCoreAware instances about the SolrCoreinform in interface SolrCoreAwarepublic void inform(ResourceLoader loader) throws IOException
ResourceLoaderAware instances about the loaderIOExceptionpublic static void informAware(ResourceLoader loader, ResourceLoaderAware aware) throws IOException
ResourceLoaderAware object in thread local so that appropriate classloader can be used for package loaded classesIOExceptionpublic void inform(Map<String,SolrInfoBean> infoRegistry)
SolrInfoBeansinfoRegistry - The Info Registry@Deprecated public static Path locateSolrHome()
public Path getInstancePath()
public static Class assertAwareCompatibility(Class aware, Object obj)
public CoreContainer getCoreContainer()
public SolrConfig getSolrConfig()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic List<SolrInfoBean> getInfoMBeans()
public <T> Class<? extends T> findClass(PluginInfo info, Class<T> type, boolean registerCoreReloadListener)
SolrResourceLoader depending of the package on that classregisterCoreReloadListener - register a listener for the package and reload the core if the package is changed.
Use this sparingly. This will result in core reloads across all the cores in
all collections using this configsetpublic <T> T newInstance(PluginInfo info, Class<T> type, boolean registerCoreReloadListener)
SolrResourceLoader depending on the package of that classregisterCoreReloadListener - register a listener for the package and reload the core if the package is changed.
Use this sparingly. This will result in core reloads across all the cores in
all collections using this configsetpublic static void persistConfLocally(SolrResourceLoader loader, String resourceName, byte[] content)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.