• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VertxException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: await

import io.vertx.core.VertxException; //导入依赖的package包/类
public static <T> T await(Consumer<Handler<AsyncResult<T>>> task) {
    CountDownLatch countDownLatch = new CountDownLatch(1);
    try {
        Future<T> f = Future.<T>future().setHandler(ar -> {
            countDownLatch.countDown();
            if (ar.failed()) {
                throw new VertxException(ar.cause());
            }
        });
        task.accept(f.completer());
        countDownLatch.await();
        return f.result();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new VertxException(e);
    }

}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:19,代码来源:Sync.java


示例2: containsValue

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public boolean containsValue(Object value) {
  try {
    return curator.getChildren().forPath(mapPath).stream().anyMatch(k -> {
      try {
        byte[] bytes = curator.getData().forPath(keyPath((K) k));
        KeyValue<K, V> keyValue = asObject(bytes);
        return keyValue.getValue().equals(value);
      } catch (Exception ex) {
        throw new VertxException(ex);
      }
    });
  } catch (Exception e) {
    throw new VertxException(e);
  }
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:17,代码来源:ZKSyncMap.java


示例3: get

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public V get(Object key) {
  try {
    String keyPath = keyPath((K) key);
    if (null == curator.checkExists().forPath(keyPath)) {
      return null;
    } else {
      KeyValue<K, V> keyValue = asObject(curator.getData().forPath(keyPath));
      return keyValue.getValue();
    }
  } catch (Exception e) {
    if (!(e instanceof KeeperException.NodeExistsException)) {
      throw new VertxException(e);
    }
  }
  return null;
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:18,代码来源:ZKSyncMap.java


示例4: put

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public V put(K key, V value) {
  try {
    String keyPath = keyPath(key);
    KeyValue<K, V> keyValue = new KeyValue<>(key, value);
    byte[] valueBytes = asByte(keyValue);
    if (get(key) != null) {
      curator.setData().forPath(keyPath, valueBytes);
    } else {
      curator.create().creatingParentsIfNeeded().forPath(keyPath, valueBytes);
    }
    return value;
  } catch (Exception e) {
    throw new VertxException(e);
  }
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:17,代码来源:ZKSyncMap.java


示例5: getLockWithTimeout

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler) {
  ContextImpl context = (ContextImpl) vertx.getOrCreateContext();
  // Ordered on the internal blocking executor
  context.executeBlocking(() -> {
    java.util.concurrent.locks.Lock lock = lockService.getLock(name);
    try {
      if (lock.tryLock(timeout, TimeUnit.MILLISECONDS)) {
        return new JGroupsLock(vertx, lock);
      } else {
        throw new VertxException("Timed out waiting to get lock " + name);
      }
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new VertxException(e);
    }
  }, resultHandler);
}
 
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:19,代码来源:InfinispanClusterManager.java


示例6: getLockWithTimeout

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> handler) {
  Context context = vertx.getOrCreateContext();
  lockCache.getUnchecked(name).whenComplete((lock, error) -> {
    if (error == null) {
      lock.async().tryLock(Duration.ofMillis(timeout)).whenComplete((lockResult, lockError) -> {
        if (lockError == null) {
          if (lockResult.isPresent()) {
            context.runOnContext(v -> Future.<Lock>succeededFuture(new AtomixLock(vertx, lock)).setHandler(handler));
          } else {
            context.runOnContext(v -> Future.<Lock>failedFuture(new VertxException("Timed out waiting to get lock " + name)).setHandler(handler));
          }
        } else {
          context.runOnContext(v -> Future.<Lock>failedFuture(lockError).setHandler(handler));
        }
      });
    } else {
      context.runOnContext(v -> Future.<Lock>failedFuture(error).setHandler(handler));
    }
  });
}
 
开发者ID:atomix,项目名称:atomix-vertx,代码行数:22,代码来源:AtomixClusterManager.java


示例7: readExternal

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  boolean isClusterSerializable = in.readBoolean();
  if (isClusterSerializable) {
    String className = in.readUTF();
    Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
    try {
      data = (T) clazz.newInstance();
      byte[] bytes = new byte[in.read()];
      in.read(bytes);
      ((ClusterSerializable) data).readFromBuffer(0, Buffer.buffer(bytes));
    } catch (InstantiationException | IllegalAccessException e) {
      throw new VertxException(e);
    }
  } else {
    data = (T) in.readObject();
  }
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:19,代码来源:DataHolder.java


示例8: visit

import io.vertx.core.VertxException; //导入依赖的package包/类
public List<MVCRoute> visit() throws IllegalAccessException, InstantiationException {
  instance = clazz.newInstance();
  List<MVCRoute> routes = new ArrayList<>();
  try {
    injectServices();
  } catch (IllegalAccessException iae) {
    throw new VertxException(iae);
  }
  extractFilters();
  for (Method method : methods) {
    MethodVisitor<T> visitor = new MethodVisitor<>(this, method);
    routes.addAll(visitor.visit());
  }
  for (MVCRoute route : routes) {
    route.addProcessorsFirst(processors);
    route.addBeforeFilters(beforeFilters);
    route.addAfterFilters(afterFilters);
  }
  return routes;
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:21,代码来源:ControllerVisitor.java


示例9: visit

import io.vertx.core.VertxException; //导入依赖的package包/类
public void visit() {
  sockJSHandler = SockJSHandler.create(config.getVertx(), config.getSockJSOptions());
  try {
    instance = clazz.newInstance();
    injectServices();
  } catch (Exception e) {
    throw new VertxException("Could not instanciate socket controller : " + clazz.getName(), e);
  }
  EventBusBridge annot = clazz.getAnnotation(EventBusBridge.class);
  path = annot.value();
  BridgeOptions bridge = createBridgeOptions(clazz);
  Map<BridgeEventType, Method> handlers = BridgeEventFactory.createFromController(clazz);
  sockJSHandler.bridge(bridge, be -> {
    Method method = handlers.get(be.type());
    if (method != null) {
      tryToInvoke(instance, method, be);
    } else {
      be.complete(true);
    }
  });
  normalizePath();
  router.route(path).handler(sockJSHandler);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:24,代码来源:EventBusBridgeVisitor.java


示例10: visit

import io.vertx.core.VertxException; //导入依赖的package包/类
public void visit() {
  sockJSHandler = SockJSHandler.create(config.getVertx(), config.getSockJSOptions());
  try {
    instance = clazz.newInstance();
    injectServices();
  } catch (Exception e) {
    throw new VertxException("Could not instanciate socket controller : " + clazz.getName(), e);
  }
  createHandlers();
  sockJSHandler.socketHandler(ws -> {
    openHandlers.forEach(handler -> tryToInvoke(instance, handler, ws, null));
    ws.handler(buff -> messageHandlers.forEach(messageHandler -> tryToInvoke(instance, messageHandler, ws, buff)));
    ws.endHandler(voidz -> closeHandlers.forEach(closeHandler -> tryToInvoke(instance, closeHandler, ws, null)));
  });
  normalizePath();
  router.route(path).handler(sockJSHandler);
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:18,代码来源:SockJSVisitor.java


示例11: readFromBuffer

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public int readFromBuffer(int pos, Buffer buffer) {
  byte b = buffer.getByte(pos++);
  if (b == (byte)1) {
    int len = buffer.getInt(pos);
    pos += 4;
    byte[] bytes = buffer.getBytes(pos, pos + len);
    pos += len;
    String className = new String(bytes, StandardCharsets.UTF_8);
    try {
      Class clazz = Utils.getClassLoader().loadClass(className);
      ClusterSerializable obj = (ClusterSerializable) clazz.newInstance();
      pos = obj.readFromBuffer(pos, buffer);
      user = (User) obj;
    } catch (Exception e) {
      throw new VertxException(e);
    }
  } else {
    user = null;
  }
  return pos;
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:23,代码来源:UserHolder.java


示例12: init

import io.vertx.core.VertxException; //导入依赖的package包/类
private synchronized void init() {
  if (gateway == null) {
    boolean connected = false;
    while (!connected) {
      try {
        gateway = new GatewayServer(this, port);
        client = gateway.getCallbackClient().getPort();
        gateway.start();
        connected = true;
      } catch (Exception e) {
        port++;
      }
      if (port > 25340) {
        throw new VertxException("Failed to bind to port");
      }
    }
  }
}
 
开发者ID:vert-x3,项目名称:vertx-lang-python,代码行数:19,代码来源:PythonVerticleFactory.java


示例13: getLockWithTimeout

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler) {
  ContextImpl context = (ContextImpl) vertx.getOrCreateContext();
  // Ordered on the internal blocking executor
  context.executeBlocking(() -> {
    ISemaphore iSemaphore = hazelcast.getSemaphore(LOCK_SEMAPHORE_PREFIX + name);
    boolean locked = false;
    long remaining = timeout;
    do {
      long start = System.nanoTime();
      try {
        locked = iSemaphore.tryAcquire(remaining, TimeUnit.MILLISECONDS);
      } catch (InterruptedException e) {
        // OK continue
      }
      remaining = remaining - MILLISECONDS.convert(System.nanoTime() - start, NANOSECONDS);
    } while (!locked && remaining > 0);
    if (locked) {
      return new HazelcastLock(iSemaphore);
    } else {
      throw new VertxException("Timed out waiting to get lock " + name);
    }
  }, resultHandler);
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:25,代码来源:HazelcastClusterManager.java


示例14: authenticate

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public void authenticate(JsonObject authInfo, Handler<AsyncResult<User>> resultHandler) {
  vertx.executeBlocking(fut -> {
    SubjectContext subjectContext = new DefaultSubjectContext();
    Subject subject = securityManager.createSubject(subjectContext);
    String username = authInfo.getString("username");
    String password = authInfo.getString("password");
    AuthenticationToken token = new UsernamePasswordToken(username, password);
    try {
      subject.login(token);
    } catch (AuthenticationException e) {
      throw new VertxException(e);
    }
    fut.complete(new ShiroUser(vertx, securityManager, subject, rolePrefix));
  }, resultHandler);
}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:17,代码来源:ShiroAuthProviderImpl.java


示例15: computeHash

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public String computeHash(String password, String salt, int version) {

  String concat =
    (salt == null ? "" : salt) +
      password;

  if (version >= 0) {
    if (nonces == null) {
      // the nonce version is not a number
      throw new VertxException("nonces are not available");
    }
    if (version < nonces.size()) {
      concat += nonces.getString(version);
    }
  }

  byte[] bHash = md.digest(concat.getBytes(StandardCharsets.UTF_8));
  if (version >= 0) {
    return bytesToHex(bHash) + '$' + version;
  } else {
    return bytesToHex(bHash);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:25,代码来源:SHA512Strategy.java


示例16: applicationTest

import io.vertx.core.VertxException; //导入依赖的package包/类
public Future<ApplicationTest> applicationTest() {
    return gradleProperties.version().map(version -> {
            try {
                return new ApplicationTest(hostname(), version);
            } catch (final IOException e) {
                throw new VertxException(e);
            }
        });
}
 
开发者ID:yyunikov,项目名称:vertx-gradle-starter,代码行数:10,代码来源:System.java


示例17: adapt

import io.vertx.core.VertxException; //导入依赖的package包/类
public static SessionStore adapt(Vertx vertx, SessionStore sessionStore) {
    MessageProducer<String> sessionMessageProducer = vertx.eventBus().sender(VAADIN_SESSION_EXPIRED_ADDRESS);
    if (sessionStore instanceof LocalSessionStoreImpl) {
        return LocalSessionStoreAdapter.of(sessionMessageProducer, (LocalSessionStoreImpl) sessionStore);
    }
    if (sessionStore instanceof ClusteredSessionStoreImpl) {
        return new ClusteredSessionStoreAdapter(sessionMessageProducer, (ClusteredSessionStoreImpl) sessionStore);
    }
    throw new VertxException("Cannot adapt session store of type " + sessionStore.getClass().getName());
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:11,代码来源:SessionStoreAdapter.java


示例18: VertxVaadin

import io.vertx.core.VertxException; //导入依赖的package包/类
private VertxVaadin(Vertx vertx, Optional<SessionStore> sessionStore, JsonObject config) {
    this.vertx = Objects.requireNonNull(vertx);
    this.config = Objects.requireNonNull(config);
    this.service = createVaadinService();
    try {
        service.init();
    } catch (Exception ex) {
        throw new VertxException("Cannot initialize Vaadin service", ex);
    }
    SessionStore adaptedSessionStore = SessionStoreAdapter.adapt(vertx, sessionStore.orElseGet(this::createSessionStore));
    this.router = initRouter(adaptedSessionStore);
    this.webSocketHandler = initWebSocketHandler(this.router, adaptedSessionStore);
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:14,代码来源:VertxVaadin.java


示例19: size

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public int size() {
  try {
    return curator.getChildren().forPath(mapPath).size();
  } catch (Exception e) {
    throw new VertxException(e);
  }
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:9,代码来源:ZKSyncMap.java


示例20: isEmpty

import io.vertx.core.VertxException; //导入依赖的package包/类
@Override
public boolean isEmpty() {
  try {
    return curator.getChildren().forPath(mapPath).isEmpty();
  } catch (Exception e) {
    throw new VertxException(e);
  }
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:9,代码来源:ZKSyncMap.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContentProducer类代码示例发布时间:2022-05-21
下一篇:
Java MethodNotFoundException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap