issue-86 #102

Merged
sebastian merged 10 commits from issue-86 into master 2024-03-14 14:57:52 +01:00
4 changed files with 38 additions and 13 deletions
Showing only changes of commit 2b0f9ef186 - Show all commits

View File

@ -5,12 +5,16 @@ import core.entities.UserRole;
import core.repositories.RoleRepository;
import core.repositories.UserRepository;
import core.services.PropertyService;
import core.services.TaskScheduleService;
import core.services.ntfy.TaskSchedulingService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class DemoApplication{
public static void main(String[] args) {
@ -18,19 +22,10 @@ public class DemoApplication{
}
/*@Bean
public CommandLineRunner init(RoleRepository roleRepository, UserRepository userRepository, PropertyService propertyService) {
@Bean
public CommandLineRunner init() {
return args -> {
for (UserRole userRole : UserRole.values()) {
if(!roleRepository.existsByName(userRole)) {
roleRepository.save(new RoleEntity(userRole));
}
}
propertyService.init();
FirstUserObserver observer = new FirstUserObserver(userRepository);
observer.start();
TaskSchedulingService.scheduleTask();
};
}*/
}
}

View File

@ -0,0 +1,8 @@
package core.services.ntfy;
public class NtfyTask implements Runnable{
@Override
public void run() {
System.out.println("A little Test");
}
}

View File

@ -0,0 +1,21 @@
package core.services.ntfy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ScheduledFuture;
public class TaskSchedulingService {
public static void scheduleTask() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.initialize();
threadPoolTaskScheduler.schedule(new NtfyTask(), new CronTrigger("0 0/1 * 1/1 * *"));
}
}

View File

@ -27,6 +27,7 @@ spring.jpa.open-in-view=false
# Spring Data Rest Setup
spring.data.rest.base-path=/api