本文整理汇总了Java中org.glassfish.jersey.client.spi.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于org.glassfish.jersey.client.spi包,在下文中一共展示了Connector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
private static ApacheConnector getConnector(final Configurable<?> component) {
if (!(component instanceof Initializable)) {
throw new IllegalArgumentException(
LocalizationMessages.INVALID_CONFIGURABLE_COMPONENT_TYPE(component.getClass().getName()));
}
final Initializable<?> initializable = (Initializable<?>) component;
Connector connector = initializable.getConfiguration().getConnector();
if (connector == null) {
initializable.preInitialize();
connector = initializable.getConfiguration().getConnector();
}
if (connector instanceof ApacheConnector) {
return (ApacheConnector) connector;
} else {
throw new IllegalArgumentException(LocalizationMessages.EXPECTED_CONNECTOR_PROVIDER_NOT_USED());
}
}
开发者ID:fod-dev,项目名称:FoDBugTrackerUtility,代码行数:20,代码来源:ApacheConnectorProvider.java
示例2: newRetryConnectorAllocator
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@VisibleForTesting
public static RetryConnectorAllocator newRetryConnectorAllocator()
{
return new RetryConnectorAllocator()
{
@Override
public RetryConnector newRetryConnector(Connector parentConnector, Retry retry)
{
return new RetryConnector(parentConnector, retry);
}
};
}
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:13,代码来源:DefaultQdsConfiguration.java
示例3: testRetryAfterBadConnection
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Test
public void testRetryAfterBadConnection() throws Exception
{
ClientConfig clientConfig = new ClientConfig();
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 100);
final AtomicBoolean hadRetry = new AtomicBoolean(false);
DefaultQdsConfiguration.RetryConnectorAllocator retryConnectorAllocator = new DefaultQdsConfiguration.RetryConnectorAllocator()
{
@Override
public RetryConnector newRetryConnector(Connector parentConnector, Retry retry)
{
return new RetryConnector(parentConnector, retry)
{
@Override
protected Future<?> internalApply(ClientRequest request, AsyncConnectorCallback callback, int tryCount)
{
if ( tryCount > 0 )
{
if ( tryCount == 1 )
{
startServer(false);
}
hadRetry.set(true);
}
return super.internalApply(request, callback, tryCount);
}
};
}
};
DefaultQdsConfiguration configuration = new DefaultQdsConfiguration("http://localhost:" + TEST_PORT, "bar", clientConfig, new StandardRetry(1000, 3), retryConnectorAllocator);
QdsClient client = new QdsClientImpl(configuration);
String value = client.command().logs("100").invoke().get(); // logs is set to retry
Assert.assertTrue(hadRetry.get());
Assert.assertEquals(value, TEST_VALUE);
}
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:37,代码来源:TestRetries.java
示例4: testRetryAfterError
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Test
public void testRetryAfterError() throws Exception
{
startServer(true);
final AtomicBoolean hadRetry = new AtomicBoolean(false);
DefaultQdsConfiguration.RetryConnectorAllocator retryConnectorAllocator = new DefaultQdsConfiguration.RetryConnectorAllocator()
{
@Override
public RetryConnector newRetryConnector(Connector parentConnector, Retry retry)
{
return new RetryConnector(parentConnector, retry)
{
@Override
protected Future<?> internalApply(ClientRequest request, AsyncConnectorCallback callback, int tryCount)
{
if ( tryCount > 0 )
{
hadRetry.set(true);
}
return super.internalApply(request, callback, tryCount);
}
};
}
};
DefaultQdsConfiguration configuration = new DefaultQdsConfiguration("http://localhost:" + TEST_PORT, "bar", new ClientConfig(), new StandardRetry(1000, 3), retryConnectorAllocator);
QdsClient client = new QdsClientImpl(configuration);
String value = client.command().logs("100").invoke().get(); // logs is set to retry
Assert.assertTrue(hadRetry.get());
Assert.assertEquals(value, TEST_VALUE);
}
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:32,代码来源:TestRetries.java
示例5: createRESTClient
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
private Client createRESTClient(final DNSAPIClientConfig config,
final ObjectMapper mapper, final SSLContextFactory sslContextFactory)
throws Exception {
final JacksonJsonProvider jacksonJsonProvider = new ErrorHandlingJacksonJsonProvider(
mapper);
final SSLContext sslContext = sslContextFactory.createSSLContext();
final SSLSocketFactory sslSocketFactory = new SSLSocketFactory(
sslContext);
final SchemeRegistry schemeRegistry = createSchemeRegistry(config,
sslSocketFactory);
final HttpParams httpParams = createHttpParams();
final PoolingClientConnectionManager clientConnectionManager = createPoolingClientConnectionManager(
config, schemeRegistry);
final ClientConfig clientConfig = createClientConfig(config,
jacksonJsonProvider, httpParams, clientConnectionManager);
final Connector connector = new ApacheConnector(clientConfig);
clientConfig.connector(connector);
final ApplicationProperties applicationProperties = new ApplicationProperties();
clientConfig.register(new CsrfProtectionFilter(
"DiscoveryDNS Reseller API Client v" + applicationProperties.getVersion()));
final ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder.withConfig(clientConfig);
return clientBuilder.build();
}
开发者ID:discoverydns,项目名称:dnsapi-client,代码行数:28,代码来源:DNSAPIClientFactory.java
示例6: getConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Override
public Connector getConnector(final Client client, final Configuration runtime) {
return new HttpComponentsConnector(apache, runtime);
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:5,代码来源:HttpComponentsProvider.java
示例7: JerseyRetryConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
public JerseyRetryConnector(Connector connector, RetryComponents retryComponents)
{
this.retryComponents = retryComponents;
this.connector = connector;
}
开发者ID:soabase,项目名称:soabase,代码行数:6,代码来源:JerseyRetryConnector.java
示例8: getConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Override
public Connector getConnector(Client client, Configuration runtimeConfig)
{
DropwizardApacheConnector dropwizardApacheConnector = new DropwizardApacheConnector(apacheHttpClient, RequestConfig.custom().build(), isChunkedEncodingEnabled);
return new JerseyRetryConnector(dropwizardApacheConnector, retryComponents);
}
开发者ID:soabase,项目名称:soabase,代码行数:7,代码来源:JerseyRetryConnectorProvider.java
示例9: RetryConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
public RetryConnector(Connector connector, Retry retry)
{
this.connector = connector;
this.retry = retry;
}
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:6,代码来源:RetryConnector.java
示例10: testFailure
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Test
public void testFailure() throws Exception
{
ServerSocket server = new ServerSocket(TEST_PORT); // make sure port is free
server.close();
ClientConfig clientConfig = new ClientConfig();
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 100);
final AtomicBoolean hadRetry = new AtomicBoolean(false);
DefaultQdsConfiguration.RetryConnectorAllocator retryConnectorAllocator = new DefaultQdsConfiguration.RetryConnectorAllocator()
{
@Override
public RetryConnector newRetryConnector(Connector parentConnector, Retry retry)
{
return new RetryConnector(parentConnector, retry)
{
@Override
protected Future<?> internalApply(ClientRequest request, AsyncConnectorCallback callback, int tryCount)
{
if ( tryCount > 0 )
{
hadRetry.set(true);
}
return super.internalApply(request, callback, tryCount);
}
};
}
};
DefaultQdsConfiguration configuration = new DefaultQdsConfiguration("http://localhost:" + TEST_PORT, "bar", clientConfig, new StandardRetry(1000, 3), retryConnectorAllocator);
QdsClient client = new QdsClientImpl(configuration);
try
{
client.command().status("100").invoke().get(); // status is set to retry
Assert.fail("Should have thrown an exception");
}
catch ( ExecutionException e )
{
// expected
}
Assert.assertTrue(hadRetry.get());
}
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:44,代码来源:TestRetries.java
示例11: getConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Override
public Connector getConnector(final Client client, final Configuration config) {
return new InMemoryServerConnector(this.baseUri, this.appHandler);
}
开发者ID:gtcGroup,项目名称:jped-parent-project,代码行数:5,代码来源:InMemoryServerConnector.java
示例12: getConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
@Override
public Connector getConnector(final Client client, final Configuration config) {
return new CdiAwareInMemoryConnector(this.baseUri, this.appHandler);
}
开发者ID:gtcGroup,项目名称:jped-parent-project,代码行数:5,代码来源:CdiAwareInMemoryConnector.java
示例13: newRetryConnector
import org.glassfish.jersey.client.spi.Connector; //导入依赖的package包/类
public RetryConnector newRetryConnector(Connector parentConnector, Retry retry);
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:2,代码来源:DefaultQdsConfiguration.java
注:本文中的org.glassfish.jersey.client.spi.Connector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论