public abstract class Vertx
extends java.lang.Object
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.
If you are using vert.x embedded, you can create an instance using one of the static newVertx
methods.
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.
Constructor and Description |
---|
Vertx() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
cancelTimer(long id)
Cancel the timer with the specified
id . |
abstract HttpClient |
createHttpClient()
Create a HTTP/HTTPS client
|
abstract HttpServer |
createHttpServer()
Create an HTTP/HTTPS server
|
abstract NetClient |
createNetClient()
Create a TCP/SSL client
|
abstract NetServer |
createNetServer()
Create a TCP/SSL server
|
abstract SockJSServer |
createSockJSServer(HttpServer httpServer)
Create a SockJS server that wraps an HTTP server
|
abstract EventBus |
eventBus()
The event bus
|
abstract FileSystem |
fileSystem()
The File system object
|
abstract boolean |
isEventLoop()
Is the current thread an event loop thread?
|
abstract boolean |
isWorker()
Is the current thread an worker thread?
|
static Vertx |
newVertx()
Create a non clustered Vertx instance
|
static Vertx |
newVertx(int port,
java.lang.String hostname)
Create a clustered Vertx instance
|
static Vertx |
newVertx(java.lang.String hostname)
Create a clustered Vertx instance listening for cluster connections on the default port 25500
|
abstract void |
runOnLoop(Handler<java.lang.Void> handler)
Put the handler on the event queue for this loop so it will be run asynchronously ASAP after this event has
been processed
|
abstract long |
setPeriodic(long delay,
Handler<java.lang.Long> handler)
Set a periodic timer to fire every
delay milliseconds, at which point handler will be called with
the id of the timer. |
abstract long |
setTimer(long delay,
Handler<java.lang.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. |
abstract SharedData |
sharedData()
The shared data object
|
abstract void |
stop()
Stop the eventbus and any resource managed by the eventbus.
|
public static Vertx newVertx()
public static Vertx newVertx(java.lang.String hostname)
hostname
- The hostname or ip address to listen for cluster connectionspublic static Vertx newVertx(int port, java.lang.String hostname)
port
- The port to listen for cluster connectionshostname
- The hostname or ip address to listen for cluster connectionspublic abstract NetServer createNetServer()
public abstract NetClient createNetClient()
public abstract HttpServer createHttpServer()
public abstract HttpClient createHttpClient()
public abstract SockJSServer createSockJSServer(HttpServer httpServer)
public abstract FileSystem fileSystem()
public abstract EventBus eventBus()
public abstract SharedData sharedData()
public abstract long setTimer(long delay, Handler<java.lang.Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.public abstract long setPeriodic(long delay, Handler<java.lang.Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.public abstract boolean cancelTimer(long id)
id
. Returns
true if the timer was successfully cancelled, or
false
if the timer does not exist.public abstract void runOnLoop(Handler<java.lang.Void> handler)
public abstract boolean isEventLoop()
public abstract boolean isWorker()
public abstract void stop()