Java 11 migrate remaining e (#1112)

* Moves eip-aggregator to Java 11

* Moves eip-message-channel to Java 11

* Moves eip-publish-subscribe to Java 11

* Moves eip-splitter to Java 11

* Moves eip-wire-tap to Java 11

* Moves event-aggregator to Java 11

* Moves event-asynchronous to Java 11

* Moves event-driven-architecture to Java 11

* Moves event-queue to Java 11

* Moves event-sourcing to Java 11

* Moves execute-around to Java 11

* Moves extension-objects to Java 11
This commit is contained in:
Anurag Agarwal
2019-12-09 22:33:30 +05:30
committed by Ilkka Seppälä
parent b09b100614
commit fb2c026822
64 changed files with 306 additions and 390 deletions

View File

@ -53,12 +53,12 @@ public class App {
*/
public static void main(String[] args) throws UnsupportedAudioFileException, IOException,
InterruptedException {
Audio audio = Audio.getInstance();
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);
LOGGER.info("Press Enter key to stop the program...");
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
try (var br = new BufferedReader(new InputStreamReader(System.in))) {
br.read();
}
audio.stopService();

View File

@ -27,7 +27,6 @@ import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.slf4j.Logger;
@ -116,10 +115,11 @@ public class Audio {
public void playSound(AudioInputStream stream, float volume) {
init();
// Walk the pending requests.
for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) {
if (getPendingAudio()[i].getStream() == stream) {
for (var i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) {
var playMessage = getPendingAudio()[i];
if (playMessage.getStream() == stream) {
// Use the larger of the two volumes.
getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume()));
playMessage.setVolume(Math.max(volume, playMessage.getVolume()));
// Don't need to enqueue.
return;
@ -137,11 +137,10 @@ public class Audio {
if (headIndex == tailIndex) {
return;
}
Clip clip = null;
try {
AudioInputStream audioStream = getPendingAudio()[headIndex].getStream();
var audioStream = getPendingAudio()[headIndex].getStream();
headIndex++;
clip = AudioSystem.getClip();
var clip = AudioSystem.getClip();
clip.open(audioStream);
clip.start();
} catch (LineUnavailableException e) {