org.vertx.java.core

## Class Vertx

- java.lang.Object
- - org.vertx.java.core.Vertx

-     public abstract class Vertx
      extends java.lang.Object

  The control centre of vert.x

  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 Summary

    Constructors
    Constructor and Description
    `Vertx()`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Vertx

          public Vertx()

  - ### Method Detail

    - #### newVertx

          public static Vertx newVertx()

      Create a non clustered Vertx instance

    - #### newVertx

          public static Vertx newVertx(java.lang.String hostname)

      Create a clustered Vertx instance listening for cluster connections on the default port 25500
      Parameters:
        `hostname` - The hostname or ip address to listen for cluster connections

    - #### newVertx

          public static Vertx newVertx(int port,
                       java.lang.String hostname)

      Create a clustered Vertx instance
      Parameters:
        `port` - The port to listen for cluster connections
        `hostname` - The hostname or ip address to listen for cluster connections

    - #### createNetServer

          public abstract NetServer createNetServer()

      Create a TCP/SSL server

    - #### createNetClient

          public abstract NetClient createNetClient()

      Create a TCP/SSL client

    - #### createHttpServer

          public abstract HttpServer createHttpServer()

      Create an HTTP/HTTPS server

    - #### createHttpClient

          public abstract HttpClient createHttpClient()

      Create a HTTP/HTTPS client

    - #### createSockJSServer

          public abstract SockJSServer createSockJSServer(HttpServer httpServer)

      Create a SockJS server that wraps an HTTP server

    - #### fileSystem

          public abstract FileSystem fileSystem()

      The File system object

    - #### eventBus

          public abstract EventBus eventBus()

      The event bus

    - #### sharedData

          public abstract SharedData sharedData()

      The shared data object

    - #### setTimer

          public 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.
      Returns:
        the unique ID of the timer

    - #### setPeriodic

          public 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.
      Returns:
        the unique ID of the timer

    - #### cancelTimer

          public abstract 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.

    - #### runOnLoop

          public 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

    - #### isEventLoop

          public abstract boolean isEventLoop()

      Is the current thread an event loop thread?
      Returns:
        true if current thread is an event loop thread

    - #### isWorker

          public abstract boolean isWorker()

      Is the current thread an worker thread?
      Returns:
        true if current thread is an worker thread

    - #### stop

          public abstract void stop()

      Stop the eventbus and any resource managed by the eventbus.