本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
}
}
示例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());
}
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例14: JaxRSResources
import org.jboss.resteasy.spi.Registry; //导入依赖的package包/类
JaxRSResources(BundleContext context, Registry registry) {
this.context = context;
this.registry = registry;
}
示例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"));
}
}