-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate TaskExecutor and TaskScheduler usage
- Loading branch information
Showing
8 changed files
with
129 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/de/rwth/idsg/steve/config/DelegatingTaskExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve | ||
* Copyright (C) 2013-2025 SteVe Community Team | ||
* All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package de.rwth.idsg.steve.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author Sevket Goekay <[email protected]> | ||
* @since 02.02.2025 | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class DelegatingTaskExecutor implements Closeable { | ||
|
||
private final ThreadPoolTaskExecutor delegate; | ||
|
||
@Override | ||
public void close() throws IOException { | ||
log.info("Shutting down"); | ||
delegate.shutdown(); | ||
} | ||
|
||
public void execute(Runnable task) { | ||
delegate.execute(task); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/de/rwth/idsg/steve/config/DelegatingTaskScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve | ||
* Copyright (C) 2013-2025 SteVe Community Team | ||
* All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package de.rwth.idsg.steve.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.concurrent.ScheduledFuture; | ||
|
||
/** | ||
* @author Sevket Goekay <[email protected]> | ||
* @since 02.02.2025 | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class DelegatingTaskScheduler implements Closeable { | ||
|
||
private final ThreadPoolTaskScheduler delegate; | ||
|
||
@Override | ||
public void close() throws IOException { | ||
log.info("Shutting down"); | ||
delegate.shutdown(); | ||
} | ||
|
||
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Instant startTime, Duration period) { | ||
return delegate.scheduleAtFixedRate(task, startTime, period); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
package de.rwth.idsg.steve.service; | ||
|
||
import de.rwth.idsg.steve.SteveException; | ||
import de.rwth.idsg.steve.config.DelegatingTaskExecutor; | ||
import de.rwth.idsg.steve.ocpp.ChargePointServiceInvokerImpl; | ||
import de.rwth.idsg.steve.ocpp.OcppCallback; | ||
import de.rwth.idsg.steve.ocpp.task.CancelReservationTask; | ||
|
@@ -74,7 +75,6 @@ | |
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* @author Sevket Goekay <[email protected]> | ||
|
@@ -89,7 +89,7 @@ public class ChargePointServiceClient { | |
private final ReservationRepository reservationRepository; | ||
private final OcppTagService ocppTagService; | ||
|
||
private final Executor asyncTaskExecutor; | ||
private final DelegatingTaskExecutor asyncTaskExecutor; | ||
private final TaskStore taskStore; | ||
private final ChargePointServiceInvokerImpl invoker; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
import com.google.common.base.Strings; | ||
import de.rwth.idsg.steve.SteveException; | ||
import de.rwth.idsg.steve.config.DelegatingTaskExecutor; | ||
import de.rwth.idsg.steve.repository.SettingsRepository; | ||
import de.rwth.idsg.steve.repository.dto.MailSettings; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
@@ -36,7 +37,6 @@ | |
import jakarta.mail.internet.MimeMessage; | ||
|
||
import java.util.Properties; | ||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* @author Sevket Goekay <[email protected]> | ||
|
@@ -47,7 +47,7 @@ | |
public class MailService { | ||
|
||
@Autowired private SettingsRepository settingsRepository; | ||
@Autowired private Executor asyncTaskExecutor; | ||
@Autowired private DelegatingTaskExecutor asyncTaskExecutor; | ||
|
||
public MailSettings getSettings() { | ||
return settingsRepository.getMailSettings(); | ||
|