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


Java ApacheHttpClient4Executor类代码示例

本文整理汇总了Java中org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor的典型用法代码示例。如果您正苦于以下问题:Java ApacheHttpClient4Executor类的具体用法?Java ApacheHttpClient4Executor怎么用?Java ApacheHttpClient4Executor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApacheHttpClient4Executor类属于org.jboss.resteasy.client.core.executors包,在下文中一共展示了ApacheHttpClient4Executor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Create
public void init() {
	if (this.umaMetadataConfiguration != null) {

		if (applicationConfiguration.isRptConnectionPoolUseConnectionPooling()) {

			// For more information about PoolingHttpClientConnectionManager, please see:
			// http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/index.html?org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html

			log.info("##### Initializing custom ClientExecutor...");
			PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
			connectionManager.setMaxTotal(applicationConfiguration.getRptConnectionPoolMaxTotal());
			connectionManager.setDefaultMaxPerRoute(applicationConfiguration.getRptConnectionPoolDefaultMaxPerRoute());
			connectionManager.setValidateAfterInactivity(applicationConfiguration.getRptConnectionPoolValidateAfterInactivity() * 1000);
			CloseableHttpClient client = HttpClients.custom()
				.setKeepAliveStrategy(connectionKeepAliveStrategy)
				.setConnectionManager(connectionManager)
				.build();
			ClientExecutor clientExecutor = new ApacheHttpClient4Executor(client);
			log.info("##### Initializing custom ClientExecutor DONE");

			this.resourceSetPermissionRegistrationService = UmaClientFactory.instance().createResourceSetPermissionRegistrationService(this.umaMetadataConfiguration, clientExecutor);
			this.rptStatusService = UmaClientFactory.instance().createRptStatusService(this.umaMetadataConfiguration, clientExecutor);

		} else {

			this.resourceSetPermissionRegistrationService = UmaClientFactory.instance().createResourceSetPermissionRegistrationService(this.umaMetadataConfiguration);
			this.rptStatusService = UmaClientFactory.instance().createRptStatusService(this.umaMetadataConfiguration);
		}
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:32,代码来源:UmaProtectionService.java

示例2: getClient

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
public static SlackApi getClient() {
	PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
	HttpClient httpClient = HttpClientBuilder.create().setConnectionManager(cm).build();
	//
	ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
	// new ApacheHttpClient4Engine(httpClient);
	//
	SlackApi slackApi = ProxyFactory.create(SlackApi.class, "https://hooks.slack.com", executor);
	// ResteasyClient client = new ResteasyClientBuilder().httpEngine(new
	// ApacheHttpClient4Engine(httpClient)).build();
	// Client client = ResteasyClientBuilder.newClient();
	// ResteasyWebTarget target =
	// (ResteasyWebTarget)client.target("https://hooks.slack.com");
	// ResteasyWebTarget rtarget = (ResteasyWebTarget) target;

	// SlackApi slackApi = target.proxy(SlackApi.class);
	return slackApi;
}
 
开发者ID:moacyrricardo,项目名称:maven-slack,代码行数:19,代码来源:SlackApiFactory.java

示例3: NubankImportador

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
public NubankImportador(){
		ClientConnectionManager cm = new ThreadSafeClientConnManager();
		DefaultHttpClient httpClient = new DefaultHttpClient(cm);

		ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);

		authApi = ProxyFactory.create(NubankAPI.class, "https://prod-auth.nubank.com.br", executor);
		costumersApi = ProxyFactory.create(NubankAPI.class, "https://prod-customers.nubank.com.br", executor);
		accountsApi = ProxyFactory.create(NubankAPI.class, "https://prod-accounts.nubank.com.br", executor);

		ClientResponse<RegistrationResp> resp = authApi.register(RegistrationReq.asNubank());
		if(resp.getStatus() != RegistrationResp.SUCCESS_CODE){
			throw new RuntimeException("Erro registrando api. Status code = "+resp.getStatus());
//			System.out.println(resp.getEntity().getClient_id());
//			System.out.println(resp.getEntity().getClient_secret());
		}
		this.regResp = resp.getEntity();
//		api.token(TokenReq.create(resp.getEntity()));
	}
 
开发者ID:moacyrricardo,项目名称:bank-importer,代码行数:20,代码来源:NubankImportador.java

示例4: setupClientExecutor

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected org.jboss.resteasy.client.ClientExecutor setupClientExecutor() {
    AuthCache authCache = new BasicAuthCache();
    AuthScheme basicAuth = new BasicScheme();
    authCache.put(new HttpHost(getServiceUrl()), basicAuth);

    BasicHttpContext localContext = new BasicHttpContext();
    localContext.setAttribute(URI.create(getServiceUrl()).getHost(), authCache);

    // BasicCredentialsProvider credentialsProvider = new
    // BasicCredentialsProvider();
    // Credentials credentials = new
    // UsernamePasswordCredentials("hqlbuilder", "hqlbuilder");
    // credentialsProvider.setCredentials(new
    // AuthScope(URI.create(getServiceUrl()).getHost(),
    // URI.create(getServiceUrl()).getPort()),
    // credentials);

    HttpClient httpClient = HttpClientBuilder.create()//
            // .setDefaultCredentialsProvider(credentialsProvider)//
            .build();//

    return new ApacheHttpClient4Executor(httpClient, localContext);
}
 
开发者ID:jurgendl,项目名称:hql-builder,代码行数:25,代码来源:HqlWebServiceClientFactory.java

示例5: testReadCollectionMeta

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
/**
 * Test method for
 * {@link nl.gridline.zieook.workflow.rest.CollectionImportImpl#readCollectionMeta(java.lang.String, java.lang.String)}
 * .
 */
@Test
@Ignore
public final void testReadCollectionMeta()
{
	CollectionImport proxy = ProxyFactory.create(CollectionImport.class, uri, new ApacheHttpClient4Executor());

	// should throw a 404 - the cp does not exist:
	try
	{
		proxy.readCollectionMeta(ConstantsTest.CP, ConstantsTest.COLLECTION);
	}
	catch (org.jboss.resteasy.client.ClientResponseFailure e)
	{
		assertEquals(e.getResponse().getStatus(), 404);
		return;
	}
	fail("a 404 exception should have been thrown");
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:24,代码来源:CollectionImportImplTest.java

示例6: testAddUser

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Test
public final void testAddUser()
{
	User user = getTestUser();

	UserData proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
	if (proxy.isUser(ConstantsTest.CP, user.getId()).equals("true"))
	{
		proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
		proxy.removeUser(ConstantsTest.CP, user.getId());
	}

	proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
	Response response = proxy.addUser(ConstantsTest.CP, user);
	assertEquals(201, response.getStatus());
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:17,代码来源:UserDataImplTest.java

示例7: testRemoveUser

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Test
public final void testRemoveUser()
{
	User user = getTestUser();

	UserData proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
	if (proxy.isUser(ConstantsTest.CP, user.getId()).equals("false"))
	{
		proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
		proxy.addUser(ConstantsTest.CP, user);
	}

	proxy = ProxyFactory.create(UserData.class, uri, new ApacheHttpClient4Executor());
	Response response = proxy.removeUser(ConstantsTest.CP, user.getId());
	assertEquals(200, response.getStatus());
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:17,代码来源:UserDataImplTest.java

示例8: testGetRecommendationFor

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
/**
 * Test method for
 * {@link nl.gridline.zieook.data.rest.RatingEventsImpl#getRecommendationForItem(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)}
 * .
 */
@Test
public final void testGetRecommendationFor()
{
	LOG.info("testing GET on recommendations");
	Recommender proxy = ProxyFactory.create(Recommender.class, uri, new ApacheHttpClient4Executor());
	try
	{
		// Recommendations result =
		proxy.getRecommendationFor(ConstantsTest.CP, ConstantsTest.COLLECTION, ConstantsTest.RECOMMENDER,
				ConstantsTest.USER, ConstantsTest.ITEM, ConstantsTest.SOURCE, ConstantsTest.SIZE, null);
		// result should be empty - as non of the resource actually exist:
	}
	catch (org.jboss.resteasy.client.ClientResponseFailure e)
	{
		assertEquals(404, e.getResponse().getStatus());
		return;
	}

	fail("a 404 exception should have been thrown");
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:26,代码来源:RecommenderImplTest.java

示例9: testGetRecommendationForAnonymousItem

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Test
public final void testGetRecommendationForAnonymousItem()
{
	LOG.info("testing GET on recommendations");
	Recommender proxy = ProxyFactory.create(Recommender.class, uri, new ApacheHttpClient4Executor());
	try
	{
		// Recommendations result =
		proxy.getRecommendationFor(ConstantsTest.CP, ConstantsTest.COLLECTION, ConstantsTest.RECOMMENDER, null,
				ConstantsTest.ITEM, ConstantsTest.SOURCE, ConstantsTest.SIZE, null);
		// result should be empty - as non of the resource actually exist:
	}
	catch (org.jboss.resteasy.client.ClientResponseFailure e)
	{
		assertEquals(404, e.getResponse().getStatus());
		return;
	}

	fail("a 404 exception should have been thrown");
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:21,代码来源:RecommenderImplTest.java

示例10: testGetRecommendationForUser

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Test
public final void testGetRecommendationForUser()
{
	LOG.info("testing GET on recommendations");
	Recommender proxy = ProxyFactory.create(Recommender.class, uri, new ApacheHttpClient4Executor());
	try
	{
		// Recommendations result =
		proxy.getRecommendationFor(ConstantsTest.CP, ConstantsTest.COLLECTION, ConstantsTest.RECOMMENDER,
				ConstantsTest.USER, null, ConstantsTest.SOURCE, ConstantsTest.SIZE, null);
		// result should be empty - as non of the resource actually exist:
	}
	catch (org.jboss.resteasy.client.ClientResponseFailure e)
	{
		assertEquals(404, e.getResponse().getStatus());
		return;
	}

	fail("a 404 exception should have been thrown");
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:21,代码来源:RecommenderImplTest.java

示例11: testInvalidGetItem

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
/**
 * Test method for
 * {@link nl.gridline.zieook.data.rest.CollectionDataImpl#getItem(java.lang.String, java.lang.String, java.lang.String)}
 * .
 */
@Test
public final void testInvalidGetItem()
{
	CollectionData proxy = ProxyFactory.create(CollectionData.class, uri, new ApacheHttpClient4Executor());
	try
	{
		proxy.getItemRaw(ConstantsTest.CP, ConstantsTest.COLLECTION, null);
	}
	catch (org.jboss.resteasy.client.ClientResponseFailure e)
	{
		assertEquals(400, e.getResponse().getStatus());
		return;
	}
	fail("A 400 exception should have been thrown.");
}
 
开发者ID:beeldengeluid,项目名称:zieook,代码行数:21,代码来源:CollectionDataImplTest.java

示例12: init

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
public void init() {
	if (authProvider == null) {
		authProvider = new DeskOAuthProvider(accessKey, accessSecret, token, tokenSecret);
	}

	ClientConnectionManager cm = new ThreadSafeClientConnManager();
	DefaultHttpClient httpClient = new DefaultHttpClient(cm);

	ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);


	userApi = ProxyFactory.create(UserApi.class, endpoint, executor);
	customerApi = ProxyFactory.create(CustomerApi.class, endpoint, executor);
	caseApi = ProxyFactory.create(CaseApi.class, endpoint, executor);
}
 
开发者ID:quintoandar,项目名称:desk.com,代码行数:16,代码来源:DeskApiWrapper.java

示例13: restApi

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@Bean
public BrooklynApi restApi(HttpClient httpClient) {
	URL url;
	try {
		url = new URL(config.toFullUrl());
		LOG.info("Creating new brooklynApi for " + url);
           
		return new BrooklynApi(url, new ApacheHttpClient4Executor(httpClient));
	} catch (MalformedURLException e) {
		e.printStackTrace();
	}
	return null;

}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:15,代码来源:BrokerConfig.java

示例14: init

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
@PostConstruct
public void init() {
	if (this.umaMetadata != null) {
		if (appConfiguration.isRptConnectionPoolUseConnectionPooling()) {

			// For more information about PoolingHttpClientConnectionManager, please see:
			// http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/index.html?org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html

			log.info("##### Initializing custom ClientExecutor...");
			PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
			connectionManager.setMaxTotal(appConfiguration.getRptConnectionPoolMaxTotal());
			connectionManager.setDefaultMaxPerRoute(appConfiguration.getRptConnectionPoolDefaultMaxPerRoute());
			connectionManager.setValidateAfterInactivity(appConfiguration.getRptConnectionPoolValidateAfterInactivity() * 1000);
			CloseableHttpClient client = HttpClients.custom()
				.setKeepAliveStrategy(connectionKeepAliveStrategy)
				.setConnectionManager(connectionManager)
				.build();
			ClientExecutor clientExecutor = new ApacheHttpClient4Executor(client);
			log.info("##### Initializing custom ClientExecutor DONE");

			this.permissionService = UmaClientFactory.instance().createPermissionService(this.umaMetadata, clientExecutor);
			this.rptStatusService = UmaClientFactory.instance().createRptStatusService(this.umaMetadata, clientExecutor);

		} else {
			this.permissionService = UmaClientFactory.instance().createPermissionService(this.umaMetadata);
			this.rptStatusService = UmaClientFactory.instance().createRptStatusService(this.umaMetadata);
		}
	}
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:30,代码来源:UmaPermissionService.java

示例15: getProxy

import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; //导入依赖的package包/类
/**
 * Returns the Snmp proxy Object.
 */
public Snmp getProxy()
{

    snmpServiceURL = snmpServiceURL + "/" + deviceIP + "/" + snmpPort + "/";

    LOGGER.info( "[SNMP Service REST URL][" + snmpServiceURL + "]" );

    ResteasyProviderFactory factory = new ResteasyProviderFactory();
    RegisterBuiltin.register( factory );
    factory.getClientExecutionInterceptorRegistry().register( new ClientExecutionInterceptor()
    {
        @Override
        public ClientResponse execute( ClientExecutionContext ctx ) throws Exception
        {
            ClientResponse response = ctx.proceed();
            if ( ( "application/xml".equals( response.getHeaders().getFirst( HttpHeaders.CONTENT_TYPE ) ) )
                    || ( "text/plain".equals( response.getHeaders().getFirst( HttpHeaders.CONTENT_TYPE ) ) ) )
            {
                response.getHeaders().putSingle( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML );
            }
            return response;
        }
    } );

    this.snmp = ProxyFactory.create( Snmp.class, URI.create( snmpServiceURL ), new ApacheHttpClient4Executor(),
            factory );

    // this.snmp = ProxyFactory.create( Snmp.class, snmpServiceURL );

    return snmp;
}
 
开发者ID:Comcast,项目名称:cats,代码行数:35,代码来源:SnmpServiceProxy.java


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