程序包 com.alazeprt
类 DependencyLoader
java.lang.Object
com.alazeprt.DependencyLoader
Utility class for loading classes, constructing objects, and invoking methods with external dependencies.
-
构造器概要
构造器构造器说明DependencyLoader(String libPath) Creates a class loader based on the specified directory.DependencyLoader(String libPath, List<Dependency> list) Creates a class loader based on the specified file. -
方法概要
修饰符和类型方法说明Constructs an instance of the specified class name.Constructs an instance of the specified class with the given arguments.Returns the underlying URLClassLoader instance.Class<?>getLocalClass(String className) Loads the specified class based on external dependencies.voidloadMoreLibrary(String libPath) Adds additional paths to the class loader.runStaticMethod(String className, String methodName, Object... args) Invokes a static method on the specified class.
-
构造器详细资料
-
DependencyLoader
Creates a class loader based on the specified file.- 参数:
libPath- The path to the directory containing external dependencies.list- List of Dependency instances representing external dependencies.- 抛出:
MalformedURLException- If the provided URL is malformed.
-
DependencyLoader
Creates a class loader based on the specified directory.- 参数:
libPath- The path to the directory containing external dependencies.- 抛出:
MalformedURLException- If the provided URL is malformed.
-
-
方法详细资料
-
construct
public DependencyClass construct(String classname) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException Constructs an instance of the specified class name.- 参数:
classname- The fully qualified class name to instantiate.- 返回:
- An instance of the specified class.
- 抛出:
ClassNotFoundException- If the class is not found.InstantiationException- If an instance of the class cannot be created.IllegalAccessException- If access to the class or its constructor is denied.NoSuchMethodException- If the constructor with no parameters is not found.InvocationTargetException- If the constructor throws an exception.
-
loadMoreLibrary
Adds additional paths to the class loader.- 参数:
libPath- The path to the directory containing more external dependencies.- 抛出:
MalformedURLException- If the provided URL is malformed.
-
construct
public DependencyClass construct(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Constructs an instance of the specified class with the given arguments.- 参数:
className- The fully qualified class name to instantiate.args- The arguments to pass to the constructor.- 返回:
- An instance of the specified class.
- 抛出:
ClassNotFoundException- If the class is not found.NoSuchMethodException- If the constructor with the specified parameter types is not found.InstantiationException- If an instance of the class cannot be created.IllegalAccessException- If access to the class or its constructor is denied.InvocationTargetException- If the constructor throws an exception.
-
getLocalClass
Loads the specified class based on external dependencies.- 参数:
className- The fully qualified class name to load.- 返回:
- The loaded class.
- 抛出:
ClassNotFoundException- If the class is not found.
-
runStaticMethod
public Object runStaticMethod(String className, String methodName, Object... args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes a static method on the specified class.- 参数:
className- The fully qualified class name containing the static method.methodName- The name of the static method to invoke.args- The arguments to pass to the method.- 返回:
- The result of invoking the static method.
- 抛出:
ClassNotFoundException- If the class is not found.NoSuchMethodException- If the method with the specified name and parameter types is not found.InvocationTargetException- If the method throws an exception.IllegalAccessException- If access to the method is denied.
-
getClassLoader
Returns the underlying URLClassLoader instance.- 返回:
- The underlying URLClassLoader.
-