AOP:域模型到 Axis beans,反之亦然
这是一个针对那些希望比我更熟悉 Spring/AOP 的人的设计问题。
我有一组由各种 Web 表单填充的域模型 bean。我需要将域模型内容提交到许多 Web 服务,我将使用 Axis2 来执行此操作。
在我的代码中的某个地方,我将不得不处理整理域对象所需的信息并将其放入 Axis2 bean 中的艰巨任务。在大多数情况下,这很简单:
AxisObject.setTheString(DomainObject.getTheString())
理想情况下,我希望将 Axis 相关代码远离我的域对象,但对我来说,一个整洁的解决方案是在域对象上有一个方法,例如 putContentsInAxisBean()
我的问题是这样的:我可以在需要时使用 AOP 的功能(例如介绍)将这种功能添加到我的域对象中吗?或者说,这里是否出现了其他设计模式?
干杯
This is a design question for those who are hopefully a bit more familiar with Spring/AOP than myself.
I have a set of domain model beans populated from various web forms. I have a requirement to submit the domain model contents to a number of web services and I will be using Axis2 to do so.
Somewhere in my code I will have to tackle the laborious task of collating the information required from my domain objects and putting it into the Axis2 beans. For the most part this is as simple as:
AxisObject.setTheString(DomainObject.getTheString())
Ideally, I would like to keep Axis related code away from my domain objects, but a tidy solution for me is to have a method on the domain object e.g. putContentsInAxisBean()
My question is this: could I use features of AOP (e.g. introductions) to add this kind of functionality to my domain objects when required? Or otherwise, is there some other design pattern emerging here?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与AOP无关。你应该寻找一个bean映射器,例如有一个Dozer,但我自己还没有尝试过。但是,我更喜欢像您引用的那样显式映射代码,它使代码导航和重构更容易。
It's nothing to do with the AOP. You should look for a bean mapper, e.g. there is a Dozer, but I've not tried it myself. However, I would prefer explicit mapping code like you quoted, it makes the code navigation and refactoring easier.