本文整理匯總了Java中org.glassfish.jersey.client.ClientConfig類的典型用法代碼示例。如果您正苦於以下問題:Java ClientConfig類的具體用法?Java ClientConfig怎麽用?Java ClientConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClientConfig類屬於org.glassfish.jersey.client包,在下文中一共展示了ClientConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Scim2Provisioner
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
public Scim2Provisioner(final String target, final String oauthToken,
final String username, final String password,
final Scim2PrincipalAttributeMapper mapper) {
final ClientConfig config = new ClientConfig();
final ApacheConnectorProvider connectorProvider = new ApacheConnectorProvider();
config.connectorProvider(connectorProvider);
final Client client = ClientBuilder.newClient(config);
if (StringUtils.isNotBlank(oauthToken)) {
client.register(OAuth2ClientSupport.feature(oauthToken));
}
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
client.register(HttpAuthenticationFeature.basic(username, password));
}
final WebTarget webTarget = client.target(target);
this.scimService = new ScimService(webTarget);
this.mapper = mapper;
}
示例2: ParaClient
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
/**
* Default constructor.
* @param accessKey app access key
* @param secretKey app secret key
*/
public ParaClient(String accessKey, String secretKey) {
this.accessKey = accessKey;
this.secretKey = secretKey;
if (StringUtils.length(secretKey) < 6) {
logger.warn("Secret key appears to be invalid. Make sure you call 'signIn()' first.");
}
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(GenericExceptionMapper.class);
clientConfig.register(new JacksonJsonProvider(ParaObjectUtils.getJsonMapper()));
clientConfig.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
SSLContext sslContext = SslConfigurator.newInstance().securityProtocol("TLSv1").createSSLContext();
System.setProperty("https.protocols", "TLSv1");
apiClient = ClientBuilder.newBuilder().
sslContext(sslContext).
withConfig(clientConfig).build();
}
示例3: dumpSwitches
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
/**
* Returns Switches through Topology-Engine-Rest service.
*
* @return The JSON document of all flows
*/
public static List<SwitchInfoData> dumpSwitches() throws Exception {
System.out.println("\n==> Topology-Engine Dump Switches");
Client client = ClientBuilder.newClient(new ClientConfig());
Response response = client
.target(topologyEndpoint)
.path("/api/v1/topology/switches")
.request()
.header(HttpHeaders.AUTHORIZATION, authHeaderValue)
.get();
System.out.println(String.format("===> Response = %s", response.toString()));
List<SwitchInfoData> switches = new ObjectMapper().readValue(
response.readEntity(String.class), new TypeReference<List<SwitchInfoData>>() {});
System.out.println(String.format("====> Data = %s", switches));
return switches;
}
示例4: createClientFromConfig
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private static Client createClientFromConfig(NiFiRegistryClientConfig registryClientConfig) {
final ClientConfig clientConfig = new ClientConfig();
clientConfig.register(jacksonJaxbJsonProvider());
final ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
final SSLContext sslContext = registryClientConfig.getSslContext();
if (sslContext != null) {
clientBuilder.sslContext(sslContext);
}
final HostnameVerifier hostnameVerifier = registryClientConfig.getHostnameVerifier();
if (hostnameVerifier != null) {
clientBuilder.hostnameVerifier(hostnameVerifier);
}
return clientBuilder.build();
}
示例5: getNumberOfDatapoints
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private List<Metric> getNumberOfDatapoints() throws Throwable {
System.out.println("\n==> OpenTSDB Metrics request");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response response = client
.target(opentsdbEndpoint)
.path("/api/query")
.queryParam("start", "24h-ago")
.queryParam("m", "sum:pen.switch.tx-bytes")
.queryParam("timezone", "Australia/Melbourne")
.request().get();
System.out.println(String.format("===> Response = %s", response));
System.out.println(String.format("===> OpenTSDB Metrics Time: %,.3f", getTimeDuration(current)));
List<Metric> metrics = new ObjectMapper().readValue(
response.readEntity(String.class), new TypeReference<List<Metric>>() {});
System.out.println(String.format("====> Metrics = %s", metrics));
return metrics;
}
示例6: trafficIsOk
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean trafficIsOk(boolean expectedResult) throws Throwable {
if (isTrafficTestsEnabled()) {
System.out.println("=====> Send traffic");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/checkflowtraffic")
.queryParam("srcswitch", "s1")
.queryParam("dstswitch", "s8")
.queryParam("srcport", "1")
.queryParam("dstport", "1")
.queryParam("srcvlan", "1000")
.queryParam("dstvlan", "1000")
.request()
.get();
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send traffic Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
} else {
return expectedResult;
}
}
示例7: disconnectSwitch
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean disconnectSwitch(String switchName) throws Exception {
System.out.println("\n==> Disconnect Switch");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/knockoutswitch")
.queryParam("switch", switchName)
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Disconnect Switch Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例8: connectSwitch
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean connectSwitch(String switchName, String controller) throws Exception {
System.out.println("\n==> Connect Switch");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/reviveswitch")
.queryParam("switch", switchName)
.queryParam("controller", "tcp:" + controller + ":6653")
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Connect Switch Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例9: islDiscovered
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean islDiscovered(String switchName, String portNo) throws Throwable {
System.out.println("\n==> Set ISL Discovered");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/restorelink")
.queryParam("switch", switchName)
.queryParam("port", portNo)
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Set ISL Discovered Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例10: portDown
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean portDown(String switchName, String portNo) throws Throwable {
System.out.println("\n==> Set Port Down");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/port/down")
.queryParam("switch", switchName)
.queryParam("port", portNo)
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Set Port Down Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例11: portUp
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
private boolean portUp(String switchName, String portNo) throws Throwable {
System.out.println("\n==> Set Port Up");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/port/up")
.queryParam("switch", switchName)
.queryParam("port", portNo)
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Set Port Up Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例12: sendMalformedLldpPacket
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
@When("^send malformed lldp packet$")
public void sendMalformedLldpPacket() throws Throwable {
System.out.println("=====> Send malformed packet");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/send_malformed_packet")
.request()
.post(null);
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send malformed packet Time: %,.3f", getTimeDuration(current)));
assertEquals(200, result.getStatus());
}
示例13: dumpLinks
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
/**
* Returns links through Topology-Engine-Rest service.
*
* @return The JSON document of all flows
*/
public static List<IslInfoData> dumpLinks() throws Exception {
System.out.println("\n==> Topology-Engine Dump Links");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response response = client
.target(topologyEndpoint)
.path("/api/v1/topology/links")
.request()
.header(HttpHeaders.AUTHORIZATION, authHeaderValue)
.get();
System.out.println(String.format("===> Response = %s", response.toString()));
System.out.println(String.format("===> Topology-Engine Dump Links Time: %,.3f", getTimeDuration(current)));
List<IslInfoData> links = new ObjectMapper().readValue(
response.readEntity(String.class), new TypeReference<List<IslInfoData>>() {});
System.out.println(String.format("====> Data = %s", links));
return links;
}
示例14: islFail
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
public static boolean islFail(String switchName, String portNo) {
System.out.println("\n==> Set ISL Discovery Failed");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/cutlink")
.queryParam("switch", switchName)
.queryParam("port", portNo)
.request()
.post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Set ISL Discovery Failed Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
示例15: DeleteMininetTopology
import org.glassfish.jersey.client.ClientConfig; //導入依賴的package包/類
public static boolean DeleteMininetTopology() {
System.out.println("\n==> Delete Mininet Topology");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(mininetEndpoint)
.path("/cleanup")
.request(MediaType.APPLICATION_JSON)
.post(null);
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Delete Mininet Topology Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}