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


Java JAXRSClientFactory类代码示例

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


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

示例1: runtimeInfoService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
@Test
public void runtimeInfoService()
    throws Exception
{
    RuntimeInfoService service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/",
                                   RuntimeInfoService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" );

    assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() );
    assertFalse( applicationRuntimeInfo.isJavascriptLog() );
    assertTrue( applicationRuntimeInfo.isLogMissingI18n() );

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RuntimeInfoServiceTest.java

示例2: getRoleManagementService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected RoleManagementService getRoleManagementService( String authzHeader )
{
    RoleManagementService service =
        JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/",
                                   RoleManagementService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    // for debuging purpose
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L );

    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    return service;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:AbstractDownloadTest.java

示例3: getSearchService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected SearchService getSearchService( String authzHeader )
{
    // START SNIPPET: cxf-searchservice-creation        
    SearchService service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                   SearchService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );
    // to add authentification
    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    // to configure read timeout
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
    // if you want to use json as exchange format xml is supported too
    WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
    WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
    return service;
    // END SNIPPET: cxf-searchservice-creation

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:22,代码来源:AbstractArchivaRestTest.java

示例4: getCommonServices

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected CommonServices getCommonServices( String authzHeader )
{
    CommonServices service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                   CommonServices.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
    WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
    WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
    return service;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:AbstractArchivaRestTest.java

示例5: getResource

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
/**
 * Creates new authenticated service for the specified service class.
 * 
 * @param resourceClass
 * 		Service class
 * @return
 * 		Returns the new service instance
 */
public static <T> T getResource(Class<T> resourceClass) {
	if (client == null) {
		fail("Null REST client");
	}

	if (session == null) {
		fail("Not authenticated");
	}

	// go to the root of REST services
	client.replacePath("/ws/rs");
	
	
	// create service
	T service = JAXRSClientFactory.fromClient(client, resourceClass);
	Client newClient = WebClient.client(service);
	// propagate session state
	newClient.cookie(session);

	// make sure we only use XML
	newClient.type(mediaType);
	newClient.accept(mediaType);
	
	return service;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:34,代码来源:BaseRestServiceTest.java

示例6: createJmsClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
/**
 * Creates two clients for {@link ITestService} and {@link ITestService2} and invokes them.<br>
 * The first client has some non-default settings, the second client is default.
 * <p>
 * See http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-Client
 */
private ITestService createJmsClient(boolean withOneWayRequestHeader)
{
	final JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider();

	//
	// setting up the client
	final ITestService client = JAXRSClientFactory.create(
			CLIENT_ADDRESS_URL_ENCODED,
			ITestService.class,
			Collections.singletonList(jacksonJaxbJsonProvider));
	assertThat(client, notNullValue());

	// we don't expect a response. Instead we expect the return code 202.
	// this doesn't work yet. If we set this header, the service won't respond, but this stupid client will still wait and eventually timeout
	if (withOneWayRequestHeader)
	{
		WebClient.client(client).header("OnewayRequest", "true");
	}

	return client;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:28,代码来源:JaxRsOneWayTests.java

示例7: start

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
public T start(Class<T> cls, String url, boolean trustAllCerts, String trustStore, String trustStorePassword, 
	List<?> providers, int connectTimeout, int receiveTimeout) {

	try {
		
		T resource = JAXRSClientFactory.create(url, cls, providers);
	    HTTPConduit conduit = WebClient.getConfig(resource).getHttpConduit();
	    WebClient.getConfig(resource).getInInterceptors().add(new LoggingInInterceptor());
	    WebClient.getConfig(resource).getOutInterceptors().add(new LoggingOutInterceptor());
		configureHTTPS(resource, conduit, trustAllCerts, trustStore, trustStorePassword);
		
	    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 
	    httpClientPolicy.setConnectionTimeout(connectTimeout); 
	    httpClientPolicy.setReceiveTimeout(receiveTimeout); 
	    conduit.setClient(httpClientPolicy);
		
		return resource;
		
	} catch (Exception e) {
		LOG.error(" rest client '{}': NOT STARTED", url);
		return null;
	}
	
}
 
开发者ID:csob,项目名称:paymentgateway,代码行数:25,代码来源:JaxRsClientStarter.java

示例8: getService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected <T>T getService(Class<T> clazz, String endpoint) {
        if(services.containsKey(clazz))
            return (T)services.get(clazz);

        if(restUrl == null)
            new IllegalStateException("GeoFence URL not set");

        synchronized(services) {
//            T proxy = JAXRSClientFactory.create(restUrl, clazz, username, password, null);
            
            T proxy = JAXRSClientFactory.create(restUrl+"/"+endpoint, clazz);
            String authorizationHeader = "Basic "  + Base64Utility.encode((username+":"+password).getBytes());
            WebClient.client(proxy).header("Authorization", authorizationHeader);

//        WebClient.client(proxy).accept("text/xml");
            services.put(clazz, proxy);
            return proxy;
        }
    }
 
开发者ID:geoserver,项目名称:geofence,代码行数:20,代码来源:GeoFenceClient.java

示例9: runtimeInfoService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
@Test
public void runtimeInfoService()
    throws Exception
{
    RuntimeInfoService service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/",
                                   RuntimeInfoService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    WebClient.client(service).header("Referer","http://localhost");
    ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" );

    assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() );
    assertFalse( applicationRuntimeInfo.isJavascriptLog() );
    assertTrue( applicationRuntimeInfo.isLogMissingI18n() );

}
 
开发者ID:apache,项目名称:archiva,代码行数:18,代码来源:RuntimeInfoServiceTest.java

示例10: getRoleManagementService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected RoleManagementService getRoleManagementService( String authzHeader )
{
    RoleManagementService service =
        JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/",
                                   RoleManagementService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    WebClient.client( service ).header( "Referer", "http://localhost:" + port );

    // for debuging purpose
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L );

    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    return service;
}
 
开发者ID:apache,项目名称:archiva,代码行数:19,代码来源:AbstractDownloadTest.java

示例11: getUserService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected UserService getUserService( String authzHeader )
{
    UserService service =
        JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/",
                                   UserService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    WebClient.client( service ).header( "Referer", "http://localhost:" + port );

    // for debuging purpose
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L );

    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    return service;
}
 
