Class service = Class.forName("com.jeesite.modules.bs.service.pp.PrepareService");
Class entity = Class.forName("com.jeesite.modules.bs.entity.pp.Prepare");
Object serviceBean = SpringBeanUtil.getBean(service);
Object entityInstance = entity.newInstance();
Method setIflowProcessId = entity.getMethod("setIflowProcessId",String.class);
setIflowProcessId.invoke(entityInstance, fdId);
Method findiList = service.getMethod("findList", entity);
List list = (List) findiList.invoke(serviceBean, entityInstance);
@Component
public class SpringBeanUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(SpringBeanUtil.applicationContext == null) {
SpringBeanUtil.applicationContext = applicationContext;
}
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public static Object getBean(String name){
return getApplicationContext().getBean(name);
}
public static <T> T getBean(Class<T> clazz){
return getApplicationContext().getBean(clazz);
}
public static <T> T getBean(String name,Class<T> clazz){
return getApplicationContext().getBean(name, clazz);
}
}