本文整理汇总了Java中com.sun.jersey.api.client.filter.ClientFilter类的典型用法代码示例。如果您正苦于以下问题:Java ClientFilter类的具体用法?Java ClientFilter怎么用?Java ClientFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientFilter类属于com.sun.jersey.api.client.filter包,在下文中一共展示了ClientFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTransportClientFactory
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public static TransportClientFactory newTransportClientFactory(final EurekaClientConfig clientConfig,
final Collection<ClientFilter> additionalFilters
) {
final TransportClientFactory jerseyFactory = JerseyEurekaHttpClientFactory.create(
clientConfig, additionalFilters, null, null);
final TransportClientFactory metricsFactory = MetricsCollectingEurekaHttpClient.createFactory(jerseyFactory);
return new TransportClientFactory() {
@Override
public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) {
return metricsFactory.newClient(serviceUrl);
}
@Override
public void shutdown() {
metricsFactory.shutdown();
jerseyFactory.shutdown();
}
};
}
示例2: buildClient
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
private static Client buildClient() {
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(ByteStringMessageBodyWriter.class);
Client client = Client.create(config);
client.setFollowRedirects(true);
client.addFilter(new ClientFilter() {
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
log.debug("Making request {} {}", cr.getMethod(), cr.getURI());
ClientResponse response = getNext().handle(cr);
return response;
}
});
return client;
}
示例3: init
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
@Before
public void init() throws Exception {
Properties properties = new Properties();
wsBaseUrl = new URIBuilder(getBaseURI()).setPath(contextPath).toString();
properties.put("occurrence.ws.url", wsBaseUrl);
properties.put("httpTimeout", HTTP_TO);
Injector clientInjector =
Guice.createInjector(new OccurrenceWsClientModule(properties), new AbstractModule() {
@Override
protected void configure() {
//ClientFilter is required by the OccurrenceDownloadClient for authentication
bind(ClientFilter.class).toInstance(Mockito.mock(ClientFilter.class));
}
});
client = clientInjector.getInstance(OccurrenceService.class);
}
示例4: TaskClient
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
/**
*
* @param config config REST Client configuration
* @param handler handler Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
* @param filters Chain of client side filters to be applied per request
*/
public TaskClient(ClientConfig config, ClientHandler handler, ClientFilter...filters) {
super(config, handler);
for(ClientFilter filter : filters) {
super.client.addFilter(filter);
}
}
示例5: WorkflowClient
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
/**
*
* @param config config REST Client configuration
* @param handler handler Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
* @param filters Chain of client side filters to be applied per request
*/
public WorkflowClient(ClientConfig config, ClientHandler handler, ClientFilter...filters) {
super(config, handler);
for(ClientFilter filter : filters) {
super.client.addFilter(filter);
}
}
示例6: RemoteInstanceRequestClientImpl
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public RemoteInstanceRequestClientImpl(RemoteConnectionConfiguration configuration)
{
client = Client.create();
client.setConnectTimeout(configuration.getConnectionTimeoutMs());
client.setReadTimeout(configuration.getReadTimeoutMs());
for ( ClientFilter filter : configuration.getFilters() )
{
client.addFilter(filter);
}
}
示例7: createTransport
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public EurekaTransport createTransport() {
TransportClientFactory transportClientFactory = newTransportClientFactory(clientConfig, Collections.<ClientFilter>emptyList());
EurekaTransportConfig transportConfig = clientConfig.getTransportConfig();
ClosableResolver<AwsEndpoint> bootstrapResolver = EurekaHttpClients.newBootstrapResolver(
clientConfig,
transportConfig,
transportClientFactory,
null,
(stalenessThreshold, timeUnit) -> {
long thresholdInMs = TimeUnit.MILLISECONDS.convert(stalenessThreshold, timeUnit);
long delay = eurekaClient.getLastSuccessfulRegistryFetchTimePeriod();
if (delay > thresholdInMs) {
log.info("Local registry is too stale for local lookup. Threshold:{}, actual:{}",
thresholdInMs, delay);
return null;
} else {
return eurekaClient.getApplications();
}
}
);
EurekaHttpClientFactory httpClientFactory;
try {
httpClientFactory = EurekaHttpClients.registrationClientFactory(
bootstrapResolver,
transportClientFactory,
transportConfig
);
} catch (Exception e) {
log.warn("Experimental transport initialization failure", e);
throw new RuntimeException(e);
}
return new EurekaTransport(httpClientFactory, httpClientFactory.newClient(), transportClientFactory, bootstrapResolver);
}
示例8: getAll
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
/**
* Goes over all GitHub pages and return all pages union.
*
* @param webResource of first page
* @param entityType type of entities
* @return union
*/
protected <T> List<T> getAll(WebResource webResource, Class<T[]> entityType, ClientFilter filter)
{
List<T> result = new LinkedList<T>();
WebResource cursor = webResource;
do
{
if (filter != null)
{
cursor.addFilter(filter);
}
WebResource.Builder builder = cursor.accept(MediaType.APPLICATION_JSON_TYPE);
ClientResponse clientResponse = builder.get(ClientResponse.class);
if (clientResponse.getStatus() < 300)
{
result.addAll(Arrays.asList(clientResponse.getEntity(entityType)));
LinkHeaders linkHeaders = getLinks(clientResponse);
LinkHeader nextLink = linkHeaders.getLink("next");
URI nextPage = nextLink != null ? nextLink.getUri() : null;
cursor = nextPage != null ? client.resource(nextPage) : null;
}
else
{
throw new UniformInterfaceException(clientResponse);
}
}
while (cursor != null);
return result;
}
示例9: JerseyClient
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
protected JerseyClient(Client client, String baseUrl, List<ClientFilter> filters, int connectTimeout, int readTimeout) {
this.baseUrl = baseUrl;
this.filters = filters;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
if (client != null) {
this.client = client;
} else {
this.client = createClient();
initializeClient();
}
}
示例10: client_applies_filter_and_base_url_to_resource
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
@Test
public void client_applies_filter_and_base_url_to_resource() {
Client client = mock(Client.class);
WebResource resource = mock(WebResource.class);
when(client.resource("base")).thenReturn(resource);
HeaderProcessor processor = mock(HeaderProcessor.class);
JerseyClient c = new JerseyClient(client, "base", new ArrayList<ClientFilter>(), 10, 10).filtered(processor);
WebResource r = c.resource();
assertSame(resource, r);
ArgumentCaptor<HeaderProcessorClientFilter> filterArg = ArgumentCaptor.forClass(HeaderProcessorClientFilter.class);
verify(resource).addFilter(filterArg.capture());
assertSame(processor, filterArg.getValue().processor);
}
示例11: creating_client_applies_connection_and_read_timeout
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
@Test
public void creating_client_applies_connection_and_read_timeout() {
final Client client = mock(Client.class);
new JerseyClient(null, "base", new ArrayList<ClientFilter>(), 1, 2) {
protected Client createClient() {
return client;
};
};
verify(client).setConnectTimeout(1);
verify(client).setReadTimeout(2);
}
示例12: RemoteConnectionConfiguration
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public RemoteConnectionConfiguration()
{
this(Lists.<ClientFilter>newArrayList(), DEFAULT_CONNECTION_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
}
示例13: getFilters
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public Collection<ClientFilter> getFilters()
{
return filters;
}
示例14: isFilterPresent
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public boolean isFilterPresent(ClientFilter clientFilter)
{
return clientFilters.contains(clientFilter);
}
示例15: addFilter
import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public void addFilter(ClientFilter clientFilter)
{
client.addFilter(clientFilter);
clientFilters.add(clientFilter);
}