Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CustomerService.class);
sf.setResourceProvider(CustomerService.class, new SingletonResourceProvider(new CustomerService()));
sf.setAddress("http://localhost:9000/");
BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
JAXRSBindingFactory factory = new JAXRSBindingFactory();
factory.setBus(sf.getBus());
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
sf.create();

Blueprint Web

This section describes how CXF JAX-RS endpoints can be bootstrapped with CXFBlueprintServlet and Blueprint contexts.

This approach is recommended for developers building CXF JAX-RS endpoints to be deployed in OSGI and which will do RequestDispatcher-based forrwards.

Additionally it allows to reuse the same Blueprint contexts between OSGI and non-OSGI deployments.

Both options below work with CXF 3.1.3:

Code Block
xml
xml
<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-rt-frontend-jaxrs</artifactId>
  <version>3.1.3</version>
</dependency>

 

Maven dependencies

OSGI

Code Block
xml
xml
<dependency>
  <groupId>org.apache.aries.blueprint</groupId>
  <artifactId>org.apache.aries.blueprint.webosgi</artifactId>
  <version>1.0.1</version>
</dependency>

In OSGI (Karaf) one should also install a 'war' feature.

Servlet Container

Code Block
xml
xml
<dependency>
  <groupId>org.apache.aries.blueprint</groupId>
  <artifactId>org.apache.aries.blueprint.web</artifactId>
  <version>1.1.1</version>
</dependency>

 

Common example

 

This web.xml shows how to setup CXFBlueprintServlet which process this Blueprint context. It works exactly the same way in OSGI and non-OSGI environments.

Configuring JAX-RS services in container with Spring configuration file.

...