1。 我有“春布申请”和“界面”
interface GraphService {
fun getGraphClient(): GraphServiceClient<Request>
fun getAllUsers(): List<User> {
// 。。。 using getGraphClient()
}
// 。。。
}
有两个服务,一个是“级联”栏,一个是“级联”栏,另一个是“级应用服务”栏。
@Service
class GraphUserService() {
override fun getGraphClient(): GraphServiceClient<Request> {
// build graph client for user requests
}
}
。
@Service
class GraphApplicationService() {
override fun getGraphClient(): GraphServiceClient<Request> {
// build graph client for application requests
}
}
现在,我有一个方法<代码>refreshUsers(>,载于Adminservice
,通过一个时间表自动和定期启动:
@Service
class ScheduleService(
private val adminService: AdminService
) {
@Scheduled(cron = "@monthly")
fun executeMonthlySchedule() {
adminService。refreshUsers()
}
}
Additionally, the method refreshUsers()
can be triggered proactive by an user。
My aim: refreshUsers()
should use the getAllUsers()
method from the GraphUserService
if its triggered by an user and the getAllUsers()
method from the GraphApplicationService
if its triggered by the automatic schedule。
How can I reach this? I thought of conditional beans but didn t come to a result until now。
Thanks in advance。