本文整理汇总了Java中org.apache.cxf.jaxrs.lifecycle.ResourceProvider类的典型用法代码示例。如果您正苦于以下问题:Java ResourceProvider类的具体用法?Java ResourceProvider怎么用?Java ResourceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceProvider类属于org.apache.cxf.jaxrs.lifecycle包,在下文中一共展示了ResourceProvider类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
public void add(ResourceProvider resourceProvider) {
if (_closed) {
return;
}
_services.add(resourceProvider);
try {
rewire();
}
catch (Exception e) {
remove(resourceProvider);
throw e;
}
}
示例2: compare
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
@Override
public int compare(
ClassResourceInfo cri1, ClassResourceInfo cri2, Message message) {
ResourceProvider rp1 = cri1.getResourceProvider();
ResourceProvider rp2 = cri2.getResourceProvider();
if (rp1 instanceof ServiceReferenceResourceProvider &&
rp2 instanceof ServiceReferenceResourceProvider) {
return comparator.compare(
(ServiceReferenceResourceProvider)rp2,
(ServiceReferenceResourceProvider)rp1);
}
if (rp1 instanceof ServiceReferenceResourceProvider) {
return -1;
}
if (rp2 instanceof ServiceReferenceResourceProvider) {
return 1;
}
return 0;
}
示例3: processJaxRs
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
public void processJaxRs() {
if (RSlookup == null)
return;
log.debug("Start procesing the Restful-Services.");
Map<Class<?>, ResourceProvider> resProviders = new HashMap<Class<?>, ResourceProvider>();
for (ServiceDefinition def : RSlookup.getServices()) {
if (def.getServiceClass() == null)
continue;
if (canPublish(def.getName(), restNamePattern)) {
ServiceDefinition context = serviceUtill.processServiceDef(def);
if (context != null) {
resProviders.put(context.getServiceClass(), new SingletonResourceProvider(context.getServiceBean()));
}
}
}
// 计算完成开始发布
if (!resProviders.isEmpty()) {
doPublishRestful(resProviders);
}
}
示例4: doPublishRestful
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
private void doPublishRestful(Map<Class<?>, ResourceProvider> springResources) {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(getBus());
for (Entry<Class<?>, ResourceProvider> e : springResources.entrySet()) {
sf.setResourceClasses(e.getKey());
sf.setResourceProvider(e.getKey(), e.getValue());
log.info("Publishing JAX-RS Service {} at {}", e, httpPrefix + restBasePath);
}
sf.setAddress(httpPrefix + restBasePath);
// if (restUseFastJson == 1) {
// sf.setProvider(new FastJSONProvider(false, restJsonWithClassname));
// } else {
sf.setProvider(new FastJSONProvider(true, restJsonWithClassname));
// }
sf.getInInterceptors().add(new LoggingInInterceptor());
sf.getOutInterceptors().add(new LoggingOutInterceptor());
sf.create();
}
示例5: getResourceProvider
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
public static <T> ResourceProvider getResourceProvider(
ServiceObjects<T> serviceObjects) {
CachingServiceReference<T> serviceReference =
new CachingServiceReference<>(
serviceObjects.getServiceReference());
return new ServiceReferenceResourceProvider(
serviceReference, serviceObjects);
}
示例6: remove
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
public void remove(ResourceProvider resourceProvider) {
if (_closed) {
return;
}
_services.remove(resourceProvider);
rewire();
}
示例7: handleMessage
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault {
final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class);
if (operationResource == null) {
log.info("OperationResourceInfo is not available, skipping validation");
return;
}
final ClassResourceInfo classResource = operationResource.getClassResourceInfo();
if (classResource == null) {
log.info("ClassResourceInfo is not available, skipping validation");
return;
}
final ResourceProvider resourceProvider = classResource.getResourceProvider();
if (resourceProvider == null) {
log.info("ResourceProvider is not available, skipping validation");
return;
}
final List<Object> arguments = MessageContentsList.getContentsList(message);
final Method method = operationResource.getAnnotatedMethod();
final Object instance = resourceProvider.getInstance(message);
if (method != null && arguments != null) {
//validate the parameters(arguments) over the invoked method
validate(method, arguments.toArray(), instance);
//validate the fields of each argument
for (Object arg : arguments) {
if (arg != null)
validate(arg);
}
}
}
示例8: jaxRsServer
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
@Bean
public Server jaxRsServer(){
List<ResourceProvider> resourceProviders = new LinkedList<ResourceProvider>();
for (String beanName : ctx.getBeanDefinitionNames()) {
if (ctx.findAnnotationOnBean(beanName, Path.class) != null) {
SpringResourceFactory resourceFactory = new SpringResourceFactory(beanName);
resourceFactory.setApplicationContext(ctx);
resourceProviders.add(resourceFactory);
}
}
JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setBus(ctx.getBean(SpringBus.class));
JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider();
ObjectMapper objectMapper = new ObjectMapper();
//set up ISO 8601 date/time stamp format:
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sss'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
objectMapper.setDateFormat(df);
jacksonJsonProvider.setMapper(objectMapper);
factory.setProviders(Arrays.asList(jacksonJsonProvider, new DefaultExceptionMapper()));
factory.setResourceProviders(resourceProviders);
return factory.create();
}
示例9: getServiceObject
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
private Object getServiceObject(final Message message) {
final OperationResourceInfo ori = message.getExchange().get(OperationResourceInfo.class);
if (ori == null) {
return null;
}
if (!ori.getClassResourceInfo().isRoot()) {
return message.getExchange().get("org.apache.cxf.service.object.last");
}
final ResourceProvider resourceProvider = ori.getClassResourceInfo().getResourceProvider();
if (resourceProvider.isSingleton()) {
return resourceProvider.getInstance(message);
}
final Object o = message.getExchange().get(CdiResourceProvider.INSTANCE_KEY);
return o != null || !OpenEJBPerRequestPojoResourceProvider.class.isInstance(resourceProvider) ? o : resourceProvider.getInstance(message);
}
示例10: getResourceProviders
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
private List<ResourceProvider> getResourceProviders() {
List<ResourceProvider> resourceProviders = new ArrayList<ResourceProvider>();
resourceProviders.add(new SingletonResourceProvider(getConfManager()));
return resourceProviders;
}
示例11: initialize
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
/**
* Configure Shiro and start the server
* @throws Exception
*/
@BeforeClass
public static void initialize() throws Exception {
//
// Set up roles
//
createTestUsersAndRoles();
//
// This is for unit testing only and uses the test.shiro.ini configuration
//
Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:test.shiro.ini");
SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
//
// Create an embedded server with JSON processing
//
//
// Create an embedded server with JSON processing
//
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
ArrayList<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
//providers.add(new UnrecognizedPropertyExceptionMapper());
//providers.add(new ValidationExceptionMapper());
sf.setProviders(providers);
//
// Add our REST resources to the server
//
ArrayList<ResourceProvider> resources = new ArrayList<ResourceProvider>();
//
// Add our REST resources to the server
//
resources.add(new SingletonResourceProvider(new Database(), true));
sf.setResourceProviders(resources);
//
// Start the server at the endpoint
//
sf.setAddress(ENDPOINT_ADDRESS);
server = sf.create();
databases = new ArrayList<DatabaseReference>();
startServer();
}
示例12: deploy
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
private void deploy(final String contextRoot, final Class<?> clazz, final String address, final ResourceProvider rp, final Object serviceBean,
final Application app, final Invoker invoker, final Collection<Object> additionalProviders, final ServiceConfiguration configuration,
final WebBeansContext webBeansContext) {
final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(CxfUtil.initBusLoader());
try {
final JAXRSServerFactoryBean factory = newFactory(address, createServiceJmxName(clazz.getClassLoader()), createEndpointName(app));
configureFactory(additionalProviders, configuration, factory, webBeansContext);
factory.setResourceClasses(clazz);
context = contextRoot;
if (context == null) {
context = "";
}
if (!context.startsWith("/")) {
context = "/" + context;
}
if (rp != null) {
factory.setResourceProvider(rp);
}
if (app != null) {
factory.setApplication(app);
}
if (invoker != null) {
factory.setInvoker(invoker);
}
if (serviceBean != null) {
factory.setServiceBean(serviceBean);
} else {
factory.setServiceClass(clazz);
}
server = factory.create();
destination = (HttpDestination) server.getDestination();
fireServerCreated(oldLoader);
} finally {
if (oldLoader != null) {
CxfUtil.clearBusLoader(oldLoader);
}
}
}