Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The cxf-rt-frontend-jaxrs dependency is the main Apache CXF dependency for JAX-RS:

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

The httpclient dependency is used in a class called BackwardsCompatibilityInterceptor, where it is used to parse query parameters from request URLs:

Code Block
xml
xml
borderStylesolidxml
<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.2.5</version>
</dependency>

The Tika dependency is used to detect the MIME types of files:

Code Block
xml
xml
borderStylesolidxml
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-core</artifactId>
      <version>0.8</version>
    </dependency>

The zip4j dependency is used for creating zip archives:

Code Block
xml
xml
borderStylesolidxml
    <dependency>
      <groupId>net.lingala.zip4j</groupId>
      <artifactId>zip4j</artifactId>
      <version>1.3.1</version>
    </dependency>

The jettison dependency is used to marshal JAXB resources to JSON format:

Code Block
xml
xml
borderStylesolidxml
    <dependency>
      <groupId>org.codehaus.jettison</groupId>
      <artifactId>jettison</artifactId>
      <version>1.3.4</version>
    </dependency>

The cxf-rt-rs-extenion-providers dependency is used to automatically map file extensions that are included in the URL (such as .xml, .json, .rss) to content types such as application/xml, application/json and application/rss:

Code Block
xml
xml
borderStylesolidxml
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-extension-providers</artifactId>
      <version>2.6.8</version>
    </dependency>

The cxf-rt-transports-local, easymock, junit and xmlunit are useful for unit testing. For example, cxf-rt-transports-local provides a local transport protocol to send HTTP requests to a JAX-RS service class within unit tests:

Code Block
xml
xml
borderStylesolidxml
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-local</artifactId>
      <version>2.6.8</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
      <version>3.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>xmlunit</groupId>
      <artifactId>xmlunit</artifactId>
      <version>1.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

...

The web.xml file, located in the src/main/webapp/WEB-INF directory, is used to configure all of the servlets in the web application. The JAX-RS package only uses one servlet and it is configured as shown below.

Code Block
xml
xml
borderStylesolidxml
<?xml version="1.0" encoding="UTF-8"?>
<web-app ...>
  ...
  <servlet>
    <servlet-name>CasProductJaxrsServlet</servlet-name>
    <servlet-class>
       org.apache.oodt.cas.product.jaxrs.servlets.CasProductJaxrsServlet
    </servlet-class>
    <init-param>
      <param-name>jaxrs.serviceClasses</param-name>
      <param-value>
        org.apache.oodt.cas.product.jaxrs.services.CasProductJaxrsService
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.providers</param-name>
      <param-value>
        org.apache.cxf.jaxrs.provider.json.JSONProvider,
        org.apache.oodt.cas.product.jaxrs.writers.ReferenceFileWriter,
        org.apache.oodt.cas.product.jaxrs.writers.ReferenceZipWriter,
        org.apache.oodt.cas.product.jaxrs.writers.ReferenceRssWriter,
        org.apache.oodt.cas.product.jaxrs.writers.ProductZipWriter,
        org.apache.oodt.cas.product.jaxrs.writers.ProductRssWriter,
        org.apache.oodt.cas.product.jaxrs.writers.DatasetZipWriter,
        org.apache.oodt.cas.product.jaxrs.writers.DatasetRdfWriter,
        org.apache.oodt.cas.product.jaxrs.writers.DatasetRssWriter,
        org.apache.oodt.cas.product.jaxrs.writers.TransfersRssWriter
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.inInterceptors</param-name>
      <param-value>
        org.apache.oodt.cas.product.jaxrs.filters.BackwardsCompatibleInterceptor
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.scope</param-name>
      <param-value>prototype</param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.extensions</param-name>
      <param-value>
        file=application/octet-stream
        json=application/json
        rdf=application/rdf+xml
        rss=application/rss+xml
        xml=application/xml
        zip=application/zip
      </param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>CasProductJaxrsServlet</servlet-name>
    <url-pattern>/jaxrs/*</url-pattern>
  </servlet-mapping>
</web-app>

...