private void initLibs() { NodeList nodes = (NodeList) evaluate("lib", XPathConstants.NODESET); if (nodes==null || nodes.getLength()==0) return; log.info("Adding specified lib dirs to ClassLoader"); for (int i=0; i<nodes.getLength(); i++) { Node node = nodes.item(i); String baseDir = DOMUtil.getAttr(node, "dir"); String path = DOMUtil.getAttr(node, "path"); if (null != baseDir) { // :TODO: add support for a simpler 'glob' mutually eclusive of regex String regex = DOMUtil.getAttr(node, "regex"); FileFilter filter = (null == regex) ? null : new RegexFileFilter(regex); getResourceLoader().addToClassLoader(baseDir, filter); } else if (null != path) { getResourceLoader().addToClassLoader(path); } else { throw new RuntimeException ("lib: missing mandatory attributes: 'dir' or 'path'"); } } } }
/** * <p> * 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. * <p> */ public SolrResourceLoader( String instanceDir, ClassLoader parent, Properties coreProperties ) { if( instanceDir == null ) { this.instanceDir = SolrResourceLoader.locateSolrHome(); } else{ this.instanceDir = normalizeDir(instanceDir); } log.info("Solr home set to '" + this.instanceDir + "'"); this.classLoader = createClassLoader(null, parent); addToClassLoader("./lib/", null); this.coreProperties = coreProperties; }