com.sun.jersey.api.client.Client.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(255)

本文整理了Java中com.sun.jersey.api.client.Client.<init>()方法的一些代码示例,展示了Client.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.<init>()方法的具体详情如下:
包路径:com.sun.jersey.api.client.Client
类名称:Client
方法名:<init>

Client.<init>介绍

[英]Create a new client instance.
[中]创建一个新的客户端实例。

代码示例

代码示例来源:origin: stackoverflow.com

BufferedReader bufferedReader = org.mockito.Mockito.mock(BufferedReader.class);
when(bufferedReader.readLine()).thenReturn("first line").thenReturn("second line");

org.junit.Assert.when(new Client(bufferedReader).parseLine()).thenEquals(IsEqual.equalTo("1"));

代码示例来源:origin: stackoverflow.com

HttpClient apacheClient = HttpClientBuilder.create().build();
Client client = new Client(new ApacheHttpClient4Handler(apacheClient,
                            new BasicCookieStore(),
                            true));
WebResource webResource = client.resource("http://localhost:8080/path");
ClientResponse response = webResource.accept("application/json")
                   .get(ClientResponse.class);

代码示例来源:origin: stackoverflow.com

public static class UsesExternalResource {
  Server myServer = new Server();

  @Rule public ExternalResource resource = new ExternalResource() {
    @Override
    protected void before() throws Throwable {
      myServer.connect();
    };

    @Override
    protected void after() {
      myServer.disconnect();
    };
  };

  @Test public void testFoo() {
    new Client().run(myServer);
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

private void initManaged( PurRepositoryMeta repositoryMeta, IUser userInfo ) throws JSONException {
 String baseUrl = repositoryMeta.getRepositoryLocation().getUrl();
 String webService = baseUrl + ( baseUrl.endsWith( "/" ) ? "" : "/" ) + "api/system/authentication-provider";
 HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter( userInfo.getLogin(), userInfo.getPassword() );
 Client client = new Client();
 client.addFilter( authFilter );
 WebResource.Builder resource = client.resource( webService ).accept( MediaType.APPLICATION_JSON_TYPE );
 /**
  * if set, _trust_user_ needs to be considered. See other places in pur-plugin's:
  *
  * @link https://github.com/pentaho/pentaho-kettle/blob/8.0.0.0-R/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepositoryConnector.java#L97-L101
  * @link https://github.com/pentaho/pentaho-kettle/blob/8.0.0.0-R/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/WebServiceManager.java#L130-L133
  */
 if ( StringUtils.isNotBlank( System.getProperty( "pentaho.repository.client.attemptTrust" ) ) ) {
  resource = resource.header( TRUST_USER, userInfo.getLogin() );
 }
 String response = resource.get( String.class );
 String provider = new JSONObject( response ).getString( "authenticationType" );
 managed = "jackrabbit".equals( provider );
}

代码示例来源:origin: Netflix/conductor

protected ClientBase(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler) {
  objectMapper = new JsonMapperProvider().get();
  JacksonJsonProvider provider = new JacksonJsonProvider(objectMapper);
  config.getSingletons().add(provider);
  if (handler == null) {
    this.client = Client.create(config);
  } else {
    this.client = new Client(handler, config);
  }
  conductorClientConfiguration = clientConfiguration;
  payloadStorage = new PayloadStorage(this);
}

代码示例来源:origin: neo4j/neo4j

Client client = new Client();
ClientResponse response = client.handle( request );
if ( response.hasEntity() && response.getStatus() != 204 )

代码示例来源:origin: stackoverflow.com

var postRequest = function(url, args, callback) {
 var client = new Client();
 var responseData = {};
 client.post(url, args, function(data, response) {
  responseData = data;
  callback(responseData);
 });
};

代码示例来源:origin: stackoverflow.com

Client c1 = new Client("Smith", null, null);
Client c2 = new Client("Smith", 20, null);
Client c3 = new Client("Smith", null, 100);
Client c4 = new Client(null, 20, 100);
Client c5 = new Client("Smith", 20, 100);

代码示例来源:origin: stackoverflow.com

final String response = in.nextLine();
 EventQueue.invokeLater(new Runnable() {
   @Override
   public void run() {
     new Client(response);
   }
 });

代码示例来源:origin: stackoverflow.com

public static void main(String args[]) throws InterruptedException {
  Server server = new Server();
  Client client = new Client();

  Thread tServer = new Thread(server);
  tServer.start();

  //here you can wait some time to Server started

  Thread tClient = new Thread(client);
  tClient.start();
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

/**
 * Create a default client.
 *
 * @return a default client.
 */
public static Client create() {
  return new Client(createDefaultClientHander());
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

/**
 * Create a default client with client configuration.
 *
 * @param cc the client configuration.
 * @return a default client.
 */
public static Client create(ClientConfig cc) {
  return new Client(createDefaultClientHander(), cc);
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

/**
 * Create a default client with client configuration and component provider.
 *
 * @param cc the client configuration.
 * @param provider the IoC component provider factory.
 * @return a default client.
 */
public static Client create(ClientConfig cc, IoCComponentProviderFactory provider) {
  return new Client(createDefaultClientHander(), cc, provider);
}

代码示例来源:origin: stackoverflow.com

async void btn_click(string username,string password)
{
  // This should be an async method as well
  Client myClient = new Client();
  // added await
  string content = await myClient.authenticate(username, password);
  Console.Out.WriteLine(content);
}

代码示例来源:origin: stackoverflow.com

Client client = new Client();
client.setA(56);
System.out.println(client.getA());

client.setA(98);
System.out.println(client.getA());

代码示例来源:origin: org.apache.tez/tez-history-parser

private Client getHttpClient() {
 if (httpClient == null) {
  ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class);
  HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory();
  return new Client(new URLConnectionClientHandler(urlFactory), config);
 }
 return httpClient;
}

代码示例来源:origin: org.apache.tez/tez-api

@Override
public Client getHttpClient() {
 ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class);
 HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory(connectionConf);
 Client httpClient = new Client(new URLConnectionClientHandler(urlFactory), config);
 return httpClient;
}

代码示例来源:origin: apache/eagle

private ObjectNode getMetadataResource(String url){
  return new Client().resource(restMetaURL + url )
    .header(ACCEPT, MediaType.APPLICATION_JSON)
    .header(CONTENT_TYPE, MediaType.APPLICATION_JSON)
    .get(ObjectNode.class);
}

代码示例来源:origin: apache/eagle

private void getMetadataResource( ){
   new Client().resource(restURL )
    .header(ACCEPT, MediaType.APPLICATION_JSON)
    .header(CONTENT_TYPE, MediaType.APPLICATION_JSON)
    .post(GenericCreateAPIResponseEntity.class, requestJson);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-timelineservice

private static Client createClient() {
 ClientConfig cfg = new DefaultClientConfig();
 cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
 return new Client(new URLConnectionClientHandler(
   new DummyURLConnectionFactory()), cfg);
}

相关文章