Class SpringBeanProcessor
java.lang.Object
org.jboss.resteasy.plugins.spring.SpringBeanProcessor
- All Implemented Interfaces:
EventListener,org.springframework.beans.factory.config.BeanFactoryPostProcessor,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>,org.springframework.context.event.SmartApplicationListener,org.springframework.core.Ordered
- Direct Known Subclasses:
SpringBeanProcessorServletAware
public class SpringBeanProcessor
extends Object
implements org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.context.event.SmartApplicationListener
The processor will register any bean annotated with @Path or @Provider into the Resteasy framework.
It also sets up Registry and ResteasyProviderFactory to be autowirable via @Autowire in Controllers/service layers.
There's quite a bit of spring integration functionality under the covers:
- @Providers, such as RESTEasy interceptors and String converters have to be registered in RESTEasy before resources and registers. That gets a bit tricky, so depends-on functionality is used as well
- Version:
- $Revision: 1 $
- Author:
- Solomon Duskis, Bill Burke
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jboss.resteasy.spi.ResteasyDeploymentprotected org.jboss.resteasy.spi.Dispatcherprotected org.jboss.resteasy.spi.ResteasyProviderFactoryprotected org.jboss.resteasy.spi.Registryprotected Map<String,SpringResourceFactory> Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionSpringBeanProcessor(org.jboss.resteasy.spi.Dispatcher dispatcher) SpringBeanProcessor(org.jboss.resteasy.spi.Dispatcher dispatcher, org.jboss.resteasy.spi.Registry registry, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) SpringBeanProcessor(org.jboss.resteasy.spi.ResteasyDeployment deployment) -
Method Summary
Modifier and TypeMethodDescriptionorg.jboss.resteasy.spi.DispatcherintgetOrder()getPropertyValue(org.springframework.beans.MutablePropertyValues registrationPropertyValues, String propertyName) org.jboss.resteasy.spi.ResteasyProviderFactoryorg.jboss.resteasy.spi.RegistryvoidonApplicationEvent(org.springframework.context.ApplicationEvent event) Register all of the resources into RESTEasy only when Spring finishes it's life-cycle and the spring singleton bean creation is completed.voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) This method keeps track of @Provider and resources for future use.protected Class<?>processBean(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, List<String> dependsOnProviders, String name, org.springframework.beans.factory.config.BeanDefinition beanDef) Process a single @Provider or a single resource.voidsetDispatcher(org.jboss.resteasy.spi.Dispatcher dispatcher) voidsetOrder(int order) voidsetProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) voidsetRegistry(org.jboss.resteasy.spi.Registry registry) booleansupportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType) booleansupportsSourceType(Class<?> sourceType) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.event.SmartApplicationListener
getListenerId
-
Field Details
-
registry
protected org.jboss.resteasy.spi.Registry registry -
providerFactory
protected org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory -
dispatcher
protected org.jboss.resteasy.spi.Dispatcher dispatcher -
deployment
protected org.jboss.resteasy.spi.ResteasyDeployment deployment -
resourceFactoryNames
-
resourceFactories
-
providerNames
-
-
Constructor Details
-
SpringBeanProcessor
public SpringBeanProcessor(org.jboss.resteasy.spi.ResteasyDeployment deployment) -
SpringBeanProcessor
public SpringBeanProcessor(org.jboss.resteasy.spi.Dispatcher dispatcher) -
SpringBeanProcessor
public SpringBeanProcessor(org.jboss.resteasy.spi.Dispatcher dispatcher, org.jboss.resteasy.spi.Registry registry, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) -
SpringBeanProcessor
public SpringBeanProcessor()
-
-
Method Details
-
getRegistry
@Autowired public org.jboss.resteasy.spi.Registry getRegistry() -
setRegistry
public void setRegistry(org.jboss.resteasy.spi.Registry registry) -
getProviderFactory
public org.jboss.resteasy.spi.ResteasyProviderFactory getProviderFactory() -
setProviderFactory
public void setProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) -
getDispatcher
public org.jboss.resteasy.spi.Dispatcher getDispatcher() -
setDispatcher
public void setDispatcher(org.jboss.resteasy.spi.Dispatcher dispatcher) -
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException This method keeps track of @Provider and resources for future use. It also registers the RESTEasy Registry, ProviderFactry, and Dispatcher for @Autowire injection.
Beyond tracking, this will ensure that non-MessageBody(Reader|Writer) @Providers are created by Spring before any resources by having the resources "depends-on" the @Providers.
- Specified by:
postProcessBeanFactoryin interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor- Parameters:
beanFactory- bean factory- Throws:
org.springframework.beans.BeansException
-
processBean
protected Class<?> processBean(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, List<String> dependsOnProviders, String name, org.springframework.beans.factory.config.BeanDefinition beanDef) Process a single @Provider or a single resource.- Parameters:
beanFactory- bean factorydependsOnProviders- dependent providers listname- bean namebeanDef- bean definition- Returns:
- bean class
-
getPropertyValue
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event) Register all of the resources into RESTEasy only when Spring finishes it's life-cycle and the spring singleton bean creation is completed.- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>- Parameters:
event- application event
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Specified by:
getOrderin interfaceorg.springframework.context.event.SmartApplicationListener
-
setOrder
public void setOrder(int order) -
supportsEventType
public boolean supportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType) - Specified by:
supportsEventTypein interfaceorg.springframework.context.event.SmartApplicationListener
-
supportsSourceType
- Specified by:
supportsSourceTypein interfaceorg.springframework.context.event.SmartApplicationListener
-