public class JAXRSServerFactoryBean extends AbstractJAXRSFactoryBean
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
| Modifier and Type | Field and Description |
|---|---|
protected Map<Class<?>,ResourceProvider> |
resourceProviders |
entityProviders, schemaLocations, serviceFactoryaddress, bindingConfig, bindingFactory, bindingId, bus, conduitSelector, dataBinding, destinationFactory, endpointName, endpointReference, features, properties, publishedEndpointUrl, serviceName, transportId| Constructor and Description |
|---|
JAXRSServerFactoryBean() |
JAXRSServerFactoryBean(JAXRSServiceFactoryBean sf) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyFeatures() |
Server |
create()
Creates the JAX-RS Server instance
|
protected Invoker |
createInvoker() |
String |
getDocLocation()
Get the reference to the document (WADL, etc) describing the endpoint
|
List<Class<?>> |
getResourceClasses() |
void |
init()
Creates the JAX-RS Server instance
|
void |
setApplication(javax.ws.rs.core.Application app)
Saves the reference to the JAX-RS
Application |
protected void |
setBeanInfo(ProviderFactory factory) |
void |
setDocLocation(String docLocation)
Set the reference to the document (WADL, etc) describing the endpoint
|
void |
setExtensionMappings(Map<Object,Object> extMaps)
Sets the extension mappings,
example, 'xml' is the key and 'text/xml' is the value.
|
void |
setInvoker(Invoker invoker)
Sets the custom Invoker which can be used to customize the way
the default JAX-RS invoker calls on the service bean
|
void |
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 classes
|
void |
setResourceClasses(List<Class<?>> classes)
Sets one or more root resource classes
|
void |
setResourceComparator(ResourceComparator rcomp)
Resource comparator which may be used to customize the way
a root resource or resource method is selected
|
void |
setResourceProvider(Class<?> c,
ResourceProvider rp)
Sets the provider managing the life-cycle of the given resource class
|
void |
setResourceProvider(ResourceProvider rp)
Sets the provider managing the life-cycle of the resource class
|
void |
setResourceProviders(List<ResourceProvider> rps)
Sets the list of providers managing the life-cycle of the resource classes
|
void |
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.
|
checkResources, createBindingInfo, createEndpoint, createEndpointInfo, getBus, getProviders, getServiceFactory, setBus, setDataBindingProvider, setModelBeans, setModelBeans, setModelBeansWithServiceClass, setModelRef, setModelRefWithServiceClass, setProvider, setProviders, setSchemaLocation, setSchemaLocations, setServiceFactory, setServiceName, setupFactorycheckPrivateEndpoint, getAddress, getBindingConfig, getBindingFactory, getBindingId, 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, setTransportIdgetInFaultInterceptors, getInInterceptors, getOutFaultInterceptors, getOutInterceptors, setInFaultInterceptors, setInInterceptors, setOutFaultInterceptors, setOutInterceptorsprotected Map<Class<?>,ResourceProvider> resourceProviders
public JAXRSServerFactoryBean()
public JAXRSServerFactoryBean(JAXRSServiceFactoryBean sf)
public void setApplication(javax.ws.rs.core.Application app)
Applicationapp - public void setResourceComparator(ResourceComparator rcomp)
rcomp - comparatorpublic void setStaticSubresourceResolution(boolean enableStatic)
enableStatic - enabling the static resolution if set to truepublic void init()
public Server create()
protected void setBeanInfo(ProviderFactory factory)
setBeanInfo in class AbstractJAXRSFactoryBeanprotected void applyFeatures()
protected Invoker createInvoker()
public void setLanguageMappings(Map<Object,Object> lMaps)
lMaps - the language mappingspublic void setExtensionMappings(Map<Object,Object> extMaps)
lMaps - the extension mappingspublic void setServiceClass(Class<?> clazz)
clazz - the service/resource classpublic void setResourceClasses(List<Class<?>> classes)
classes - the list of resource classespublic void setResourceClasses(Class<?>... classes)
classes - the array of resource classespublic void setServiceBeanObjects(Object... beans)
beans - the array of resource instancespublic void setServiceBean(Object bean)
bean - resource instancepublic void setServiceBeans(List<Object> beans)
beans - the list of resource instancespublic void setResourceProvider(Class<?> c, ResourceProvider rp)
Example: setResourceProvider(BookStoreInterface.class, new SingletonResourceProvider(new BookStore()));
c - resource classrp - resource providerpublic void setResourceProvider(ResourceProvider rp)
Example: setResourceProvider(new SingletonResourceProvider(new BookStore()));
rp - resource providerpublic void setResourceProviders(List<ResourceProvider> rps)
rps - resource providerspublic void setInvoker(Invoker invoker)
invoker - public void setStart(boolean start)
start - Whether (true) or not (false) to start the Server during Server creation.public void setDocLocation(String docLocation)
documentLocation - document locationpublic String getDocLocation()
Apache CXF