public class LoadService extends Object
First, decide on what name should be used to require the extension. In this purely hypothetical example, this name will be 'active_record/connection_adapters/jdbc_adapter'. Then create the class name for this require-name, by looking at the guidelines above. Our class should be named active_record.connection_adapters.JdbcAdapterService, and implement one of the library-interfaces. The easiest one is BasicLibraryService, where you define the basicLoad-method, which will get called when your library should be loaded.
The next step is to either put your compiled class on JRuby's classpath, or package the class/es inside a jar-file. To package into a jar-file, we first create the file, then rename it to jdbc_adapter.jar. Then we put this jar-file in the directory active_record/connection_adapters somewhere in JRuby's load path. For example, copying jdbc_adapter.jar into JRUBY_HOME/lib/ruby/site_ruby/1.8/active_record/connection_adapters will make everything work. If you've packaged your extension inside a RubyGem, write a setub.rb-script that copies the jar-file to this place.
Modifier and Type | Class and Description |
---|---|
class |
LoadService.BailoutSearcher
Deprecated.
|
class |
LoadService.ClassLoaderSearcher
Deprecated.
|
class |
LoadService.ExtensionSearcher
Deprecated.
|
static interface |
LoadService.LoadSearcher
Deprecated.
|
class |
LoadService.NormalSearcher
Deprecated.
|
class |
LoadService.ScriptClassSearcher
Deprecated.
|
static class |
LoadService.SearchState |
class |
LoadService.SourceBailoutSearcher
Deprecated.
|
static class |
LoadService.SuffixType |
Modifier and Type | Field and Description |
---|---|
protected Map<String,Library> |
builtinLibraries |
protected static Pattern |
extensionPattern |
protected Map<String,JarFile> |
jarFiles |
protected org.jruby.runtime.load.LibrarySearcher |
librarySearcher |
protected StringArraySet |
loadedFeatures |
protected RubyArray |
loadedFeaturesDup |
protected RubyArray |
loadPath |
protected org.jruby.runtime.load.LoadService.RequireLocks |
requireLocks |
protected Ruby |
runtime |
protected List<LoadService.LoadSearcher> |
searchers |
protected static Pattern |
sourcePattern |
Constructor and Description |
---|
LoadService(Ruby runtime) |
Modifier and Type | Method and Description |
---|---|
void |
addBuiltinLibrary(String name,
Library library) |
protected void |
addFeatureToIndex(String shortName,
String name) |
protected void |
addLoadedFeature(String name)
Deprecated.
|
protected void |
addLoadedFeature(String shortName,
String name) |
protected void |
addPath(String path) |
void |
addPaths(List<String> additionalDirectories)
Add additional directories to the load path.
|
void |
addPaths(String... additionalDirectories)
Add additional directories to the load path.
|
boolean |
autoloadRequire(String requireName) |
protected String |
buildClassName(String className) |
protected void |
checkEmptyLoad(String file) |
protected Library |
createLibrary(LoadService.SearchState state,
LoadServiceResource resource)
Deprecated.
|
protected void |
debugLogFound(LoadServiceResource resource)
Deprecated.
|
protected void |
debugLogFound(String what,
String msg)
Deprecated.
|
protected void |
debugLogTry(String what,
String msg)
Deprecated.
|
protected boolean |
featureAlreadyLoaded(String name) |
protected Library |
findBuiltinLibrary(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
LoadService.SearchState |
findFileForLoad(String file) |
protected LoadServiceResource |
findFileInClasspath(String name)
this method uses the appropriate lookup strategy to find a file.
|
protected Library |
findLibraryWithClassloaders(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType) |
protected Library |
findLibraryWithoutCWD(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected LoadServiceResource |
getClassPathResource(ClassLoader classLoader,
String name) |
protected String |
getFileName(JRubyFile file,
String namePlusSuffix) |
JarFile |
getJarFile(String jarFileName) |
IRubyObject |
getLoadedFeatures() |
IRubyObject |
getLoadPath() |
protected String |
getLoadPathEntry(IRubyObject entry) |
void |
init(List prependDirectories)
Called to initialize the load path with a set of optional prepended
directories and then the standard set of dirs.
|
protected boolean |
isFeatureInIndex(String shortName) |
protected boolean |
isJarfileLibrary(LoadService.SearchState state,
String file) |
protected boolean |
isRequireable(URL loc) |
void |
load(String file,
boolean wrap) |
void |
loadFromClassLoader(ClassLoader classLoader,
String file,
boolean wrap) |
protected boolean |
loadPathLooksLikeClasspathURL(String loadPathEntry) |
protected boolean |
loadPathLooksLikeJarURL(String loadPathEntry) |
static void |
reflectedLoad(Ruby runtime,
String libraryName,
String className,
ClassLoader classLoader,
boolean wrap)
Load the org.jruby.runtime.load.Library implementation specified by
className.
|
void |
removeBuiltinLibrary(String name) |
void |
removeInternalLoadedFeature(String name) |
boolean |
require(String requireName) |
protected void |
reraiseRaiseExceptions(Throwable e) |
protected String |
resolveLoadName(LoadServiceResource foundResource,
String previousPath) |
boolean |
smartLoad(String file)
Deprecated.
|
protected boolean |
tryLoadingLibraryOrScript(Ruby runtime,
LoadService.SearchState state) |
protected LoadServiceResource |
tryResourceAsIs(String namePlusSuffix)
Deprecated.
|
protected LoadServiceResource |
tryResourceAsIs(String namePlusSuffix,
String debugName)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromCWD(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromDotSlash(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromHome(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromJarURL(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromJarURLWithLoadPath(String namePlusSuffix,
String loadPathEntry)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromLoadPath(String namePlusSuffix,
String loadPathEntry)
Deprecated.
|
protected LoadServiceResource |
tryResourceFromLoadPathOrURL(LoadService.SearchState state,
String baseName,
LoadService.SuffixType suffixType)
Deprecated.
|
protected void |
warnCircularRequire(String requireName) |
protected static final Pattern sourcePattern
protected static final Pattern extensionPattern
protected RubyArray loadPath
protected StringArraySet loadedFeatures
protected RubyArray loadedFeaturesDup
protected final Ruby runtime
protected final org.jruby.runtime.load.LibrarySearcher librarySearcher
protected final org.jruby.runtime.load.LoadService.RequireLocks requireLocks
protected final List<LoadService.LoadSearcher> searchers
public LoadService(Ruby runtime)
public void init(List prependDirectories)
prependDirectories
- public void addPaths(List<String> additionalDirectories)
additionalDirectories
- a List of additional dirs to append to the load pathpublic void addPaths(String... additionalDirectories)
additionalDirectories
- an array of additional dirs to append to the load pathprotected boolean isFeatureInIndex(String shortName)
@Deprecated protected void addLoadedFeature(String name)
protected void addPath(String path)
public void load(String file, boolean wrap)
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap)
public LoadService.SearchState findFileForLoad(String file)
public boolean require(String requireName)
public boolean autoloadRequire(String requireName)
protected void warnCircularRequire(String requireName)
@Deprecated public boolean smartLoad(String file)
require(String)
instead.public static void reflectedLoad(Ruby runtime, String libraryName, String className, ClassLoader classLoader, boolean wrap)
runtime
- The runtime in which to loadlibraryName
- The name of the library, to use for error messagesclassName
- The class of the libraryclassLoader
- The classloader to use to load itwrap
- Whether to wrap top-level in an anonymous modulepublic IRubyObject getLoadPath()
public IRubyObject getLoadedFeatures()
public void removeBuiltinLibrary(String name)
public void removeInternalLoadedFeature(String name)
protected boolean featureAlreadyLoaded(String name)
protected boolean isJarfileLibrary(LoadService.SearchState state, String file)
protected void reraiseRaiseExceptions(Throwable e) throws RaiseException
RaiseException
protected boolean tryLoadingLibraryOrScript(Ruby runtime, LoadService.SearchState state)
protected void checkEmptyLoad(String file) throws RaiseException
RaiseException
@Deprecated protected void debugLogTry(String what, String msg)
@Deprecated protected void debugLogFound(String what, String msg)
@Deprecated protected void debugLogFound(LoadServiceResource resource)
@Deprecated protected Library findBuiltinLibrary(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType)
@Deprecated protected Library findLibraryWithoutCWD(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType)
protected Library findLibraryWithClassloaders(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType)
@Deprecated protected Library createLibrary(LoadService.SearchState state, LoadServiceResource resource)
@Deprecated protected LoadServiceResource tryResourceFromCWD(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType) throws RaiseException
RaiseException
@Deprecated protected LoadServiceResource tryResourceFromDotSlash(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType) throws RaiseException
RaiseException
@Deprecated protected LoadServiceResource tryResourceFromHome(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType) throws RaiseException
RaiseException
@Deprecated protected LoadServiceResource tryResourceFromJarURL(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType)
@Deprecated protected LoadServiceResource tryResourceFromLoadPathOrURL(LoadService.SearchState state, String baseName, LoadService.SuffixType suffixType)
protected String getLoadPathEntry(IRubyObject entry)
@Deprecated protected LoadServiceResource tryResourceFromJarURLWithLoadPath(String namePlusSuffix, String loadPathEntry)
protected boolean loadPathLooksLikeJarURL(String loadPathEntry)
protected boolean loadPathLooksLikeClasspathURL(String loadPathEntry)
@Deprecated protected LoadServiceResource tryResourceFromLoadPath(String namePlusSuffix, String loadPathEntry) throws RaiseException
RaiseException
@Deprecated protected LoadServiceResource tryResourceAsIs(String namePlusSuffix) throws RaiseException
RaiseException
@Deprecated protected LoadServiceResource tryResourceAsIs(String namePlusSuffix, String debugName) throws RaiseException
RaiseException
protected LoadServiceResource findFileInClasspath(String name)
name
- the file to find, this is a path nameprotected boolean isRequireable(URL loc)
protected LoadServiceResource getClassPathResource(ClassLoader classLoader, String name)
protected String resolveLoadName(LoadServiceResource foundResource, String previousPath)
Copyright © 2001-2014 JRuby. All Rights Reserved.