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


Java Client.create方法代码示例

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


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

示例1: setUp

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();

    RestCfg cfg = new RestCfg(new ByteArrayInputStream(String.format(
            "rest.port=%s\n" + 
            "rest.endpoint.1=%s;%s\n",
            GRIZZLY_PORT, CONTEXT_PATH, ZKHOSTPORT).getBytes()));

    rest = new RestMain(cfg);
    rest.start();

    zk = new ZooKeeper(ZKHOSTPORT, 30000, new MyWatcher());

    client = Client.create();
    znodesr = client.resource(BASEURI).path("znodes/v1");
    sessionsr = client.resource(BASEURI).path("sessions/v1/");
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:19,代码来源:Base.java

示例2: setUp

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    RestCfg cfg = new RestCfg(new ByteArrayInputStream(String.format(
            "rest.port=%s\n" + 
            "rest.endpoint.1=%s;%s\n",
            GRIZZLY_PORT, CONTEXT_PATH, ZKHOSTPORT).getBytes()));

    rest = new RestMain(cfg);
    rest.start();

    zk = new ZooKeeper(ZKHOSTPORT, 30000, new MyWatcher());

    client = Client.create();
    znodesr = client.resource(BASEURI).path("znodes/v1");
    sessionsr = client.resource(BASEURI).path("sessions/v1/");
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:17,代码来源:Base.java

示例3: jirasend

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
/**
 * Sends an Activity to SCMActivity Plugin's REST api
 * @param activity ScmActivity object corresponding to commit found in push payload
 * @throws ScmSyncException on post failure
 */
private void jirasend(ScmActivity activity) throws ScmSyncException {

  // Setup Client
  Client client = Client.create();
  WebResource webResource = client.resource(jiraRestUrl);
  client.addFilter(new HTTPBasicAuthFilter(jiraUser, jiraPassword));

  // Post to SCMActivity
  ClientResponse clientResponse = webResource.type("application/json").post(ClientResponse.class, activity.toJson());

  String result = clientResponse.getStatus() + " " + clientResponse.getEntity(String.class);
  logger.debug("Jira Send: \n\t" + activity.toString() + "\n\tResponse: " + result );

  if (clientResponse.getStatus() == 201 ) {
    logger.info("OK " + activity.getChangeId());
  } else {
    throw new ScmSyncException("Jira Rejected Activity because " + result  + " " + activity.toString());
  }
}
 
开发者ID:attivio,项目名称:scmsynchronizer,代码行数:25,代码来源:Server.java

示例4: readVoteCountForCandidate

import com.sun.jersey.api.client.Client; //导入方法依赖的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

示例5: zkGet

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public String zkGet(){
	Client client = Client.create();
	String url = musicurl+"/purezk/"+userForGets;
	System.out.println("in zk get:"+url);
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("text/plain")
			.get(ClientResponse.class);

	if (response.getStatus() != 200) {
		throw new RuntimeException("Failed : HTTP error code : "
				+ response.getStatus());
	}

	String output = response.getEntity(String.class);
	return "zkGet:"+url;
}
 
开发者ID:att,项目名称:music,代码行数:19,代码来源:MicroBenchMarks.java

示例6: whoIsLockHolder

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public  static String whoIsLockHolder(String lockName){
	Client client = Client.create();
	WebResource webResource = client.resource(HalUtil.getMusicNodeURL()+"/locks/enquire/"+lockName);


	WebResource.Builder wb = webResource.accept(MediaType.TEXT_PLAIN);

	ClientResponse response = wb.get(ClientResponse.class);

	if (response.getStatus() != 200) {
		throw new RuntimeException("Failed : HTTP error code : "
				+ response.getStatus());
	}

	String output = response.getEntity(String.class);
//	System.out.println("Server response .... \n");
//	System.out.println(output);
	return output;
}
 
开发者ID:att,项目名称:music,代码行数:20,代码来源:MusicHandle.java

示例7: musicGet

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public String musicGet(){
	ClientConfig clientConfig = new DefaultClientConfig();

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

	Client client = Client.create(clientConfig);
	
	String url = musicurl+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+userForGets;
	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 "musicGet:"+url;	
}
 
开发者ID:att,项目名称:music,代码行数:21,代码来源:MicroBenchMarks.java

