Interface CoreContext

All Known Implementing Classes:
ContextMock, StorageContext, SystemContext

public interface CoreContext
Provides a simplified subset of the vertx toolkit with some wrapping to simplify usage.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    blocking​(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
    Call to execute the given blocking handler on a worker thread that is scoped to the current context.
    <T> void
    blocking​(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
    Call to execute the given blocking handler on a worker thread that is scoped to the current context.
    io.vertx.core.eventbus.EventBus
    bus()
     
    void
    cancel​(long timer)
    Cancels a running timer.
    void
    Shuts down the context and underlying pools and connections.
    void
    close​(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
     
    io.vertx.core.Future<String>
    deploy​(String target)
    Instantiates an object of the given class identifier and determines the type that should be deployed.
    default io.vertx.core.file.FileSystem
     
    io.vertx.core.Future<String>
    Deploys a new handler in the cluster from given handler with a completion handler.
    io.vertx.core.Future<String>
    Deploys the given verticle with a completion handler.
    logger​(Class aClass)
     
     
    metrics​(String registryName)
    Creates a new metric namespace using the registryName.
    void
    periodic​(TimerSource delay, io.vertx.core.Handler<Long> handler)
    Set a periodic timer that uses a timersource to adjust interval during runtime.
    io.vertx.core.Future<String>
    Deploys the given verticle with a completion handler.
    io.vertx.core.Future<io.vertx.core.CompositeFuture>
     
    void
    stop​(String deploymentId)
    Undeploys a deployed handler by the deployment id.
     
    long
    timer​(long ms, io.vertx.core.Handler<Long> handler)
    Sets a timer that executes the given handler after the given time.
    io.vertx.core.Vertx
     
  • Method Details

    • vertx

      io.vertx.core.Vertx vertx()
      Returns:
      the vertx instance.
    • bus

      io.vertx.core.eventbus.EventBus bus()
      Returns:
      get the EventBus attached to the vertx instance.
    • metrics

      MetricCollector metrics()
      Returns:
      the metrics collector.
    • metrics

      MetricCollector metrics(String registryName)
      Creates a new metric namespace using the registryName.
      Parameters:
      registryName - the name of the registry to attach metrics to.
      Returns:
      a new metric collector using the default timer.
    • fileSystem

      default io.vertx.core.file.FileSystem fileSystem()
      Returns:
      get filesystem access.
    • system

      SystemSettings system()
      Returns:
      the system configuration.
    • periodic

      void periodic(TimerSource delay, io.vertx.core.Handler<Long> handler)
      Set a periodic timer that uses a timersource to adjust interval during runtime.
      Parameters:
      delay - a timer source that may change period during runtime.
      handler - the handler to be invoked when each interval ends.
    • timer

      long timer(long ms, io.vertx.core.Handler<Long> handler)
      Sets a timer that executes the given handler after the given time.
      Parameters:
      ms - time unit in ms.
      handler - the handler to be invoken when the timer runs out.
      Returns:
      the id of the created timer so that it may be cancelled.
    • cancel

      void cancel(long timer)
      Cancels a running timer.
      Parameters:
      timer - the id of the timer to be stopped.
    • deploy

      io.vertx.core.Future<String> deploy(String target)
      Instantiates an object of the given class identifier and determines the type that should be deployed. May be a CoreHandler CoreService CoreListener or a plain Verticle.
      Parameters:
      target - the target class to deploy.
      Returns:
      future completed on deployment.
    • handler

      io.vertx.core.Future<String> handler(Supplier<CoreHandler> handler)
      Deploys a new handler in the cluster from given handler with a completion handler.
      Parameters:
      handler - the handler to be used to handle incoming requests.
      Returns:
      a future to be completed on deployment completion.
    • listener

      io.vertx.core.Future<String> listener(Supplier<CoreListener> listener)
      Deploys the given verticle with a completion handler.
      Parameters:
      listener - the verticle to be deployed.
      Returns:
      future completed on deployment completion.
    • service

      io.vertx.core.Future<String> service(Supplier<CoreService> service)
      Deploys the given verticle with a completion handler.
      Parameters:
      service - the verticle to be deployed.
      Returns:
      future to be completed on deployment completion.
    • stop

      void stop(String deploymentId)
      Undeploys a deployed handler by the deployment id.
      Parameters:
      deploymentId - the id of the deployment to undeploy.
    • stop

      io.vertx.core.Future<io.vertx.core.CompositeFuture> stop()
    • blocking

      <T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
      Call to execute the given blocking handler on a worker thread that is scoped to the current context.
      Type Parameters:
      T - type parameter.
      Parameters:
      blocking - a method that is blocking, to be executed on worker thread.
      result - handler for the result of the blocking execution.
    • blocking

      <T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
      Call to execute the given blocking handler on a worker thread that is scoped to the current context.
      Type Parameters:
      T - type parameter for the result
      Parameters:
      blocking - a handler that executes blocking code
      ordered - if true, indicates that the tasks must be completed in the same order as they are started.
      result - handler for the result that is called asynchronously
    • logger

      Logger logger(Class aClass)
      Parameters:
      aClass - added as metadata to all logged events.
      Returns:
      get a new instance of a logger.
    • close

      void close()
      Shuts down the context and underlying pools and connections.
    • close

      void close(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      Parameters:
      handler - called when the context has closed or failed closing.