Skip to content

Commit

Permalink
Merge pull request quarkusio#3951 from cescoffier/features/vertx-exte…
Browse files Browse the repository at this point in the history
…nsion-improvements

Various improvement around the Vert.x extensions
  • Loading branch information
gsmet authored Sep 20, 2019
2 parents d51d17c + 854ff9f commit bd3e6d7
Show file tree
Hide file tree
Showing 69 changed files with 1,557 additions and 284 deletions.
3 changes: 2 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ stages:

- template: ci-templates/native-build-steps.yaml
parameters:
timeoutInMinutes: 15
timeoutInMinutes: 25
modules:
- resteasy-jackson
- vertx
- vertx-http
- virtual-http
name: http

Expand Down
4 changes: 4 additions & 0 deletions extensions/smallrye-reactive-messaging-amqp/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment</artifactId>
<artifactId>quarkus-vertx-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
4 changes: 0 additions & 4 deletions extensions/smallrye-reactive-messaging-kafka/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-streams-operators</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment</artifactId>
<artifactId>quarkus-vertx-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/smallrye-reactive-messaging-mqtt/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-provider</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/smallrye-reactive-messaging/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-streams-operators</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-core</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand Down
2 changes: 1 addition & 1 deletion extensions/smallrye-reactive-messaging/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
<artifactId>quarkus-vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanContainerBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.IOThreadDetectorBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.substrate.SubstrateConfigBuildItem;
import io.quarkus.netty.deployment.EventLoopSupplierBuildItem;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.vertx.core.runtime.VertxConfiguration;
import io.quarkus.vertx.core.runtime.VertxCoreProducer;
import io.quarkus.vertx.core.runtime.VertxCoreRecorder;
import io.quarkus.vertx.core.runtime.VertxLogDelegateFactory;
import io.quarkus.vertx.core.runtime.config.VertxConfiguration;
import io.vertx.core.Vertx;

class VertxCommonProcessor {
class VertxCoreProcessor {

@BuildStep
SubstrateConfigBuildItem build() {
SubstrateConfigBuildItem build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, VertxLogDelegateFactory.class.getName()));
return SubstrateConfigBuildItem.builder()
.addNativeImageSystemProperty("vertx.disableDnsResolver", "true")
.addNativeImageSystemProperty("vertx.logger-delegate-factory-class-name",
VertxLogDelegateFactory.class.getName())
.addRuntimeInitializedClass("io.vertx.core.http.impl.VertxHttp2ClientUpgradeCodec")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.quarkus.vertx.core.deployment;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.vertx.core.impl.NoStackTraceThrowable;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;

public class VertxLoggingTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(BeanThatLog.class));

@Inject
BeanThatLog bean;

@Test
public void test() {
bean.info();

bean.trace();
}

@ApplicationScoped
static class BeanThatLog {

private final static Logger LOGGER = LoggerFactory.getLogger("verbose-bean");

public void info() {
LOGGER.info("Info");
LOGGER.info("Info with exception", new NoStackTraceThrowable("boom"));
LOGGER.info("Info with parameters {0} {1}", "Quarkus", 1);
LOGGER.info("Info with exception and param {0}", new NoStackTraceThrowable("boom"), "quarkus");
LOGGER.info("Info with exception as last param {0}", "quarkus", new NoStackTraceThrowable("boom"));
LOGGER.info("Info with null as failure", (Throwable) null);
LOGGER.info("Info with null as parameter {0}", (String) null);

// Null message -> NULL
LOGGER.info(null);
}

public void trace() {
LOGGER.trace("Should not be displayed");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;
import io.quarkus.vertx.core.runtime.config.ClusterConfiguration;
import io.quarkus.vertx.core.runtime.config.EventBusConfiguration;
import io.quarkus.vertx.core.runtime.config.VertxConfiguration;
import io.vertx.core.Context;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package io.quarkus.vertx.core.runtime;

import java.util.logging.LogRecord;

import org.jboss.logmanager.Level;
import org.jboss.logmanager.Logger;

import io.vertx.core.spi.logging.LogDelegate;

public class VertxLogDelegate implements LogDelegate {
private final Logger logger;

public VertxLogDelegate(String name) {
this.logger = Logger.getLogger(name);
}

@Override
public boolean isWarnEnabled() {
return logger.isLoggable(Level.WARN);
}

public boolean isInfoEnabled() {
return logger.isLoggable(Level.INFO);
}

public boolean isDebugEnabled() {
return logger.isLoggable(Level.DEBUG);
}

public boolean isTraceEnabled() {
return logger.isLoggable(Level.TRACE);
}

public void fatal(final Object message) {
log(Level.FATAL, message);
}

public void fatal(final Object message, final Throwable t) {
log(Level.FATAL, message, t);
}

public void error(final Object message) {
log(Level.ERROR, message);
}

@Override
public void error(Object message, Object... params) {
log(Level.ERROR, message, null, params);
}

public void error(final Object message, final Throwable t) {
log(Level.ERROR, message, t);
}

@Override
public void error(Object message, Throwable t, Object... params) {
log(Level.ERROR, message, t, params);
}

public void warn(final Object message) {
log(Level.WARN, message);
}

@Override
public void warn(Object message, Object... params) {
log(Level.WARN, message, null, params);
}

public void warn(final Object message, final Throwable t) {
log(Level.WARN, message, t);
}

@Override
public void warn(Object message, Throwable t, Object... params) {
log(Level.WARN, message, t, params);
}

public void info(final Object message) {
log(Level.INFO, message);
}

@Override
public void info(Object message, Object... params) {
log(Level.INFO, message, null, params);
}

public void info(final Object message, final Throwable t) {
log(Level.INFO, message, t);
}

@Override
public void info(Object message, Throwable t, Object... params) {
log(Level.INFO, message, t, params);
}

public void debug(final Object message) {
log(Level.DEBUG, message);
}

@Override
public void debug(Object message, Object... params) {
log(Level.DEBUG, message, null, params);
}

public void debug(final Object message, final Throwable t) {
log(Level.DEBUG, message, t);
}

@Override
public void debug(Object message, Throwable t, Object... params) {
log(Level.DEBUG, message, t, params);
}

public void trace(final Object message) {
log(Level.TRACE, message);
}

@Override
public void trace(Object message, Object... params) {
log(Level.TRACE, message, null, params);
}

public void trace(final Object message, final Throwable t) {
log(Level.TRACE, message, t);
}

@Override
public void trace(Object message, Throwable t, Object... params) {
log(Level.TRACE, message, t, params);
}

private void log(Level level, Object message) {
log(level, message, null);
}

private void log(Level level, Object message, Throwable t, Object... params) {
if (!logger.isLoggable(level)) {
return;
}
String msg = (message == null) ? "NULL" : message.toString();
LogRecord record = new LogRecord(level, msg);
record.setLoggerName(logger.getName());
if (t != null) {
record.setThrown(t);
} else if (params != null && params.length != 0 && params[params.length - 1] instanceof Throwable) {
// The exception may be the last parameters (SLF4J uses this convention).
// As the logger can be used in a SLF4J style, we need to check
record.setThrown((Throwable) params[params.length - 1]);
}
record.setSourceClassName(null);
record.setParameters(params);
logger.log(record);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.vertx.core.runtime;

import io.vertx.core.spi.logging.LogDelegate;
import io.vertx.core.spi.logging.LogDelegateFactory;

public class VertxLogDelegateFactory implements LogDelegateFactory {
@Override
public LogDelegate createDelegate(String name) {
return new VertxLogDelegate(name);
}
}
Loading

0 comments on commit bd3e6d7

Please sign in to comment.