com.envision.core.MarsController Maven / Gradle / Ivy
The newest version!
package com.envision.core;
import com.envision.annotation.Processor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.ResponseEntity;
/**
* @author qiweishi
* @date 2018/11/10
*/
public class MarsController {
@Autowired
private ApplicationContext applicationContext;
public ResponseEntity handle(Object... params) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
String processorName = this.getProcessorName();
Class> aClass = Class.forName(processorName);
Object bean = applicationContext.getBean(aClass);
MarsProcessor baseProcessor = (MarsProcessor) bean;
return baseProcessor.actor();
}
private String getProcessorName() {
return this.getClass().getAnnotation(Processor.class).value();
}
}