反射
/**
*
* @param planStatus
* @return
*/
public T getBusinessService(PlanStatus planStatus) {
try {
Reflections reflections = new Reflections("com.gf.impl");
Set<Class<?>> classesList = reflections.getTypesAnnotatedWith(ServiceAnnotation.class);
for (Class classes : classesList) {
ServiceAnnotation serviceAnnotation = (ServiceAnnotation) classes.getAnnotation(ServiceAnnotation.class);
if (planStatus.equals(serviceAnnotation.value())) {
Class<?> aClass = Class.forName(classes.getName());
T newInstance = (T) aClass.newInstance();
return newInstance;
}
}
return null;
} catch (Exception e) {
}
return null;
}
/**
* 获取业务服务
*
* @param planStatus
* @return
*/
public T getBusinessService(PlanStatus planStatus) {
AnnoManageUtil<T> annoManageUtil = new AnnoManageUtil<>();
T iThorService = annoManageUtil.getBusinessService(planStatus);
return iThorService;
}
小蚊子大人