mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Dev: migrated to single logger lib (replaced slf4j usage by log4j), clean up and documented pom files, updated some libs;
This commit is contained in:
parent
16d20e73d2
commit
08407eef25
10 changed files with 125 additions and 110 deletions
|
@ -14,7 +14,6 @@
|
|||
<name>Mage Client</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage</artifactId>
|
||||
|
@ -31,89 +30,105 @@
|
|||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-counter-plugin</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
<artifactId>truevfs-profile-base</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.unbescape</groupId>
|
||||
<artifactId>unbescape</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- needs for server connection by jboss -->
|
||||
<!-- inner lib for jboss network implementation -->
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- wtf lib, related to plugins system TODO: unused and can be deleted? -->
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- image scaling for card images -->
|
||||
<!-- TODO: library is dead, must be replaced -->
|
||||
<groupId>com.mortennobel</groupId>
|
||||
<artifactId>java-image-scaling</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- graphic lib to draw GUI with effects -->
|
||||
<!-- TODO: library is dead, must be replaced -->
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swingx</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetlang</groupId>
|
||||
<artifactId>jetlang</artifactId>
|
||||
<version>0.2.23</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.11.827</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jgoodies</groupId>
|
||||
<artifactId>forms</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intellij</groupId>
|
||||
<artifactId>forms_rt</artifactId>
|
||||
<version>7.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-counter-plugin</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdesktop</groupId>
|
||||
<artifactId>beansbinding</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- GUI lib, part of SwingX -->
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swing-layout</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- multi-threading lib for symbols/images download -->
|
||||
<groupId>org.jetlang</groupId>
|
||||
<artifactId>jetlang</artifactId>
|
||||
<version>0.2.23</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- amazon s3 cloud lib to upload game logs from experimental client -->
|
||||
<!-- TODO: feature must be removed as unused or implemented for all -->
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.12.78</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- GUI lib TODO: unused and can be deleted? -->
|
||||
<groupId>com.jgoodies</groupId>
|
||||
<artifactId>forms</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- GUI lib TODO: unused and can be deleted? -->
|
||||
<groupId>com.intellij</groupId>
|
||||
<artifactId>forms_rt</artifactId>
|
||||
<version>7.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- GUI lib -->
|
||||
<groupId>org.jdesktop</groupId>
|
||||
<artifactId>beansbinding</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- scraping lib to download and parse symbols/images/svg -->
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.14.2</version>
|
||||
<version>1.14.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- music player START -->
|
||||
|
@ -135,6 +150,7 @@
|
|||
<!-- music player END -->
|
||||
|
||||
<dependency>
|
||||
<!-- GUI lib for balloon popup TODO: unused and can be deleted? -->
|
||||
<groupId>net.java.balloontip</groupId>
|
||||
<artifactId>balloontip</artifactId>
|
||||
<version>1.2.4.1</version>
|
||||
|
@ -153,15 +169,11 @@
|
|||
<!-- svg support END -->
|
||||
|
||||
<dependency>
|
||||
<!-- time lib for GUI time info -->
|
||||
<groupId>org.ocpsoft.prettytime</groupId>
|
||||
<artifactId>prettytime</artifactId>
|
||||
<version>4.0.6.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.unbescape</groupId>
|
||||
<artifactId>unbescape</artifactId>
|
||||
<version>1.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ -->
|
||||
|
|
|
@ -16,14 +16,13 @@ import javax.sound.sampled.LineUnavailableException;
|
|||
import javax.sound.sampled.Mixer;
|
||||
import javax.sound.sampled.SourceDataLine;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import mage.utils.ThreadUtils;
|
||||
|
||||
public class LinePool {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final org.apache.log4j.Logger logger = Logger.getLogger(LinePool.class);
|
||||
private static final int LINE_CLEANUP_INTERVAL = 30000;
|
||||
|
||||
private final Queue<SourceDataLine> freeLines = new ArrayDeque<>();
|
||||
|
@ -55,7 +54,7 @@ public class LinePool {
|
|||
SourceDataLine line = (SourceDataLine) mixer.getLine(lineInfo);
|
||||
freeLines.add(line);
|
||||
} catch (LineUnavailableException e) {
|
||||
log.warn("Failed to get line from mixer", e);
|
||||
logger.warn("Failed to get line from mixer", e);
|
||||
}
|
||||
}
|
||||
new Timer("Line cleanup", true).scheduleAtFixedRate(new TimerTask() {
|
||||
|
@ -65,7 +64,7 @@ public class LinePool {
|
|||
for (SourceDataLine sourceDataLine : freeLines) {
|
||||
if (sourceDataLine.isOpen()) {
|
||||
sourceDataLine.close();
|
||||
log.debug("Closed line {}", sourceDataLine);
|
||||
logger.debug("Closed line " + sourceDataLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,13 +95,13 @@ public class LinePool {
|
|||
public void playSound(final MageClip mageClip) {
|
||||
final SourceDataLine line;
|
||||
synchronized (LinePool.this) {
|
||||
log.debug("Playing {}", mageClip.getFilename());
|
||||
logger.debug("Playing: " + mageClip.getFilename());
|
||||
logLineStats();
|
||||
line = borrowLine();
|
||||
if (line == null) {
|
||||
// no lines available, queue sound to play it when a line is available
|
||||
queue.add(mageClip);
|
||||
log.debug("Sound {} queued.", mageClip.getFilename());
|
||||
logger.debug("Sound queued: " + mageClip.getFilename());
|
||||
return;
|
||||
}
|
||||
logLineStats();
|
||||
|
@ -113,19 +112,19 @@ public class LinePool {
|
|||
if (!line.isOpen()) {
|
||||
line.open();
|
||||
line.addLineListener(event -> {
|
||||
log.debug("Event: {}", event);
|
||||
logger.debug("Event: " + event);
|
||||
if (event.getType() != Type.STOP) {
|
||||
return;
|
||||
}
|
||||
synchronized (LinePool.this) {
|
||||
log.debug("Before stop on line {}", line);
|
||||
logger.debug("Before stop on line " + line);
|
||||
logLineStats();
|
||||
returnLine(line);
|
||||
log.debug("After stop on line {}", line);
|
||||
logger.debug("After stop on line " + line);
|
||||
logLineStats();
|
||||
MageClip queuedSound = queue.poll();
|
||||
if (queuedSound != null) {
|
||||
log.debug("Playing queued sound {}", queuedSound);
|
||||
logger.debug("Playing queued sound " + queuedSound);
|
||||
playSound(queuedSound);
|
||||
}
|
||||
}
|
||||
|
@ -133,19 +132,21 @@ public class LinePool {
|
|||
}
|
||||
line.start();
|
||||
} catch (LineUnavailableException e) {
|
||||
log.warn("Failed to open line", e);
|
||||
logger.warn("Failed to open line", e);
|
||||
}
|
||||
}
|
||||
byte[] buffer = mageClip.getBuffer();
|
||||
log.debug("Before write to line {}", line);
|
||||
logger.debug("Before write to line " + line);
|
||||
line.write(buffer, 0, buffer.length);
|
||||
line.drain();
|
||||
line.stop();
|
||||
log.debug("Line completed: {}", line);
|
||||
logger.debug("Line completed: " + line);
|
||||
});
|
||||
}
|
||||
|
||||
private void logLineStats() {
|
||||
log.debug("Free lines: {} Active: {} Busy: {}", freeLines.size(), activeLines.size(), busyLines.size());
|
||||
logger.debug(String.format("Free lines: %d; Active: %d; Busy: %d",
|
||||
freeLines.size(), activeLines.size(), busyLines.size()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,12 +63,10 @@
|
|||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
|
@ -54,10 +53,6 @@
|
|||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-player-ai</artifactId>
|
||||
|
@ -284,12 +279,14 @@
|
|||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.unbescape</groupId>
|
||||
<artifactId>unbescape</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ import mage.server.util.SystemUtil;
|
|||
import mage.utils.*;
|
||||
import mage.view.*;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.unbescape.html.HtmlEscape;
|
||||
|
||||
import javax.management.timer.Timer;
|
||||
import java.security.SecureRandom;
|
||||
|
@ -489,7 +489,7 @@ public class MageServerImpl implements MageServer {
|
|||
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
||||
try {
|
||||
callExecutor.execute(
|
||||
() -> managerFactory.chatManager().broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null)
|
||||
() -> managerFactory.chatManager().broadcast(chatId, userName, HtmlEscape.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null)
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
|
61
pom.xml
61
pom.xml
|
@ -15,7 +15,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
@ -157,23 +157,14 @@
|
|||
|
||||
<dependencyManagement>
|
||||
<!-- write libs from all childs here to control a versions -->
|
||||
<!-- if you want to use it in the child module then copy groupId and artifactId only (without scope and version) -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- logs support -->
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.8.0-beta2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- json support -->
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
|
@ -181,24 +172,16 @@
|
|||
<version>2.8.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- extended lib from google (collections, io, etc) -->
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>30.1.1-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.18.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
<!-- escape/unescape html in texts -->
|
||||
<groupId>org.unbescape</groupId>
|
||||
<artifactId>unbescape</artifactId>
|
||||
<version>1.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- zip files support -->
|
||||
|
@ -206,6 +189,34 @@
|
|||
<artifactId>truevfs-profile-base</artifactId>
|
||||
<version>0.14.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- lib with useful code and utils -->
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- junit 4 tests -->
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- junit 5 tests -->
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- write asserts in unit tests like a real language -->
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.19.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
|
|
Loading…
Reference in a new issue