是否有一个 Maven 插件可以从我的域类生成 RequestFactory EntityProxy 类?
我正在寻找一个 Maven 插件,它将自动从我的域类生成 EntityProxy 接口。
该类可以实现要生成的各种接口,然后每个字段或访问器方法可以使用注释。
public class MyDomainObject implements MyDOProxyFoo, MyDOProxyBar {
@ExposedBy({MyDOProxyFoo.class})
public String foo;
@ExposedBy({MyDOProxyBar.class})
public String bar;
@ExposedBy({MyDOProxyFoo.class,MyDOProxyBar.class})
public String foobar;
...
}
然后,各个字段的 getter/setter 将位于各自生成的接口中。
您可以在注释中执行类似 readonly 属性的操作,以仅在指定接口中公开 getter。
...
@ExposedBy({MyDOProxyBar.class}, readOnly = {MyDOProxyFoo.class})
public String bar;
...
我可以运行类似的东西
mvn rfproxygen:generateproxies
,并且我可以在生成的源目录中很好地创建所有代理接口。
我想争论的焦点是决定你的域模型中是否应该有服务数据绑定逻辑。
I am looking for a maven plugin that will auto generate EntityProxy interfaces from my domain classes.
The class could implement the various interfaces to be generated and then each field or accessor method could use an annotation.
public class MyDomainObject implements MyDOProxyFoo, MyDOProxyBar {
@ExposedBy({MyDOProxyFoo.class})
public String foo;
@ExposedBy({MyDOProxyBar.class})
public String bar;
@ExposedBy({MyDOProxyFoo.class,MyDOProxyBar.class})
public String foobar;
...
}
Then the getters/setters for the respective fields would be in the respective generated interfaces.
You could do something like a readonly attribute in the annotation to only expose a getter in the specified interfaces.
...
@ExposedBy({MyDOProxyBar.class}, readOnly = {MyDOProxyFoo.class})
public String bar;
...
I could run something like
mvn rfproxygen:generateproxies
and I would have all my proxy interfaces nicely created in the generated sources directory.
I guess the argument is deciding wether you should have service data binding logic in your domain model.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道有一个能够生成代理的 Maven 插件,但有一个 问题为 GWTP 解决这个问题。如果它完成了,也许你会对它感兴趣。
I don't know a maven plugin that is capable of generating proxies but there is an issue addressing this for GWTP. Maybe this will of interests for you if it's finished.