First, get the object class name
Class<?> Handlerclass = classutils. Getuserclass (handler);
Second, query whether a method has an annotation
requestmapping mapping = annotationutils. findannotation requestmapping. class );
Iii. obtaining a class that implements an interface
Beanfactoryutils. beansoftypeincludingancestors (Context, handlermapping. class, true, false);
Iv. getting the class object corresponding to a string
Class<?> clazz = classutils. forname (ClassName, this. getclass (). getClassLoader ());
v. creating managed beans using the Spring context
protected Object Createdefaultstrategy (applicationcontext context, class<?> clazz) {
return context.getautowirecapablebeanfactory (). Createbean (Clazz);
}
Get the Class property of an incoming object and find its registered object name in the Spring container accordingly beanname
Getapplicationcontext (). Getbeannamesfortype (Object. Class)
Querying all beanname registered in the Spring container According to the parent of the incoming object class
Beanfactoryutils. beannamesfortypeincludingancestors (Getapplicationcontext (), Object. class)
In the Spring container, find the corresponding annotation on this object according to Beanname , note that not all annotations
ApplicationContext context = Getapplicationcontext ();
requestmapping mapping = Context.findannotationonbean (Beanname, requestmapping. Class);
Spring uses beanname to find out the class type of this object
class<?> Handlertype = Context.gettype (beanname);
Method Methodtoinvoke = Bridgemethodresolver. Findbridgedmethod (Initbindermethod);
Reflectionutils. makeaccessible (Methodtoinvoke);
X. Getting an object with an annotation
String[] Beannames = (this. Detecthandlersinancestorcontexts ?
Beanfactoryutils. beannamesfortypeincludingancestors (Getapplicationcontext (), Object. class) :
Getapplicationcontext (). Getbeannamesfortype (Object. Class));//Get all beanname
for (String beanname:beannames) {
class<?> Handlertype = Context.gettype (beanname);
ApplicationContext context = Getapplicationcontext ();
if (Annotationutils. findannotation (Handlertype, Controller.) class) ! = null) {
}
}
Xi. Spring Collections static method
Collectionutils.mergearrayintocollection
Base API for building infrastructure using spring