Download Jersey 2.10 User Guide

Transcript
Entity Data Filtering
Example 18.2. Registering and configuring entity-filtering feature with security
annotations on server.
1 new ResourceConfig()
2
// Set entity-filtering scope via configuration.
3
.property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, new Annotation[] {
4
// Register the SecurityEntityFilteringFeature.
5
.register(SecurityEntityFilteringFeature.class)
6
// Further configuration of ResourceConfig.
7
.register( ... );
Example 18.3. Registering and configuring entity-filtering feature based on
dynamic and configurable query parameters.
1 new ResourceConfig()
2
// Set query parameter name for dynamic filtering
3
.property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select")
4
// Register the SelectableEntityFilteringFeature.
5
.register(SelectableEntityFilteringFeature.class)
6
// Further configuration of ResourceConfig.
7
.register( ... );
Use similar steps to register entity-filtering on client:
Example 18.4. Registering and configuring entity-filtering feature on client.
1
2
3
4
5
6
7
8
9
10
11
12
final ClientConfig config = new ClientConfig()
// Set entity-filtering scope via configuration.
.property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, new Annotation[] {
// Register the EntityFilteringFeature.
.register(EntityFilteringFeature.class)
// Further configuration of ClientConfig.
.register( ... );
// Create new client.
final Client client = ClientClientBuilder.newClient(config);
// Use the client.
18.2. Components used to describe Entity
Filtering concepts
In the next section the entity-filtering features will be illustrated on a project-tracking application that
contains three classes in it's domain model and few resources (only Project resource will be shown
in this chapter). The full source code for the example application can be found in Jersey Entity Filtering
example [https://github.com/jersey/jersey/tree/2.10/examples/entity-filtering].
Suppose there are three domain model classes (or entities) in our model: Project, User and Task
(getters/setter are omitted for brevity).
214