protected Library findLibraryWithoutCWD(SearchState state, String baseName, SuffixType suffixType) { Library library = null; switch (suffixType) { case Both: library = findBuiltinLibrary(state, baseName, SuffixType.Source); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Source)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Source)); // If we fail to find as a normal Ruby script, we try to find as an extension, // checking for a builtin first. if (library == null) library = findBuiltinLibrary(state, baseName, SuffixType.Extension); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Extension)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Extension)); break; case Source: case Extension: // Check for a builtin first. library = findBuiltinLibrary(state, baseName, suffixType); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, suffixType)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, suffixType)); break; case Neither: library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Neither)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Neither)); break; } return library; }
@Deprecated protected Library findLibraryWithoutCWD(SearchState state, String baseName, SuffixType suffixType) { Library library = null; switch (suffixType) { case Both: library = findBuiltinLibrary(state, baseName, SuffixType.Source); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Source)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Source)); // If we fail to find as a normal Ruby script, we try to find as an extension, // checking for a builtin first. if (library == null) library = findBuiltinLibrary(state, baseName, SuffixType.Extension); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Extension)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Extension)); break; case Source: case Extension: // Check for a builtin first. library = findBuiltinLibrary(state, baseName, suffixType); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, suffixType)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, suffixType)); break; case Neither: library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Neither)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Neither)); break; } return library; }
@Deprecated protected Library findLibraryWithoutCWD(SearchState state, String baseName, SuffixType suffixType) { Library library = null; switch (suffixType) { case Both: library = findBuiltinLibrary(state, baseName, SuffixType.Source); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Source)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Source)); // If we fail to find as a normal Ruby script, we try to find as an extension, // checking for a builtin first. if (library == null) library = findBuiltinLibrary(state, baseName, SuffixType.Extension); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Extension)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Extension)); break; case Source: case Extension: // Check for a builtin first. library = findBuiltinLibrary(state, baseName, suffixType); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, suffixType)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, suffixType)); break; case Neither: library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Neither)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Neither)); break; } return library; }
/** * Support for 'bundle:/' to look for libraries in osgi bundles. */ @Override @Deprecated protected Library createLibrary(SearchState state, LoadServiceResource resource) { if (resource == null) { return null; } String file = state.loadName; if (file.startsWith(OSGI_BUNDLE_CLASSPATH_SCHEME)) { file = cleanupFindName(file); StringTokenizer tokenizer = new StringTokenizer(file, "/", false); tokenizer.nextToken(); String symname = tokenizer.nextToken(); Bundle bundle = OSGiFileLocator.getBundle(symname); if (bundle != null) { return new OSGiBundleLibrary(bundle); } } return super.createLibrary(state, resource); }
/** * Support for 'bundle:/' to look for libraries in osgi bundles. */ @Override @Deprecated protected Library createLibrary(SearchState state, LoadServiceResource resource) { if (resource == null) { return null; } String file = state.loadName; if (file.startsWith(OSGI_BUNDLE_CLASSPATH_SCHEME)) { file = cleanupFindName(file); StringTokenizer tokenizer = new StringTokenizer(file, "/", false); tokenizer.nextToken(); String symname = tokenizer.nextToken(); Bundle bundle = OSGiFileLocator.getBundle(symname); if (bundle != null) { return new OSGiBundleLibrary(bundle); } } return super.createLibrary(state, resource); }
protected Library findLibraryWithoutCWD(SearchState state, String baseName, SuffixType suffixType) { Library library = null; switch (suffixType) { case Both: library = findBuiltinLibrary(state, baseName, SuffixType.Source); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Source)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Source)); // If we fail to find as a normal Ruby script, we try to find as an extension, // checking for a builtin first. if (library == null) library = findBuiltinLibrary(state, baseName, SuffixType.Extension); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Extension)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Extension)); break; case Source: case Extension: // Check for a builtin first. library = findBuiltinLibrary(state, baseName, suffixType); if (library == null) library = createLibrary(state, tryResourceFromJarURL(state, baseName, suffixType)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, suffixType)); break; case Neither: library = createLibrary(state, tryResourceFromJarURL(state, baseName, SuffixType.Neither)); if (library == null) library = createLibrary(state, tryResourceFromLoadPathOrURL(state, baseName, SuffixType.Neither)); break; } return library; }
/** * Support for 'bundle:/' to look for libraries in osgi bundles. */ @Override protected Library createLibrary(SearchState state, LoadServiceResource resource) { if (resource == null) { return null; } String file = state.loadName; if (file.startsWith(OSGI_BUNDLE_CLASSPATH_SCHEME)) { file = cleanupFindName(file); StringTokenizer tokenizer = new StringTokenizer(file, "/", false); tokenizer.nextToken(); String symname = tokenizer.nextToken(); Bundle bundle = OSGiFileLocator.getBundle(symname); if (bundle != null) { return new OSGiBundleLibrary(bundle); } } return super.createLibrary(state, resource); }
/** * Support for 'bundle:/' to look for libraries in osgi bundles. */ @Override protected Library createLibrary(SearchState state, LoadServiceResource resource) { if (resource == null) { return null; } String file = state.loadName; if (file.startsWith(OSGI_BUNDLE_CLASSPATH_SCHEME)) { file = cleanupFindName(file); StringTokenizer tokenizer = new StringTokenizer(file, "/", false); tokenizer.nextToken(); String symname = tokenizer.nextToken(); Bundle bundle = OSGiFileLocator.getBundle(symname); if (bundle != null) { return new OSGiBundleLibrary(bundle); } } return super.createLibrary(state, resource); }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.loadName = resolveLoadName(resource, file); return createLibrary(state, resource); } } return null; }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.loadName = resolveLoadName(resource, file); return createLibrary(state, resource); } } return null; }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); return createLibrary(state, resource); } } return null; }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); return createLibrary(state, resource); } } return null; }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.loadName = resolveLoadName(resource, file); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { if (runtime.getDebug().isTrue()) e.printStackTrace(runtime.getErr()); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { loadTimer.endLoad("classloader:" + file, startTime); } }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.loadName = resolveLoadName(resource, file); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { if (runtime.getDebug().isTrue()) e.printStackTrace(runtime.getErr()); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { loadTimer.endLoad("classloader:" + file, startTime); } }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); int currentLine = runtime.getCurrentLine(); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { debugLoadException(runtime, e); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { runtime.setCurrentLine(currentLine); loadTimer.endLoad("classloader:" + file, startTime); } }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); int currentLine = runtime.getCurrentLine(); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { debugLoadException(runtime, e); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { runtime.setCurrentLine(currentLine); loadTimer.endLoad("classloader:" + file, startTime); } }