Use of BeanPersistAdapter in a Plugin

ぐ巨炮叔叔 提交于 2019-12-23 05:47:11

问题


In order to perform pre/post insert/update/delete actions (isRegisterFor(Class<?> clazz), postInsert(BeanPersistRequest<?> request), ... ) with Ebean in Play, I implemented a class IndexAdapter extends BeanPersistAdapter.

Works

- app

-- models
--- Car
--- Person
--- House
--- IndexAdapter

-- controllers
--- ...

Everything went well until I decided to transform it (it's more than one class actually) into a Play plugin.

Doesn't work

- app

-- plugin
--- IndexAdapter

-- models
--- Car
--- Person
--- House

-- controllers
--- ...

From a colleague I learned that the class derived from BeanPersistAdapter will only intervene into the insert/update/delete actions if it's placed inside the models directory. So is there any way of telling the Adapter where the models (on which insert/update/delete actions it should intervene) are located?


回答1:


If you want, you can put the class in a module project (http://www.playframework.com/documentation/2.1.x/SBTSubProjects)

I did this on my project. I have the main project, with two modules: - the common module (where my BeanPersistAdapter is) - the models module (where all my model classes are), which depends on the common module The main project depends on the models module.

Doing this, you will have the same thing you want, but in modules, not in the app folder of the main project.



来源:https://stackoverflow.com/questions/20371960/use-of-beanpersistadapter-in-a-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!