-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into suneditor-rework
- Loading branch information
Showing
21 changed files
with
341 additions
and
51 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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ buildscript { | |
} | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
apply plugin: 'ensemble' | ||
|
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,42 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
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,45 @@ | ||
plugins { | ||
application | ||
id("org.openjfx.javafxplugin") | ||
id("jpro-gradle-plugin") | ||
} | ||
|
||
group = "one.jpro.samples" | ||
version = "0.0.1" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
val JAVAFX_VERSION = properties["JAVAFX_VERSION"] as String | ||
val SLF4J_VERSION = properties["SLF4J_VERSION"] as String | ||
val LOGBACK_VERSION = properties["LOGBACK_VERSION"] as String | ||
val JUNIT_VERSION = properties["JUNIT_VERSION"] as String | ||
|
||
javafx { | ||
version = JAVAFX_VERSION | ||
modules = listOf("javafx.graphics", "javafx.controls", "javafx.fxml", "javafx.media", "javafx.web") | ||
} | ||
|
||
dependencies { | ||
implementation("org.slf4j:slf4j-api:$SLF4J_VERSION") | ||
implementation("org.slf4j:jul-to-slf4j:$SLF4J_VERSION") | ||
implementation("ch.qos.logback:logback-classic:$LOGBACK_VERSION") | ||
|
||
testImplementation(platform("org.junit:junit-bom:$JUNIT_VERSION")) | ||
testImplementation("org.junit.jupiter:junit-jupiter") | ||
} | ||
|
||
application { | ||
mainModule.set("one.jpro.samples.logging") | ||
// Define the main class for the application. | ||
mainClass.set("one.jpro.samples.logging.SampleApp") | ||
} | ||
|
||
jpro { | ||
port = 8080 | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} |
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,15 @@ | ||
/** | ||
* Module descriptor. | ||
* | ||
* @author Besmir Beqiri | ||
*/ | ||
module one.jpro.samples.logging { | ||
requires javafx.controls; | ||
requires java.logging; | ||
requires org.slf4j; | ||
requires jul.to.slf4j; | ||
requires ch.qos.logback.core; | ||
requires ch.qos.logback.classic; | ||
|
||
exports one.jpro.samples.logging; | ||
} |
18 changes: 18 additions & 0 deletions
18
logging/src/main/java/one/jpro/samples/logging/LogOnFXStartup.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,18 @@ | ||
package one.jpro.samples.logging; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Log config on FX startup. | ||
* | ||
* @author Besmir Beqiri | ||
*/ | ||
public class LogOnFXStartup { | ||
|
||
private static final Logger logger = Logger.getLogger(LogOnFXStartup.class.getName()); | ||
|
||
public static void main(String[] args) { | ||
logger.log(Level.INFO, "Some logging on JavaFX Application Startup!"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
logging/src/main/java/one/jpro/samples/logging/LogOnJVMShutdown.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,26 @@ | ||
package one.jpro.samples.logging; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* This is a simple class that will be executed on JVM startup. | ||
* | ||
* @author Besmir Beqiri | ||
*/ | ||
public class LogOnJVMShutdown { | ||
|
||
private static final Logger jullogger = Logger.getLogger(LogOnJVMShutdown.class.getName()); | ||
|
||
public static void main(String[] args) { | ||
|
||
jullogger.log(Level.INFO, "JUL Logging on JVM Shutdown!"); | ||
|
||
for (java.util.logging.Handler handler : Logger.getLogger("").getHandlers()) { | ||
handler.flush(); | ||
} | ||
LogOnJVMStartup.julShutdownTrigger.complete(null); | ||
LogOnJVMStartup.loggerContext.stop(); | ||
|
||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
logging/src/main/java/one/jpro/samples/logging/LogOnJVMStartup.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,99 @@ | ||
package one.jpro.samples.logging; | ||
|
||
import ch.qos.logback.classic.LoggerContext; | ||
import ch.qos.logback.classic.joran.JoranConfigurator; | ||
import ch.qos.logback.core.joran.spi.JoranException; | ||
import org.slf4j.LoggerFactory; | ||
import org.slf4j.bridge.SLF4JBridgeHandler; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.logging.*; | ||
|
||
/** | ||
* This is a simple class that will be executed on JVM startup. | ||
* | ||
* @author Besmir Beqiri | ||
*/ | ||
public class LogOnJVMStartup { | ||
public static LoggerContext loggerContext = null; | ||
private static final Logger logger = Logger.getLogger(LogOnJVMStartup.class.getName()); | ||
|
||
public static void main(String[] args) { | ||
// redirect j.u.l. logging to SLF4J | ||
SLF4JBridgeHandler.removeHandlersForRootLogger(); | ||
|
||
String logbackFile = LogOnJVMStartup.class.getResource("/logback-sample.xml").getFile(); | ||
loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); | ||
loggerContext.reset(); | ||
JoranConfigurator configurator = new JoranConfigurator(); | ||
configurator.setContext(loggerContext); | ||
|
||
SLF4JBridgeHandler.install(); | ||
try { | ||
configurator.doConfigure(logbackFile); | ||
} catch (JoranException je) { | ||
je.printStackTrace(); | ||
throw new RuntimeException(je.getMessage()); | ||
} | ||
|
||
synchronizeJULShutdown(); | ||
|
||
logger.log(Level.INFO, "Logging on JVM Startup!"); | ||
} | ||
|
||
public static void synchronizeJULShutdown() { | ||
// For reference: https://stackoverflow.com/questions/60687511/why-is-the-new-java-logger-failing-to-work-consistently-here | ||
Logger root = Logger.getLogger(""); | ||
Handler[] handlers = root.getHandlers(); | ||
|
||
for(Handler h : handlers) { | ||
root.removeHandler(h); | ||
} | ||
|
||
root.addHandler(new CleanerJoin()); | ||
|
||
for(Handler h : handlers) { | ||
root.addHandler(h); | ||
} | ||
} | ||
|
||
|
||
public static CompletableFuture<Void> julShutdownTrigger = new CompletableFuture<>(); | ||
static class CleanerJoin extends Handler { | ||
|
||
CleanerJoin() { | ||
} | ||
|
||
@Override | ||
public void close() { | ||
boolean interrupted = false; | ||
try { | ||
for(;;) { | ||
try { //Could use LogManager to lookup timeout values and use a timed join. | ||
julShutdownTrigger.get(); | ||
break; | ||
} catch (ExecutionException e) { | ||
reportError("Shutdown hook failed.", e, ErrorManager.CLOSE_FAILURE); | ||
break; | ||
} catch (InterruptedException retry) { | ||
interrupted = true; | ||
} | ||
} | ||
} finally { | ||
if (interrupted) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
} | ||
|
||
@Override | ||
public void publish(LogRecord r) { | ||
isLoggable(r); | ||
} | ||
} | ||
} |
Oops, something went wrong.