リポジトリ用
ThxをはRepositoriesクラスを使用して、スプリングデータ休止で解決されています。
repositoriesクラスは、与えられたクラスのリポジトリを見つけるヘルパーメソッド(getRepositoryFor(Class<?>)
)を公開します。
あなたのインターセプタで指定されたクラスのリポジトリを見つけるための次のスニペットを使用することができます。
Repositories repositories = new Repositories(appContext);
repositories.getRepositoryFor(entityObject.getClass());
よりエレガントなソリューションが内蔵されたバネのデータレストリポジトリのルックアップを利用することであろうカスタムコントローラー(RootResourceInformationHandlerMethodArgumentResolver)を使用した実装
このためには、RepositoryRestControllerエンドポイントメソッドにRootResourceInformation
パラメーターを追加するだけです。
@RepositoryRestController
@RequestMapping("/customName")
public class RepositoryExportController {
@Autowired
private ApplicationContext appContext;
@RequestMapping(method = RequestMethod.GET, value = "{repository}",
produces = MediaTypes.HAL_JSON_VALUE)
@ResponseBody
public Resources<Resource<?>> export(RootResourceInformation resourceInformation, ...) {
Repositories repositories = new Repositories(appContext);
CrudRepository repo=(CrudRepository)repositories.getRepositoryFor(resourceInformation.getDomainType());
repo.findAll();
...other logic....
}
これにより、私はspring-security-aclのための適切なコントローラメソッドをサブリソースとして実装することができました。 – mbonato