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


Java JAXRSClientFactoryBean.setAddress方法代码示例

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


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

示例1: setupJAXRSClientFactoryBean

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
protected void setupJAXRSClientFactoryBean(JAXRSClientFactoryBean cfb, String address) {
    // address
    if (address != null) {
        cfb.setAddress(address);
    }
    if (modelRef != null) {
        cfb.setModelRef(modelRef);
    }
    if (getResourceClasses() != null && !getResourceClasses().isEmpty()) {
        cfb.setResourceClass(getResourceClasses().get(0));
        cfb.getServiceFactory().setResourceClasses(getResourceClasses());
    }
    setupCommonFactoryProperties(cfb);
    cfb.setThreadSafe(true);
    getNullSafeCxfRsEndpointConfigurer().configure(cfb);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CxfRsEndpoint.java

示例2: build

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
/**
 * Build a client proxy, for a specific proxy type.
 * 
 * @param proxyType proxy type class
 * @return client proxy stub
 */
protected <T> T build(Class<T> proxyType) {
    String address = generateAddress();
    T rootResource;
    // Synchronized on the class to correlate with the scope of clientStaticResources
    // We want to ensure that the shared bean isn't set concurrently in multiple callers
    synchronized (AmbariClientBuilder.class) {
        JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType));
        bean.setAddress(address);
        if (username != null) {
            bean.setUsername(username);
            bean.setPassword(password);
        }

        if (enableLogging) {
            bean.setFeatures(Arrays.<AbstractFeature> asList(new LoggingFeature()));
        }
        rootResource = bean.create(proxyType);
    }

    boolean isTlsEnabled = address.startsWith("https://");
    ClientConfiguration config = WebClient.getConfig(rootResource);
    HTTPConduit conduit = (HTTPConduit) config.getConduit();
    if (isTlsEnabled) {
        TLSClientParameters tlsParams = new TLSClientParameters();
        if (!validateCerts) {
            tlsParams.setTrustManagers(new TrustManager[] { new AcceptAllTrustManager() });
        } else if (trustManagers != null) {
            tlsParams.setTrustManagers(trustManagers);
        }
        tlsParams.setDisableCNCheck(!validateCn);
        conduit.setTlsClientParameters(tlsParams);
    }

    HTTPClientPolicy policy = conduit.getClient();
    policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout));
    policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout));
    return rootResource;
}
 
开发者ID:Talend,项目名称:components,代码行数:45,代码来源:AmbariClientBuilder.java

示例3: rawTest

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
@Test
	@Ignore
	public void rawTest(){
		JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean();
		bean.setAddress("http://localhost:8080/cxf-plus/ws/rest/");
		                 
		bean.setServiceClass(PeopleServiceXml.class);
//		bean.setProvider(new FastJSONProvider(true, false));
		
		bean.getInInterceptors().add(new LoggingInInterceptor());
		bean.getOutInterceptors().add(new LoggingOutInterceptor());
		
		PeopleServiceXml s=(PeopleServiceXml)bean.create();
		List<People> r=s.getAll();
		
		System.out.println("-------------------");
		System.out.println("得到用户"+r.size());
//		int id=s.create(new People("[email protected]","jiyi","lu"));
//		System.out.println(id);
	}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:21,代码来源:ClientTest.java

