diff --git a/pom.xml b/pom.xml
index a2748ea..e0a7f6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,12 +87,6 @@
provided
-
-
io.github.classgraph
classgraph
@@ -113,11 +107,6 @@
jackson-core
-
- org.slf4j
- slf4j-api
-
-
com.fasterxml.jackson.core
jackson-databind
@@ -143,18 +132,6 @@
guava
-
- org.slf4j
- jcl-over-slf4j
- test
-
-
-
- org.slf4j
- slf4j-simple
- test
-
-
org.junit.jupiter
junit-jupiter-api
diff --git a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java
index fd7c25b..9383b09 100644
--- a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java
+++ b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java
@@ -25,6 +25,13 @@
import io.github.classgraph.ResourceList;
import io.github.classgraph.ScanResult;
import lombok.extern.java.Log;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
@@ -85,12 +92,54 @@ public class GuiceContext> implements IGuiceContext
private CompletableFuture loadingFinished = new CompletableFuture<>();
+
+ private ConfigurationBuilder logBuilder;
+
/**
* Creates a new Guice context. Not necessary
*/
private GuiceContext()
{
- //No config required
+ try
+ {
+ // String cn = "org.apache.logging.log4j.jul.LogManager";
+ // System.setProperty("java.util.logging.manager", cn);
+
+ ConfigurationBuilder builder =
+ ConfigurationBuilderFactory.newConfigurationBuilder();
+
+ builder.setStatusLevel(org.apache.logging.log4j.Level.DEBUG);
+ builder.setConfigurationName("GuicedEE");
+
+// create the console appender
+ AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE")
+ .addAttribute("target",
+ ConsoleAppender.Target.SYSTEM_ERR)
+ //.addAttribute("additivity", "true")
+ ;
+ appenderBuilder.add(builder.newLayout("PatternLayout").
+ addAttribute("pattern", "%d{ABSOLUTE} %-5level: %msg%n"));
+ builder.add(appenderBuilder);
+
+
+
+ RootLoggerComponentBuilder rootLogger = builder.newRootLogger(org.apache.logging.log4j.Level.DEBUG);
+ ServiceLoader log4JConfigurators = ServiceLoader.load(Log4JConfigurator.class);
+ for (Log4JConfigurator log4jConfigurator : log4JConfigurators)
+ {
+ builder = log4jConfigurator.configure(builder, rootLogger);
+ }
+
+ rootLogger.add(builder.newAppenderRef("Stdout"));
+ builder.add(rootLogger);
+
+ builder.writeXmlConfiguration(System.out);
+ Configurator.initialize(builder.build());
+ }
+ catch (Throwable T)
+ {
+ log.log(Level.SEVERE, "Failed to configure Log4JConfigurator", T);
+ }
}
/**
@@ -142,15 +191,18 @@ public Injector inject()
log.config("Modules - " + Arrays.toString(cModules.toArray()));
GuiceContext.instance().injector = Guice.createInjector(cModules);
GuiceContext.buildingInjector = false;
- GuiceContext.instance().loadPostStartups();
- GuiceContext.instance().loadPreDestroyServices();
+ GuiceContext.instance()
+ .loadPostStartups();
+ GuiceContext.instance()
+ .loadPreDestroyServices();
Runtime
.getRuntime()
.addShutdownHook(new Thread()
{
public void run()
{
- GuiceContext.instance().destroy();
+ GuiceContext.instance()
+ .destroy();
}
});
LocalDateTime end = LocalDateTime.now();
@@ -786,20 +838,21 @@ private void loadPostStartups()
Integer key = entry.getKey();
Set> value = entry.getValue();
List> futures = new ArrayList<>();
- // log.info("Starting Post Startup Group [" + key + "]");
+ // log.info("Starting Post Startup Group [" + key + "]");
ExecutorService ex = null;
for (IGuicePostStartup> iGuicePostStartup : value)
{
log.info("Starting Post Load [" + iGuicePostStartup.getClass()
- .getSimpleName() + "] - Start Order [" + key + "]");
- ex= iGuicePostStartup.getExecutorService();
+ .getSimpleName() + "] - Start Order [" + key + "]");
+ ex = iGuicePostStartup.getExecutorService();
futures.addAll(iGuicePostStartup.postLoad());
}
try
{
- if(!futures.isEmpty())
+ if (!futures.isEmpty())
{
- CompletableFuture.allOf(futures.toArray(new CompletableFuture[]{})).join();
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[]{}))
+ .join();
if (ex != null)
{
ex.shutdown();
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index b9fa788..e781f86 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,6 +1,9 @@
import com.guicedee.guicedinjection.JobService;
-import com.guicedee.guicedinjection.implementations.*;
-import com.guicedee.guicedinjection.interfaces.*;
+import com.guicedee.guicedinjection.implementations.GuiceContextProvision;
+import com.guicedee.guicedinjection.implementations.JobServiceProvision;
+import com.guicedee.guicedinjection.interfaces.IGuicePreDestroy;
+import com.guicedee.guicedinjection.interfaces.IGuiceProvider;
+import com.guicedee.guicedinjection.interfaces.IJobServiceProvider;
module com.guicedee.guicedinjection {
requires transitive com.guicedee.client;
@@ -11,11 +14,11 @@
//requires transitive com.guicedee.logmaster;
requires transitive org.apache.commons.lang3;
-
- requires static org.slf4j;
+
requires static lombok;
-
- exports com.guicedee.guicedinjection;
+ requires org.apache.logging.log4j.core;
+
+ exports com.guicedee.guicedinjection;
//exports com.guicedee.guicedinjection.exceptions;
//exports com.guicedee.guicedinjection.abstractions;
//exports com.guicedee.guicedinjection.pairing;
@@ -40,8 +43,9 @@
uses com.guicedee.guicedinjection.interfaces.IPackageRejectListScanner;
uses com.guicedee.guicedinjection.interfaces.IGuiceScanJarExclusions;
uses com.guicedee.guicedinjection.interfaces.IGuiceScanJarInclusions;
-
- provides com.guicedee.guicedinjection.interfaces.IGuiceScanModuleExclusions with com.guicedee.guicedinjection.implementations.GuiceDefaultModuleExclusions;
+ uses com.guicedee.guicedinjection.interfaces.Log4JConfigurator;
+
+ provides com.guicedee.guicedinjection.interfaces.IGuiceScanModuleExclusions with com.guicedee.guicedinjection.implementations.GuiceDefaultModuleExclusions;
provides com.guicedee.guicedinjection.interfaces.IGuiceScanJarExclusions with com.guicedee.guicedinjection.implementations.GuiceDefaultModuleExclusions;
provides com.guicedee.guicedinjection.interfaces.IGuiceModule with com.guicedee.guicedinjection.injections.ContextBinderGuice;
diff --git a/src/test/java/com/guicedee/tests/FileSearchTest.java b/src/test/java/com/guicedee/tests/FileSearchTest.java
index 75c2100..a6579cb 100644
--- a/src/test/java/com/guicedee/tests/FileSearchTest.java
+++ b/src/test/java/com/guicedee/tests/FileSearchTest.java
@@ -1,14 +1,12 @@
package com.guicedee.tests;
-import com.guicedee.client.*;
+import com.guicedee.client.IGuiceContext;
import com.guicedee.guicedinjection.GuiceContext;
-import com.guicedee.guicedinjection.interfaces.IPathContentsRejectListScanner;
import io.github.classgraph.ResourceList;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
-import java.util.logging.Level;
import java.util.regex.Pattern;
public class FileSearchTest {
@@ -32,6 +30,7 @@ public void findJSFiles()
IGuiceContext
.getContext().inject();
+
ResourceList resourceswithPattern = GuiceContext.instance().getScanResult()
.getResourcesMatchingPattern(Pattern.compile("(.*)\\/resources\\/testResourceFind\\.js"));
System.out.println("Resource List found : " + resourceswithPattern);
diff --git a/src/test/java/module-info.java b/src/test/java/module-info.java
index fa2e43f..bf80421 100644
--- a/src/test/java/module-info.java
+++ b/src/test/java/module-info.java
@@ -4,8 +4,8 @@
requires static lombok;
requires org.junit.jupiter.api;
- requires org.slf4j;
- requires org.slf4j.simple;
+ //requires org.slf4j;
+ //requires org.apache.logging.log4j.slf4j2.impl;
opens com.guicedee.tests to org.junit.platform.commons;
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
deleted file mode 100644
index d59ef06..0000000
--- a/src/test/resources/logback.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- %d %highlight(%-5level) [%thread] %cyan(%logger{15}): %msg%n
-
-
\ No newline at end of file