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


Java JSONProvider类代码示例

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


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

示例1: testCxfRsEndpointSetProvider

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
@Test
public void testCxfRsEndpointSetProvider() throws Exception {

    String endpointUri = "cxfrs://http://localhost:" + CTX + ""
                         + "?resourceClass=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService";

    CxfRsComponent component = new CxfRsComponent(context);
    CxfRsEndpoint endpoint = (CxfRsEndpoint)component.createEndpoint(endpointUri);
    JSONProvider<?> jsonProvider = new JSONProvider<Object>();
    jsonProvider.setDropRootElement(true);
    jsonProvider.setSupportUnwrapped(true);
    endpoint.setProvider(jsonProvider);
    JAXRSServerFactoryBean sfb = endpoint.createJAXRSServerFactoryBean();
    assertEquals("Get a wrong proider size", 1, sfb.getProviders().size());
    JAXRSClientFactoryBean cfb = endpoint.createJAXRSClientFactoryBean();
    assertEquals("Get a wrong proider size", 1, cfb.getProviders().size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CxfRsEndpointTest.java

示例2: startServices

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
/**
 * Helper method to start all rest services on a Jettison server as supplied
 * by the Apache cxf libraries.
 * 
 * @throws Exception
 */
private static void startServices() throws Exception {
	List<JSONProvider> providers = new ArrayList<JSONProvider>();
	JSONProvider jsonProvider = new JSONProvider();
	// jsonProvider.setSerializeAsArray(false);
	// jsonProvider.setConvertTypesToStrings(true);
	Map<String, String> map = new HashMap<String, String>();
	map.put("http://www.goodrick.ch", "brewcontrol");
	jsonProvider.setNamespaceMap(map);
	providers.add(jsonProvider);

	JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
	factoryBean.setResourceClasses(RestService.class, MashingService.class, InfoService.class);
	factoryBean.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
	factoryBean.setAddress("http://" + getNetworkAddress() + ":8080/");
	factoryBean.setProviders(providers);
	factoryBean.create();
}
 
开发者ID:SebiGo,项目名称:BrewControlServer,代码行数:24,代码来源:BrewControl.java

示例3: getProviderK2A

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
public static List<Object> getProviderK2A() {
	List<Object> providers = new ArrayList<Object>();
	JSONProvider jsonProvider = new JSONProvider();
	jsonProvider.setDropRootElement(true);
    providers.add(jsonProvider);
    
    return providers;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:9,代码来源:OAuth1Utils.java

示例4: getProvider

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
public static List<Object> getProvider() {
	List<Object> providers = new ArrayList<Object>();
	providers.add(new JSONProvider<Object>());
	providers.add(new JAXBElementProvider<Object>());
	providers.add(new MultipartProvider());
	providers.add(new XPathProvider<Object>());
	providers.add(new DataBindingProvider<Object>());
	providers.add(new BinaryDataProvider<Object>());
	providers.add(new JacksonJaxbJsonProvider());
	return providers;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:12,代码来源:CxfServerBean.java

示例5: UDDIInquiryJAXRSTest

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
public UDDIInquiryJAXRSTest() {

                List<Object> providers = new ArrayList<Object>();
                // add custom providers if any
                providers.add(new org.apache.cxf.jaxrs.provider.JAXBElementProvider());

                Map<String, Object> properties = new HashMap<String, Object>();

// Create a mapping between the XML namespaces and the JSON prefixes.
// The JSON prefix can be "" to specify that you don't want any prefix.
                HashMap<String, String> nstojns = new HashMap<String, String>();
                nstojns.put("urn:uddi-org:api_v3", "urn:uddi-org:api_v3");
                nstojns.put("urn:uddi-org:sub_v3", "urn:uddi-org:sub_v3");
                nstojns.put("urn:uddi-org:custody_v3", "urn:uddi-org:custody_v3");
                nstojns.put("urn:uddi-org:repl_v3", "urn:uddi-org:repl_v3");
                nstojns.put("urn:uddi-org:subr_v3", "urn:uddi-org:subr_v3");
                nstojns.put("urn:uddi-org:repl_v3", "urn:uddi-org:repl_v3");
                nstojns.put("urn:uddi-org:vs_v3", "urn:uddi-org:vs_v3");
                nstojns.put("urn:uddi-org:vscache_v3", "urn:uddi-org:vscache_v3");
                nstojns.put("urn:uddi-org:policy_v3", "urn:uddi-org:policy_v3");
                nstojns.put("urn:uddi-org:policy_instanceParms_v3", "urn:uddi-org:policy_instanceParms_v3");
                nstojns.put("http://www.w3.org/2000/09/xmldsig#", "http://www.w3.org/2000/09/xmldsig#");

                properties.put("namespaceMap", nstojns);
                JSONProvider jsonProvider = new org.apache.cxf.jaxrs.provider.json.JSONProvider();
                jsonProvider.setNamespaceMap(nstojns);

                providers.add(jsonProvider);
                instance = JAXRSClientFactory.create(ENDPOINT_ADDRESS, UDDIInquiryJAXRS.class, providers);
        }
 
开发者ID:apache,项目名称:juddi,代码行数:31,代码来源:UDDIInquiryJAXRSTest.java

示例6: startServer

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
private static void startServer() throws Exception {
                JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
                sf.setResourceClasses(UDDIInquiryJAXRS.class);

                List<Object> providers = new ArrayList<Object>();
                // add custom providers if any
                providers.add(new org.apache.cxf.jaxrs.provider.JAXBElementProvider());

                Map<String, Object> properties = new HashMap<String, Object>();

// Create a mapping between the XML namespaces and the JSON prefixes.
// The JSON prefix can be "" to specify that you don't want any prefix.
                HashMap<String, String> nstojns = new HashMap<String, String>();
                nstojns.put("urn:uddi-org:api_v3", "urn:uddi-org:api_v3");
                nstojns.put("urn:uddi-org:sub_v3", "urn:uddi-org:sub_v3");
                nstojns.put("urn:uddi-org:custody_v3", "urn:uddi-org:custody_v3");
                nstojns.put("urn:uddi-org:repl_v3", "urn:uddi-org:repl_v3");
                nstojns.put("urn:uddi-org:subr_v3", "urn:uddi-org:subr_v3");
                nstojns.put("urn:uddi-org:repl_v3", "urn:uddi-org:repl_v3");
                nstojns.put("urn:uddi-org:vs_v3", "urn:uddi-org:vs_v3");
                nstojns.put("urn:uddi-org:vscache_v3", "urn:uddi-org:vscache_v3");
                nstojns.put("urn:uddi-org:policy_v3", "urn:uddi-org:policy_v3");
                nstojns.put("urn:uddi-org:policy_instanceParms_v3", "urn:uddi-org:policy_instanceParms_v3");
                nstojns.put("http://www.w3.org/2000/09/xmldsig#", "http://www.w3.org/2000/09/xmldsig#");

                properties.put("namespaceMap", nstojns);
                JSONProvider jsonProvider = new org.apache.cxf.jaxrs.provider.json.JSONProvider();
                jsonProvider.setNamespaceMap(nstojns);

                providers.add(jsonProvider);
                sf.setProviders(providers);

                sf.setResourceProvider(UDDIInquiryJAXRS.class,
                        new SingletonResourceProvider(new UDDIInquiryJAXRS(), true));
                sf.setAddress(ENDPOINT_ADDRESS);

                server = sf.create();
        }
 
开发者ID:apache,项目名称:juddi,代码行数:39,代码来源:UDDIInquiryJAXRSTest.java

示例7: callComplexType

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
public void callComplexType(final FormMain formMain) {

        final Thread t = new Thread() {
            @Override
            public void run() {

                ComplexType ct = null;

                try {

                    /**
                     * REST STEP 5 - Call the REST service using a client API
                     *
                     * EE6 skipped a beat here by not defining a client API
                     * This is a CXF client API, which makes sense as this is what
                     * TomEE uses server side.
                     */
                    final List<Object> providers = new ArrayList<Object>();
                    providers.add(new JSONProvider());

                    final WebClient webClient = WebClient.create(uri.toASCIIString(), providers);
                    webClient.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML);

                    ct = webClient.path("app/api/myrest/complex").get(ComplexType.class);

                } finally {
                    formMain.setComplexType(ct);
                }

            }
        };

        t.start();
    }
 
开发者ID:tomitribe,项目名称:tomcat_to_tomee,代码行数:35,代码来源:ClientRs.java

示例8: getSingletons

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
@Override
public Set<Object> getSingletons() {
    Set<Object> classes = new HashSet<Object>();

    ControlCenterService personService = new ControlCenterService();
    classes.add(personService);

    // custom providers
    JSONProvider<?> provider = new JSONProvider<Object>();
    provider.setIgnoreNamespaces(true);
    classes.add(provider);

    return classes;
}
 
开发者ID:hzbarcea,项目名称:activemq-samples,代码行数:15,代码来源:ControlCenterApp.java

示例9: JAXRSClient

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public JAXRSClient() {
   	List providers = new ArrayList();
   	JSONProvider jsonProvider = new JSONProvider();
   	Map<String, String> map = new HashMap<String, String>();
   	jsonProvider.setNamespaceMap (map);
   	providers.add (jsonProvider);
   	providers.add (new TestResponseExceptionMapper());
       emr = JAXRSClientFactory.create(
           "http://localhost:" + System.getProperty("restEndpointPort") + "/rest",
           MedicalRecords.class,
           providers);        
   }
 
开发者ID:OSEHRA,项目名称:vista-soa-ri,代码行数:14,代码来源:JAXRSClient.java

示例10: rewire

import org.apache.cxf.jaxrs.provider.json.JSONProvider; //导入依赖的package包/类
protected synchronized void rewire() {
	if (_server != null) {
		_server.destroy();
	}

	RuntimeDelegate runtimeDelegate = RuntimeDelegate.getInstance();

	JAXRSServerFactoryBean jaxRsServerFactoryBean =
		runtimeDelegate.createEndpoint(
			_application, JAXRSServerFactoryBean.class);

	jaxRsServerFactoryBean.setBus(_bus);
	jaxRsServerFactoryBean.setProperties(_properties);

	JSONProvider<Object> jsonProvider = new JSONProvider<>();

	jsonProvider.setDropCollectionWrapperElement(true);
	jsonProvider.setDropRootElement(true);
	jsonProvider.setSerializeAsArray(true);
	jsonProvider.setSupportUnwrapped(true);

	jaxRsServerFactoryBean.setProvider(jsonProvider);

	for (Object provider : _providers) {
		jaxRsServerFactoryBean.setProvider(provider);
	}

	for (Object service : _services) {
		jaxRsServerFactoryBean.setResourceProvider(
			new SingletonResourceProvider(service, true));
	}

	String address = _properties.get("CXF_ENDPOINT_ADDRESS").toString();

	if (address != null) {
		jaxRsServerFactoryBean.setAddress(address);
	}

	_server = jaxRsServerFactoryBean.create();

	_server.start();
}
 
开发者ID:csierra,项目名称:osgi-jaxrs-extracted,代码行数:43,代码来源:CXFJaxRsServiceRegistrator.java


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