diff --git a/src/main/asciidoc/dataobjects.adoc b/src/main/asciidoc/dataobjects.adoc index fb629450d91..6ac83206caf 100644 --- a/src/main/asciidoc/dataobjects.adoc +++ b/src/main/asciidoc/dataobjects.adoc @@ -1,30 +1,5 @@ = Cheatsheets -[[DeliveryOptions]] -== DeliveryOptions - -++++ - Delivery options are used to configure message delivery. -

- Delivery options allow to configure delivery timeout and message codec name, and to provide any headers - that you wish to send with the message. -++++ -''' - -[cols=">25%,^25%,50%"] -[frame="topbot"] -|=== -^|Name | Type ^| Description -|[[codecName]]`codecName`|`String`| -+++ -Set the codec name. -+++ -|[[sendTimeout]]`sendTimeout`|`Number (long)`| -+++ -Set the send timeout. -+++ -|=== - [[NetworkOptions]] == NetworkOptions @@ -55,6 +30,31 @@ Set the value of traffic class +++ |=== +[[DeliveryOptions]] +== DeliveryOptions + +++++ + Delivery options are used to configure message delivery. +

+ Delivery options allow to configure delivery timeout and message codec name, and to provide any headers + that you wish to send with the message. +++++ +''' + +[cols=">25%,^25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[codecName]]`codecName`|`String`| ++++ +Set the codec name. ++++ +|[[sendTimeout]]`sendTimeout`|`Number (long)`| ++++ +Set the send timeout. ++++ +|=== + [[OpenOptions]] == OpenOptions @@ -717,6 +717,25 @@ Set whether Netty pooled buffers are enabled +++ |=== +[[MetricsOptions]] +== MetricsOptions + +++++ + Vert.x metrics base configuration, this class can be extended by provider implementations to configure + those specific implementations. +++++ +''' + +[cols=">25%,^25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[enabled]]`enabled`|`Boolean`| ++++ +Set whether metrics will be enabled on the Vert.x instance. ++++ +|=== + [[ClientOptionsBase]] == ClientOptionsBase @@ -828,25 +847,6 @@ Set whether Netty pooled buffers are enabled +++ |=== -[[MetricsOptions]] -== MetricsOptions - -++++ - Vert.x metrics base configuration, this class can be extended by provider implementations to configure - those specific implementations. -++++ -''' - -[cols=">25%,^25%,50%"] -[frame="topbot"] -|=== -^|Name | Type ^| Description -|[[enabled]]`enabled`|`Boolean`| -+++ -Set whether metrics will be enabled on the Vert.x instance. -+++ -|=== - [[DeploymentOptions]] == DeploymentOptions @@ -1125,11 +1125,11 @@ Set the websocket subprotocols supported by the server. +++ |=== -[[HttpClientOptions]] -== HttpClientOptions +[[EventBusOptions]] +== EventBusOptions ++++ - Options describing how an link will make connections. + Options to configure the event bus. ++++ ''' @@ -1137,19 +1137,43 @@ Set the websocket subprotocols supported by the server. [frame="topbot"] |=== ^|Name | Type ^| Description -|[[alpnVersions]]`alpnVersions`|`Array of link:enums.html#HttpVersion[HttpVersion]`| +|[[acceptBacklog]]`acceptBacklog`|`Number (int)`| +++ -Set the list of protocol versions to provide to the server during the Application-Layer Protocol Negotiatiation. - When the list is empty, the client provides a best effort list according to link: - -

+Set the accept back log. ++++ +|[[clientAuth]]`clientAuth`|`link:enums.html#ClientAuth[ClientAuth]`| ++++ +Set whether client auth is required ++++ +|[[clusterPingInterval]]`clusterPingInterval`|`Number (long)`| ++++ +Set the value of cluster ping interval, in ms. ++++ +|[[clusterPingReplyInterval]]`clusterPingReplyInterval`|`Number (long)`| ++++ +Set the value of cluster ping reply interval, in ms. ++++ +|[[clusterPublicHost]]`clusterPublicHost`|`String`| ++++ +Set the public facing hostname to be used for clustering. + Sometimes, e.g. when running on certain clouds, the local address the server listens on for clustering is + not the same address that other nodes connect to it at, as the OS / cloud infrastructure does some kind of + proxying. If this is the case you can specify a public hostname which is different from the hostname the + server listens at. +

