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