Java 类io.vertx.core.spi.VerticleFactory 实例源码

项目:incubator-tamaya-sandbox    文件:ConfiguredJavaVerticleFactory.java   
@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
    verticleName = VerticleFactory.removePrefix(verticleName);
    Class clazz;
    if (verticleName.endsWith(".java")) {
        CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, verticleName);
        String className = compilingLoader.resolveMainClassName();
        clazz = compilingLoader.loadClass(className);
    } else {
        clazz = classLoader.loadClass(verticleName);
    }

    Verticle instance = (Verticle)clazz.newInstance();
    ConfigurationInjection.getConfigurationInjector().configure(instance);
    return instance;
}
项目:vertx-spring-boot-example    文件:SpringDeploymentManager.java   
@Autowired
SpringDeploymentManager(
        final ApplicationContext context,
        final VerticleFactory verticleFactory,
        final Vertx vertx,
        @Value("${thread.pool.size}") final int threadPoolSize
) {
    this.context = context;
    this.verticleFactory = verticleFactory;
    this.vertx = vertx;
    this.threadPoolSize = getThreadPoolSize(threadPoolSize);
}
项目:ninja-vertx-standalone    文件:GuiceVerticleFactory.java   
@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
    verticleName = VerticleFactory.removePrefix(verticleName);

    // Use the provided class loader to create an instance of GuiceVerticleLoader.  This is necessary when working with vert.x IsolatingClassLoader
    @SuppressWarnings("unchecked")
    Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(GuiceVerticleLoader.class.getName());
    Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, Injector.class);

    if (ctor == null) {
        throw new IllegalStateException("Could not find GuiceVerticleLoader constructor");
    }

    return ctor.newInstance(verticleName, classLoader, getInjector());
}
项目:knotx    文件:KnotxModuleVerticleFactory.java   
@Override
public void resolve(String id, DeploymentOptions deploymentOptions, ClassLoader classLoader,
    Future<String> resolution) {
  String identifier = VerticleFactory.removePrefix(id);
  String descriptorFile = identifier + ".json";
  try {
    JsonObject descriptor = readDescriptor(classLoader, descriptorFile);
    String main = readVerticleMainClass(descriptor, descriptorFile);

    // Any options specified in the module config will override anything specified at deployment time
    // Options and Config specified in knotx starter JSON will override those configurations
    JsonObject depOptions = deploymentOptions.toJson();
    JsonObject depConfig = depOptions.getJsonObject(CONFIG_KEY, new JsonObject());

    JsonObject knotOptions = descriptor.getJsonObject(OPTIONS_KEY, new JsonObject());
    JsonObject knotConfig = knotOptions.getJsonObject(CONFIG_KEY, new JsonObject());
    depOptions.mergeIn(knotOptions);
    depOptions.put(CONFIG_KEY, JsonObjectUtil.deepMerge(knotConfig, depConfig));

    JsonObject serviceDescriptor = new JsonObject().put(OPTIONS_KEY, depOptions);

    // Any options or config provided by system properties will override anything specified
    // at deployment time and on starter Json config
    serviceDescriptor = overrideConfigWithSystemProperties(identifier, serviceDescriptor);

    deploymentOptions.fromJson(serviceDescriptor.getJsonObject(OPTIONS_KEY));
    resolution.complete(main);
  } catch (Exception e) {
    resolution.fail(e);
  }
}
项目:vertx-sisu    文件:Identifier.java   
public static Identifier parseIdentifier(String identifier) {
  String identifierNoPrefix = VerticleFactory.removePrefix(identifier);
  String verticleName = identifierNoPrefix;
  String serviceFilter = null;
  int pos = identifierNoPrefix.lastIndexOf("::");
  if (pos != -1) {
    verticleName = identifierNoPrefix.substring(0, pos);
    serviceFilter = identifierNoPrefix.substring(pos + 2);
  }
  return new Identifier(verticleName, serviceFilter);
}
项目:spring-vertx-ext    文件:SpringVerticleFactory.java   
@Override
public synchronized Verticle createVerticle(final String verticleName, final ClassLoader classLoader) throws Exception {
    final String className = VerticleFactory.removePrefix(verticleName);
    Class<?> clazz;
    if (className.endsWith(SUFFIX)) {
        CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, className);
        clazz = compilingLoader.loadClass(compilingLoader.resolveMainClassName());
    } else {
        clazz = classLoader.loadClass(className);
    }
    return createVerticle(clazz, classLoader);
}
项目:vertx-spring-boot-example    文件:SpringVerticleFactory.java   
@Override
public Verticle createVerticle(final String verticleName, final ClassLoader classLoader) throws Exception {
    final String clazz = VerticleFactory.removePrefix(verticleName);
    return (Verticle) applicationContext.getBean(Class.forName(clazz));
}
项目:vertx-spring-aware    文件:SpringVerticleFactory.java   
@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
  String beanName = VerticleFactory.removePrefix(verticleName);
  log.debug(String.format("Getting Verticle bean (%s) from context", beanName));
  return (Verticle) applicationContext.getBean(beanName);
}
项目:sfs    文件:SfsVertxImpl.java   
@Override
public void registerVerticleFactory(VerticleFactory factory) {
    vertx.registerVerticleFactory(factory);
}
项目:sfs    文件:SfsVertxImpl.java   
@Override
public void unregisterVerticleFactory(VerticleFactory factory) {
    vertx.unregisterVerticleFactory(factory);
}
项目:sfs    文件:SfsVertxImpl.java   
@Override
public Set<VerticleFactory> verticleFactories() {
    return vertx.verticleFactories();
}
项目:vertx-nodejs-service-factory    文件:NodeJSVerticleFactory.java   
@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
  return new NodeJSVerticle(VerticleFactory.removePrefix(verticleName), classLoader);
}
项目:wisdom    文件:WisdomVertxServer.java   
/**
 * Starts the servers (HTTP and HTTPS).
 * The actual start is asynchronous.
 */
