类 Reflections
java.lang.Object
org.apache.pulsar.common.util.Reflections
Utils related to reflections.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleanclassExists(String fqcn) Check if class exists.static booleanclassExistsInJar(File jar, String fqcn) Check if a class is in a jar.static booleanclassImplementsIface(String fqcn, Class xface) check if class implements interface.static booleanclassInJarImplementsIface(File jar, String fqcn, Class xface) check if a class implements an interface.static ObjectcreateInstance(String userClassName, File jar) static <T> TcreateInstance(String userClassName, Class<T> xface, ClassLoader classLoader) Create an instance ofuserClassNameusing providedclassLoader.static ObjectcreateInstance(String userClassName, ClassLoader classLoader) Create an instance ofuserClassNameusing providedclassLoader.static ObjectcreateInstance(String userClassName, ClassLoader classLoader, Object[] params, Class[] paramTypes) getAllFields(Class<?> type) static ClassloadClass(String className, ClassLoader classLoader) Load class to resolve array types.
-
构造器详细资料
-
Reflections
public Reflections()
-
-
方法详细资料
-
createInstance
Create an instance ofuserClassNameusing providedclassLoader. This instance should implement the provided interfacexface.- 参数:
userClassName- user class namexface- the interface that the reflected instance should implementclassLoader- class loader to load the class.- 返回:
- the instance
-
createInstance
Create an instance ofuserClassNameusing providedclassLoader.- 参数:
userClassName- user class nameclassLoader- class loader to load the class.- 返回:
- the instance
-
createInstance
public static Object createInstance(String userClassName, ClassLoader classLoader, Object[] params, Class[] paramTypes) -
createInstance
-
classExistsInJar
Check if a class is in a jar.- 参数:
jar- location of the jarfqcn- fully qualified class name to search for in jar- 返回:
- true if class can be loaded from jar and false if otherwise
-
classExists
Check if class exists.- 参数:
fqcn- fully qualified class name to search for- 返回:
- true if class can be loaded from jar and false if otherwise
-
classInJarImplementsIface
check if a class implements an interface.- 参数:
fqcn- fully qualified class name to search for in jarxface- interface to check if implement- 返回:
- true if class from jar implements interface xface and false if otherwise
-
classImplementsIface
check if class implements interface.- 参数:
fqcn- fully qualified class namexface- the interface the fqcn should implement- 返回:
- true if class implements interface xface and false if otherwise
-
loadClass
public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException Load class to resolve array types.- 参数:
className- class nameclassLoader- class loader- 返回:
- loaded class
- 抛出:
ClassNotFoundException
-
getAllFields
-