Versions Compared

Key

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

...

Apache Wink provides the "SimpleSymphonyApplication" class in order to support the loading of resources and providers through a simple text file that contains a list of fully qualified class names of the resource and provider classes. Each line contains a single fully qualified class name that is either a resource or a provider. Empty lines and lines that begin with a number sign (#) are permitted and ignored.

Code Block
xml
xml

# Providers
com.example.MyXmlProvider
com.example.MyJSONProvider

# Resources
com.example.FooResource
com.example.BarResource

Specifying the Simple Application File Location

The path to a simple application file is configured via the symphony.applicationConfigLocation init-param in the web.xml file. It is possible to specify multiple files by separating them with a semicolon.

Code Block
xml
xml

<servlet>
  <servlet-name>restSdkService</servlet-name>
  <servlet-class>
    com.hp.symphony.server.internal.servlet.RestServlet
  </servlet-class>
  <init-param>
    <param-name>symphony.applicationConfigLocation</param-name>
    <param-value>/WEB-INF/providers;/WEB-INF/resources</param-value>
  </init-param>
</servlet

Apache Wink Application

Apache Wink extends the javax.ws.rs.core.Application class with the com.hp.symphony.common.SymphonyApplication class in order to provide the Dynamic Resources and the Priorities functionality.

Info
titleReference

Refer to sections ‎TBD and ‎TBD for more information on Dynamic Resources and Priorities.

An application may provide an instance of the Apache Wink Application to the Apache Wink runtime as specified by the JAX-RS specification.

Dynamic Resources

Dynamic Resources enable the binding of a Resource class to a URI path during runtime instead of by using the @Path annotation. A dynamic resource must implement the DynamicResource interface and must not be annotated with the @Path annotation.

Motivation

A Dynamic Resource is useful for situations where a resource class must be bound to multiple paths, for example, a sorting resource:

Code Block
xml
xml

public class SortingResource<E extends Comparable<? super E>> {
    private List<E> list;
    @POST
    public void sort() {
        Collections.sort(list);
    }
    public void setList(List<E> list) {
        this.list = list;
    }
    public List<E> getList() {
        return list;
    }
}
Explanation

In this example, the SortingResource class can sort any list. If the application manages a library of books and exposes the following resource paths, then the SortingResource class can be used for the implementation of all these resource paths, assuming that it could be bound to more than one path.

Code Block
xml
xml

/sort-books
/sort-authors
/sort-titles

A dynamic resource is also useful for situations where the resource path is unknown during development, and is only known during the application startup.

Usage

A Dynamic Resource is a resource class that implements the com.hp.symphony.server.DynamicResource interface or extends the com.hp.symphony.server.AbstractDynamicResource convenience class.
A Dynamic Resource is not registered in Apache Wink through the Application#getClasses() method or the Application#getSignletons() method, since the same class can be used for multiple resources.
In order to register Dynamic Resources in the system, the SymphonyApplication#getInstances()method must be used.

Info
titleReference

Refer to section TBD for more information about Registration.