deps: Refactor dependencies (#3224)

* remove spring dep
move junit, logging, mockito under dep mgmt

* upgrade anti-corruption-layer deps

* async method invocation

* balking, bloc

* bridge to bytecode

* caching

* callback - cqrs

* component - health check

* hexagonal - metadata mapping

* rest of the patterns

* remove checkstyle, take spotless into use
This commit is contained in:
Ilkka Seppälä
2025-03-29 19:34:27 +02:00
committed by GitHub
parent 371439aeaa
commit 0ca162a55c
1863 changed files with 14408 additions and 17637 deletions
@@ -47,11 +47,11 @@ public class App {
* Program entry point.
*
* @param args command line args
* @throws IOException when there is a problem with the audio file loading
* @throws IOException when there is a problem with the audio file loading
* @throws UnsupportedAudioFileException when the loaded audio file is unsupported
*/
public static void main(String[] args) throws UnsupportedAudioFileException, IOException,
InterruptedException {
public static void main(String[] args)
throws UnsupportedAudioFileException, IOException, InterruptedException {
var audio = Audio.getInstance();
audio.playSound(audio.getAudioStream("./etc/Bass-Drum-1.wav"), -10.0f);
audio.playSound(audio.getAudioStream("./etc/Closed-Hi-Hat-1.wav"), -8.0f);
@@ -33,10 +33,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
* This class implements the Event Queue pattern.
*
*/
/** This class implements the Event Queue pattern. */
@Slf4j
public class Audio {
private static final Audio INSTANCE = new Audio();
@@ -49,21 +46,16 @@ public class Audio {
private volatile Thread updateThread = null;
@Getter
private final PlayMessage[] pendingAudio = new PlayMessage[MAX_PENDING];
@Getter private final PlayMessage[] pendingAudio = new PlayMessage[MAX_PENDING];
// Visible only for testing purposes
Audio() {
}
Audio() {}
public static Audio getInstance() {
return INSTANCE;
}
/**
* This method stops the Update Method's thread and waits till service stops.
*/
/** This method stops the Update Method's thread and waits till service stops. */
public synchronized void stopService() throws InterruptedException {
if (updateThread != null) {
updateThread.interrupt();
@@ -82,23 +74,23 @@ public class Audio {
}
/**
* Starts the thread for the Update Method pattern if it was not started previously. Also, when the
* thread is ready initializes the indexes of the queue
* Starts the thread for the Update Method pattern if it was not started previously. Also, when
* the thread is ready initializes the indexes of the queue
*/
public void init() {
if (updateThread == null) {
updateThread = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
update();
}
});
updateThread =
new Thread(
() -> {
while (!Thread.currentThread().isInterrupted()) {
update();
}
});
}
startThread();
}
/**
* This is a synchronized thread starter.
*/
/** This is a synchronized thread starter. */
private synchronized void startThread() {
if (!updateThread.isAlive()) {
updateThread.start();
@@ -130,9 +122,7 @@ public class Audio {
tailIndex = (tailIndex + 1) % MAX_PENDING;
}
/**
* This method uses the Update Method pattern. It takes the audio from the queue and plays it
*/
/** This method uses the Update Method pattern. It takes the audio from the queue and plays it */
private void update() {
// If there are no pending requests, do nothing.
if (headIndex == tailIndex) {
@@ -159,7 +149,7 @@ public class Audio {
* @param filePath is the path of the audio file
* @return AudioInputStream
* @throws UnsupportedAudioFileException when the audio file is not supported
* @throws IOException when the file is not readable
* @throws IOException when the file is not readable
*/
public AudioInputStream getAudioStream(String filePath)
throws UnsupportedAudioFileException, IOException {
@@ -29,17 +29,12 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
/**
* The Event Queue's queue will store the instances of this class.
*
*/
/** The Event Queue's queue will store the instances of this class. */
@Getter
@AllArgsConstructor
public class PlayMessage {
private final AudioInputStream stream;
@Setter
private float volume;
@Setter private float volume;
}