示例4: createSAMLClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private static WebClient createSAMLClient(String address, boolean selfSigned) {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress(address);

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("ws-security.callback-handler", "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
    properties.put("ws-security.saml-callback-handler", "org.teiid.saml.jaxrs.SamlCallbackHandler");
    properties.put("ws-security.signature.username", "alice");
    properties.put("ws-security.signature.properties", "org/apache/cxf/systest/jaxrs/security/alice.properties");
    if (selfSigned) {
        properties.put("ws-security.self-sign-saml-assertion", "true");
    }
    bean.setProperties(properties);

    bean.getOutInterceptors().add(new SamlEnvelopedOutInterceptor(!selfSigned));
    XmlSigOutInterceptor xmlSig = new XmlSigOutInterceptor();
    if (selfSigned) {
        xmlSig.setStyle(XmlSigOutInterceptor.DETACHED_SIG);
    }
    return bean.createWebClient();
}
 
开发者ID:rareddy,项目名称:ws-security-examples,代码行数:22,代码来源:Client.java

示例5: createClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
public IOpenDaylightStaticFlowPusherClient createClient(ProtocolSessionContext sessionContext) {
      String uri = (String) sessionContext.getSessionParameters().get(ProtocolSessionContext.PROTOCOL_URI);
      String switchId = (String) sessionContext.getSessionParameters().get(OpenDaylightProtocolSession.SWITCHID_CONTEXT_PARAM_NAME);
// TODO use switch id to instantiate the client

      // create CXF client
      ProxyClassLoader classLoader = new ProxyClassLoader();
      classLoader.addLoader(IOpenDaylightStaticFlowPusherClient.class.getClassLoader());
      classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());

      JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
      bean.setAddress(uri);
      bean.setUsername(odlUserName);
      bean.setPassword(odlPassword);
      bean.setProvider(new CustomJSONProvider());
      bean.setResourceClass(IOpenDaylightStaticFlowPusherClient.class);
      bean.setClassLoader(classLoader);

      IOpenDaylightStaticFlowPusherClient cxfClient = (IOpenDaylightStaticFlowPusherClient) bean.create();

      // create mixed client using CXF and custom Java clients
      IOpenDaylightStaticFlowPusherClient client = new OpenDaylightStaticFlowPusherClient(cxfClient, sessionContext);

      return client;
  }
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:26,代码来源:OpenDaylightClientFactory.java

示例6: createClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
public IFloodlightStaticFlowPusherClient createClient(ProtocolSessionContext sessionContext) {

		String uri = (String) sessionContext.getSessionParameters().get(ProtocolSessionContext.PROTOCOL_URI);
		String switchId = (String) sessionContext.getSessionParameters().get(FloodlightProtocolSession.SWITCHID_CONTEXT_PARAM_NAME);
		// TODO use switch id to instantiate the client

		// create CXF client
		ProxyClassLoader classLoader = new ProxyClassLoader();
		classLoader.addLoader(IFloodlightStaticFlowPusherClient.class.getClassLoader());
		classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());

		JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
		bean.setAddress(uri);
		bean.setProvider(new CustomJSONProvider());
		bean.setResourceClass(IFloodlightStaticFlowPusherClient.class);
		bean.setClassLoader(classLoader);

		IFloodlightStaticFlowPusherClient cxfClient = (IFloodlightStaticFlowPusherClient) bean.create();

		// create mixed client using CXF and custom Java clients
		IFloodlightStaticFlowPusherClient client = new FloodlightStaticFlowPusherClient(cxfClient, sessionContext);

		return client;
	}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:25,代码来源:FloodlightClientFactory.java

示例7: createRestClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
/**
 * Creates a JAXRSClient with given clientInterface.
 * 
 * @param uri
 *            the URI where the service is running
 * @param clientInterface
 *            interface class the client should has.
 * @param providers
 *            custom JAX-RS providers
 * @param username
 *            Basic authentication username
 * @param password
 *            Basic authentication password
 * @return JAX-RX Client configured with given parameters.
 */
@SuppressWarnings("unchecked")
public static <T> T createRestClient(String uri, Class<T> clientInterface, List<? extends Object> providers, String username, String password) {

	ProxyClassLoader classLoader = new ProxyClassLoader();
	classLoader.addLoader(clientInterface.getClassLoader());
	classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());

	JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
	bean.setAddress(uri);
	if (providers != null && !providers.isEmpty())
		bean.setProviders(providers);
	bean.setResourceClass(clientInterface);
	bean.setClassLoader(classLoader);
	if (username != null && password != null) {
		bean.setUsername(username);
		bean.setPassword(password);
	}

	return (T) bean.create();
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:36,代码来源:InitializerTestHelper.java

示例8: build

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
/**
 * This method returns an instance of an implementation the specified {@code clazz} (which should be a REST service
 * interface, e.g. TablemanagementRestService.class). <br/>
 * The caller must take care that no parameter value is equal to {@code NULL}. <br/>
 * The caller will be authenticated using basic authentication with the provided credentials. The method
 * {@code setLocalServerPort} MUST be called in advance.
 *
 * @param <T> The return type.
 * @param clazz This must be an interface type.
 * @param userName The userName for basic authentication.
 * @param tmpPassword The password for basic authentication.
 * @param tmpUrl The URL through which the server is reached.
 * @return A REST proxy of type {@code T}
 */
