问题描述
我正在用 java 编写一个 azure 函数。为了使用良好的模块化模式,我创建了一个具有抽象接口类的服务层和一个实现服务层的 impl 层。
但是,我没有使用 Spring-framework
,因此我无法使用 @Autowired
在运行程序文件中创建服务层的单例实例。如何在我的跑步者类(或我项目中的其他地方)中使用我的服务层函数?
服务层
public interface TimeTriggeredService {
String getLogs(String token,String url,final ExecutionContext context);
}
Impl 层
public class TimeTriggeredServiceImpl implements TimeTriggeredService {
public String getLogs(String token,final ExecutionContext context) {
// Some logic
}
}
跑步类
public class TimeTriggeredFunction {
@FunctionName("TimeTriggeredFunction")
public void run(@TimerTrigger(name = "timerInfo",schedule = "0 */1 * * * *") String timerInfo,final ExecutionContext context) {
String timeAuditLogs = TimeTriggeredService.getLogs(token,URL,context); // unsure what should replace this line or what should be done before this.
}
}
注意:这不是春季项目。