Java Reference
In-Depth Information
Per-JAX-RS Method Bindings
On the server side, you can apply a filter or interceptor on a per-JAX-RS-method basis. This
allows you to do some really cool things like adding annotation extensions to your JAX-RS
container. There are two ways to accomplish this. One is by registering an implementation of
the DynamicFeature interface. The other is through annotation binding. Let's look at Dynam-
icFeature first.
DynamicFeature
package
package javax . ws . rs . container ;
public
public interface
interface DynamicFeature
DynamicFeature {
public
public void
void configure ( ResourceInfo resourceInfo , FeatureContext context );
}
public
public interface
interface ResourceInfo
ResourceInfo {
/**
* Get the resource method that is the target of a request,
* or <code>null</code> if this information is not available.
*
* @return resource method instance or null
* @see #getResourceClass()
*/
Method getResourceMethod ();
/**
* Get the resource class that is the target of a request,
* or <code>null</code> if this information is not available.
*
* @return resource class instance or null
* @see #getResourceMethod()
*/
Class <?> getResourceClass ();
}
The DynamicFeature interface has one callback method, configure() . This configure()
method is invoked for each and every deployed JAX-RS method. The ResourceInfo para-
meter contains information about the current JAX-RS method being deployed. The
FeatureContext is an extension of the Configurable interface. You'll use the register()
methods of this parameter to bind the filters and interceptors you want to assign to this meth-
od.
Search WWH ::




Custom Search