Package org.apache.cxf.jaxrs
Class JAXRSServerFactoryBean
java.lang.Object
org.apache.cxf.interceptor.AbstractBasicInterceptorProvider
org.apache.cxf.endpoint.AbstractEndpointFactory
org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
org.apache.cxf.jaxrs.JAXRSServerFactoryBean
- All Implemented Interfaces:
org.apache.cxf.interceptor.InterceptorProvider
- Direct Known Subclasses:
JAXRSServerFactoryBeanDefinitionParser.SpringJAXRSServerFactoryBean
Bean to help easily create Server endpoints for JAX-RS. Example:
JAXRSServerFactoryBean sf = JAXRSServerFactoryBean(); sf.setResourceClasses(Book.class); sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID); sf.setAddress("http://localhost:9080/"); Server myServer = sf.create();This will start a server for you and register it with the ServerManager. Note you should explicitly close the
Server
created
when finished with it:
myServer.close(); myServer.destroy(); // closes first if close() not previously called
-
Field Summary
FieldsFields inherited from class org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
entityProviders, schemaLocations, serviceFactory
Fields inherited from class org.apache.cxf.endpoint.AbstractEndpointFactory
address, bindingConfig, bindingFactory, bindingId, bus, conduitSelector, dataBinding, destinationFactory, endpointName, endpointReference, features, properties, publishedEndpointUrl, serviceName, transportId
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyBusFeatures
(org.apache.cxf.Bus bus) protected void
org.apache.cxf.endpoint.Server
create()
Creates the JAX-RS Server instanceprotected org.apache.cxf.service.invoker.Invoker
Get the reference to the document (WADL, etc) describing the endpointorg.apache.cxf.endpoint.Server
void
init()
Creates the JAX-RS Server instanceprotected void
injectContexts
(ServerProviderFactory factory, ApplicationInfo fallback) void
setApplication
(jakarta.ws.rs.core.Application app) Saves the reference to the JAX-RSApplication
void
setApplicationInfo
(ApplicationInfo provider) protected void
setBeanInfo
(ServerProviderFactory factory) protected void
void
setDocLocation
(String docLocation) Set the reference to the document (WADL, etc) describing the endpointvoid
setExtensionMappings
(Map<Object, Object> extMaps) Sets the extension mappings, example, 'xml' is the key and 'text/xml' is the value.void
setInvoker
(org.apache.cxf.service.invoker.Invoker invoker) Sets the custom Invoker which can be used to customize the way the default JAX-RS invoker calls on the service beanvoid
setLanguageMappings
(Map<Object, Object> lMaps) Sets the language mappings, example, 'en' is the key and 'en-gb' is the value.void
setResourceClasses
(Class<?>... classes) Sets one or more root resource classesvoid
setResourceClasses
(List<Class<?>> classes) Sets one or more root resource classesvoid
Resource comparator which may be used to customize the way a root resource or resource method is selectedvoid
setResourceProvider
(Class<?> c, ResourceProvider rp) Sets the provider managing the life-cycle of the given resource classvoid
Sets the provider managing the life-cycle of the resource classvoid
Sets the list of providers managing the life-cycle of the resource classesvoid
setServiceBean
(Object bean) Sets the single resource bean.void
setServiceBeanObjects
(Object... beans) Sets the resource beans.void
setServiceBeans
(List<Object> beans) Sets the resource beans.void
setServiceClass
(Class<?> clazz) This method is used primarily by Spring handler processing the jaxrs:server/@serviceClass attribute.void
setStart
(boolean start) Determines whether Services are automatically started during the create() call.void
setStaticSubresourceResolution
(boolean enableStatic) By default the subresources are resolved dynamically, mainly due to the JAX-RS specification allowing Objects being returned from the subresource locators.protected ServerProviderFactory
setupFactory
(org.apache.cxf.endpoint.Endpoint ep) protected void
updateClassResourceProviders
(org.apache.cxf.endpoint.Endpoint ep) Methods inherited from class org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
checkResources, createBindingInfo, createEndpoint, createEndpointInfo, getBus, getProviders, getServiceFactory, isValidClassResourceInfo, setBus, setDataBindingProvider, setModelBeans, setModelBeans, setModelBeansWithServiceClass, setModelRef, setModelRefWithServiceClass, setProvider, setProviderComparator, setProviders, setSchemaLocation, setSchemaLocations, setServiceFactory, setServiceName, setupFactory
Methods inherited from class org.apache.cxf.endpoint.AbstractEndpointFactory
addToBeans, checkPrivateEndpoint, getAddress, getBindingConfig, getBindingFactory, getBindingId, getBus, getConduitSelector, getDataBinding, getDestinationFactory, getEndpointName, getFeatures, getProperties, getProperties, getPublishedEndpointUrl, getServiceName, getTransportId, initializeAnnotationInterceptors, initializeAnnotationInterceptors, initializeAnnotationInterceptors, setAddress, setBindingConfig, setBindingFactory, setBindingId, setConduitSelector, setDataBinding, setDestinationFactory, setEndpointName, setEndpointReference, setFeatures, setProperties, setPublishedEndpointUrl, setTransportId
Methods inherited from class org.apache.cxf.interceptor.AbstractBasicInterceptorProvider
getInFaultInterceptors, getInInterceptors, getOutFaultInterceptors, getOutInterceptors, setInFaultInterceptors, setInInterceptors, setOutFaultInterceptors, setOutInterceptors
-
Field Details
-
resourceProviders
-
-
Constructor Details
-
JAXRSServerFactoryBean
public JAXRSServerFactoryBean() -
JAXRSServerFactoryBean
-
-
Method Details
-
setApplication
public void setApplication(jakarta.ws.rs.core.Application app) Saves the reference to the JAX-RSApplication
- Parameters:
app
-
-
setApplicationInfo
-
setResourceComparator
Resource comparator which may be used to customize the way a root resource or resource method is selected- Parameters:
rcomp
- comparator
-
setStaticSubresourceResolution
public void setStaticSubresourceResolution(boolean enableStatic) By default the subresources are resolved dynamically, mainly due to the JAX-RS specification allowing Objects being returned from the subresource locators. Setting this property to true enables the runtime to do the early resolution.- Parameters:
enableStatic
- enabling the static resolution if set to true
-
init
public void init()Creates the JAX-RS Server instance -
create
public org.apache.cxf.endpoint.Server create()Creates the JAX-RS Server instance- Returns:
- the server
-
getServer
public org.apache.cxf.endpoint.Server getServer() -
setupFactory
-
setBeanInfo
-
applyBusFeatures
protected void applyBusFeatures(org.apache.cxf.Bus bus) -
applyFeatures
protected void applyFeatures() -
createInvoker
protected org.apache.cxf.service.invoker.Invoker createInvoker() -
setLanguageMappings
Sets the language mappings, example, 'en' is the key and 'en-gb' is the value.- Parameters:
lMaps
- the language mappings
-
setExtensionMappings
Sets the extension mappings, example, 'xml' is the key and 'text/xml' is the value.- Parameters:
extMaps
- the extension mappings
-
getResourceClasses
-
setServiceClass
This method is used primarily by Spring handler processing the jaxrs:server/@serviceClass attribute. It delegates to setResourceClasses method accepting the array of Class parameters.- Parameters:
clazz
- the service/resource class
-
setResourceClasses
Sets one or more root resource classes- Parameters:
classes
- the list of resource classes
-
setResourceClasses
Sets one or more root resource classes- Parameters:
classes
- the array of resource classes
-
setServiceBeanObjects
Sets the resource beans. If this is set then the JAX-RS runtime will not be responsible for the life-cycle of resource classes.- Parameters:
beans
- the array of resource instances
-
setServiceBean
Sets the single resource bean. If this is set then the JAX-RS runtime will not be responsible for the life-cycle of resource classes. Please avoid setting the resource class of this bean explicitly, the runtime will determine it itself.- Parameters:
bean
- resource instance
-
setServiceBeans
Sets the resource beans. If this is set then the JAX-RS runtime will not be responsible for the life-cycle of resource classes.- Parameters:
beans
- the list of resource instances
-
setResourceProvider
Sets the provider managing the life-cycle of the given resource classExample: setResourceProvider(BookStoreInterface.class, new SingletonResourceProvider(new BookStore()));
- Parameters:
c
- resource classrp
- resource provider
-
setResourceProvider
Sets the provider managing the life-cycle of the resource classExample: setResourceProvider(new SingletonResourceProvider(new BookStore()));
- Parameters:
rp
- resource provider
-
setResourceProviders
Sets the list of providers managing the life-cycle of the resource classes- Parameters:
rps
- resource providers
-
setInvoker
public void setInvoker(org.apache.cxf.service.invoker.Invoker invoker) Sets the custom Invoker which can be used to customize the way the default JAX-RS invoker calls on the service bean- Parameters:
invoker
-
-
setStart
public void setStart(boolean start) Determines whether Services are automatically started during the create() call. Default is true. If false will need to call start() method on Server to activate it.- Parameters:
start
- Whether (true) or not (false) to start the Server during Server creation.
-
injectContexts
-
updateClassResourceProviders
protected void updateClassResourceProviders(org.apache.cxf.endpoint.Endpoint ep) -
setDefaultResourceProvider
-
setDocLocation
Set the reference to the document (WADL, etc) describing the endpoint- Parameters:
docLocation
- document location
-
getDocLocation
Get the reference to the document (WADL, etc) describing the endpoint- Returns:
- document location
-