开发者

spring IOC, can I drop a .jar that adheres to an interface and modify the app-config.xml?

Say I have a database layer, with DTO's for each table, and a factory that returns the DTO's for each table.

As long as I build to interfaces, I can re-implement the db layer and then just change my app-config.xml to use another implementation.

Now, is it possible for me to have this new implementation in another .jar file?

The goal is to allow for someone else to run this spring mvc application, drop their own implementation and change the app-config.xml file so that it now uses their library to re-implement a module.

Is this possible? How e开发者_运维问答xactly do I go about this?


Is this possible?

Yes.

How exactly do I go about this?

Well the straight-forward approach would be to expose a setter for the DTOFactory instance in some bean that you have previously declared in your "app-config.xml" file. Then instantiate and inject the required DTOFactory bean via the corresponding property. To use an alternative factory, just change the classname in the bean.

The approach above assumes that your application currently use a shared instance of the (existing) DTOFactory class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