• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ResourceProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:17,代码来源:CXFJaxRsServiceRegistrator.java


示例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;
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:26,代码来源:CXFJaxRsServiceRegistrator.java


示例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);
	}
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:22,代码来源:CXFPlusServlet.java


示例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();

	}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:20,代码来源:CXFPlusServlet.java


示例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);
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:11,代码来源:Utils.java


示例6: remove

import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; //导入依赖的package包/类
public void remove(ResourceProvider resourceProvider) {
    if (_closed) {
        return;
    }

    _services.remove(resourceProvider);

    rewire();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:10,代码来源:CXFJaxRsServiceRegistrator.java


示例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);
        }
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:36,代码来源:ValidationInterceptor.java


示例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();
}
 
开发者ID:fernandocamargoti,项目名称:JavaMagazineRESTfulAPI,代码行数:28,代码来源:JaxRsServerConfig.java


示例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);
}
 
开发者ID:apache,项目名称:tomee,代码行数:16,代码来源:CxfRsHttpListener.java


示例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;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:6,代码来源:NutchServer.java


示例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();
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:56,代码来源:AbstractResourceTest.java


示例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);
        }
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:43,代码来源:CxfRsHttpListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FinalArrayList类代码示例发布时间:2022-05-23
下一篇:
Java WhitespaceTokenizer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap