Added the ability to control the exporting of Repositories, query methods or entity fields by adding "exported = true|false" to the @RestResource annotation.
This commit is contained in:
@@ -98,3 +98,34 @@ This would result in a link value of:
|
||||
} ]
|
||||
}
|
||||
|
||||
### Hiding certain Repositories, query methods, or fields
|
||||
|
||||
You may not want a certain Repository, a query method on a Repository, or a field of your entity to be exported at all. To tell the exporter to not export your these items, annotate them with `@RestResource` and set `exported = false`.
|
||||
|
||||
For example, to skip exporting a Repository:
|
||||
|
||||
@RestResource(exported = false)
|
||||
public interface PersonRepository extends CrudRepository<Person, Long> {
|
||||
}
|
||||
|
||||
To skip exporting a query method:
|
||||
|
||||
@RestResource(path = "people", rel = "people")
|
||||
public interface PersonRepository extends CrudRepository<Person, Long> {
|
||||
|
||||
@RestResource(exported = false)
|
||||
public List<Person> findByName(String name);
|
||||
|
||||
}
|
||||
|
||||
Or to skip exporting a field:
|
||||
|
||||
@Entity
|
||||
@RestResource(exported = false)
|
||||
public class Person {
|
||||
@Id @GeneratedValue private Long id;
|
||||
@OneToMany
|
||||
@RestResource(exported = false)
|
||||
private Map<String, Profile> profiles;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ If you have a JPA entity in your domain model that looks like...
|
||||
|
||||
...your PersonRepository will by default be declared in the ApplicationContext with a bean name of "personRepository". The web exporter will strip the word "Repository" from it and expose a resource named "person". The resulting URL of this repository (assuming the exporter webapp is deployed at context path `/data` in your servlet container) will be `http://localhost:8080/data/person`.
|
||||
|
||||
You can configure under what path, or whether a resource is exported at all, by using the `@RestResource` annotation. Details are here: [Configuring the REST URL path](../wiki/Configuring-the-REST-URL-path)
|
||||
|
||||
### Discoverability
|
||||
|
||||
The Web Exporter implements some aspects of the [HATEOS](http://en.wikipedia.org/wiki/HATEOAS) methodology. That means all the services of the web exporter are discoverable and exposed to the client using links.
|
||||
|
||||
Reference in New Issue
Block a user