public class Vertx extends Object implements Measured
You use an instance of this class for functionality including:
Most functionality in Vert.x core is fairly low level.
To create an instance of this class you can use the static factory methods: vertx()
,
vertx()
and clusteredVertx(io.vertx.core.VertxOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.core.Vertx>>)
.
Please see the user manual for more detailed usage information.
NOTE: This class has been automatically generated from theoriginal
non RX-ified interface using Vert.x codegen.Modifier and Type | Method and Description |
---|---|
boolean |
cancelTimer(long id)
Cancels the timer with the specified
id . |
void |
close()
Stop the the Vertx instance and release any resources held by it.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
Vertx but the completionHandler will be called when the close is complete |
rx.Observable<Void> |
closeObservable()
Like
Vertx but the completionHandler will be called when the close is complete |
static void |
clusteredVertx(VertxOptions options,
Handler<AsyncResult<Vertx>> resultHandler)
Creates a clustered instance using the specified options.
|
static rx.Observable<Vertx> |
clusteredVertxObservable(VertxOptions options)
Creates a clustered instance using the specified options.
|
DatagramSocket |
createDatagramSocket()
Create a datagram socket using default options
|
DatagramSocket |
createDatagramSocket(DatagramSocketOptions options)
Create a datagram socket using the specified options
|
DnsClient |
createDnsClient(int port,
String host)
Create a DNS client to connect to a DNS server at the specified host and port
|
HttpClient |
createHttpClient()
Create a HTTP/HTTPS client using default options
|
HttpClient |
createHttpClient(HttpClientOptions options)
Create a HTTP/HTTPS client using the specified options
|
HttpServer |
createHttpServer()
Create an HTTP/HTTPS server using default options
|
HttpServer |
createHttpServer(HttpServerOptions options)
Create an HTTP/HTTPS server using the specified options
|
NetClient |
createNetClient()
Create a TCP/SSL client using default options
|
NetClient |
createNetClient(NetClientOptions options)
Create a TCP/SSL client using the specified options
|
NetServer |
createNetServer()
Create a TCP/SSL server using default options
|
NetServer |
createNetServer(NetServerOptions options)
Create a TCP/SSL server using the specified options
|
static Context |
currentContext()
Gets the current context
|
Set<String> |
deploymentIDs()
Return a Set of deployment IDs for the currently deployed deploymentIDs.
|
void |
deployVerticle(String name)
Deploy a verticle instance given a name.
|
void |
deployVerticle(String name,
DeploymentOptions options)
Like
Vertx but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx but the completionHandler will be notified when the deployment is complete. |
rx.Observable<String> |
deployVerticleObservable(String name)
Like
Vertx but the completionHandler will be notified when the deployment is complete. |
rx.Observable<String> |
deployVerticleObservable(String name,
DeploymentOptions options)
Like
Vertx but DeploymentOptions are provided to configure the
deployment. |
EventBus |
eventBus()
Get the event bus object.
|
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
boolean ordered,
Handler<AsyncResult<T>> resultHandler)
Safely execute some blocking code.
|
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
Handler<AsyncResult<T>> resultHandler)
Like
Vertx called with ordered = true. |
<T> rx.Observable<T> |
executeBlockingObservable(Handler<Future<T>> blockingCodeHandler)
Like
Vertx called with ordered = true. |
<T> rx.Observable<T> |
executeBlockingObservable(Handler<Future<T>> blockingCodeHandler,
boolean ordered)
Safely execute some blocking code.
|
FileSystem |
fileSystem()
Get the filesystem object.
|
Object |
getDelegate() |
Context |
getOrCreateContext()
Gets the current context, or creates one if there isn't one
|
boolean |
isClustered()
Is this Vert.x instance clustered?
|
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
static Vertx |
newInstance(Vertx arg) |
TimeoutStream |
periodicStream(long delay)
Returns a periodic timer as a read stream.
|
void |
runOnContext(Handler<Void> action)
Puts the handler on the event queue for the current context so it will be run asynchronously ASAP after all
preceeding events have been handled.
|
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()
Get the shared data object.
|
TimeoutStream |
timerStream(long delay)
Returns a one-shot timer as a read stream.
|
void |
undeploy(String deploymentID)
Undeploy a verticle deployment.
|
void |
undeploy(String deploymentID,
Handler<AsyncResult<Void>> completionHandler)
Like
Vertx but the completionHandler will be notified when the undeployment is complete. |
rx.Observable<Void> |
undeployObservable(String deploymentID)
Like
Vertx but the completionHandler will be notified when the undeployment is complete. |
static Vertx |
vertx()
Creates a non clustered instance using default options.
|
static Vertx |
vertx(VertxOptions options)
Creates a non clustered instance using the specified options
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newInstance
public Vertx(Vertx delegate)
public Object getDelegate()
getDelegate
in interface Measured
public boolean isMetricsEnabled()
isMetricsEnabled
in interface Measured
public static Vertx vertx()
public static Vertx vertx(VertxOptions options)
options
- the options to usepublic static void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> resultHandler)
The instance is created asynchronously and the resultHandler is called with the result when it is ready.
options
- the options to useresultHandler
- the result handler that will receive the resultpublic static rx.Observable<Vertx> clusteredVertxObservable(VertxOptions options)
The instance is created asynchronously and the resultHandler is called with the result when it is ready.
options
- the options to usepublic static Context currentContext()
public Context getOrCreateContext()
public NetServer createNetServer(NetServerOptions options)
options
- the options to usepublic NetServer createNetServer()
public NetClient createNetClient(NetClientOptions options)
options
- the options to usepublic NetClient createNetClient()
public HttpServer createHttpServer(HttpServerOptions options)
options
- the options to usepublic HttpServer createHttpServer()
public HttpClient createHttpClient(HttpClientOptions options)
options
- the options to usepublic HttpClient createHttpClient()
public DatagramSocket createDatagramSocket(DatagramSocketOptions options)
options
- the options to usepublic DatagramSocket createDatagramSocket()
public FileSystem fileSystem()
public EventBus eventBus()
public DnsClient createDnsClient(int port, String host)
port
- the porthost
- the hostpublic SharedData sharedData()
public long setTimer(long delay, Handler<Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.delay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer firespublic TimeoutStream timerStream(long delay)
delay
milliseconds after
the has been called.delay
- the delay in milliseconds, after which the timer will firepublic long setPeriodic(long delay, Handler<Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.delay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer firespublic TimeoutStream periodicStream(long delay)
delay
milliseconds after
the has been called.delay
- the delay in milliseconds, after which the timer will firepublic boolean cancelTimer(long id)
id
.id
- The id of the timer to cancelpublic void runOnContext(Handler<Void> action)
action
- - a handler representing the action to executepublic void close()
The instance cannot be used after it has been closed.
The actual close is asynchronous and may not complete until after the call has returned.
public void close(Handler<AsyncResult<Void>> completionHandler)
Vertx
but the completionHandler will be called when the close is completecompletionHandler
- The handler will be notified when the close is complete.public rx.Observable<Void> closeObservable()
Vertx
but the completionHandler will be called when the close is completepublic void deployVerticle(String name)
Given the name, Vert.x selects a instance to use to instantiate the verticle.
For the rules on how factories are selected please consult the user manual.
name
- the name.public void deployVerticle(String name, Handler<AsyncResult<String>> completionHandler)
Vertx
but the completionHandler will be notified when the deployment is complete.
If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.
This deployment ID can subsequently be used to undeploy the verticle.
name
- The identifiercompletionHandler
- a handler which will be notified when the deployment is completepublic rx.Observable<String> deployVerticleObservable(String name)
Vertx
but the completionHandler will be notified when the deployment is complete.
If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.
This deployment ID can subsequently be used to undeploy the verticle.
name
- The identifierpublic void deployVerticle(String name, DeploymentOptions options)
Vertx
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.public void deployVerticle(String name, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
Vertx
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.completionHandler
- a handler which will be notified when the deployment is completepublic rx.Observable<String> deployVerticleObservable(String name, DeploymentOptions options)
Vertx
but DeploymentOptions
are provided to configure the
deployment.name
- the nameoptions
- the deployment options.public void undeploy(String deploymentID)
The actual undeployment happens asynchronously and may not complete until after the method has returned.
deploymentID
- the deployment IDpublic void undeploy(String deploymentID, Handler<AsyncResult<Void>> completionHandler)
Vertx
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDcompletionHandler
- a handler which will be notified when the undeployment is completepublic rx.Observable<Void> undeployObservable(String deploymentID)
Vertx
but the completionHandler will be notified when the undeployment is complete.deploymentID
- the deployment IDpublic Set<String> deploymentIDs()
public boolean isClustered()
public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler)
Executes the blocking code in the handler blockingCodeHandler
using a thread from the worker pool.
When the code is complete the handler resultHandler
will be called with the result on the original context
(e.g. on the original event loop of the caller).
A Future
instance is passed into blockingCodeHandler
. When the blocking code successfully completes,
the handler should call the Future
or Future
method, or the Future
method if it failed.
blockingCodeHandler
- handler representing the blocking code to runordered
- if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guaranteesresultHandler
- handler that will be called when the blocking code is completepublic <T> rx.Observable<T> executeBlockingObservable(Handler<Future<T>> blockingCodeHandler, boolean ordered)
Executes the blocking code in the handler blockingCodeHandler
using a thread from the worker pool.
When the code is complete the handler resultHandler
will be called with the result on the original context
(e.g. on the original event loop of the caller).
A Future
instance is passed into blockingCodeHandler
. When the blocking code successfully completes,
the handler should call the Future
or Future
method, or the Future
method if it failed.
blockingCodeHandler
- handler representing the blocking code to runordered
- if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guaranteespublic <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler)
Vertx
called with ordered = true.blockingCodeHandler
- resultHandler
- public <T> rx.Observable<T> executeBlockingObservable(Handler<Future<T>> blockingCodeHandler)
Vertx
called with ordered = true.blockingCodeHandler
- Copyright © 2015. All Rights Reserved.