在插件中使用BeanPersistAdapter [英] Use of BeanPersistAdapter in a Plugin

查看:94
本文介绍了在插件中使用BeanPersistAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在Play中使用Ebean进行前/后插入/更新/删除操作(isRegisterFor(Class<?> clazz)postInsert(BeanPersistRequest<?> request),...),我实现了一个类IndexAdapter extends BeanPersistAdapter.

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.

工程

- app

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

-- controllers
--- ...

一切顺利,直到我决定将它(实际上是一个类以上)转换为Play插件.

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

不起作用

- app

-- plugin
--- IndexAdapter

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

-- controllers
--- ...

我从一位同事那里了解到,从BeanPersistAdapter派生的类只有将其放置在models目录中,才会进行插入/更新/删除操作.那么,有没有办法告诉适配器模型在哪里(应该干预哪些插入/更新/删除操作)?

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?

推荐答案

如果需要,可以将类放在模块项目中(

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

我在我的项目中做到了这一点.我有一个主要项目,有两个模块: -通用模块(我的BeanPersistAdapter所在的模块) -模型模块(我所有的模型类都在其中),这取决于公共模块 主要项目取决于模型模块.

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.

这样做,您将拥有所需的东西,但是在模块中,而不是在主项目的app文件夹中.

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

这篇关于在插件中使用BeanPersistAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