當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。