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


Java Holder类代码示例

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


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

示例1: getAllMicroservices

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public List<Microservice> getAllMicroservices() {
  Holder<GetAllServicesResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.get(ipPort,
      Const.REGISTRY_API.MICROSERVICE_OPERATION_ALL,
      new RequestParam(),
      syncHandler(countDownLatch, GetAllServicesResponse.class, holder));
  try {
    countDownLatch.await();
    if (holder.value != null) {
      return holder.value.getServices();
    }
  } catch (Exception e) {
    LOGGER.error("query all microservices failed", e);
  }
  return emptyList();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:ServiceRegistryClientImpl.java

示例2: testInvokingServiceFromCXFClient

import javax.xml.ws.Holder; //导入依赖的package包/类
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(ADDRESS);
    clientBean.setServiceClass(MyOrderEndpoint.class);
    
    MyOrderEndpoint client = (MyOrderEndpoint) proxyFactory.create();
    
    Holder<String> strPart = new Holder<String>();
    strPart.value = "parts";
    Holder<String> strCustomer = new Holder<String>();
    strCustomer.value = "";

    String result = client.myOrder(strPart, 2, strCustomer);
    assertEquals("Get a wrong order result", "Ordered ammount 2", result);
    assertEquals("Get a wrong parts", "parts", strPart.value);
    assertEquals("Get a wrong customer", "newCustomer", strCustomer.value);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CxfHolderConsumerTest.java

示例3: blockDeploy

import javax.xml.ws.Holder; //导入依赖的package包/类
public static <VERTICLE extends AbstractVerticle> boolean blockDeploy(Vertx vertx,
    Class<VERTICLE> cls,
    DeploymentOptions options) throws InterruptedException {
  Holder<Boolean> result = new Holder<>();

  CountDownLatch latch = new CountDownLatch(1);
  vertx.deployVerticle(cls.getName(), options, ar -> {
    result.value = ar.succeeded();

    if (ar.failed()) {
      LOGGER.error("deploy vertx failed, cause ", ar.cause());
    }

    latch.countDown();
  });

  latch.await();

  return result.value;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:VertxUtils.java

示例4: setBodyBuffer

import javax.xml.ws.Holder; //导入依赖的package包/类
@Test
public void setBodyBuffer() {
  Holder<Buffer> bodyHolder = new Holder<>();
  context = new MockUp<RoutingContext>() {
    @Mock
    HttpServerRequest request() {
      return vertxRequest;
    }

    @Mock
    void setBody(Buffer body) {
      bodyHolder.value = body;
    }
  }.getMockInstance();
  request = new VertxServerRequestToHttpServletRequest(context);

  Buffer bodyBuffer = Buffer.buffer();
  request.setBodyBuffer(bodyBuffer);

  Assert.assertSame(bodyBuffer, bodyHolder.value);
  Assert.assertSame(bodyBuffer, request.getBodyBuffer());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:TestVertxServerRequestToHttpServletRequest.java

示例5: syncHandlerEx

import javax.xml.ws.Holder; //导入依赖的package包/类
private Handler<RestResponse> syncHandlerEx(CountDownLatch countDownLatch, Holder<ResponseWrapper> holder) {
  return restResponse -> {
    RequestContext requestContext = restResponse.getRequestContext();
    HttpClientResponse response = restResponse.getResponse();
    if (response == null) {
      // 请求失败,触发请求SC的其他实例
      if (!requestContext.isRetry()) {
        retry(requestContext, syncHandlerEx(countDownLatch, holder));
      } else {
        countDownLatch.countDown();
      }

      return;
    }

    response.bodyHandler(bodyBuffer -> {
      ResponseWrapper responseWrapper = new ResponseWrapper();
      responseWrapper.response = response;
      responseWrapper.bodyBuffer = bodyBuffer;
      holder.value = responseWrapper;
      countDownLatch.countDown();
    });
  };
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:ServiceRegistryClientImpl.java

示例6: isSchemaExist

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public boolean isSchemaExist(String microserviceId, String schemaId) {
  Holder<GetExistenceResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.get(ipPort,
      Const.REGISTRY_API.MICROSERVICE_EXISTENCE,
      new RequestParam().addQueryParam("type", "schema")
          .addQueryParam("serviceId", microserviceId)
          .addQueryParam("schemaId", schemaId),
      syncHandler(countDownLatch, GetExistenceResponse.class, holder));
  try {
    countDownLatch.await();
  } catch (Exception e) {
    LOGGER.error("query schema exist {}/{} fail",
        microserviceId,
        schemaId,
        e);
  }
  return holder.value != null;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:ServiceRegistryClientImpl.java

示例7: getSchema

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public String getSchema(String microserviceId, String schemaId) {
  Holder<GetSchemaResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.get(ipPort,
      String.format(Const.REGISTRY_API.MICROSERVICE_SCHEMA, microserviceId, schemaId),
      new RequestParam(),
      syncHandler(countDownLatch, GetSchemaResponse.class, holder));
  try {
    countDownLatch.await();
  } catch (Exception e) {
    LOGGER.error("query schema exist {}/{} failed",
        microserviceId,
        schemaId,
        e);
  }
  if (holder.value != null) {
    return holder.value.getSchema();
  }

  return null;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:ServiceRegistryClientImpl.java

示例8: getMicroservice

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public Microservice getMicroservice(String microserviceId) {
  Holder<GetServiceResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.get(ipPort,
      String.format(Const.REGISTRY_API.MICROSERVICE_OPERATION_ONE, microserviceId),
      new RequestParam(),
      syncHandler(countDownLatch, GetServiceResponse.class, holder));
  try {
    countDownLatch.await();
    if (holder.value != null) {
      return holder.value.getService();
    }
  } catch (Exception e) {
    LOGGER.error("query microservice {} failed", microserviceId, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:ServiceRegistryClientImpl.java

示例9: getMicroserviceInstance

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public List<MicroserviceInstance> getMicroserviceInstance(String consumerId, String providerId) {
  Holder<GetInstancesResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.get(ipPort,
      String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ALL, providerId),
      new RequestParam().addHeader("X-ConsumerId", consumerId),
      syncHandler(countDownLatch, GetInstancesResponse.class, holder));
  try {
    countDownLatch.await();
    if (holder.value != null) {
      return holder.value.getInstances();
    }
  } catch (Exception e) {
    LOGGER.error("query microservice instances {} failed", providerId, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:ServiceRegistryClientImpl.java

示例10: unregisterMicroserviceInstance

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public boolean unregisterMicroserviceInstance(String microserviceId, String microserviceInstanceId) {
  Holder<HttpClientResponse> holder = new Holder<>();
  IpPort ipPort = ipPortManager.getAvailableAddress();

  CountDownLatch countDownLatch = new CountDownLatch(1);
  RestUtils.delete(ipPort,
      String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ONE, microserviceId, microserviceInstanceId),
      new RequestParam(),
      syncHandler(countDownLatch, HttpClientResponse.class, holder));
  try {
    countDownLatch.await();
    if (holder.value != null) {
      if (holder.value.statusCode() == Status.OK.getStatusCode()) {
        return true;
      }
      LOGGER.warn(holder.value.statusMessage());
    }
  } catch (Exception e) {
    LOGGER.error("unregister microservice instance {}/{} failed",
        microserviceId,
        microserviceInstanceId,
        e);
  }
  return false;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:27,代码来源:ServiceRegistryClientImpl.java

示例11: findServiceInstance

import javax.xml.ws.Holder; //导入依赖的package包/类
@Override
public MicroserviceInstance findServiceInstance(String serviceId, String instanceId) {
  try {
    Holder<MicroserviceInstanceResponse> holder = new Holder<>();
    IpPort ipPort = ipPortManager.getAvailableAddress();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort,
        String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ONE, serviceId, instanceId),
        new RequestParam().addHeader("X-ConsumerId", serviceId),
        syncHandler(countDownLatch, MicroserviceInstanceResponse.class, holder));
    countDownLatch.await();
    if (null != holder.value) {
      return holder.value.getInstance();
    }
    return null;
  } catch (Exception e) {
    LOGGER.error("get instance from sc failed");
    return null;
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:ServiceRegistryClientImpl.java

示例12: testPullEvent

import javax.xml.ws.Holder; //导入依赖的package包/类
private void testPullEvent(Object event) {
  Map<String, MicroserviceVersions> versionsByName = Deencapsulation.getField(microserviceManager, "versionsByName");

  Holder<Integer> count = new Holder<>();
  count.value = 0;
  MicroserviceVersions versions = new MockUp<MicroserviceVersions>() {
    @Mock
    void submitPull() {
      count.value++;
    }
  }.getMockInstance();
  versionsByName.put("ms", versions);

  eventBus.post(event);
  Assert.assertEquals(1, (int) count.value);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestMicroserviceManager.java

示例13: testWatchOpen

import javax.xml.ws.Holder; //导入依赖的package包/类
@Test
public void testWatchOpen(@Mocked ServiceRegistryConfig serviceRegistryConfig,
    @Mocked ServiceRegistryClient srClient,
    @Mocked Microservice microservice) {
  initWatch(serviceRegistryConfig, srClient, microservice);

  new MockUp<ServiceRegistryClient>(srClient) {
    @Mock
    void watch(String selfMicroserviceId, AsyncResultCallback<MicroserviceInstanceChangedEvent> callback,
        AsyncResultCallback<Void> onOpen, AsyncResultCallback<Void> onClose) {
      onOpen.success(null);
    }
  };

  Holder<Boolean> openHolder = new Holder<>();
  eventBus.register(new Object() {
    @Subscribe
    public void onOpen(RecoveryEvent event) {
      openHolder.value = true;
    }
  });
  Assert.assertNull(openHolder.value);
  microserviceWatchTask.run();
  Assert.assertTrue(openHolder.value);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:TestMicroserviceWatchTask.java

示例14: testWatchFailed

import javax.xml.ws.Holder; //导入依赖的package包/类
@Test
public void testWatchFailed(@Mocked ServiceRegistryConfig serviceRegistryConfig,
    @Mocked ServiceRegistryClient srClient,
    @Mocked Microservice microservice) {
  initWatch(serviceRegistryConfig, srClient, microservice);

  new MockUp<ServiceRegistryClient>(srClient) {
    @Mock
    void watch(String selfMicroserviceId, AsyncResultCallback<MicroserviceInstanceChangedEvent> callback,
        AsyncResultCallback<Void> onOpen, AsyncResultCallback<Void> onClose) {
      callback.fail(new Error("test failed"));
    }
  };

  Holder<Throwable> holder = new Holder<>();
  eventBus.register(new Object() {
    @Subscribe
    public void onException(ExceptionEvent event) {
      holder.value = event.getThrowable();
    }
  });
  Assert.assertNull(holder.value);
  microserviceWatchTask.run();
  Assert.assertEquals("test failed", holder.value.getMessage());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:TestMicroserviceWatchTask.java

示例15: service

import javax.xml.ws.Holder; //导入依赖的package包/类
@Test
public void service() {
  Holder<Boolean> handled = new Holder<>();

  new MockUp<RestServletProducerInvocation>() {
    @Mock
    void invoke(Transport transport, HttpServletRequestEx requestEx, HttpServletResponseEx responseEx,
        List<HttpServerFilter> httpServerFilters) {
      handled.value = true;
    }
  };

  dispatcher.service(request, response);

  Assert.assertTrue(handled.value);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestServletRestDispatcher.java


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