diff --git a/vertx-core/src/main/java/io/vertx/core/Vertx.java b/vertx-core/src/main/java/io/vertx/core/Vertx.java index 18a127b7c1d..789c9552eb4 100644 --- a/vertx-core/src/main/java/io/vertx/core/Vertx.java +++ b/vertx-core/src/main/java/io/vertx/core/Vertx.java @@ -21,7 +21,6 @@ import io.vertx.core.http.*; import io.vertx.core.impl.VertxImpl; import io.vertx.core.internal.ContextInternal; -import io.vertx.core.impl.VertxBuilder; import io.vertx.core.dns.impl.DnsAddressResolverProvider; import io.vertx.core.internal.VertxBootstrap; import io.vertx.core.metrics.Measured; diff --git a/vertx-core/src/main/java/io/vertx/core/impl/VertxBuilder.java b/vertx-core/src/main/java/io/vertx/core/impl/VertxBootstrapImpl.java similarity index 90% rename from vertx-core/src/main/java/io/vertx/core/impl/VertxBuilder.java rename to vertx-core/src/main/java/io/vertx/core/impl/VertxBootstrapImpl.java index d657c74e1a7..39e3e3a8c99 100644 --- a/vertx-core/src/main/java/io/vertx/core/impl/VertxBuilder.java +++ b/vertx-core/src/main/java/io/vertx/core/impl/VertxBootstrapImpl.java @@ -38,13 +38,13 @@ import java.util.List; /** - * Vertx builder for creating vertx instances with SPI overrides. + * Bootstrap implementation. * * @author Julien Viet */ -public class VertxBuilder implements VertxBootstrap { +public class VertxBootstrapImpl implements VertxBootstrap { - private static final Logger log = LoggerFactory.getLogger(VertxBuilder.class); + private static final Logger log = LoggerFactory.getLogger(VertxBootstrapImpl.class); private VertxOptions options; private JsonObject config; @@ -60,16 +60,16 @@ public class VertxBuilder implements VertxBootstrap { private VertxMetrics metrics; private FileResolver fileResolver; - public VertxBuilder(JsonObject config) { + public VertxBootstrapImpl(JsonObject config) { this(new VertxOptions(config)); this.config = config; } - public VertxBuilder(VertxOptions options) { + public VertxBootstrapImpl(VertxOptions options) { this.options = options; } - public VertxBuilder() { + public VertxBootstrapImpl() { this(new VertxOptions()); } @@ -102,7 +102,7 @@ public Transport transport() { * @param transport the transport * @return this builder instance */ - public VertxBuilder transport(Transport transport) { + public VertxBootstrapImpl transport(Transport transport) { this.transport = transport; return this; } @@ -111,7 +111,7 @@ public ClusterManager clusterManager() { return clusterManager; } - public VertxBuilder clusterManager(ClusterManager clusterManager) { + public VertxBootstrapImpl clusterManager(ClusterManager clusterManager) { this.clusterManager = clusterManager; return this; } @@ -121,7 +121,7 @@ public VertxMetricsFactory metricsFactory() { return metricsFactory; } - public VertxBuilder metricsFactory(VertxMetricsFactory factory) { + public VertxBootstrapImpl metricsFactory(VertxMetricsFactory factory) { this.metricsFactory = factory; return this; } @@ -130,7 +130,7 @@ public NodeSelector clusterNodeSelector() { return clusterNodeSelector; } - public VertxBuilder clusterNodeSelector(NodeSelector selector) { + public VertxBootstrapImpl clusterNodeSelector(NodeSelector selector) { this.clusterNodeSelector = selector; return this; } @@ -140,7 +140,7 @@ public VertxTracerFactory tracerFactory() { return tracerFactory; } - public VertxBuilder tracerFactory(VertxTracerFactory factory) { + public VertxBootstrapImpl tracerFactory(VertxTracerFactory factory) { this.tracerFactory = factory; return this; } @@ -149,7 +149,7 @@ public VertxTracer tracer() { return tracer; } - public VertxBuilder tracer(VertxTracer tracer) { + public VertxBootstrapImpl tracer(VertxTracer tracer) { this.tracer = tracer; return this; } @@ -158,7 +158,7 @@ public VertxMetrics metrics() { return metrics; } - public VertxBuilder metrics(VertxMetrics metrics) { + public VertxBootstrapImpl metrics(VertxMetrics metrics) { this.metrics = metrics; return this; } @@ -175,7 +175,7 @@ public FileResolver fileResolver() { * @param resolver the file resolver * @return this builder instance */ - public VertxBuilder fileResolver(FileResolver resolver) { + public VertxBootstrapImpl fileResolver(FileResolver resolver) { this.fileResolver = resolver; return this; } @@ -184,7 +184,7 @@ public VertxThreadFactory threadFactory() { return threadFactory; } - public VertxBuilder threadFactory(VertxThreadFactory factory) { + public VertxBootstrapImpl threadFactory(VertxThreadFactory factory) { this.threadFactory = factory; return this; } @@ -193,7 +193,7 @@ public ExecutorServiceFactory executorServiceFactory() { return executorServiceFactory; } - public VertxBuilder executorServiceFactory(ExecutorServiceFactory factory) { + public VertxBootstrapImpl executorServiceFactory(ExecutorServiceFactory factory) { this.executorServiceFactory = factory; return this; } @@ -241,7 +241,7 @@ public Future clusteredVertx() { * Initialize the service providers. * @return this builder instance */ - public VertxBuilder init() { + public VertxBootstrapImpl init() { initTransport(); initMetrics(); initTracing(); diff --git a/vertx-core/src/main/java/io/vertx/core/internal/VertxBootstrap.java b/vertx-core/src/main/java/io/vertx/core/internal/VertxBootstrap.java index 0f7762e193d..7b601f448a3 100644 --- a/vertx-core/src/main/java/io/vertx/core/internal/VertxBootstrap.java +++ b/vertx-core/src/main/java/io/vertx/core/internal/VertxBootstrap.java @@ -13,20 +13,27 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.spi.ExecutorServiceFactory; import io.vertx.core.spi.VertxMetricsFactory; import io.vertx.core.spi.VertxThreadFactory; import io.vertx.core.spi.VertxTracerFactory; import io.vertx.core.spi.cluster.ClusterManager; -import io.vertx.core.spi.cluster.NodeSelector; import io.vertx.core.spi.file.FileResolver; import io.vertx.core.spi.transport.Transport; +/** + * Vertx bootstrap for creating vertx instances with SPI overrides. + * + * @author Julien Viet + */ public interface VertxBootstrap { + /** + * @return a new fresh to use bootstrap + */ static VertxBootstrap create() { - return new VertxBuilder(); + return new VertxBootstrapImpl(); } /** @@ -117,7 +124,7 @@ static VertxBootstrap create() { * @param transport the transport * @return this builder instance */ - VertxBuilder transport(Transport transport); + VertxBootstrapImpl transport(Transport transport); /** * @return the cluster manager to use diff --git a/vertx-core/src/main/java/io/vertx/core/spi/VertxMetricsFactory.java b/vertx-core/src/main/java/io/vertx/core/spi/VertxMetricsFactory.java index edee7ecf38b..b4c6e38aa3a 100644 --- a/vertx-core/src/main/java/io/vertx/core/spi/VertxMetricsFactory.java +++ b/vertx-core/src/main/java/io/vertx/core/spi/VertxMetricsFactory.java @@ -12,7 +12,7 @@ package io.vertx.core.spi; import io.vertx.core.VertxOptions; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.internal.VertxBootstrap; import io.vertx.core.json.JsonObject; import io.vertx.core.metrics.MetricsOptions; @@ -27,7 +27,7 @@ public interface VertxMetricsFactory extends VertxServiceProvider { @Override default void init(VertxBootstrap bootstrap) { - VertxBuilder builder = (VertxBuilder) bootstrap; + VertxBootstrapImpl builder = (VertxBootstrapImpl) bootstrap; if (builder.metrics() == null) { VertxOptions vertxOptions = builder.options(); builder.metrics(metrics(vertxOptions)); diff --git a/vertx-core/src/main/java/io/vertx/core/spi/VertxTracerFactory.java b/vertx-core/src/main/java/io/vertx/core/spi/VertxTracerFactory.java index abb8c8cb2dc..0ace198f394 100644 --- a/vertx-core/src/main/java/io/vertx/core/spi/VertxTracerFactory.java +++ b/vertx-core/src/main/java/io/vertx/core/spi/VertxTracerFactory.java @@ -11,7 +11,7 @@ package io.vertx.core.spi; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.internal.VertxBootstrap; import io.vertx.core.json.JsonObject; import io.vertx.core.spi.tracing.VertxTracer; @@ -32,7 +32,7 @@ public interface VertxTracerFactory extends VertxServiceProvider { @Override default void init(VertxBootstrap bootstrap) { - VertxBuilder builder = (VertxBuilder) bootstrap; + VertxBootstrapImpl builder = (VertxBootstrapImpl) bootstrap; if (builder.tracer() == null) { TracingOptions tracingOptions = builder.options().getTracingOptions(); if (tracingOptions == null) { diff --git a/vertx-core/src/test/java/io/vertx/tests/eventbus/CustomNodeSelectorTest.java b/vertx-core/src/test/java/io/vertx/tests/eventbus/CustomNodeSelectorTest.java index 6800b1e25d4..a39a7d5cd67 100644 --- a/vertx-core/src/test/java/io/vertx/tests/eventbus/CustomNodeSelectorTest.java +++ b/vertx-core/src/test/java/io/vertx/tests/eventbus/CustomNodeSelectorTest.java @@ -13,7 +13,7 @@ import io.vertx.core.*; import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.internal.VertxBootstrap; import io.vertx.core.json.JsonObject; import io.vertx.core.spi.cluster.ClusterManager; @@ -46,7 +46,7 @@ public void test() throws Exception { return vertxOptions; }) .map(options -> { - VertxBootstrap factory = ((VertxBuilder)VertxBootstrap.create().options(options).init()).clusterNodeSelector(new CustomNodeSelector()); + VertxBootstrap factory = ((VertxBootstrapImpl)VertxBootstrap.create().options(options).init()).clusterNodeSelector(new CustomNodeSelector()); return factory.clusteredVertx(); }) .collect(collectingAndThen(toList(), Future::all)); diff --git a/vertx-core/src/test/java/io/vertx/tests/eventbus/MessageQueueOnWorkerThreadTest.java b/vertx-core/src/test/java/io/vertx/tests/eventbus/MessageQueueOnWorkerThreadTest.java index 23969e3d712..280819ac94d 100644 --- a/vertx-core/src/test/java/io/vertx/tests/eventbus/MessageQueueOnWorkerThreadTest.java +++ b/vertx-core/src/test/java/io/vertx/tests/eventbus/MessageQueueOnWorkerThreadTest.java @@ -13,7 +13,7 @@ import io.vertx.core.*; import io.vertx.core.eventbus.impl.clustered.Serializer; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.spi.cluster.ClusterManager; import io.vertx.core.spi.cluster.NodeSelector; import io.vertx.core.spi.cluster.RegistrationUpdateEvent; @@ -38,7 +38,7 @@ public class MessageQueueOnWorkerThreadTest extends VertxTestBase { public void setUp() throws Exception { super.setUp(); CustomNodeSelector selector = new CustomNodeSelector(); - VertxBuilder factory = new VertxBuilder().init().clusterNodeSelector(selector); + VertxBootstrapImpl factory = new VertxBootstrapImpl().init().clusterNodeSelector(selector); Future fut = factory.clusteredVertx(); vertx = fut.toCompletionStage().toCompletableFuture().get(); } diff --git a/vertx-core/src/test/java/io/vertx/tests/eventbus/WriteHandlerLookupFailureTest.java b/vertx-core/src/test/java/io/vertx/tests/eventbus/WriteHandlerLookupFailureTest.java index 0801d18a28e..78531e06de6 100644 --- a/vertx-core/src/test/java/io/vertx/tests/eventbus/WriteHandlerLookupFailureTest.java +++ b/vertx-core/src/test/java/io/vertx/tests/eventbus/WriteHandlerLookupFailureTest.java @@ -15,7 +15,7 @@ import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.eventbus.MessageProducer; -import io.vertx.core.impl.VertxBuilder; +import io.vertx.core.impl.VertxBootstrapImpl; import io.vertx.core.internal.VertxBootstrap; import io.vertx.core.spi.cluster.NodeSelector; import io.vertx.core.spi.cluster.impl.DefaultNodeSelector; @@ -49,7 +49,7 @@ public void selectForPublish(String address, Promise> promise) promise.fail("Not implemented"); } }; - ((VertxBuilder)VertxBootstrap.create().options(options).init()).clusterNodeSelector(nodeSelector).clusteredVertx().onComplete(onSuccess(node -> { + ((VertxBootstrapImpl)VertxBootstrap.create().options(options).init()).clusterNodeSelector(nodeSelector).clusteredVertx().onComplete(onSuccess(node -> { vertx = node; MessageProducer sender = vertx.eventBus().sender("foo"); sender.write("the_string").onComplete(onFailure(err -> {