本文整理汇总了Java中org.apache.cxf.jaxrs.JAXRSBindingFactory类的典型用法代码示例。如果您正苦于以下问题:Java JAXRSBindingFactory类的具体用法?Java JAXRSBindingFactory怎么用?Java JAXRSBindingFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JAXRSBindingFactory类属于org.apache.cxf.jaxrs包,在下文中一共展示了JAXRSBindingFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NutchServer
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的package包/类
private NutchServer() {
configManager = new ConfManagerImpl();
BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY);
NutchServerPoolExecutor executor = new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS, runnables);
jobManager = new JobManagerImpl(new JobFactory(), configManager, executor);
fetchNodeDb = FetchNodeDb.getInstance();
sf = new JAXRSServerFactoryBean();
BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
JAXRSBindingFactory factory = new JAXRSBindingFactory();
factory.setBus(sf.getBus());
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
sf.setResourceClasses(getClasses());
sf.setResourceProviders(getResourceProviders());
sf.setProvider(new JacksonJaxbJsonProvider());
}
示例2: shutdown
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的package包/类
public static void shutdown() throws Exception {
logger.warn("shutdown");
if (restartNum > 0) {
throw new Exception("Cannot support shutdown again");
}
if (server != null) {
server.stop();
server.destroy();
server = null;
}
if (serverFactoryBean != null) {
serverFactoryBean.getBus().shutdown(true);
BindingFactoryManager manager = serverFactoryBean.getBus().getExtension(BindingFactoryManager.class);
manager.unregisterBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID);
serverFactoryBean = null;
bindingFactory.getBus().shutdown(true);
bindingFactory = null;
}
}
示例3: startServices
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的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();
}
示例4: prepareTestInstance
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的package包/类
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
JAXRSServerFactoryBean factory = testContext.getApplicationContext().getBean(JAXRSServerFactoryBean.class);
String basePath = testContext.getApplicationContext().getEnvironment()
.getProperty("basePath", "http://localhost:9080/api/");
logger.debug("Creating JAX-RS Server for resource {} under {} ", testContext.getTestClass(), basePath);
factory.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
factory.setAddress(basePath);
server = factory.create();
}
示例5: publishService
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的package包/类
/**
* This publishes the cxf service onto the cxf bus.
*
* @param serviceImpl
* @throws Exception
*/
@Override
public void publishService(ServiceDefinition serviceDefinition, Object serviceImpl, String address) {
RestServiceDefinition restServiceDef = (RestServiceDefinition)serviceDefinition;
LOG.info("Creating JAXRSService " + restServiceDef.getServiceName());
JAXRSServerFactoryBean svrFactory = new JAXRSServerFactoryBean();
svrFactory.setBus(getCXFBus());
List<Object> resources = restServiceDef.getResources();
if (resources != null && !resources.isEmpty()) {
svrFactory.setServiceBeans(resources);
} else {
try {
Class<?> resourceClass = this.getClass().getClassLoader().loadClass(restServiceDef.getResourceClass());
svrFactory.setResourceClasses(resourceClass);
svrFactory.setResourceProvider(resourceClass, new SingletonResourceProvider(serviceImpl));
} catch (ClassNotFoundException e) {
throw new RiceRuntimeException("Failed to publish the service because resource class could not be loaded: " + restServiceDef.getResourceClass(), e);
}
}
svrFactory.setServiceName(restServiceDef.getServiceName());
svrFactory.setAddress(address);
svrFactory.setExtensionMappings(restServiceDef.getExtensionMappings());
svrFactory.setLanguageMappings(restServiceDef.getLanguageMappings());
List<Object> providers = restServiceDef.getProviders();
if (providers != null) {
svrFactory.setProviders(providers);
}
BindingFactoryManager bindingFactoryManager = getCXFBus().getExtension(BindingFactoryManager.class);
JAXRSBindingFactory bindingFactory = new JAXRSBindingFactory();
bindingFactory.setBus(getCXFBus());
bindingFactoryManager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, bindingFactory);
//Set logging interceptors
if (LOG.isDebugEnabled()) {
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
}
// svrFactory.getInInterceptors().add(new RESTConnector.VerifyingInInterceptor());
if (LOG.isDebugEnabled()) {
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
}
// svrFactory.getOutInterceptors().add(new RESTConnector.SigningOutInterceptor());
svrFactory.setPublishedEndpointUrl(restServiceDef.getEndpointUrl().toExternalForm());
svrFactory.create();
}
示例6: messageTo
import org.apache.cxf.jaxrs.JAXRSBindingFactory; //导入依赖的package包/类
private Message messageTo(String requestBaseURL, String requestPath) {
Message message = new SoapMessage(Soap11.getInstance());
String requestURL = requestBaseURL + requestPath;
message.put(Message.ENDPOINT_ADDRESS, requestURL);
message.put(Message.BASE_PATH, requestBaseURL);
message.put(Message.REQUEST_URI, requestURL);
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put(Client.REQUEST_CONTEXT, new HashMap<String, Object>());
message.put(Message.INVOCATION_CONTEXT, ctx);
CXFBusImpl bus = new CXFBusImpl();
BindingFactoryManagerImpl bindingFactoryManager = new BindingFactoryManagerImpl();
bindingFactoryManager.registerBindingFactory("abc", new JAXRSBindingFactory());
bus.setExtension(bindingFactoryManager, BindingFactoryManager.class);
Map<String, ConduitInitiator> conduitInitiators = new HashMap<String, ConduitInitiator>();
ConduitInitiator ci = new HTTPTransportFactory(bus);
conduitInitiators.put(ENDPOINT_TRANSPORT_ID, ci);
ConduitInitiatorManagerImpl cim = new ConduitInitiatorManagerImpl(conduitInitiators);
bus.setExtension(cim, ConduitInitiatorManager.class);
Exchange exchange = exchange(message);
exchange.put(Bus.class, bus);
EndpointInfo ei = new EndpointInfo();
ei.setAddress("http://abc123");
BindingInfo b = new BindingInfo(null, "abc");
ei.setBinding(b);
Endpoint endpointMock = mock(Endpoint.class);
when(endpointMock.getEndpointInfo()).thenReturn(ei);
exchange.put(Endpoint.class, endpointMock);
message.setExchange(exchange);
message.setContent(List.class, new ArrayList<String>());
circuitBreakerTargetSelector.prepare(message);
InvocationKey key = new InvocationKey(exchange);
InvocationContext invocation = circuitBreakerTargetSelector.getInvocation(key);
invocation.getContext().put(Message.ENDPOINT_ADDRESS, requestPath);
invocation.getContext().put("org.apache.cxf.request.uri", requestPath);
return message;
}