JAVA一个接口多个实现逐个调用
经测试确认,当一个接口有多个实现时,调用时只会执行一个
有时候需要多个实现调用,方法示例如下:
public interface TransCallbackInterface { public void callback(String taskId, int code, String fixed); }public interface TransCallbackInterface { public void callback(String taskId, int code, String fixed); }
@Component public class TransCallbackDy implements InitializingBean,TransCallbackInterface{ @Override public void callback(String taskId, int code, String fixed) { System.out.println("TransCallback"); }
@Override public void afterPropertiesSet() throws Exception { // TODO Auto-generated method stub System.out.println("callback registerCallbackProcessor .");
FileTransferShedule.registerCallbackProcessor(this);
}
}@Component public class TransCallbackDy implements InitializingBean,TransCallbackInterface{ @Override public void callback(String taskId, int code, String fixed) { System.out.println("TransCallback"); } @Override public void afterPropertiesSet() throws Exception { // TODO Auto-generated method stub System.out.println("callback registerCallbackProcessor ."); FileTransferShedule.registerCallbackProcessor(this); } }