示例8: main

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public static void main(String [] args) {
    System.out.println("Simple Java test for calling Hello Word service");

    try {
        // Get the endpoint for Hello World API
        String endpoint = args[0];

        // Create the client and call the API
        Client client = Client.create();
        WebResource webResource = client
                .resource(endpoint+"helloworld/");
        ClientResponse response = webResource.accept("application/json")
                .get(ClientResponse.class);

        // Process the result
        if (response.getStatus() != 200) {
            throw new RuntimeException("Called failed to HelloWorld : "
                    + response.getStatus());
        }

        String output = response.getEntity(String.class);

        System.out.println("Response: ");
        System.out.println(output);

    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:aws-samples,项目名称:blog-multi-region-serverless-service,代码行数:31,代码来源:JavaClient.java

示例9: getJSONData

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
private String getJSONData(){
    Client client = Client.create();
    WebResource webResource = client.resource(UriBuilder.fromUri("https://api.github.com/repos/"+username+"/"+repoName+"/releases").build());
    ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
    String output = response.getEntity(String.class);
    return output;
}
 
开发者ID:LithiumSR,项目名称:gw2_launcher,代码行数:8,代码来源:UpdateNotifier.java

示例10: getJSONData

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
private String getJSONData(){
    Client client = Client.create();
    WebResource webResource = client.resource(UriBuilder.fromUri("https://api.github.com/repos/"+username+"/"+repoName+"/releases").build());
    ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
    String output = response.getEntity(String.class);
    //System.out.println(output);
    return output;
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:9,代码来源:UpdateNotifier.java

示例11: getABFMapper

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public static ImmutableBiMap<String,String> getABFMapper()    {
    String serviceURL = null;
    ImmutableBiMap<String,String> ABFMAPPER = null;
    try {
        serviceURL = System.getenv("authcode.service.URL");
        if (serviceURL == null)
            serviceURL = System.getProperty("authcode.service.URL","http://localhost:9876/references");
        LOG.info("Initializing ABF Reference with remote service URL: "+ serviceURL);
        Client client = Client.create();
        WebResource webResource = client.resource(serviceURL);
        ClientResponse response = webResource.accept("application/json")
                .get(ClientResponse.class);
        String output = response.getEntity(String.class);
        if (response.getStatus() == 200 && output != null && !output.isEmpty()) {
            Map<String, String> mapResponse = OBJECT_MAPPER.readValue(output, new TypeReference<Map<String, String>>() {});
            ABFMAPPER = ImmutableBiMap.copyOf(Collections.unmodifiableMap(mapResponse));
            LOG.info("Success on getting ABF Reference map from  "+ serviceURL);
        } else {
            ABFMAPPER = ImmutableBiMap.copyOf(Collections.unmodifiableMap(ABFCodeMap.defaultABFMapper()));
        }

    }catch(Exception ex){
        ABFMAPPER = ImmutableBiMap.copyOf(Collections.unmodifiableMap(ABFCodeMap.defaultABFMapper()));
        LOG.warn("ABF Mapper initialization failed");
    }
    return ABFMAPPER;
}
 
开发者ID:tmobile,项目名称:keybiner,代码行数:28,代码来源:ABFCodeMap.java

示例12: MusicHandle

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public MusicHandle(String[] musicNodes, int repFactor){
	this.musicNodes = musicNodes;
	this.repFactor=repFactor;
	
	bmKeySpace = "BmKeySpace";
	bmTable = "BmEmployees";
	
	clientConfig = new DefaultClientConfig();

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

	client = Client.create(clientConfig);
}
 
开发者ID:att,项目名称:music,代码行数:15,代码来源:MusicHandle.java

示例13: releaseLock

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public  void releaseLock(String lockId){
	Client client = Client.create();
	WebResource webResource = client.resource(getMusicNodeURL()+"/locks/release/"+lockId);

	ClientResponse response = webResource.delete(ClientResponse.class);


	if (response.getStatus() != 204) {
		throw new RuntimeException("Failed : HTTP error code : "
				+ response.getStatus());
	}
}
 
开发者ID:att,项目名称:music,代码行数:13,代码来源:MusicRestClient.java

示例14: createKeyspace

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public void createKeyspace(String keyspaceName){
	Map<String,Object> replicationInfo = new HashMap<String, Object>();
	replicationInfo.put("class", "SimpleStrategy");
	replicationInfo.put("replication_factor", 1);
	String durabilityOfWrites="false";
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");
	com.att.research.music.datastore.jsonobjects.JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);
	jsonKp.setDurabilityOfWrites(durabilityOfWrites);
	jsonKp.setReplicationInfo(replicationInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

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

	Client client = Client.create(clientConfig);

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

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

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

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

示例15: OrganisationRestClient

import com.sun.jersey.api.client.Client; //导入方法依赖的package包/类
public OrganisationRestClient(String uri) 
{
  ClientConfig config = new DefaultClientConfig();
  config.getClasses().add(JacksonJsonProvider.class);
  client = Client.create(config);
  webResource = client.resource(uri).path("organisations");
  endpointWebResource = client.resource(uri).path("endpoint");
  channelWebResource = client.resource(uri).path("channel");
  contactWebResource = client.resource(uri).path("endpointcontact");
}
 
开发者ID:UnionVMS,项目名称:USM,代码行数:11,代码来源:OrganisationRestClient.java


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