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


Java InvocationCallback类代码示例

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


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

示例1: invokeCallbackString

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
private MyResult invokeCallbackString(String url) {
	Client client = newClient();
	WebTarget target = client.target(url);
	final AsyncInvoker asyncInvoker = target.request().async();
	final MyResult myResponse = new MyResult();

	asyncInvoker.get(new InvocationCallback<String>() {
		@Override
		public void completed(String response) {
			myResponse.setResponse(response);
			myResponse.setOk(true);
		}

		@Override
		public void failed(Throwable arg0) {
			myResponse.setResponse(arg0.getMessage());
			myResponse.setOk(false);
		}
	});
	try {
		sleep(2000);
	} catch (InterruptedException e) {
		logger.log(SEVERE, "error", e);
	}
	return myResponse;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:27,代码来源:ReceiveMessagesTestCase.java

示例2: invokeCallbackResponse

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
private MyResult invokeCallbackResponse(String url) {
	Client client = newClient();
	WebTarget target = client.target(url);
	final AsyncInvoker asyncInvoker = target.request().async();
	final MyResult myResponse = new MyResult();

	asyncInvoker.get(new InvocationCallback<Response>() {
		@Override
		public void completed(Response response) {
			myResponse.setResponse(response.readEntity(String.class));
			myResponse.setOk(response.hasEntity());
		}

		@Override
		public void failed(Throwable arg0) {
			myResponse.setResponse(arg0.getMessage());
			myResponse.setOk(false);
		}
	});
	try {
		sleep(2000);
	} catch (InterruptedException e) {
		logger.log(SEVERE, "error", e);
	}
	return myResponse;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:27,代码来源:ReceiveMessagesTestCase.java

示例3: responseInvocationCallback

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
private static InvocationCallback<Response> responseInvocationCallback() {
    return new InvocationCallback<Response>() {
        @Override
        public void completed(Response res) {
            System.out.println("Status:" + res.getStatusInfo());
            System.out.println("Entity:" + res.getEntity());
            System.out.println("Request success!");
        }

        @Override
        public void failed(Throwable e) {
            System.out.println("Request failed!");
        }

    };
}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:17,代码来源:AsyncClient.java

示例4: getPartitionedTopicMetadataAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadataAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PartitionedTopicMetadata> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("partitions"),
            new InvocationCallback<PartitionedTopicMetadata>() {

                @Override
                public void completed(PartitionedTopicMetadata response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PersistentTopicsImpl.java

示例5: getSubscriptionsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<List<String>> getSubscriptionsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<List<String>> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscriptions"),
            new InvocationCallback<List<String>>() {

                @Override
                public void completed(List<String> response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PersistentTopicsImpl.java

示例6: getStatsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PersistentTopicStats> getStatsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PersistentTopicStats> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("stats"),
            new InvocationCallback<PersistentTopicStats>() {

                @Override
                public void completed(PersistentTopicStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PersistentTopicsImpl.java

示例7: getInternalStatsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PersistentTopicInternalStats> getInternalStatsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PersistentTopicInternalStats> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("internalStats"),
            new InvocationCallback<PersistentTopicInternalStats>() {

                @Override
                public void completed(PersistentTopicInternalStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PersistentTopicsImpl.java

示例8: getInternalInfoAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<JsonObject> getInternalInfoAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<JsonObject> future = new CompletableFuture<>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("internal-info"),
            new InvocationCallback<String>() {
                @Override
                public void completed(String response) {
                    JsonObject json = new Gson().fromJson(response, JsonObject.class);
                    future.complete(json);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:PersistentTopicsImpl.java

示例9: getPartitionedStatsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PartitionedTopicStats> getPartitionedStatsAsync(String destination,
        boolean perPartition) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PartitionedTopicStats> future = new CompletableFuture<>();
    asyncGetRequest(
            persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("partitioned-stats"),
            new InvocationCallback<PartitionedTopicStats>() {

                @Override
                public void completed(PartitionedTopicStats response) {
                    if (!perPartition) {
                        response.partitions.clear();
                    }
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:25,代码来源:PersistentTopicsImpl.java

示例10: peekNthMessage

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
private CompletableFuture<List<Message>> peekNthMessage(String destination, String subName, int messagePosition) {
    DestinationName ds = validateTopic(destination);
    String encodedSubName = Codec.encode(subName);
    final CompletableFuture<List<Message>> future = new CompletableFuture<List<Message>>();
    asyncGetRequest(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscription")
            .path(encodedSubName).path("position").path(String.valueOf(messagePosition)),
            new InvocationCallback<Response>() {

                @Override
                public void completed(Response response) {
                    try {
                        future.complete(getMessageFromHttpResponse(response));
                    } catch (Exception e) {
                        future.completeExceptionally(getApiException(e));
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:25,代码来源:PersistentTopicsImpl.java

示例11: getPartitionedTopicMetadataAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadataAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PartitionedTopicMetadata> future = new CompletableFuture<>();
    asyncGetRequest(nonPersistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("partitions"),
            new InvocationCallback<PartitionedTopicMetadata>() {

                @Override
                public void completed(PartitionedTopicMetadata response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:NonPersistentTopicsImpl.java

示例12: getStatsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<NonPersistentTopicStats> getStatsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<NonPersistentTopicStats> future = new CompletableFuture<>();
    asyncGetRequest(nonPersistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("stats"),
            new InvocationCallback<NonPersistentTopicStats>() {

                @Override
                public void completed(NonPersistentTopicStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:NonPersistentTopicsImpl.java

示例13: getInternalStatsAsync

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
@Override
public CompletableFuture<PersistentTopicInternalStats> getInternalStatsAsync(String destination) {
    DestinationName ds = validateTopic(destination);
    final CompletableFuture<PersistentTopicInternalStats> future = new CompletableFuture<>();
    asyncGetRequest(nonPersistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("internalStats"),
            new InvocationCallback<PersistentTopicInternalStats>() {

                @Override
                public void completed(PersistentTopicInternalStats response) {
                    future.complete(response);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:20,代码来源:NonPersistentTopicsImpl.java

示例14: asyncPutRequest

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
public <T> CompletableFuture<Void> asyncPutRequest(final WebTarget target, Entity<T> entity) {
    final CompletableFuture<Void> future = new CompletableFuture<>();
    try {
        request(target).async().put(entity, new InvocationCallback<ErrorData>() {

            @Override
            public void completed(ErrorData response) {
                future.complete(null);
            }

            @Override
            public void failed(Throwable throwable) {
                log.warn("[{}] Failed to perform http put request: {}", target.getUri(), throwable.getMessage());
                future.completeExceptionally(getApiException(throwable.getCause()));
            }

        });
    } catch (PulsarAdminException cae) {
        future.completeExceptionally(cae);
    }
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:23,代码来源:BaseResource.java

示例15: asyncPostRequest

import javax.ws.rs.client.InvocationCallback; //导入依赖的package包/类
public <T> CompletableFuture<Void> asyncPostRequest(final WebTarget target, Entity<T> entity) {
    final CompletableFuture<Void> future = new CompletableFuture<>();
    try {
        request(target).async().post(entity, new InvocationCallback<ErrorData>() {

            @Override
            public void completed(ErrorData response) {
                future.complete(null);
            }

            @Override
            public void failed(Throwable throwable) {
                log.warn("[{}] Failed to perform http post request: {}", target.getUri(), throwable.getMessage());
                future.completeExceptionally(getApiException(throwable.getCause()));
            }

        });
    } catch (PulsarAdminException cae) {
        future.completeExceptionally(cae);
    }
    return future;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:23,代码来源:BaseResource.java


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