[英]Strategies for dealing with inflexible 3rd party libraries
I need help controlling the behavior of a couple of 3rd party libraries I am required to use in my application: 我需要帮助控制我需要在我的应用程序中使用的几个第三方库的行为:
DBLib makes a lot of static-method calls to PropsLib to acquire configuration settings. DBLib对PropsLib进行了大量静态方法调用以获取配置设置。 For example:
String dbHost = PropsLib.getString("dbHost")
. 例如:
String dbHost = PropsLib.getString("dbHost")
。 PropsLib uses non-standard .properties
files that is reads from the filesystem. PropsLib使用从文件系统读取的非标准
.properties
文件。 (non-standard meaning they have a quirky placeholder syntax that doesn't match any of our other .properties
files) Also, the method for externalizing (overriding) those files per-environment is strange and clunky. (非标准意味着它们有一个古怪的占位符语法,与我们的任何其他
.properties
文件都不匹配)此外,每个环境外部化(覆盖)这些文件的方法很奇怪而且很笨重。
Are there any design strategies I could use that would allow me to use my existing Spring-based configuration mechanisms here? 是否有任何我可以使用的设计策略可以让我在这里使用现有的基于Spring的配置机制? Or is my only option to write my own implementation of the PropsLib library?
或者我是编写自己的PropsLib库实现的唯一选择?
If PropsLib
is as short and easy as you described, I would recommend you to reimplement it in your own code to cheat DBLib
and retrieve your spring-based configuration, instead using the properties file you hate :) 如果
PropsLib
像你描述的那样简单易行,我建议你在你自己的代码中重新实现它来欺骗DBLib
并检索你的基于spring的配置,而不是使用你讨厌的属性文件:)
Of course, if PropsLib
is in a .jar
you would need to remove it from that archive before. 当然,如果
PropsLib
在.jar
您需要先将其从该存档中删除。 You could also include your own version inside the .jar
but this is not mandatory. 您也可以在
.jar
包含您自己的版本,但这不是强制性的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.