本文整理汇总了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() );
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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() );
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例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()));
}