io.vertx.core.spi

## Interface VerticleFactory

- All Known Implementing Classes:
    GroovyVerticleFactory, HttpSecureServiceFactory, HttpServiceFactory, JRubyVerticleFactory, MavenVerticleFactory, ServiceVerticleFactory

      public interface VerticleFactory

  Has responsibility for creating verticle instances.

  Implementations of this are responsible for creating verticle written in various different JVM languages and for other purposes.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default boolean` | `blockingCreate()` If the `createVerticle(String, ClassLoader)` method might be slow Vert.x will call it using a worker thread instead of an event loop if this returns true
    `default void` | `close()` Close the factory.
    `Verticle` | `createVerticle(String verticleName, ClassLoader classLoader)` Create a verticle instance.
    `default void` | `init(Vertx vertx)` Initialise the factory
    `default int` | `order()` The order of the factory.
    `String` | `prefix()`
    `static String` | `removePrefix(String identifer)` Helper method to remove a prefix from an identifier string
    `default boolean` | `requiresResolve()` Does the factory require resolution? See `resolve(String, DeploymentOptions, ClassLoader, Future)` for more information.
    `default void` | `resolve(String identifier, DeploymentOptions deploymentOptions, ClassLoader classLoader, Future<String> resolution)` Some verticle factories can "resolve" the identifer to another identifier which is then used to look up the real verticle factory.

- - ### Method Detail

    - #### removePrefix

          static String removePrefix(String identifer)

      Helper method to remove a prefix from an identifier string
      Parameters:
        `identifer` - the identifier
      Returns:
        The identifier without the prefix (if it had any)

    - #### order

          default int order()

      The order of the factory. If there is more than one matching verticle they will be tried in ascending order.
      Returns:
        the order

    - #### requiresResolve

          default boolean requiresResolve()

      Does the factory require resolution? See `resolve(String, DeploymentOptions, ClassLoader, Future)` for more information.
      Returns:
        true if yes

    - #### blockingCreate

          default boolean blockingCreate()

      If the `createVerticle(String, ClassLoader)` method might be slow Vert.x will call it using a worker thread instead of an event loop if this returns true
      Returns:
        true if `createVerticle(String, ClassLoader)` should be called on a worker thread.

    - #### resolve

          default void resolve(String identifier,
                               DeploymentOptions deploymentOptions,
                               ClassLoader classLoader,
                               Future<String> resolution)

      Some verticle factories can "resolve" the identifer to another identifier which is then used to look up the real verticle factory. An Example is the Vert.x service factory which takes an identifier of form `service:com.mycompany.clever-db-service" then looks for a JSON file which it loads to get the real identifier (main verticle).
      Parameters:
        `identifier` - The identifier
        `deploymentOptions` - The deployment options - these can be changed inside the resolve method (e.g. to add an extra classpath)
        `classLoader` - The classloader
        `resolution` - A future which will receive the result of the resolution.

    - #### init

          default void init(Vertx vertx)

      Initialise the factory
      Parameters:
        `vertx` - The Vert.x instance

    - #### close

          default void close()

      Close the factory. The implementation must release all resources.

    - #### prefix

          String prefix()

      Returns:
        The prefix for the factory, e.g. "java", or "js".

    - #### createVerticle

          Verticle createVerticle(String verticleName,
                                  ClassLoader classLoader)
                           throws Exception

      Create a verticle instance. If this method is likely to be slow (e.g. Ruby or JS verticles which might have to start up a language engine) then make sure it is run on a worker thread by returning `true` from `blockingCreate()`.
      Parameters:
        `verticleName` - The verticle name
        `classLoader` - The class loader
      Returns:
        The instance
      Throws:
        `Exception`

Copyright © 2018 Eclipse. All rights reserved.