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


Java DefaultClientConfig类代码示例

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


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

示例1: getResource

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
@Override
public WebResource getResource() {
	WebResource webResource = null;
	ClientConfig config = new DefaultClientConfig();
	config.getClasses().add(GsonJerseyProvider.class);
	Client client = Client.create(config);
	OAuthParameters oaParams = new OAuthParameters().signatureMethod("HMAC-SHA1").consumerKey(consumerKey)
			.token(accessToken).version("1.0");
	OAuthSecrets oaSecrets = new OAuthSecrets().consumerSecret(consumerSecret).tokenSecret(accessTokenSecret);

	OAuthClientFilter oAuthFilter = new OAuthClientFilter(client.getProviders(), oaParams, oaSecrets);
	client.addFilter(oAuthFilter);

	if (this.sandbox) {
		webResource = client.resource(Constants.SANDBOX_BASE_API_URL);
	} else if (null!= this.domain){
		webResource = client.resource(this.domain);
	}
	else{
		webResource = client.resource(Constants.BASE_API_URL);
	}
	
	
	if (this.trace) {
		webResource.addFilter(new LoggingFilter());
	}
	return webResource;
}
 
开发者ID:mrisney,项目名称:twitter-java-ads-sdk,代码行数:29,代码来源:ClientServiceImpl.java

示例2: getClient

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public Client getClient() {

		ClientConfig config = new DefaultClientConfig();
		Client client = Client.create(config);

		OAuthParameters oaParams = new OAuthParameters().signatureMethod("HMAC-SHA1").consumerKey(consumerKey)
				.token(accessToken).version("1.0");

		OAuthSecrets oaSecrets = new OAuthSecrets().consumerSecret(consumerSecret).tokenSecret(accessTokenSecret);

		OAuthClientFilter oAuthFilter = new OAuthClientFilter(client.getProviders(), oaParams, oaSecrets);
		client.addFilter(oAuthFilter);

		return client;
	}
 
开发者ID:mrisney,项目名称:twitter-java-ads-sdk,代码行数:16,代码来源:ClientServiceImpl.java

示例3: rebuildHttpClient

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
/**
 * Build the Client used to make HTTP requests with the latest settings,
 * i.e. objectMapper and debugging.
 * TODO: better to use the Builder Pattern?
 */
public ApiClient rebuildHttpClient() {
  // Add the JSON serialization support to Jersey
  JacksonJsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);
  DefaultClientConfig conf = new DefaultClientConfig();
  conf.getSingletons().add(jsonProvider);
  Client client = Client.create(conf);
  if (debugging) {
    client.addFilter(new LoggingFilter());
  }
  
  //to solve the issue of GET:metadata/:guid with accepted encodeing is 'gzip' 
  //in the past, when clients use gzip header, actually it doesn't trigger a gzip encoding... So everything is fine 
  //After the release, the content is return in gzip, while the sdk doesn't handle it correctly
  client.addFilter(new GZIPContentEncodingFilter(false));

  this.httpClient = client;
  return this;
}
 
开发者ID:Autodesk-Forge,项目名称:forge-api-java-client,代码行数:24,代码来源:ApiClient.java

示例4: hostIgnoringClient

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
/**
 * Create a client which trust any HTTPS server
 * 
 * @return
 */
