Skip to content

Commit 7e9ae81

Browse files
gselzerctrueden
authored andcommitted
Remove SciJava Common dependency from SciJava Log2
1 parent b098901 commit 7e9ae81

11 files changed

Lines changed: 24 additions & 121 deletions

File tree

scijava/scijava-log2/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@
9292
<allowedDuplicateClasses>${scijava-log2.allowedDuplicateClasses}</allowedDuplicateClasses>
9393
</properties>
9494
<dependencies>
95-
<dependency>
96-
<groupId>org.scijava</groupId>
97-
<artifactId>scijava-common</artifactId>
98-
</dependency>
99-
10095
<!-- Test scope dependencies -->
10196
<dependency>
10297
<groupId>junit</groupId>

scijava/scijava-log2/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
opens org.scijava.log2 to org.scijava;
44
exports org.scijava.log2;
5-
requires org.scijava;
65

76
}

scijava/scijava-log2/src/main/java/org/scijava/log2/AbstractLoggerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
package org.scijava.log2;
3131

3232
/**
33-
* Base class for {@link LogService} implementations.
33+
* Base class for {@link LoggerFactory} implementations.
3434
*
3535
* @author Johannes Schindelin
3636
* @author Curtis Rueden

scijava/scijava-log2/src/main/java/org/scijava/log2/CallingClassUtils.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
package org.scijava.log2;
3131

32-
import org.scijava.Context;
33-
3432
/**
3533
* Utility class for getting the calling class of a method.
3634
*
@@ -62,14 +60,29 @@ public static String getCallingClassName() {
6260

6361
private static boolean hasIgnoreAsCallingClassAnnotation(String className) {
6462
try {
65-
Class< ? > clazz = Context.getClassLoader().loadClass(className);
63+
Class< ? > clazz = getClassLoader().loadClass(className);
6664
return clazz.isAnnotationPresent(IgnoreAsCallingClass.class);
6765
}
6866
catch (ClassNotFoundException ignore) {
6967
return false;
7068
}
7169
}
7270

71+
/**
72+
* Gets the class loader to use. This will be the current thread's context
73+
* class loader if non-null; otherwise it will be the system class loader.
74+
* <p>
75+
* Forked from SciJava Common's Context class.
76+
*
77+
* @see Thread#getContextClassLoader()
78+
* @see ClassLoader#getSystemClassLoader()
79+
*/
80+
private static ClassLoader getClassLoader() {
81+
final ClassLoader contextCL = Thread.currentThread()
82+
.getContextClassLoader();
83+
return contextCL != null ? contextCL : ClassLoader.getSystemClassLoader();
84+
}
85+
7386
/**
7487
* @deprecated Use {@link #getCallingClassName()} instead.
7588
*

scijava/scijava-log2/src/main/java/org/scijava/log2/DefaultUncaughtExceptionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public class DefaultUncaughtExceptionHandler implements
4545
UncaughtExceptionHandler
4646
{
4747

48-
private final LogService log;
48+
private final Logger log;
4949

50-
public DefaultUncaughtExceptionHandler(final LogService log) {
50+
public DefaultUncaughtExceptionHandler(final Logger log) {
5151
this.log = log;
5252
}
5353

@@ -62,7 +62,7 @@ public void handle(final Exception exception) {
6262
log.error("Uncaught exception on the Event Dispatch Thread", exception);
6363
}
6464

65-
public static void install(final LogService log) {
65+
public static void install(final Logger log) {
6666
final UncaughtExceptionHandler handler =
6767
new DefaultUncaughtExceptionHandler(log);
6868
Thread.setDefaultUncaughtExceptionHandler(handler);

scijava/scijava-log2/src/main/java/org/scijava/log2/LogMessage.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@
3636
import java.util.Date;
3737
import java.util.LinkedList;
3838

39-
import org.scijava.event.EventService;
40-
4139
/**
4240
* A log message broadcast by a {@link Logger}.
4341
* <p>
4442
* NB: The message is published <em>on the calling thread</em> by
45-
* {@link Logger#notifyListeners}, <em>not</em> on a dedicated event dispatch
46-
* thread by the {@link EventService}. This is done to avoid the overhead of the
43+
* {@link Logger#notifyListeners}. This is done to avoid the overhead of the
4744
* event service's synchronized pub/sub implementation, as well as to avoid
4845
* potential infinite loops caused by debugging log messages surrounding event
4946
* publication.

scijava/scijava-log2/src/main/java/org/scijava/log2/LogService.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

scijava/scijava-log2/src/main/java/org/scijava/log2/Logged.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
*/
3737
public interface Logged {
3838

39-
/** Gets the {@link LogService} to use when logging activities. */
40-
// TODO: SJC3: Generalize to Logger instead of LogService.
41-
LogService log();
39+
/** Gets the {@link Logger} to use when logging activities. */
40+
Logger log();
4241
}

scijava/scijava-log2/src/main/java/org/scijava/log2/Logger.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
*
4545
* @author Curtis Rueden
4646
* @see LogLevel
47-
* @see LogService
4847
*/
4948
@IgnoreAsCallingClass
5049
public interface Logger {

scijava/scijava-log2/src/main/java/org/scijava/log2/StderrLogFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import java.util.function.Function;
3434

3535
/**
36-
* Implementation of {@link LogService} using the standard error stream.
36+
* Implementation of {@link LoggerFactory} using the standard error stream.
3737
* <p>
3838
* Actually, this service is somewhat misnamed now, since it prints {@code WARN}
3939
* and {@code ERROR} messages to stderr, but messages at lesser severities to

0 commit comments

Comments
 (0)