public <T extends RestService> T build(Class<T> clazz, String userName, String tmpPassword, String tmpUrl) {

  JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
  factoryBean.setAddress(tmpUrl);
  factoryBean.setHeaders(new HashMap<String, String>());
  // example for basic auth
  String payload = userName + ":" + tmpPassword;
  String authorizationHeader = "Basic " + Base64Utility.encode(payload.getBytes());
  factoryBean.getHeaders().put("Authorization", Arrays.asList(authorizationHeader));
  factoryBean.setProviders(Arrays.asList(this.jacksonJsonProvider));

  factoryBean.setServiceClass(clazz);
  return factoryBean.create(clazz);
}
 
开发者ID:oasp,项目名称:oasp-tutorial-sources,代码行数:29,代码来源:RestTestClientBuilder.java

示例9: getBean

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation, Map<String, String> headers) {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    if (configLocation != null) {
        SpringBusFactory bf = new SpringBusFactory();
        Bus bus = bf.createBus(configLocation);
        bean.setBus(bus);
    }
    bean.setAddress(baseAddress);
    if (headers != null && !headers.isEmpty()) {
        bean.setHeaders(headers);
    }
    return bean;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:14,代码来源:IdentityManagementEndpointUtil.java

示例10: createProxy

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createProxy(String url, Class<T> clz) {
	JAXRSClientFactoryBean proxyFactoryBean = new JAXRSClientFactoryBean();
	proxyFactoryBean.setAddress(url);
	proxyFactoryBean.setServiceClass(clz);
	proxyFactoryBean.setProvider(new FastJSONProvider(true, false));
	proxyFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
	proxyFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
	T client = (T) proxyFactoryBean.create();
	return client;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:12,代码来源:RsClientFactoryImpl.java

示例11: createClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private static WebClient createClient(String address, String userName, String password) {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress(address);
    bean.setUsername(userName);
    bean.setPassword(password);
    
    bean.getOutInterceptors().add(new LoggingOutInterceptor());
    bean.getInInterceptors().add(new LoggingInInterceptor());
    
    return bean.createWebClient();
}
 
开发者ID:rareddy,项目名称:ws-security-examples,代码行数:12,代码来源:Client.java

示例12: getAccessTokenService

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private WebClient getAccessTokenService() {
  final JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
  bean.setAddress(oauth2TokenServiceURI.toASCIIString());
  bean.setUsername("odatajclient");
  bean.setPassword("odatajclient");
  return bean.createWebClient().
      type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON_TYPE);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:CXFOAuth2HttpClientFactory.java

示例13: createClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private IResourceModelReader createClient(String addressUri) {

		// create CXF client
		ProxyClassLoader classLoader = new ProxyClassLoader(IResourceModelReader.class.getClassLoader());
		classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());

		JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
		bean.setAddress(addressUri);
		bean.setResourceClass(IResourceModelReader.class);
		bean.setClassLoader(classLoader);

		return (IResourceModelReader) bean.create();
	}
 
开发者ID:dana-i2cat,项目名称:mqnaas,代码行数:14,代码来源:ResourceModelReaderTest.java

示例14: createClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
public IOpenDaylightFlowProgrammerNorthbound createClient(String addressUri, String username, String password) {

        // create CXF client
        ProxyClassLoader classLoader = new ProxyClassLoader(IOpenDaylightFlowProgrammerNorthbound.class.getClassLoader());
        classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());

        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress(addressUri);
        bean.setUsername(username);
        bean.setPassword(password);
        bean.setResourceClass(IOpenDaylightFlowProgrammerNorthbound.class);
        bean.setClassLoader(classLoader);

        return (IOpenDaylightFlowProgrammerNorthbound) bean.create();
    }
 
开发者ID:dana-i2cat,项目名称:mqnaas,代码行数:16,代码来源:OpenDaylightClientFactory.java

示例15: getClient

import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; //导入方法依赖的package包/类
private static ISwitchNorthboundAPI getClient(String baseURL, String username, String password) {
	JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
	bean.setAddress(baseURL);
	bean.setResourceClass(ISwitchNorthboundAPI.class);

	bean.setUsername(username);
	bean.setPassword(password);

	return bean.create(ISwitchNorthboundAPI.class);
}
 
开发者ID:dana-i2cat,项目名称:mqnaas,代码行数:11,代码来源:SwitchNorthboundAPITests.java


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