public static Client hostIgnoringClient() {
    try {
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, null, null);
        DefaultClientConfig config = new DefaultClientConfig();
        Map<String, Object> properties = config.getProperties();
        HTTPSProperties httpsProperties = new HTTPSProperties(new HostnameVerifier() {
            @Override
            public boolean verify(String s, SSLSession sslSession) {
                return true;
            }
        }, sslcontext);
        properties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
        // config.getClasses().add( JacksonJsonProvider.class );
        return Client.create(config);
    } catch (KeyManagementException | NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:25,代码来源:RestUtilTest.java

示例5: checkActiveRMWebServices

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
private void checkActiveRMWebServices() throws JSONException {

    // Validate web-service
    Client webServiceClient = Client.create(new DefaultClientConfig());
    InetSocketAddress rmWebappAddr =
        NetUtils.getConnectAddress(rm.getWebapp().getListenerAddress());
    String webappURL =
        "http://" + rmWebappAddr.getHostName() + ":" + rmWebappAddr.getPort();
    WebResource webResource = webServiceClient.resource(webappURL);
    String path = app.getApplicationId().toString();

    ClientResponse response =
        webResource.path("ws").path("v1").path("cluster").path("apps")
          .path(path).accept(MediaType.APPLICATION_JSON)
          .get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);

    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject appJson = json.getJSONObject("app");
    assertEquals("ACCEPTED", appJson.getString("state"));
    // Other stuff is verified in the regular web-services related tests
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRMHA.java

示例6: galaxyRestConnect

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
@Test
    public void galaxyRestConnect() throws URISyntaxException, MalformedURLException, IOException, JSONException {
        //http://galaxy.readthedocs.io/en/master/lib/galaxy.webapps.galaxy.api.html#module-galaxy.webapps.galaxy.api.histories

        ClientConfig config = new DefaultClientConfig();
        Client client = Client.create(config);
        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
        WebResource service = client.resource(new URI(gURL));

//        MultivaluedMap<String, String> params = new MultivaluedMapImpl();
//        params.add("key", gKey);
        ClientResponse responseHist = service.path("/api/histories").queryParam("key", gApiKey).accept("application/json").type("application/json").get(ClientResponse.class);
        System.out.println("----------");
        String r = responseHist.getEntity(String.class);
        Util.jsonPP(r);
        System.out.println("----------");

//        /api/tools
        ClientResponse responseTools = service.path("/api/tools").queryParam("key", gApiKey).accept("application/json").type("application/json").get(ClientResponse.class);
        System.out.println("----------");
        r = responseTools.getEntity(String.class);
        Util.jsonPP(r);
    }
 
开发者ID:albangaignard,项目名称:galaxy-PROV,代码行数:24,代码来源:GalaxyApiTest.java

示例7: readSpecificRow

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public  static Map<String,Object> readSpecificRow(String keyspaceName, String tableName,String keyName, String keyValue){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	
	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+keyName+"="+keyValue);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	
	Map<String, Object> rowMap=null;
	for (Map.Entry<String, Object> entry : output.entrySet()){
		rowMap = (Map<String, Object>)entry.getValue();
		break;
	}

	return rowMap;	
}
 
开发者ID:att,项目名称:music,代码行数:27,代码来源:MusicHandle.java

示例8: dropTable

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public static void dropTable(String keyspaceName, String tableName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonTable jsonTb = new JsonTable();
	jsonTb.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonTb);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
开发者ID:att,项目名称:music,代码行数:24,代码来源:MusicHandle.java

示例9: dropKeySpace

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public static void dropKeySpace(String keyspaceName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
开发者ID:att,项目名称:music,代码行数:24,代码来源:MusicHandle.java

示例10: deleteCandidateEntryEventually

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
private  void deleteCandidateEntryEventually(String candidateName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonDelete jDel = new JsonDelete();
	jDel.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	System.out.println(url);
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").delete(ClientResponse.class, jDel);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url);

}
 
开发者ID:att,项目名称:music,代码行数:25,代码来源:VotingApp.java

示例11: readVoteCountForCandidate

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public  Map<String,Object> readVoteCountForCandidate(String candidateName){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
开发者ID:att,项目名称:music,代码行数:20,代码来源:VotingApp.java

示例12: readAllVotes

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public  Map<String,Object> readAllVotes(){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows";
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
开发者ID:att,项目名称:music,代码行数:20,代码来源:VotingApp.java

示例13: dropKeySpace

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
private void dropKeySpace(){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
开发者ID:att,项目名称:music,代码行数:24,代码来源:VotingApp.java

示例14: createStringMapTable

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public void createStringMapTable(String keyspaceName, String tableName,Map<String,String> fields){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonTable jtab = new JsonTable();
	jtab.setFields(fields);
	jtab.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").post(ClientResponse.class, jtab);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());

}
 
开发者ID:att,项目名称:music,代码行数:26,代码来源:MusicRestClient.java

示例15: createRow

import com.sun.jersey.api.client.config.DefaultClientConfig; //导入依赖的package包/类
public  void createRow(String keyspaceName, String tableName,Map<String, Object> values){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonInsert jIns = new JsonInsert();
	jIns.setValues(values);
	jIns.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows";
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").post(ClientResponse.class, jIns);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url+"values:"+values);


}
 
开发者ID:att,项目名称:music,代码行数:27,代码来源:MusicRestClient.java


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