+ The default value is null which means use the same as the cluster hostname. ++++ +|[[clusterPublicPort]]`clusterPublicPort`|`Number (int)`| ++++ +See link for an explanation. ++++ +|[[clustered]]`clustered`|`Boolean`| ++++ +Sets whether or not the event bus is clustered. +++ |[[connectTimeout]]`connectTimeout`|`Number (int)`| +++ -Set the connect timeout +Sets the connect timeout +++ |[[crlPaths]]`crlPaths`|`Array of String`| +++ @@ -1159,14 +1183,6 @@ Add a CRL path +++ Add a CRL value +++ -|[[defaultHost]]`defaultHost`|`String`| -+++ -Set the default host name to be used by this client in requests if none is provided when making the request. -+++ -|[[defaultPort]]`defaultPort`|`Number (int)`| -+++ -Set the default port to be used by this client in requests if none is provided when making the request. -+++ |[[enabledCipherSuites]]`enabledCipherSuites`|`Array of String`| +++ Add an enabled cipher suite @@ -1175,45 +1191,19 @@ Add an enabled cipher suite +++ Add an enabled SSL/TLS protocols +++ -|[[h2cUpgrade]]`h2cUpgrade`|`Boolean`| +|[[host]]`host`|`String`| +++ -Set to true when an h2c connection is established using an HTTP/1.1 upgrade request, and false - when an h2c connection is established directly (with prior knowledge). +Sets the host. +++ |[[idleTimeout]]`idleTimeout`|`Number (int)`| +++ Set the idle timeout, in seconds. zero means don't timeout. This determines if a connection will timeout and be closed if no data is received within the timeout. +++ -|[[initialSettings]]`initialSettings`|`link:dataobjects.html#Http2Settings[Http2Settings]`| -+++ -Set the HTTP/2 connection settings immediatly sent by to the server when the client connects. -+++ -|[[keepAlive]]`keepAlive`|`Boolean`| -+++ -Set whether keep alive is enabled on the client -+++ |[[keyStoreOptions]]`keyStoreOptions`|`link:dataobjects.html#JksOptions[JksOptions]`| +++ Set the key/cert options in jks format, aka Java keystore. +++ -|[[maxChunkSize]]`maxChunkSize`|`Number (int)`| -+++ -Set the maximum HTTP chunk size -+++ -|[[maxPoolSize]]`maxPoolSize`|`Number (int)`| -+++ -Set the maximum pool size for connections -+++ -|[[maxWaitQueueSize]]`maxWaitQueueSize`|`Number (int)`| -+++ -Set the maximum requests allowed in the wait queue, any requests beyond the max size will result in - a ConnectionPoolTooBusyException. If the value is set to a negative number then the queue will be unbounded. -+++ -|[[maxWebsocketFrameSize]]`maxWebsocketFrameSize`|`Number (int)`| -+++ -Set the max websocket frame size -+++ |[[pemKeyCertOptions]]`pemKeyCertOptions`|`link:dataobjects.html#PemKeyCertOptions[PemKeyCertOptions]`| +++ Set the key/cert store options in pem format. @@ -1230,18 +1220,22 @@ Set the key/cert options in pfx format. +++ Set the trust options in pfx format +++ -|[[pipelining]]`pipelining`|`Boolean`| -+++ -Set whether pipe-lining is enabled on the client -+++ -|[[protocolVersion]]`protocolVersion`|`link:enums.html#HttpVersion[HttpVersion]`| +|[[port]]`port`|`Number (int)`| +++ -Set the protocol version. +Sets the port. +++ |[[receiveBufferSize]]`receiveBufferSize`|`Number (int)`| +++ Set the TCP receive buffer size +++ +|[[reconnectAttempts]]`reconnectAttempts`|`Number (int)`| ++++ +Sets the value of reconnect attempts. ++++ +|[[reconnectInterval]]`reconnectInterval`|`Number (long)`| ++++ +Set the reconnect interval. ++++ |[[reuseAddress]]`reuseAddress`|`Boolean`| +++ Set the value of reuse address @@ -1276,16 +1270,12 @@ Set the value of traffic class +++ |[[trustAll]]`trustAll`|`Boolean`| +++ -Set whether all server certificates should be trusted +Set whether all server certificates should be trusted. +++ |[[trustStoreOptions]]`trustStoreOptions`|`link:dataobjects.html#JksOptions[JksOptions]`| +++ Set the trust options in jks format, aka Java trustore +++ -|[[tryUseCompression]]`tryUseCompression`|`Boolean`| -+++ -Set whether compression is enabled -+++ |[[useAlpn]]`useAlpn`|`Boolean`| +++ Set the ALPN usage. @@ -1294,10 +1284,6 @@ Set the ALPN usage. +++ Set whether Netty pooled buffers are enabled +++ -|[[verifyHost]]`verifyHost`|`Boolean`| -+++ -Set whether hostname verification is enabled -+++ |=== [[DatagramSocketOptions]] @@ -1350,11 +1336,11 @@ Set the value of traffic class +++ |=== -[[EventBusOptions]] -== EventBusOptions +[[HttpClientOptions]] +== HttpClientOptions ++++ - Options to configure the event bus. + Options describing how an link will make connections. ++++ ''' @@ -1362,43 +1348,19 @@ Set the value of traffic class [frame="topbot"] |=== ^|Name | Type ^| Description -|[[acceptBacklog]]`acceptBacklog`|`Number (int)`| -+++ -Set the accept back log. -+++ -|[[clientAuth]]`clientAuth`|`link:enums.html#ClientAuth[ClientAuth]`| -+++ -Set whether client auth is required -+++ -|[[clusterPingInterval]]`clusterPingInterval`|`Number (long)`| -+++ -Set the value of cluster ping interval, in ms. -+++ -|[[clusterPingReplyInterval]]`clusterPingReplyInterval`|`Number (long)`| -+++ -Set the value of cluster ping reply interval, in ms. -+++ -|[[clusterPublicHost]]`clusterPublicHost`|`String`| -+++ -Set the public facing hostname to be used for clustering. - Sometimes, e.g. when running on certain clouds, the local address the server listens on for clustering is - not the same address that other nodes connect to it at, as the OS / cloud infrastructure does some kind of - proxying. If this is the case you can specify a public hostname which is different from the hostname the - server listens at. -

- The default value is null which means use the same as the cluster hostname. -+++ -|[[clusterPublicPort]]`clusterPublicPort`|`Number (int)`| -+++ -See link for an explanation. -+++ -|[[clustered]]`clustered`|`Boolean`| +|[[alpnVersions]]`alpnVersions`|`Array of link:enums.html#HttpVersion[HttpVersion]`| +++ -Sets whether or not the event bus is clustered. +Set the list of protocol versions to provide to the server during the Application-Layer Protocol Negotiatiation. + When the list is empty, the client provides a best effort list according to link: + +

+++ |[[connectTimeout]]`connectTimeout`|`Number (int)`| +++ -Sets the connect timeout +Set the connect timeout +++ |[[crlPaths]]`crlPaths`|`Array of String`| +++ @@ -1408,6 +1370,14 @@ Add a CRL path +++ Add a CRL value +++ +|[[defaultHost]]`defaultHost`|`String`| ++++ +Set the default host name to be used by this client in requests if none is provided when making the request. ++++ +|[[defaultPort]]`defaultPort`|`Number (int)`| ++++ +Set the default port to be used by this client in requests if none is provided when making the request. ++++ |[[enabledCipherSuites]]`enabledCipherSuites`|`Array of String`| +++ Add an enabled cipher suite @@ -1416,19 +1386,45 @@ Add an enabled cipher suite +++ Add an enabled SSL/TLS protocols +++ -|[[host]]`host`|`String`| +|[[h2cUpgrade]]`h2cUpgrade`|`Boolean`| +++ -Sets the host. +Set to true when an h2c connection is established using an HTTP/1.1 upgrade request, and false + when an h2c connection is established directly (with prior knowledge). +++ |[[idleTimeout]]`idleTimeout`|`Number (int)`| +++ Set the idle timeout, in seconds. zero means don't timeout. This determines if a connection will timeout and be closed if no data is received within the timeout. +++ +|[[initialSettings]]`initialSettings`|`link:dataobjects.html#Http2Settings[Http2Settings]`| ++++ +Set the HTTP/2 connection settings immediatly sent by to the server when the client connects. ++++ +|[[keepAlive]]`keepAlive`|`Boolean`| ++++ +Set whether keep alive is enabled on the client ++++ |[[keyStoreOptions]]`keyStoreOptions`|`link:dataobjects.html#JksOptions[JksOptions]`| +++ Set the key/cert options in jks format, aka Java keystore. +++ +|[[maxChunkSize]]`maxChunkSize`|`Number (int)`| ++++ +Set the maximum HTTP chunk size ++++ +|[[maxPoolSize]]`maxPoolSize`|`Number (int)`| ++++ +Set the maximum pool size for connections ++++ +|[[maxWaitQueueSize]]`maxWaitQueueSize`|`Number (int)`| ++++ +Set the maximum requests allowed in the wait queue, any requests beyond the max size will result in + a ConnectionPoolTooBusyException. If the value is set to a negative number then the queue will be unbounded. ++++ +|[[maxWebsocketFrameSize]]`maxWebsocketFrameSize`|`Number (int)`| ++++ +Set the max websocket frame size ++++ |[[pemKeyCertOptions]]`pemKeyCertOptions`|`link:dataobjects.html#PemKeyCertOptions[PemKeyCertOptions]`| +++ Set the key/cert store options in pem format. @@ -1445,21 +1441,17 @@ Set the key/cert options in pfx format. +++ Set the trust options in pfx format +++ -|[[port]]`port`|`Number (int)`| -+++ -Sets the port. -+++ -|[[receiveBufferSize]]`receiveBufferSize`|`Number (int)`| +|[[pipelining]]`pipelining`|`Boolean`| +++ -Set the TCP receive buffer size +Set whether pipe-lining is enabled on the client +++ -|[[reconnectAttempts]]`reconnectAttempts`|`Number (int)`| +|[[protocolVersion]]`protocolVersion`|`link:enums.html#HttpVersion[HttpVersion]`| +++ -Sets the value of reconnect attempts. +Set the protocol version. +++ -|[[reconnectInterval]]`reconnectInterval`|`Number (long)`| +|[[receiveBufferSize]]`receiveBufferSize`|`Number (int)`| +++ -Set the reconnect interval. +Set the TCP receive buffer size +++ |[[reuseAddress]]`reuseAddress`|`Boolean`| +++ @@ -1495,12 +1487,16 @@ Set the value of traffic class +++ |[[trustAll]]`trustAll`|`Boolean`| +++ -Set whether all server certificates should be trusted. +Set whether all server certificates should be trusted +++ |[[trustStoreOptions]]`trustStoreOptions`|`link:dataobjects.html#JksOptions[JksOptions]`| +++ Set the trust options in jks format, aka Java trustore +++ +|[[tryUseCompression]]`tryUseCompression`|`Boolean`| ++++ +Set whether compression is enabled ++++ |[[useAlpn]]`useAlpn`|`Boolean`| +++ Set the ALPN usage. @@ -1509,6 +1505,10 @@ Set the ALPN usage. +++ Set whether Netty pooled buffers are enabled +++ +|[[verifyHost]]`verifyHost`|`Boolean`| ++++ +Set whether hostname verification is enabled ++++ |=== [[PemTrustOptions]] diff --git a/src/main/java/io/vertx/core/impl/launcher/VertxCommandLauncher.java b/src/main/java/io/vertx/core/impl/launcher/VertxCommandLauncher.java index 2e4ef2b7cee..9b37a711823 100644 --- a/src/main/java/io/vertx/core/impl/launcher/VertxCommandLauncher.java +++ b/src/main/java/io/vertx/core/impl/launcher/VertxCommandLauncher.java @@ -375,6 +375,7 @@ public void dispatch(Object main, String[] args) { // By default this method retrieve the value from the 'Main-Verticle' Manifest header. However it can be overridden. String verticle = getMainVerticle(); + String command = getCommandFromManifest(); if (verticle != null) { // We have a main verticle, append it to the arg list and execute the default command (run) String[] newArgs = new String[args.length + 1]; @@ -382,9 +383,12 @@ public void dispatch(Object main, String[] args) { System.arraycopy(args, 0, newArgs, 1, args.length); execute(getDefaultCommand(), newArgs); return; + } else if (command != null) { + execute(command, args); + return; } - // Fall backs + // Fallbacks if (args.length == 0) { printGlobalUsage(); } else { @@ -401,6 +405,14 @@ public void dispatch(Object main, String[] args) { * @return the default command if specified in the {@code MANIFEST}, "run" if not found. */ protected String getDefaultCommand() { + String fromManifest = getCommandFromManifest(); + if (fromManifest == null) { + return "run"; + } + return fromManifest; + } + + protected String getCommandFromManifest() { try { Enumeration resources = RunCommand.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { @@ -420,7 +432,7 @@ protected String getDefaultCommand() { } catch (IOException e) { throw new IllegalStateException(e.getMessage()); } - return "run"; + return null; } /** diff --git a/src/test/java/io/vertx/test/core/LauncherTest.java b/src/test/java/io/vertx/test/core/LauncherTest.java index 13b7ea228ae..7cb198da487 100644 --- a/src/test/java/io/vertx/test/core/LauncherTest.java +++ b/src/test/java/io/vertx/test/core/LauncherTest.java @@ -220,6 +220,54 @@ public void testRunVerticleWithMainVerticleInManifestWithCustomCommand() throws waitUntil(() -> HelloCommand.called); } + @Test + public void testRunVerticleWithoutMainVerticleInManifestButWithCustomCommand() throws Exception { + // Copy the right manifest + File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher-Default-Command.MF"); + if (!manifest.isFile()) { + throw new IllegalStateException("Cannot find the MANIFEST-Default-Command.MF file"); + } + File target = new File("target/test-classes/META-INF/MANIFEST.MF"); + Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); + + Launcher launcher = new Launcher(); + HelloCommand.called = false; + String[] args = {"--name=vert.x"}; + launcher.dispatch(args); + waitUntil(() -> HelloCommand.called); + } + + @Test + public void testRunWithOverriddenDefaultCommand() throws Exception { + // Copy the right manifest + File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher-hello.MF"); + if (!manifest.isFile()) { + throw new IllegalStateException("Cannot find the MANIFEST-Launcher-hello.MF file"); + } + File target = new File("target/test-classes/META-INF/MANIFEST.MF"); + Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); + + HelloCommand.called = false; + String[] args = {"run", TestVerticle.class.getName(), "--name=vert.x"}; + Launcher.main(args); + waitUntil(() -> TestVerticle.instanceCount.get() == 1); + } + + @Test + public void testRunWithOverriddenDefaultCommandRequiringArgs() throws Exception { + // Copy the right manifest + File manifest = new File("target/test-classes/META-INF/MANIFEST-Launcher-run.MF"); + if (!manifest.isFile()) { + throw new IllegalStateException("Cannot find the MANIFEST-Launcher-run.MF file"); + } + File target = new File("target/test-classes/META-INF/MANIFEST.MF"); + Files.copy(manifest.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING); + + String[] args = {TestVerticle.class.getName()}; + Launcher.main(args); + waitUntil(() -> TestVerticle.instanceCount.get() == 1); + } + @Test public void testRunVerticleWithExtendedMainVerticleNoArgs() throws Exception { @@ -366,7 +414,7 @@ private void testConfigureFromSystemProperties(boolean clustered) throws Excepti VertxOptions opts = launcher.getVertxOptions(); assertEquals(123, opts.getEventLoopPoolSize(), 0); - assertEquals(123767667l, opts.getMaxEventLoopExecuteTime()); + assertEquals(123767667L, opts.getMaxEventLoopExecuteTime()); assertEquals(true, opts.getMetricsOptions().isEnabled()); assertEquals("somegroup", opts.getHAGroup()); diff --git a/src/test/resources/META-INF/MANIFEST-Launcher-Default-Command.MF b/src/test/resources/META-INF/MANIFEST-Launcher-Default-Command.MF new file mode 100644 index 00000000000..08fce72cdbb --- /dev/null +++ b/src/test/resources/META-INF/MANIFEST-Launcher-Default-Command.MF @@ -0,0 +1,2 @@ +Main-Class: io.vertx.core.Launcher +Main-Command: hello diff --git a/src/test/resources/META-INF/MANIFEST-Launcher-run.MF b/src/test/resources/META-INF/MANIFEST-Launcher-run.MF new file mode 100644 index 00000000000..4a09047ba1f --- /dev/null +++ b/src/test/resources/META-INF/MANIFEST-Launcher-run.MF @@ -0,0 +1,2 @@ +Main-Class: io.vertx.core.Launcher +Main-Command: run