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


Java ClientFilter类代码示例

本文整理汇总了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();
		}
	};
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:21,代码来源:Eureka.java

示例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;
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:20,代码来源:KeyValueClient.java

示例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);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:17,代码来源:OccurrenceWsClientIT.java

示例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);
	}
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:13,代码来源:TaskClient.java

示例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);
	}
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:13,代码来源:WorkflowClient.java

示例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);
    }
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:11,代码来源:RemoteInstanceRequestClientImpl.java

示例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);
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:37,代码来源:Eureka.java

示例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;
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:40,代码来源:AbstractGitHubRESTClientImpl.java

示例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();
    }
}
 
开发者ID:Tradeshift,项目名称:Tradeshift-Java-Client,代码行数:13,代码来源:JerseyClient.java

示例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);
}
 
开发者ID:Tradeshift,项目名称:Tradeshift-Java-Client,代码行数:15,代码来源:JerseyClientTest.java

示例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);
}
 
开发者ID:Tradeshift,项目名称:Tradeshift-Java-Client,代码行数:12,代码来源:JerseyClientTest.java

示例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);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:5,代码来源:RemoteConnectionConfiguration.java

示例13: getFilters

import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public Collection<ClientFilter> getFilters()
{
    return filters;
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:5,代码来源:RemoteConnectionConfiguration.java

示例14: isFilterPresent

import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public boolean isFilterPresent(ClientFilter clientFilter)
{
  return clientFilters.contains(clientFilter);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:5,代码来源:WebServicesClient.java

示例15: addFilter

import com.sun.jersey.api.client.filter.ClientFilter; //导入依赖的package包/类
public void addFilter(ClientFilter clientFilter)
{
  client.addFilter(clientFilter);
  clientFilters.add(clientFilter);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:6,代码来源:WebServicesClient.java


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