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


Java Builder.get方法代码示例

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


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

示例1: getDruidTableMeta

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private DruidRestTableMeta getDruidTableMeta(String tableName, WebTarget webTarget) {
	WebTarget tableResource = webTarget.path(DATASOURCE).path(tableName);
	Builder builder = tableResource.request(MediaType.APPLICATION_JSON_TYPE);
	builder.accept(MediaType.APPLICATION_JSON);
	Response response = builder.get();
	
	int statusCode = response.getStatus();
	DruidRestTableMeta result = null;
	if (statusCode == Status.OK.getStatusCode()) {
		result = response.readEntity(DruidRestTableMeta.class);
	} else {
		String errorMsg = "Druid HTTP Status Code - " + statusCode + "; Response - " + response.readEntity(String.class) + "; GET - " + webTarget.getUri();
		logger.warn (errorMsg);
		throw new DataSourceException(errorMsg);
	}
	return result;
}
 
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:18,代码来源:DruidRestDBConnector.java

示例2: testJaxRSOptionsDeleteTypes

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testJaxRSOptionsDeleteTypes() throws Exception {
	logger.info("start JaxRS options delete test");
	Client client = newClient();
	WebTarget target = client.target(url + "services/receiver/options");
	Response response = target.request().options();
	String calledMethod = response.getHeaderString("calledMethod");
	double value = response.readEntity(Double.class);
	assertEquals("options implemented: ", 88.99, value, 0.0);
	client.close();
	assertEquals("The filter registerCall is called only for @Logged services", OPTIONS, calledMethod);
	client = newClient();
	target = client.target(url + "services/receiver/delete");
	response = target.request().delete();
	calledMethod = response.getHeaderString("calledMethod");
	value = response.readEntity(Double.class);
	assertEquals("delete implemented: ", 99.66, value, 0.0);
	client.close();
	assertEquals("The filter registerCall is called only for @Logged services", DELETE, calledMethod);
	client = newClient();
	target = client.target(url + "services/receiver/header");
	Builder builder = target.request().header("my_new_header", "Hi all");
	response = builder.get();
	calledMethod = response.getHeaderString("calledMethod");
	String valueStr = response.readEntity(String.class);
	assertEquals("head implemented: ", "Hi all", valueStr);
	client.close();
	assertNotEquals("The filter registerCall is called only for @Logged services", HEAD, calledMethod);
	client = newClient();
	target = client.target(url + "services/receiver/headerWithContext");
	builder = target.request(TEXT_PLAIN).header("my_new_header", "Hi allll");
	response = builder.get();
	calledMethod = response.getHeaderString("calledMethod");
	valueStr = response.readEntity(String.class);
	assertEquals("head implemented: ", "Hi allll", valueStr);
	client.close();
	assertNotEquals("The filter registerCall is called only for @Logged services", HEAD, calledMethod);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:40,代码来源:OtherTestCase.java

示例3: getTotalOnlineUsers

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public int getTotalOnlineUsers() {
	Builder builder = getBuilder("system/statistics/sessions");
	SessionsCount sessionsCount = builder.get(SessionsCount.class);
	int clusterSessions = sessionsCount.getClusterSessions();
	if (clusterSessions > 1) {
		return clusterSessions - 1;
	}
	return 0;
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:10,代码来源:OpenFireRestApiCli.java

示例4: getAllPersonaByGroup

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public List<Long> getAllPersonaByGroup(Long personaId) {
	Builder builder = getBuilder("chatrooms");
	MUCRoomEntities roomEntities = builder.get(MUCRoomEntities.class);
	List<MUCRoomEntity> listRoomEntity = roomEntities.getMucRooms();
	for(MUCRoomEntity entity : listRoomEntity) {
		String roomName = entity.getRoomName();
		if(roomName.contains("group.channel.")) {
			Long idOwner = Long.parseLong(roomName.substring(roomName.lastIndexOf('.') + 1));
			if(idOwner.equals(personaId)) {
				return getAllOccupantInGroup(roomName);
			}
		}
	}
	return new ArrayList<Long>();
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:16,代码来源:OpenFireRestApiCli.java

示例5: getAllOccupantInGroup

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private List<Long> getAllOccupantInGroup(String roomName) {
	Builder builder = getBuilder("chatrooms/" + roomName + "/occupants");
	OccupantEntities occupantEntities = builder.get(OccupantEntities.class);
	List<Long> listOfPersona = new ArrayList<Long>();
	for(OccupantEntity entity : occupantEntities.getOccupants()) {
		String jid = entity.getJid();
		Long personaId = Long.parseLong(jid.substring(jid.lastIndexOf('.') + 1));
		listOfPersona.add(personaId);
	}
	return listOfPersona;
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:12,代码来源:OpenFireRestApiCli.java

示例6: fetchWorksXML

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private Element fetchWorksXML(WebTarget target) throws JDOMException, IOException, SAXException {
    LOGGER.info("get {}", target.getUri());
    Builder b = target.request().accept(MCRORCIDConstants.ORCID_XML_MEDIA_TYPE)
        .header("Authorization", "Bearer " + MCRReadPublicTokenFactory.getToken());
    MCRContent response = new MCRStreamContent(b.get(InputStream.class));
    MCRContent transformed = T_WORK2MCR.transform(response);
    return transformed.asXML().detachRootElement();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:9,代码来源:MCRWorksFetcher.java

示例7: getDruidVersion

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private String getDruidVersion() {
	checkState();
	if(targetSize == 0)
		throw new DataSourceException("No available Druid Broker Servers.");
	List<WebTarget> druidHostList =
			FluentIterable.from(configuration.getEndPoint()).transform(new Function<String, WebTarget>() {
				@Override
				public WebTarget apply(String input) {
					return druidRestClient.target(input.replace("druid/v2", "status"));
			}
			}).toList();
	WebTarget webTarget = druidHostList.get(0);
	Builder builder = webTarget.request(MediaType.APPLICATION_JSON_TYPE);
	builder.accept(MediaType.APPLICATION_JSON);
	Response response = builder.get();
	
	int statusCode = response.getStatus();
	Map result = null;
	String version = "";
	if (statusCode == Status.OK.getStatusCode()) {
		result = response.readEntity(Map.class);
		if(result.size() > 0 && result.containsKey("version")){
			version = result.get("version").toString();
		}
	} else {
		String errorMsg = "Druid HTTP Status Code - " + statusCode + "; Response - " + response.readEntity(String.class) + "; GET - " + webTarget.getUri();
		logger.warn (errorMsg);
		throw new DataSourceException(errorMsg);
	}
	return version;
}
 
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:33,代码来源:DruidRestDBConnector.java

示例8: retrieveList

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Override
public List<T> retrieveList(WebTarget webClient, final String idName, final Long id,
		final Map<String, Object> pathParams, final Map<String, Object> queryParams, final Map<String, Object> builderProperties)
		throws Exception {

	if (queryParams != null)
		webClient = applyQuery(webClient, queryParams);

	GenericType<List<T>> genericType = new GenericType<List<T>>(getTypeListP()) {
	};

	if (pathParams != null)
		webClient = webClient.resolveTemplates(pathParams);

	if (id != null && idName != null)
		webClient = webClient.resolveTemplate(idName, id);

	Builder builder = acceptMediaType(webClient.request());
       if (builderProperties != null){
           addBuilderProperties(builder, builderProperties);
       }

	Method methodGet = Builder.class.getMethod("get", GenericType.class);

	List<T> objects = null;
	if (restCachingManager != null)
		objects = restCachingManager.manageRestCaching(builder, methodGet, genericType,
				this,
				getKey(webClient));
	else
		objects = builder.get(genericType);

	return objects;

}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:36,代码来源:RestPersistenceService.java

示例9: getPageable

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
<T, LT extends ObjectList<T, LT>> LT getPageable(Builder request, Class<LT> responseType) {
    Response response = request.get();
    LT responseBody = response.readEntity(responseType);
    Link next = response.getLink("next");
    return followPageable(next, responseBody, responseType);
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:7,代码来源:ApiBase.java

示例10: get

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public String get(String url) {

		Client client = ClientBuilder.newClient();

		WebTarget resource = client.target(url);

		Builder request = resource.request();
		request.accept(MediaType.TEXT_PLAIN);

		return request.get(String.class);

	}
 
开发者ID:aol,项目名称:micro-server,代码行数:13,代码来源:RestAgent.java

示例11: getJson

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public String getJson(String url) {

		Client client = ClientBuilder.newClient();

		WebTarget resource = client.target(url);

		Builder request = resource.request();
		request.accept(MediaType.APPLICATION_JSON);

		return request.get(String.class);

	}
 
开发者ID:aol,项目名称:micro-server,代码行数:13,代码来源:RestAgent.java


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