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


Java Registry类代码示例

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


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

示例1: contextInitialized

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent event) {
  super.contextInitialized(event);

  final ServletContext context = event.getServletContext();
  final Registry registry = (Registry) context.getAttribute(Registry.class.getName());
  final ResteasyProviderFactory providerFactory =
      (ResteasyProviderFactory) context.getAttribute(ResteasyProviderFactory.class.getName());
  final ModuleProcessor processor = new ModuleProcessor(registry, providerFactory);

  final List<? extends Module> appModules = getModules(context);

  List<Module> modules = Lists.newArrayList();
  modules.addAll(appModules);

  injector = GuiceLifecycleContainers.initialize(this, modules);

  withInjector(injector);

  processor.processInjector(injector);
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:22,代码来源:ResteasyContextListener.java

示例2: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void init(ServletConfig servletConfig)
        throws ServletException
{
    super.init(servletConfig);
    Registry registry = servletContainerDispatcher.getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = servletContainerDispatcher.getDispatcher().getProviderFactory();

    // add injected providers
    for (Key<Object> key : providers) {
        providerFactory.registerProviderInstance(injector.getInstance(key));
    }

    // add injected resources
    for (Map.Entry<Key<Object>, Class<?>> pair : resources.entrySet()) {
        GuiceRsResourceFactory resourceFactory = new GuiceRsResourceFactory(injector.getProvider(pair.getKey()), pair.getValue());
        registry.addResourceFactory(resourceFactory);
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:20,代码来源:GuiceRsApplicationServlet.java

示例3: contextInitialized

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
   ServletContext context = contextEvent.getServletContext();
   Registry registry = (Registry) context.getAttribute(Registry.class.getName());
   if (registry == null) {
      throw new RuntimeException("You must install RESTEasy as a Bootstrap Listener and it must be listed before this class");
   }
   String configfile = context.getInitParameter("rest.messaging.config.file");
   deserializationBlackList = context.getInitParameter(ObjectInputStreamWithClassLoader.BLACKLIST_PROPERTY);
   deserializationWhiteList = context.getInitParameter(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY);
   manager = new MessageServiceManager(this);

   if (configfile != null) {
      manager.setConfigResourcePath(configfile);
   }
   try {
      manager.start();
      registry.addSingletonResource(manager.getQueueManager().getDestination());
      registry.addSingletonResource(manager.getTopicManager().getDestination());
   } catch (Exception e) {
      throw new RuntimeException(e);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:RestMessagingBootstrapListener.java

示例4: testServletContextListener

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
private void testServletContextListener(ServletContext servletContext) throws Exception {
    ResteasyAutoConfiguration resteasyAutoConfiguration = new ResteasyAutoConfiguration();
    BeanFactoryPostProcessor beanFactoryPostProcessor = ResteasyAutoConfiguration.springBeanProcessor();
    ServletContextListener servletContextListener = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    Assert.assertNotNull(servletContextListener);

    ServletContextEvent sce = new ServletContextEvent(servletContext);
    servletContextListener.contextInitialized(sce);

    ResteasyProviderFactory servletContextProviderFactory = (ResteasyProviderFactory) servletContext.getAttribute(ResteasyProviderFactory.class.getName());
    Dispatcher servletContextDispatcher = (Dispatcher) servletContext.getAttribute(Dispatcher.class.getName());
    Registry servletContextRegistry = (Registry) servletContext.getAttribute(Registry.class.getName());

    Assert.assertNotNull(servletContextProviderFactory);
    Assert.assertNotNull(servletContextDispatcher);
    Assert.assertNotNull(servletContextRegistry);

    // Exercising fully cobertura branch coverage
    servletContextListener.contextDestroyed(sce);
    ServletContextListener servletContextListener2 = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    servletContextListener2.contextDestroyed(sce);
}
 
开发者ID:paypal,项目名称:resteasy-spring-boot,代码行数:23,代码来源:ResteasyAutoConfigurationTest.java

示例5: stop

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void stop() {
    if ((_context != null) && _context.isStarted()) {
        Registry registry = (Registry)_context.getServletContext().getAttribute(Registry.class.getName());
        if (registry != null) {
            // Remove registrations
            for (Class<?> clazz : _classes) {
                LOG.debug("Stopping ... " + clazz);
                registry.removeRegistrations(clazz);
            }
            // Destroy the web context unless if it is default
            if ((registry.getSize() == 0) && (!_context.getPath().equals("/"))) {
                try {
                    Container container = _context.getParent();
                    container.removeChild(_context);
                    _context.stop();
                    _context.destroy();
                    LOG.info("Destroyed RESTEasy context " + _context.getPath());
                } catch (Exception e) {
                    ExtensionLogger.ROOT_LOGGER.unableToDestroyWebContext(_context.getPath(), e);
                }
            }
        }
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:28,代码来源:RESTEasyResource.java

示例6: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                log.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
            	log.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-resteasy-webapp,代码行数:25,代码来源:GuiceRestEasyFilterDispatcher.java

示例7: getResourceServiceTracker

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
static ServiceTracker<Object, Object> getResourceServiceTracker(BundleContext context, Registry registry) {
    ServiceTracker<Object, Object> resourceTracker = new ServiceTracker<>(context,
            OSGiUtils.anyServiceFilter(context, RES_FILTER_EXPR),
            new JaxRSResources(context, registry));
    resourceTracker.open();
    return resourceTracker;
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:8,代码来源:JaxRSUtil.java

示例8: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
/**
 */
@Override
public void init(FilterConfig cfg) throws ServletException {
	super.init(cfg);

	final ServletContext context = cfg.getServletContext();
	final ResteasyDeployment deployment = (ResteasyDeployment) context.getAttribute(ResteasyDeployment.class.getName());
	final Registry registry = deployment.getRegistry();
	final ResteasyProviderFactory providerFactory = deployment.getProviderFactory();
	final ModuleProcessor processor = new ModuleProcessor(registry, providerFactory);

	processor.processInjector(injector);
}
 
开发者ID:stickfigure,项目名称:gstrap,代码行数:15,代码来源:GuiceResteasyFilterDispatcher.java

示例9: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
    logger.entry();
    servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);

    if (injector == null)
        injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());

    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                logger.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
                logger.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:webshooters,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例10: registerRESTEasyResources

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
/**
 * Registers RESTEasy resources to the registered RESTEasy servlet.
 * @param alias alias
 * @param resources resource instances
 * @return classes of the registered resources
 */
public List<Class<?>> registerRESTEasyResources(String alias, List<Object> resources) {
    OsgiRESTEasyServletWrapper servlet = getRegisteredRESTEasyServlet(alias);
    if (servlet == null) {
        throw new IllegalArgumentException("No servlet is registered for the alias '" + alias + "'");
    }

    Registry registry = servlet.getDispatcher().getRegistry();
    List<Class<?>> classes = new ArrayList<Class<?>>();
    for (Object instance : resources) {
        registry.addSingletonResource(instance);
        classes.add(instance.getClass());
    }
    return classes;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:OsgiRESTEasyServletRegistry.java

示例11: unregisterRESTEasyResources

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
/**
 * Unregisters RESTEasy resources from the servlet.
 * @param alias alias
 * @param resourceClasses resource classes
 */
public void unregisterRESTEasyResources(String alias, List<Class<?>> resourceClasses) {
    OsgiRESTEasyServletWrapper servlet = getRegisteredRESTEasyServlet(alias);
    if (servlet == null) {
        throw new IllegalArgumentException("No servlet is registered for the alias '" + alias + "'");
    }

    Registry registry = servlet.getDispatcher().getRegistry();
    for (Class<?> clazz : resourceClasses) {
        registry.removeRegistrations(clazz);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:17,代码来源:OsgiRESTEasyServletRegistry.java

示例12: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
	logger.entry();
	servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);
    
    if(injector == null)
    	injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());
    
    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                logger.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
            	logger.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例13: init

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
@Override
public void init(FilterConfig config) throws ServletException {

	config.getServletContext().setInitParameter("resteasy.servlet.mapping.prefix", "/api");
	config.getServletContext().setInitParameter("javax.ws.rs.Application", RestApplication.class.getName());
	config.getServletContext().setInitParameter("resteasy.logger.type", "SLF4J");
	
	super.init(config);

	Registry registry = getDispatcher().getRegistry();
	ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

	ModuleProcessor processor = new ModuleProcessor(registry, providerFactory);

	Injector injector = parentInjector.createChildInjector(getModule());

	processor.processInjector(injector);

	while (injector.getParent() != null) {
		injector = injector.getParent();
		processor.processInjector(injector);
	}      

}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:25,代码来源:GuiceFilterDispatcher.java

示例14: JaxRSResources

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
JaxRSResources(BundleContext context, Registry registry) {
    this.context = context;
    this.registry = registry;
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:5,代码来源:JaxRSResources.java

示例15: publish

import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public synchronized Endpoint publish(ServiceDomain domain, String context, List<Object> instances, Map<String, String> contextParams) throws Exception {
    Host host = ServerUtil.getDefaultHost().getHost();
    StandardContext serverContext = (StandardContext) host.findChild("/" + context);
    if (serverContext == null) {
        serverContext = new StandardContext();
        serverContext.setPath("/" + context);
        File docBase = new File(SERVER_TEMP_DIR, context);
        if (!docBase.exists()) {
            if (!docBase.mkdirs()) {
                throw ExtensionMessages.MESSAGES.unableToCreateTempDirectory(docBase.getPath());
            }
        }
        serverContext.setDocBase(docBase.getPath());
        serverContext.addLifecycleListener(new ContextConfig());

        final Loader loader = new WebCtxLoader(instances.get(0).getClass().getClassLoader());
        loader.setContainer(host);
        serverContext.setLoader(loader);
        serverContext.setInstanceManager(new LocalInstanceManager());

        Wrapper wrapper = serverContext.createWrapper();
        wrapper.setName(SERVLET_NAME);
        wrapper.setServletClass(SERVLET_CLASS);
        wrapper.setLoadOnStartup(1);
        serverContext.addChild(wrapper);
        serverContext.addServletMapping("/*", SERVLET_NAME);
        serverContext.addApplicationListener(LISTENER_CLASS);

        if (contextParams != null) {
            for (Map.Entry<String, String> cp : contextParams.entrySet()) {
                serverContext.addParameter(cp.getKey(), cp.getValue());
            }
        }

        host.addChild(serverContext);
        serverContext.create();
        serverContext.start();
        LOG.info("Published RESTEasy context " + serverContext.getPath());
    }
    while (serverContext.isStarting()) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException ie) {
            // Ignore
            if (LOG.isDebugEnabled()) {
                LOG.debug("Spent sometime to start context.");
            }
        }
    }
    if (serverContext.isStarted()) {
        Registry registry = (Registry)serverContext.getServletContext().getAttribute(Registry.class.getName());
        List<Class<?>> classes = new ArrayList<Class<?>>();
        // Add as singleton instance
        for (Object instance : instances) {
            registry.addSingletonResource(instance);
            classes.add(instance.getClass());
        }
        RESTEasyResource resource = new RESTEasyResource();
        resource.setClasses(classes);
        resource.setContext(serverContext);
        return resource;
    } else {
        throw ExtensionMessages.MESSAGES.unableToStartContext(context, new RuntimeException("Context not yet started"));
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:69,代码来源:RESTEasyResourcePublisher.java


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