public interface Vertx extends Measured
The control centre of the Vert.x Core API.<p>
You should normally only use a single instance of this class throughout your application. If you are running in the
Vert.x container an instance will be provided to you.<p>
If you are using Vert.x embedded, you can create an instance using one of the static VertxFactory.newVertx
methods.<p>
This class acts as a factory for TCP/SSL and HTTP/HTTPS servers and clients, SockJS servers, and provides an
instance of the event bus, file system and shared data classes, as well as methods for setting and cancelling
timers.<p>
Instances of this class are thread-safe.<p>
Modifier and Type | Field and Description |
---|---|
static VertxFactory |
factory |
Modifier and Type | Method and Description |
---|---|
boolean |
cancelTimer(long id)
Cancel the timer with the specified
id . |
void |
close()
Stop the eventbus and any resource managed by the eventbus.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Stop the eventbus and any resource managed by the eventbus.
|
static void |
clusteredVertx(VertxOptions options,
Handler<AsyncResult<Vertx>> resultHandler) |
DatagramSocket |
createDatagramSocket(DatagramSocketOptions options) |
DnsClient |
createDnsClient(int port,
String host)
Return the
DnsClient |
HttpClient |
createHttpClient(HttpClientOptions options)
Create a HTTP/HTTPS client
|
HttpServer |
createHttpServer(HttpServerOptions options)
Create an HTTP/HTTPS server
|
NetClient |
createNetClient(NetClientOptions options)
Create a TCP/SSL client
|
NetServer |
createNetServer(NetServerOptions options)
Create a TCP/SSL server
|
static Context |
currentContext()
Gets the current context
|
Set<String> |
deployments() |
void |
deployVerticle(String identifier) |
void |
deployVerticle(String identifier,
DeploymentOptions options) |
void |
deployVerticle(String identifier,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler) |
void |
deployVerticle(String identifier,
Handler<AsyncResult<String>> completionHandler) |
void |
deployVerticle(Verticle verticle) |
void |
deployVerticle(Verticle verticle,
DeploymentOptions options) |
void |
deployVerticle(Verticle verticle,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler) |
void |
deployVerticle(Verticle verticle,
Handler<AsyncResult<String>> completionHandler) |
EventBus |
eventBus()
The event bus
|
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
Handler<AsyncResult<T>> resultHandler) |
FileSystem |
fileSystem()
The File system object
|
Context |
getOrCreateContext()
Gets the current context, or creates one if there isn’t one
|
TimeoutStream |
periodicStream(long delay)
Returns a periodic timer as a read stream.
|
void |
registerVerticleFactory(VerticleFactory factory) |
void |
runOnContext(Handler<Void> action)
Put the handler on the event queue for the current loop (or worker context) so it will be run asynchronously ASAP after this event has
been processed
|
long |
setPeriodic(long delay,
Handler<Long> handler)
Set a periodic timer to fire every
delay milliseconds, at which point handler will be called with
the id of the timer. |
long |
setTimer(long delay,
Handler<Long> handler)
Set a one-shot timer to fire after
delay milliseconds, at which point handler will be called with
the id of the timer. |
SharedData |
sharedData()
The shared data object
|
TimeoutStream |
timerStream(long delay)
Returns a one-shot timer as a read stream.
|
void |
undeployVerticle(String deploymentID) |
void |
undeployVerticle(String deploymentID,
Handler<AsyncResult<Void>> completionHandler) |
void |
unregisterVerticleFactory(VerticleFactory factory) |
Set<VerticleFactory> |
verticleFactories() |
static Vertx |
vertx() |
static Vertx |
vertx(VertxOptions options) |
metricBaseName, metrics
static final VertxFactory factory
static Vertx vertx()
static Vertx vertx(VertxOptions options)
static void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> resultHandler)
static Context currentContext()
Gets the current context
Context getOrCreateContext()
Gets the current context, or creates one if there isn’t one
NetServer createNetServer(NetServerOptions options)
Create a TCP/SSL server
NetClient createNetClient(NetClientOptions options)
Create a TCP/SSL client
HttpServer createHttpServer(HttpServerOptions options)
Create an HTTP/HTTPS server
HttpClient createHttpClient(HttpClientOptions options)
Create a HTTP/HTTPS client
DatagramSocket createDatagramSocket(DatagramSocketOptions options)
FileSystem fileSystem()
The File system object
EventBus eventBus()
The event bus
SharedData sharedData()
The shared data object
long setTimer(long delay, Handler<Long> handler)
Set a one-shot timer to fire after delay
milliseconds, at which point handler
will be called with
the id of the timer.
TimeoutStream timerStream(long delay)
Returns a one-shot timer as a read stream. The timer will be fired after delay
milliseconds after
the ReadStream.handler(io.vertx.core.Handler<T>)
has been called.
long setPeriodic(long delay, Handler<Long> handler)
Set a periodic timer to fire every delay
milliseconds, at which point handler
will be called with
the id of the timer.
TimeoutStream periodicStream(long delay)
Returns a periodic timer as a read stream. The timer will be fired every delay
milliseconds after
the ReadStream.handler(io.vertx.core.Handler<T>)
has been called.
boolean cancelTimer(long id)
Cancel the timer with the specified id
. Returns true if the timer was successfully cancelled, or
false
if the timer does not exist.
void runOnContext(Handler<Void> action)
Put the handler on the event queue for the current loop (or worker context) so it will be run asynchronously ASAP after this event has been processed
void close()
Stop the eventbus and any resource managed by the eventbus.
void close(Handler<AsyncResult<Void>> completionHandler)
Stop the eventbus and any resource managed by the eventbus.
void deployVerticle(Verticle verticle)
void deployVerticle(Verticle verticle, Handler<AsyncResult<String>> completionHandler)
void deployVerticle(Verticle verticle, DeploymentOptions options)
void deployVerticle(Verticle verticle, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
void deployVerticle(String identifier)
void deployVerticle(String identifier, Handler<AsyncResult<String>> completionHandler)
void deployVerticle(String identifier, DeploymentOptions options)
void deployVerticle(String identifier, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
void undeployVerticle(String deploymentID)
void undeployVerticle(String deploymentID, Handler<AsyncResult<Void>> completionHandler)
void registerVerticleFactory(VerticleFactory factory)
void unregisterVerticleFactory(VerticleFactory factory)
<T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler)
Set<VerticleFactory> verticleFactories()
Copyright © 2014. All Rights Reserved.