开发者ID:apache,项目名称:archiva,代码行数:18,代码来源:AbstractDownloadTest.java

示例12: getArchivaAdministrationService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected ArchivaAdministrationService getArchivaAdministrationService()
{
    ArchivaAdministrationService service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                   ArchivaAdministrationService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
    WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );

    WebClient.client( service ).header( "Authorization", authorizationHeader );
    WebClient.client(service).header("Referer","http://localhost:"+port);

    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
    return service;
}
 
开发者ID:apache,项目名称:archiva,代码行数:17,代码来源:AbstractArchivaRestTest.java

示例13: getSearchService

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected SearchService getSearchService( String authzHeader )
{
    // START SNIPPET: cxf-searchservice-creation        
    SearchService service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                   SearchService.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );
    // to add authentification
    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    // Set the Referer header to your archiva server url
    WebClient.client(service).header("Referer","http://localhost:"+port);
    // to configure read timeout
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
    // if you want to use json as exchange format xml is supported too
    WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
    WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
    return service;
    // END SNIPPET: cxf-searchservice-creation

}
 
开发者ID:apache,项目名称:archiva,代码行数:24,代码来源:AbstractArchivaRestTest.java

示例14: getCommonServices

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
protected CommonServices getCommonServices( String authzHeader )
{
    CommonServices service =
        JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                   CommonServices.class,
                                   Collections.singletonList( new JacksonJaxbJsonProvider() ) );

    if ( authzHeader != null )
    {
        WebClient.client( service ).header( "Authorization", authzHeader );
    }
    WebClient.client(service).header("Referer","http://localhost:"+port);
    WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
    WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
    WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
    return service;
}
 
开发者ID:apache,项目名称:archiva,代码行数:18,代码来源:AbstractArchivaRestTest.java

示例15: init

import org.apache.cxf.jaxrs.client.JAXRSClientFactory; //导入依赖的package包/类
@Before
public void init() {
	restClient = JAXRSClientFactory.create(getBaseCxf() + CXFConfig.REST_SIGNATURE_ONE_DOCUMENT, RestDocumentSignatureService.class,
			Arrays.asList(new JacksonJsonProvider()));

	restMultiDocsClient = JAXRSClientFactory.create(getBaseCxf() + CXFConfig.REST_SIGNATURE_MULTIPLE_DOCUMENTS, RestMultipleDocumentSignatureService.class,
			Arrays.asList(new JacksonJsonProvider()));
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:9,代码来源:SignatureRestServiceIT.java


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