Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d61d0c65d | ||
|
|
e77be6dee7 | ||
|
|
7d02637843 |
28
pom.xml
28
pom.xml
@@ -22,13 +22,12 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
||||
<maven-source-plugin.version>3.1.0</maven-source-plugin.version>
|
||||
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
|
||||
@@ -59,29 +58,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Java EE API replacements for JDK 11 -->
|
||||
<!-- JAXB for Java 11 -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.4.0-b180830.0438</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JAXWS for Java 11 -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-rt</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>rt</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
@@ -5,12 +5,16 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
class OnSoapClientExistsCondition extends AnyNestedCondition {
|
||||
|
||||
static final String HTTP_ADAPTER_JAVA_8 = "com.sun.xml.ws.transport.http.HttpAdapter";
|
||||
|
||||
static final String HTTP_ADAPTER_JAVA_11 = "com.sun.xml.internal.ws.transport.http.HttpAdapter";
|
||||
|
||||
OnSoapClientExistsCondition() {
|
||||
super(ConfigurationPhase.REGISTER_BEAN);
|
||||
}
|
||||
|
||||
// This class is a part of Java runtime 8
|
||||
@ConditionalOnClass(name = "com.sun.xml.internal.ws.transport.http.HttpAdapter")
|
||||
@ConditionalOnClass(name = HTTP_ADAPTER_JAVA_11)
|
||||
static class OnJava8 {
|
||||
|
||||
}
|
||||
@@ -23,7 +27,7 @@ class OnSoapClientExistsCondition extends AnyNestedCondition {
|
||||
* <artifactId>rt</artifactId>
|
||||
* </pre>
|
||||
*/
|
||||
@ConditionalOnClass(name = "com.sun.xml.ws.transport.http.HttpAdapter")
|
||||
@ConditionalOnClass(name = HTTP_ADAPTER_JAVA_8)
|
||||
static class OnJava11 {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.kodgemisi.soaplogger;
|
||||
|
||||
import com.sun.xml.ws.transport.http.client.HttpTransportPipe;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
@@ -9,6 +8,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -32,7 +32,7 @@ public class SoapLoggerAutoConfiguration {
|
||||
*
|
||||
* @see <a href="https://stackoverflow.com/a/43544608/878361">https://stackoverflow.com/a/43544608/878361</a>
|
||||
*/
|
||||
private static final Logger LOGGER = Logger.getLogger(HttpTransportPipe.class.getName());
|
||||
private static Logger LOGGER;
|
||||
|
||||
private final SoapLoggerProperties properties;
|
||||
|
||||
@@ -43,15 +43,14 @@ public class SoapLoggerAutoConfiguration {
|
||||
return args -> {
|
||||
log.debug("Configuring WS Logger...");
|
||||
|
||||
final Class<?> aClass = getHttpAdapterClass();
|
||||
final Field field = aClass.getField("dump_threshold");
|
||||
field.set(null, properties.getDumpThreshold());
|
||||
|
||||
final WsLogHandler handler = wsLogHandler.orElse(wsLogHandler());
|
||||
LOGGER.setLevel(Level.FINER); // The level have to be FINER in order the dump to work!
|
||||
LOGGER.addHandler(handler);
|
||||
|
||||
// https://github.com/javaee/metro-jax-ws/issues/1237#issuecomment-439302776
|
||||
System.setProperty("javax.xml.soap.SAAJMetaFactory", "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
|
||||
|
||||
com.sun.xml.ws.transport.http.HttpAdapter.dump_threshold = properties.getDumpThreshold();
|
||||
|
||||
log.trace("WS Logger is configured with following configuration: handler -> {} properties: {}", handler.getClass().getCanonicalName(), properties);
|
||||
};
|
||||
}
|
||||
@@ -60,4 +59,25 @@ public class SoapLoggerAutoConfiguration {
|
||||
return properties.isUseTandemLogger() ? new WsRequestResponseTandemLogger() : new WsLogHandler();
|
||||
}
|
||||
|
||||
private Class<?> getHttpAdapterClass() {
|
||||
try {
|
||||
// Comes from Java 8 rt.jar
|
||||
//System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
|
||||
LOGGER = Logger.getLogger("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe");
|
||||
return Class.forName("com.sun.xml.internal.ws.transport.http.HttpAdapter");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
try {
|
||||
// https://github.com/javaee/metro-jax-ws/issues/1237#issuecomment-439302776
|
||||
System.setProperty("javax.xml.soap.SAAJMetaFactory", "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
|
||||
//System.setProperty("com.sun.xml.ws.transport.http.HttpTransportPipe.dump", "true");
|
||||
LOGGER = Logger.getLogger("com.sun.xml.ws.transport.http.HttpTransportPipe");
|
||||
return Class.forName("com.sun.xml.ws.transport.http.HttpAdapter");
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new IllegalStateException("Neither com.sun.xml.ws.transport.http.HttpAdapter nor com.sun.xml.internal.ws.transport.http.HttpAdapter class is on the classpath!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user