@Validate
public synchronized void start() {

    LOGGER.info("Starting the vert.x server");

    // Check whether we have a specific vertx configuration, if not try the global one, and if not use default.
    int httpPort = accessor.getConfiguration().getIntegerWithDefault(
            "vertx.http.port",
            accessor.getConfiguration().getIntegerWithDefault(ApplicationConfiguration.HTTP_PORT, 9000));
    int httpsPort = accessor.getConfiguration().getIntegerWithDefault(
            "vertx.https.port",
            accessor.getConfiguration().getIntegerWithDefault(ApplicationConfiguration.HTTPS_PORT, -1));

    initializeInetAddress();


    // Parse server configuration if any
    Configuration servers = configuration.getConfiguration("vertx.servers");
    if (servers == null) {
        if (httpPort != -1) {
            LOGGER.info("Configuring default HTTP Server");
            this.servers.add(Server.defaultHttp(accessor, vertx));
        }
        if (httpsPort != -1) {
            LOGGER.info("Configuring default HTTPS Server");
            this.servers.add(Server.defaultHttps(accessor, vertx));
        }
    } else {
        // Custom configuration
        for (String name : servers.asMap().keySet()) {
            LOGGER.info("Configuring server {}", name);
            this.servers.add(Server.from(accessor, vertx, name,
                    servers.getConfiguration(name)));
        }
    }

    // Check whether or not the wisdom-internal verticle factory is already registered
    boolean found = false;
    for (VerticleFactory factory : vertx.verticleFactories()) {
        if (factory.prefix().equalsIgnoreCase("wisdom-internal")) {
            found = true;
        }
    }

    if (!found) {
        vertx.registerVerticleFactory(new WisdomInternalVerticleFactory(accessor, this.servers));
    }

    vertx.runOnContext(v -> vertx.deployVerticle("wisdom-internal:wisdom", ar -> {
        LOGGER.info("Wisdom verticle deployed : " + ar.result());
        deploymentId = ar.result();
    }));
}