當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientConfig類代碼示例

本文整理匯總了Java中com.sun.jersey.api.client.config.ClientConfig的典型用法代碼示例。如果您正苦於以下問題:Java ClientConfig類的具體用法?Java ClientConfig怎麽用?Java ClientConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClientConfig類屬於com.sun.jersey.api.client.config包,在下文中一共展示了ClientConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getResource

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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.ClientConfig; //導入依賴的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: get

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的package包/類
/**
    * Make HTTP GET call to the given url
    * 
    * @param url
    */
   public void get(String url) {
ClientConfig cc = new DefaultNonBlockingClientConfig();
Client c = NonBlockingClient.create(cc);
AsyncWebResource awr = c.asyncResource(url);
// makes HTTP GET call
awr.get(new TypeListener<ClientResponse>(ClientResponse.class) {

    public void onComplete(Future<ClientResponse> f)
	    throws InterruptedException {
	try {
	    System.out.println("Got Response. HTTP Code = "
		    + f.get().getStatus());
	} catch (ExecutionException e) {
	    System.out.println("Something went wrong!");
	}
    }

});
System.out.println("Continued to execute...");
System.out.println("Done!");
   }
 
開發者ID:sithu,項目名稱:jersey-http-client,代碼行數:27,代碼來源:NonBlockingHttpClient.java

示例4: galaxyRestConnect

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例5: readSpecificRow

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例6: dropTable

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例7: dropKeySpace

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例8: deleteCandidateEntryEventually

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例9: readVoteCountForCandidate

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例10: readAllVotes

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例11: dropKeySpace

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例12: createStringMapTable

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例13: createRow

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的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

示例14: basicUpdateRow

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的package包/類
private void basicUpdateRow(String keyspaceName, String tableName, String primaryKeyName, String primaryKeyValue, Map<String, Object> values, Map<String,String> consistencyInfo){
	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?"+primaryKeyName+"="+primaryKeyValue;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").put(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,代碼行數:22,代碼來源:MusicRestClient.java

示例15: deleteEntry

import com.sun.jersey.api.client.config.ClientConfig; //導入依賴的package包/類
public  void deleteEntry(String keyspaceName, String tableName, String primaryKeyName, String primaryKeyValue){
	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 =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+primaryKeyName+"="+primaryKeyValue;
	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,代碼行數:24,代碼來源:MusicRestClient.java


注:本文中的com.sun.jersey.api.client.config.ClientConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。