当前位置: 首页>>代码示例>>Java>>正文


Java Verticle类代码示例

本文整理汇总了Java中io.vertx.core.Verticle的典型用法代码示例。如果您正苦于以下问题:Java Verticle类的具体用法?Java Verticle怎么用?Java Verticle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Verticle类属于io.vertx.core包,在下文中一共展示了Verticle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createVerticleFromBean

import io.vertx.core.Verticle; //导入依赖的package包/类
private Verticle createVerticleFromBean(String beanName) {
    if (!beanFactory.containsBean(beanName)) {
        throw new IllegalArgumentException("No such bean: " + beanName);
    }

    if (!beanFactory.isTypeMatch(beanName, Verticle.class)) {
        throw new IllegalArgumentException("Bean \"" + beanName + "\" is not of type Verticle");
    }

    if (beanFactory.isSingleton(beanName)) {
        throw new IllegalArgumentException("Verticle bean \"" + beanName + "\" is a singleton bean");
    }

    logger.debug("Creating verticle from bean \"{}\"", beanName);
    return beanFactory.getBean(beanName, Verticle.class);
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:17,代码来源:SpringVerticleFactory.java

示例2: createVerticle

import io.vertx.core.Verticle; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-tamaya-sandbox,代码行数:17,代码来源:ConfiguredJavaVerticleFactory.java

示例3: addVerticle

import io.vertx.core.Verticle; //导入依赖的package包/类
@Reference(unbind = "removeVerticle", policy=ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE)
public void addVerticle(Verticle verticle) {
    LOGGER.info("Deploying verticle " + verticle);
    verticles.add(verticle);
    if (verticle == null)
        return;
    if (vertxService != null)
        vertxService.deployVerticle(verticle, deploy -> {
            if (deploy.succeeded()) {
                LOGGER.info("Deployment of verticle succeeded");
                String id = deploy.result();
                deployedVerticles.put(verticle, id);
            } else {
                LOGGER.log(Level.SEVERE, "Deployment of verticle failed", deploy.cause());
            }
        });
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:18,代码来源:VertxVerticleHost.java

示例4: installExtendedBundle

import io.vertx.core.Verticle; //导入依赖的package包/类
@Test
public void installExtendedBundle() throws Exception {
    logger.info("testing extender ... ");
    String bundlePath = "mvn:de.nierbeck.example.vertx/Vertx-Extended-Verticles/0.1.0-SNAPSHOT";
    logger.info("installing bundle with url: {}", bundlePath);
    Bundle bundle = bc.installBundle(bundlePath);
    bundle.start();
    int count = 0;
    while (bundle.getState() != Bundle.ACTIVE && count < 50) {
        Thread.sleep(1000);
        count = count++;
    }
    
    assertTrue (bundle.getState() == Bundle.ACTIVE);
    logger.info("Bundle is active");
    
    Thread.sleep(1000); //wait a second so the service is registered. 

    Collection<ServiceReference<Verticle>> serviceReferences = bc.getServiceReferences(Verticle.class, null);
    
    logger.info("found {} services", serviceReferences.size());
    List<ServiceReference<Verticle>> collect = serviceReferences.stream().filter(serviceReference -> serviceReference.getBundle() == bundle).collect(Collectors.toList());
    assertTrue(collect.size() > 0);
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:25,代码来源:VertxExtenderKarafTest.java

示例5: main

import io.vertx.core.Verticle; //导入依赖的package包/类
public static void main(String[] args) {
    Vertx vertx = Vertx.vertx();
    Verticle todoVerticle = new TodoVerticle();

    final int port = Integer.getInteger("http.port", 8082);
    DeploymentOptions options = new DeploymentOptions()
            .setConfig(new JsonObject().put("http.port", port)
            );

    vertx.deployVerticle(todoVerticle, options, res -> {
        if (res.succeeded())
            System.out.println("Todo service is running at " + port + " port...");
        else
            res.cause().printStackTrace();
    });
}
 
开发者ID:sczyh30,项目名称:todo-backend-vert.x,代码行数:17,代码来源:Application.java

示例6: BootstrapVerticle

import io.vertx.core.Verticle; //导入依赖的package包/类
@Inject
public BootstrapVerticle(@Nullable @Named("bootstrap.filter") final String filterString,
                         final Map<String, Verticle> verticleMap)
{
  this.filter = filterFromString(filterString);
  this.verticles = verticleMap.entrySet().stream()
      .filter(e -> !NAME.equals(e.getKey()) && filter.test(e.getKey()))
      .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
  if (verticles.isEmpty()) {
    log.warn("No verticle participates in bootstrap? (are they discoverable, or filter '" + filter +
        "' filtered out all of them?)");
  }
  else {
    log.debug("Bootstrap verticle(filter='" + filterString + "', verticles=" + verticles.keySet() + ")");
  }
}
 
开发者ID:cstamas,项目名称:vertx-sisu,代码行数:17,代码来源:BootstrapVerticle.java

示例7: start

import io.vertx.core.Verticle; //导入依赖的package包/类
@Override
public void start(final Future<Void> startFuture) throws Exception {
  log.debug("Starting bootstrap verticle");
  List<Future> futures = new ArrayList<>(verticles.size());
  for (Verticle verticle : verticles.values()) {
    Future<Void> f = Future.future();
    verticle.start(f);
    futures.add(f);
  }
  CompositeFuture.all(futures).setHandler(ar -> {
    if (ar.succeeded()) {
      startFuture.complete();
    }
    else {
      startFuture.fail(ar.cause());
    }
  });
}
 
开发者ID:cstamas,项目名称:vertx-sisu,代码行数:19,代码来源:BootstrapVerticle.java

示例8: stop

import io.vertx.core.Verticle; //导入依赖的package包/类
@Override
public void stop(final Future<Void> stopFuture) throws Exception {
  log.debug("Stopping bootstrap verticle");
  List<Future> futures = new ArrayList<>(verticles.size());
  for (Verticle verticle : verticles.values()) {
    Future<Void> f = Future.future();
    verticle.stop(f);
    futures.add(f);
  }
  CompositeFuture.all(futures).setHandler(ar -> {
    if (ar.succeeded()) {
      stopFuture.complete();
    }
    else {
      stopFuture.fail(ar.cause());
    }
  });
}
 
开发者ID:cstamas,项目名称:vertx-sisu,代码行数:19,代码来源:BootstrapVerticle.java

示例9: AMQPServiceImpl

import io.vertx.core.Verticle; //导入依赖的package包/类
public AMQPServiceImpl(Vertx vertx, AmqpServiceConfig config, Verticle parent) throws MessagingException {
  _vertx = vertx;
  _parent = parent;
  _eb = _vertx.eventBus();
  _config = config;
  _msgTranslator = new MessageTranslator();
  _msgBasedRouter = new MessageRouter(_config);
  _linkBasedRouter = new LinkRouter();
  _linkManager = new LinkManager(vertx, _config, this);
  _replyToAddressPrefix = "amqp://" + _config.getInboundHost() + ":" + _config.getInboundPort();

  _eb.consumer(config.getDefaultHandlerAddress(), this);
  for (String handlerAddress : config.getHandlerAddressList()) {
    _consumers.add(_eb.consumer(handlerAddress, this));
  }
  // TODO _config.print() // prints the current config at start time.
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-service,代码行数:18,代码来源:AMQPServiceImpl.java

示例10: asJavaVerticle

import io.vertx.core.Verticle; //导入依赖的package包/类
/**
 * @return the Java {@link Verticle} adapter for this Groovy Verticle
 */
public Verticle asJavaVerticle() {
  return new AbstractVerticle() {

    @Override
    public void start(Future<Void> startFuture) throws Exception {
      GroovyVerticle.this.vertx = super.vertx;
      GroovyVerticle.this.context = super.context;
      GroovyVerticle.this.start(startFuture);
    }

    @Override
    public void stop(Future<Void> stopFuture) throws Exception {
      GroovyVerticle.this.stop(stopFuture);
    }
  };
}
 
开发者ID:vert-x3,项目名称:vertx-lang-groovy,代码行数:20,代码来源:GroovyVerticle.java

示例11: createSpringVerticle

import io.vertx.core.Verticle; //导入依赖的package包/类
private Verticle createSpringVerticle(final Class<?> currentVerticleClass, ClassLoader classLoader) {
    final SpringVerticle annotation = currentVerticleClass.getAnnotation(SpringVerticle.class);
    final Class<?> springConfigClass = annotation.springConfig();
    
    // Create the parent context  
    final GenericApplicationContext genericApplicationContext = getGenericApplicationContext(
        classLoader);

    // 1. Create a new context for each verticle and use the specified spring configuration class if possible
    AnnotationConfigApplicationContext annotationConfigApplicationContext = getAnnotationConfigApplicationContext(
        springConfigClass, genericApplicationContext);

    // 2. Register the Vertx instance as a singleton in spring context
    annotationConfigApplicationContext.getBeanFactory().registerSingleton(vertx.getClass().getSimpleName(), vertx);

    // 3. Register a bean definition for this verticle
    annotationConfigApplicationContext.registerBeanDefinition(currentVerticleClass.getSimpleName(), new VerticleBeanDefinition(currentVerticleClass));
    
    // 4. Add a bean factory post processor to avoid configuration issues
    addPostprocessorAndUpdateContext(currentVerticleClass, annotationConfigApplicationContext);
    
    // 5. Return the verticle by fetching the bean from the context
    return (Verticle) annotationConfigApplicationContext.getBeanFactory().getBean(currentVerticleClass.getSimpleName());
}
 
开发者ID:amoAHCP,项目名称:spring-vertx-ext,代码行数:25,代码来源:SpringVerticleFactory.java

示例12: testIsolatedContext

import io.vertx.core.Verticle; //导入依赖的package包/类
@Test
    public void testIsolatedContext() throws Exception {
        SpringVerticleFactory springVerticleFactory = createCleanSpringVerticleFactory();
        Vertx vertx = mock(Vertx.class);
        springVerticleFactory.init(vertx);
        Verticle verticle1 = springVerticleFactory.createVerticle(SpringTestVerticle.class.getName(), Thread.currentThread().getContextClassLoader());
        assertNotNull(verticle1);
        Verticle verticle2 = springVerticleFactory.createVerticle(SpringTestVerticle.class.getName(), Thread.currentThread().getContextClassLoader());
        assertNotNull(verticle2);
//        SpringTestVerticle v1 = SpringTestVerticle.class.cast(verticle1);
//        SpringTestVerticle v2 = SpringTestVerticle.class.cast(verticle2);
//        assertFalse(v1.equals(v2));
//        assertFalse(v1.getBean().equals(v2.getBean()));
//        assertEquals(v1.getBean().getClass().getCanonicalName(),v2.getBean().getClass().getCanonicalName());
//        assertFalse(v1.getSpringContext().equals(v2.getSpringContext()));
//        assertEquals(v1.getSpringContext().getClass().getCanonicalName(),v2.getSpringContext().getClass().getCanonicalName());
    }
 
开发者ID:amoAHCP,项目名称:spring-vertx-ext,代码行数:18,代码来源:SpringVerticleFactoryTest.java

示例13: main

import io.vertx.core.Verticle; //导入依赖的package包/类
public static void main(String[] args) {
	VertxOptions options = new VertxOptions(); 
	options.setMaxEventLoopExecuteTime(Long.MAX_VALUE);
	final Vertx vertx = Vertx.factory.vertx(options);
	ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class);
	
	Verticle serverVerticle =  (Verticle) context.getBean("serverVerticle");
	Verticle userDatabaseVerticle =  (Verticle) context.getBean("userDatabaseVerticle");
	Verticle blogServiceVerticle = (Verticle) context.getBean("blogServiceVerticle");
	
	vertx.deployVerticle(serverVerticle);
	vertx.deployVerticle(userDatabaseVerticle, new DeploymentOptions().setWorker(true));
	vertx.deployVerticle(blogServiceVerticle, new DeploymentOptions().setWorker(true));
	
}
 
开发者ID:srihas,项目名称:vertx-spring-mongo-blog,代码行数:16,代码来源:ApplicationStarter.java

示例14: isVerticleBeanDefinition

import io.vertx.core.Verticle; //导入依赖的package包/类
private boolean isVerticleBeanDefinition(String beanName, BeanDefinition beanDefinition) {
    Class<?> beanClass = getBeanClass(beanName, beanDefinition);
    if (beanClass != null) {
        if (Verticle.class.isAssignableFrom(beanClass)) {
            return true;
        }
        if (FactoryBean.class.isAssignableFrom(beanClass) && beanDefinition instanceof AnnotatedBeanDefinition) {
            MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata();
            if (factoryMethodMetadata != null && factoryMethodMetadata.isAnnotated(VerticleDeployment.class.getName())) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:16,代码来源:VerticleBeanPostProcessor.java

示例15: loadVerticleByClass

import io.vertx.core.Verticle; //导入依赖的package包/类
/**
 * Loads a Verticle by instantiating the Java class first needed when
 * objects need to be handed over
 * 
 * @param bc
 *            the Base configuration
 * @return a future that resolves after loading
 */
private Future<Void> loadVerticleByClass(final BaseConfig bc) {
	final Future<Void> result = Future.future();
	final String verticleId = bc.getVerticleName();
	final DeploymentOptions options = this.getDeploymentOptions(bc);

	try {
		@SuppressWarnings("unchecked")
		final Class<Verticle> vClass = (Class<Verticle>) Class.forName(verticleId);
		final Verticle v = vClass.newInstance();

		/*
		 * This is the magic: we hand over the router to the verticle to be
		 * used only sparingly
		 */
		if (v instanceof SFDCRouterExtension) {
			((SFDCRouterExtension) v).addRoutes(this.router);
		}
		this.getVertx().deployVerticle(v, options, r -> {
			if (r.succeeded()) {
				final String vid = r.result();
				this.logger.trace(verticleId + "started as " + vid);
				this.loadedVerticles.add(vid);
				result.complete();
			} else {
				this.logger.fatal(r.cause());
				result.fail(r.cause());
			}
		});

	} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
		this.logger.fatal(e.getMessage(), e);
		result.fail(e);
	}

	return result;

}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:46,代码来源:ApplicationStarter.java


注:本文中的io.vertx.core.Verticle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。