Class BoxResolver
java.lang.Object
ortus.boxlang.runtime.loader.resolvers.BaseResolver
ortus.boxlang.runtime.loader.resolvers.BoxResolver
- All Implemented Interfaces:
IClassResolver
This resolver is in charge of resolving and returning BoxLang classes. It will follow the
rules of checking runtime mappings and the current template directory for the class requesting
resolution.
In order to access it you must go via the @{link ClassLocator} class, as the ClassLocator controls all the resolvers in the runtime.
Example:
ClassLocator.getJavaResolver(); or ClassLocator.getResolver( ClassLocator.JAVA_PREFIX );
-
Field Summary
Fields inherited from class ortus.boxlang.runtime.loader.resolvers.BaseResolver
classLocator, importCache, logger, name, prefix, runtime -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindFromLocal(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports) Load a class from the configured directory byte codefindFromLocal(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports, boolean loadClass, IStruct properties) Load a class from the configured directory byte codefindFromModule(String fullyQualifiedName, Key moduleName, List<ImportDefinition> imports, IBoxContext context) Find a class from a specific module explicitly.findFromModules(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports) Load a class from the registered runtime module class loadersfindFromModules(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports, boolean loadClass) This tries to load a BoxLang class from registered modules using thefullyQualifiedName@moduleNameprovided.Get all the valid extensions we can process.booleanimportHasMulti(IBoxContext context, ImportDefinition thisImport, String className) Checks if the import has the given class name as a multi-importresolve(IBoxContext context, String name) Each resolver has a way to resolve the class it represents.resolve(IBoxContext context, String name, boolean loadClass) Each resolver has a way to resolve the class it represents.resolve(IBoxContext context, String name, List<ImportDefinition> imports) Each resolver has a way to resolve the class it represents.resolve(IBoxContext context, String name, List<ImportDefinition> imports, boolean loadClass, IStruct properties) Each resolver has a way to resolve the class it represents.resolve(IBoxContext context, String name, List<ImportDefinition> imports, IStruct properties) Each resolver has a way to resolve the class it represents.Methods inherited from class ortus.boxlang.runtime.loader.resolvers.BaseResolver
clearImportCache, expandFromImport, getClassLocator, getConfiguration, getImportCache, getImportCacheSize, getLogger, getName, getPrefix, getRuntime, getSystemClassLoader, importApplies, importHas
-
Constructor Details
-
BoxResolver
Constructor- Parameters:
classLocator- The class locator to use
-
-
Method Details
-
getValidExtensions
Get all the valid extensions we can process. This list does NOT include the dot. -
resolve
Each resolver has a way to resolve the class it represents. This method will be called by theClassLocatorclass to resolve the class if the prefix matches.- Parameters:
context- The current context of executionname- The name of the class to resolveloadClass- When false, the class location is returned with informatino about where the class was found, but the class is not loaded and will be null.- Returns:
- An optional class object representing the class if found
-
resolve
Each resolver has a way to resolve the class it represents. This method will be called by theClassLocatorclass to resolve the class if the prefix matches.- Specified by:
resolvein interfaceIClassResolver- Overrides:
resolvein classBaseResolver- Parameters:
context- The current context of executionname- The name of the class to resolve- Returns:
- An optional class object representing the class if found
-
resolve
public Optional<ClassLocation> resolve(IBoxContext context, String name, List<ImportDefinition> imports, IStruct properties) Each resolver has a way to resolve the class it represents. This method will be called by theClassLocatorclass to resolve the class if the prefix matches with imports.- Specified by:
resolvein interfaceIClassResolver- Overrides:
resolvein classBaseResolver- Parameters:
context- The current context of executionname- The name of the class to resolveimports- The list of imports to useproperties- The properties to use- Returns:
- An optional class object representing the class if found
-
resolve
public Optional<ClassLocation> resolve(IBoxContext context, String name, List<ImportDefinition> imports) Each resolver has a way to resolve the class it represents. This method will be called by theClassLocatorclass to resolve the class if the prefix matches with imports.- Parameters:
context- The current context of executionname- The name of the class to resolveimports- The list of imports to use- Returns:
- An optional class object representing the class if found
-
resolve
public Optional<ClassLocation> resolve(IBoxContext context, String name, List<ImportDefinition> imports, boolean loadClass, IStruct properties) Each resolver has a way to resolve the class it represents. This method will be called by theClassLocatorclass to resolve the class if the prefix matches with imports.- Parameters:
context- The current context of executionname- The name of the class to resolveimports- The list of imports to useloadClass- When false, the class location is returned with informatino about where the class was found, but the class is not loaded and will be null.- Returns:
- An optional class object representing the class if found
-
findFromModules
public Optional<ClassLocation> findFromModules(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports) Load a class from the registered runtime module class loaders- Parameters:
context- The current context of executionfullyQualifiedName- The fully qualified path of the class to loadimports- The list of imports to use- Returns:
- The loaded class or null if not found
-
findFromModules
public Optional<ClassLocation> findFromModules(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports, boolean loadClass) This tries to load a BoxLang class from registered modules using thefullyQualifiedName@moduleNameprovided. If the class is not found, it will return an empty Optional.If there is no module name, then we return an empty Optional, because it will delegate to the
findFromLocal(ortus.boxlang.runtime.context.IBoxContext, java.lang.String, java.util.List<ortus.boxlang.runtime.loader.ImportDefinition>)method, which will look for the class in the current template directory, or using module mappings.- Parameters:
context- The current context of executionfullyQualifiedName- The fully qualified path of the class to loadimports- The list of imports to useloadClass- When false, the class location is returned with informatino about where the class was found, but the class is not loaded and will be null.- Returns:
- The loaded class or null if not found
-
findFromModule
public Optional<ClassLocation> findFromModule(String fullyQualifiedName, Key moduleName, List<ImportDefinition> imports, IBoxContext context) Find a class from a specific module explicitly.- Parameters:
fullyQualifiedName- The fully qualified path of the class to load in the module rootmoduleName- The name of the module to look inimports- The list of imports to usecontext- The current context of execution- Returns:
- The ClassLocation record wrapped in an optional if found, empty otherwise
- Throws:
BoxRuntimeException- If the module is not found
-
findFromLocal
public Optional<ClassLocation> findFromLocal(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports) Load a class from the configured directory byte code- Parameters:
context- The current context of executionfullyQualifiedName- The fully qualified path of the class to loadimports- The list of imports to use- Returns:
- The loaded class or null if not found
-
findFromLocal
public Optional<ClassLocation> findFromLocal(IBoxContext context, String fullyQualifiedName, List<ImportDefinition> imports, boolean loadClass, IStruct properties) Load a class from the configured directory byte code- Parameters:
context- The current context of executionfullyQualifiedName- The fully qualified path of the class to loadimports- The list of imports to useloadClass- When false, the class location is returned with informatino about where the class was found, but the class is not loaded and will be null.- Returns:
- The loaded class or null if not found
-
importHasMulti
Checks if the import has the given class name as a multi-import- Overrides:
importHasMultiin classBaseResolver- Parameters:
context- The current context of executionthisImport- The import to checkclassName- The class name to check- Returns:
- True if the import has the class name, false otherwise
-