...
The path to a simple application file is configured via the wink. applicationConfigLocation init-param in the web.xml file. It is possible to specify multiple files by separating them with a semicolon.
Code Block | ||||
---|---|---|---|---|
| ||||
<servlet> <servlet-name>restSdkService</servlet-name> <servlet-class> comorg.hpapache.wink.server.internal.servlet.RestServlet </servlet-class> <init-param> <param-name>wink.applicationConfigLocation<name>applicationConfigLocation</param-name> <param-value>/WEB-INF/providers;/WEB-INF/resources</param-value> </init-param> </servletservlet> |
Apache Wink Application
Apache Wink extends the javax.ws.rs.core.Application class with the comorg.hpapache.symphonywink.common.SymphonyApplication WinkApplication class in order to provide the Dynamic Resources and the Priorities functionality.
...
title | Reference |
---|
...
.
An application may provide an instance of the Apache Wink Application to the Apache Wink runtime as specified by the JAX-RS specification.
...
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 the following 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.
...
A Dynamic Resource is a resource class that implements the comorg.hpapache.symphonywink.server.DynamicResource interface or extends the comorg.hpapache.symphonywink.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#getInstancesWinkApplication#getInstances()method must be used.
...
title | Reference |
---|
...
.
Scope
The scope of a Dynamic Resource is limited to "singleton" as it is initialized prior to its registration, and the system does not have enough information to create it in runtime. This limitation is irrelevant when working with Spring. Refer to chapter 0 for more information on Spring integration.
...
Property Name | Description | Default Value | Reference |
---|---|---|---|
wink.http.uri | URI that is used by the Link Builders in case of HTTP | Use the URI from the request | |
wink.https.uri | URI used by the Link Builders in case of HTTPS | Use the URI from the request | Chapter TBD |
wink.context.uri | Context path used by the Link Builders | Use the context path from the request | |
wink.defaultUrisRelative | Indicates if URIs generated by the Link Builders are absolute or relative, valid values: true or false | true - links are relative | |
wink.addAltParam | Indicates if the "alt" query parameter should be added to URIs generated by the Link Builders. Valid values are: true, false | true - add the alt query parameter | Chapter TBD |
wink.searchPolicyContinuedSearch search | Indicates if continues search is enabled. Valid values: true, false | true - continued search is enabled | |
wink.rootResource | ndicates Indicates if a root resource with Service Document generation capabilities should be added. | atom+html --atom and html Service Document generation capabilities | |
wink.serviceDocumentCssPath | Defines path to a css file that is used in the html Service Document generation. Relevant only if html Service Document is defined | No css file defined | |
wink.handlersFactoryClass | Defines a org.apache.wink.server | No user handlers defined | |
wink.mediaType | Defines a org.apache.wink.server.handlers | No media type mappers defined | |
wink.loadApplications | Loads providers defined | True, automatically load all wink-application specified classes Chapter TBD |
Custom Properties File Definition
In order to provide a custom properties file, the application should define the symphony. propertiesLocation init-param in the Apache Wink Servlet definition.
Code Block | ||||
---|---|---|---|---|
| ||||
# Providers <servlet> <servlet-name>restSdkService</servlet-name> <servlet-class> comorg.hpapache.wink.server.internal.servlet.RestServlet </servlet-class> <init-param> <param-name>wink.propertiesLocation<name>propertiesLocation</param-name> <param-value>/WEB-INF/configuration.properties</param-value> </init-param> <init-param> <param-name>winkApplicationConfigLocation</param-name> <param-value>/WEB-INF/application</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> |
...
RegistrationApache Wink provides several APIs for Runtime Registration. The APIs appear in the comorg.hpapache.symphonywink.server.utils.RegistrationUtils class. The most important method is the one that registers an instance of the javax.ws.rs.core.Application class
Code Block | ||||
---|---|---|---|---|
| ||||
# Providers static void registerApplication(Application application, ServletContext servletContext) |
Infonote | ||
---|---|---|
| ||
Registration is ignored and a warning is printed to the log if the instance was previously registered |
...
Apache Wink provides a set of predefined Media-Type mappings for use in such cases by supplying the MediaTypeMapper class. Applications may extend or override the MediaTypeMapper class to define additional mappings.
Predefined Mapping Table
...
User Agent
...
Content Type
...
Map To
...
Mozilla/
...
application/atom+xml text/xml
...
text/xml
...
Mozilla/
...
application/atomsvc+xml text/xml
...
text/xml
...
Mozilla/
...
pplication/opensearchdescription+xml
...
Customizing Mappings
In order to customize these mappings the application should create a instance of a comorg.hpapache.symphonywink.server.internalhandlers.MediaTypeMapper MediaTypeMapperFactory class and set it on the DeploymentConfiguration instancein a customized Wink properties file.
Info | ||
---|---|---|
| ||
Refer to section TBD 5.1 Registration and Configuration for more information on Customizing the Default Deployment Properties Configuration. |
Alternative Shortcuts
...
Info | ||
---|---|---|
| ||
Refer to chapter 0 section 2 Apache Wink Building Blocks for more information about on Customizing the Default Deployment Configuration. |