public URI uri() {
   try {
     return new URI(this.uri);
   } catch (URISyntaxException e) {
     ReflectionUtils.rethrowRuntimeException(e);
   }
   return null;
 }
 public GrailsWebRequest(
     HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) {
   super(request, response);
   try {
     attributes = grailsApplicationAttributesConstructor.newInstance(servletContext);
     this.applicationContext = attributes.getApplicationContext();
   } catch (Exception e) {
     ReflectionUtils.rethrowRuntimeException(e);
   }
   inheritEncodingStateRegistry();
 }
 private Object findTarget(Object item) {
   Object current = item;
   while (current instanceof Advised) {
     try {
       current = ((Advised) current).getTargetSource().getTarget();
     } catch (Exception e) {
       ReflectionUtils.rethrowRuntimeException(e);
     }
   }
   return current;
 }
Beispiel #4
0
 public boolean invokeExistsSync(String nameSpace, final String path) {
   Assert.notNull(path, "path不能为空!");
   Assert.hasText(nameSpace, "nameSpace不能为空");
   try {
     return curatorFramework.usingNamespace(nameSpace).checkExists().forPath(path) == null;
   } catch (NoNodeException ex) {
     logger.warn(
         "ZK服务端({})没有配置节点:{}:{}",
         curatorFramework.getZookeeperClient().getCurrentConnectionString(),
         nameSpace,
         path);
   } catch (ConnectionLossException ex) {
     logger.error("ZK服务器连接失败!", ex);
   } catch (Exception ex) {
     rethrowRuntimeException(ex);
   }
   return false;
 }
Beispiel #5
0
 public String getDataSync(String nameSpace, String path) {
   Assert.hasText(nameSpace, "nameSpace不能为空");
   try {
     byte[] data = curatorFramework.usingNamespace(nameSpace).getData().forPath(path);
     String dataStr = new String(data, "UTF-8");
     logger.info("节点:{}:{} 的值为: {}", nameSpace, path, dataStr);
     return dataStr;
   } catch (NoNodeException ex) {
     logger.warn(
         "ZK服务端({})没有配置节点:{}:{}",
         curatorFramework.getZookeeperClient().getCurrentConnectionString(),
         nameSpace,
         path);
   } catch (ConnectionLossException ex) {
     logger.error("ZK服务器连接失败!", ex);
   } catch (Exception ex) {
     rethrowRuntimeException(ex);
   }
   return null;
 }
Beispiel #6
0
  private void invokeGetChildrenData(
      String nameSpace, String path, BackgroundCallback callback, Watcher watcher) {
    Assert.hasText(nameSpace, "nameSpace不能为空");

    try {
      curatorFramework
          .usingNamespace(nameSpace)
          .getChildren()
          .usingWatcher(watcher)
          .inBackground(callback)
          .forPath(path);
    } catch (NoNodeException ex) {
      logger.warn(
          "ZK服务端({})没有配置节点:{}:{}",
          curatorFramework.getZookeeperClient().getCurrentConnectionString(),
          nameSpace,
          path);
    } catch (ConnectionLossException ex) {
      logger.error("ZK服务器连接失败!", ex);
    } catch (Exception ex) {
      rethrowRuntimeException(ex);
    }
  }