重写javamoney.properties中的属性?
使用的新1.0版本,我们试图通过重写javamoney.properties来阻止资源加载器加载其他ExchangeProvider重写javamoney.properties中的属性?,java,jsr354,java-money,Java,Jsr354,Java Money,使用的新1.0版本,我们试图通过重写javamoney.properties来阻止资源加载器加载其他ExchangeProvider {1}conversion.default-chain=MY-PROVIDER # Turn off loading of the default Moneta ExchangeRateProviders. {1}load.ECBCurrentRateProvider.type=NEVER {1}load.ECBHistoric90RateProvider.typ
{1}conversion.default-chain=MY-PROVIDER
# Turn off loading of the default Moneta ExchangeRateProviders.
{1}load.ECBCurrentRateProvider.type=NEVER
{1}load.ECBHistoric90RateProvider.type=NEVER
{1}load.ECBHistoricRateProvider.type=NEVER
{1}load.IMFRateProvider.type=NEVER
{1}load.AbstractECBRateProvider=NEVER
但是,日志告诉我它们仍在加载中:
jun 19, 2015 8:27:58 AM org.javamoney.moneta.internal.convert.AbstractECBRateProvider newDataLoaded
INFO: Loaded ECBCurrentRateProvider exchange rates for days:1
从LoaderService接口“从不”触发加载本地资源(而不是远程资源),但我也尝试了“惰性”
public interface LoaderService {
/**
* Platform RI: The update policy defines how and when the
* {@link LoaderService} tries to update the local cache with newest version of
* the registered data resources, accessing the configured remote
* {@link URI}s. By default no remote connections are done (
* {@link UpdatePolicy#NEVER} ).
*
* @author Anatole Tresch
*/
public enum UpdatePolicy {
/**
* The resource will never be updated from remote, only the fallback URL
* will be evaluated.
*/
NEVER,
/**
* The resource will be loaded automatically from remote only once on
* startup.
*/
ONSTARTUP,
/**
* The resource will be loaded automatically from remote only once, when
* accessed the first time.
*/
LAZY,
/**
* The resource should be regularly reloaded based on a schedule.
*/
SCHEDULED
}
...
我们注意到,在org.javamoney.moneta.internal.convert中ExchangeProviders的构造函数中,有一个对loader.loadDataAsync的调用:
AbstractECBRateProvider(ProviderContext context) {
super(context);
saxParserFactory.setNamespaceAware(false);
saxParserFactory.setValidating(false);
LoaderService loader = Bootstrap.getService(LoaderService.class);
loader.addLoaderListener(this, getDataId());
loader.loadDataAsync(getDataId());
}
这与中方法中的“ONSTARTUP”情况相同:
这可能是无论我在javamoney.properties中放入什么都会加载它的原因吗
我们如何完全关闭其他Exchange服务提供商?我们只想使用我们的定制功能。看来我们遇到了一个问题。您能否在我们的java.net/javamoney项目中提交Jira问题(并检查此问题是否已提交:)。我们计划在未来几天发布一个ri的补丁版本,所以我们可能也会解决这个问题 非常感谢!
阿纳托利感谢您的回复!我已经提交了一个Jira:。Jira链接已经过时,请看这张票
switch (updatePolicy) {
case NEVER:
loadDataLocal(resourceId);
break;
case ONSTARTUP:
loadDataAsync(resourceId);
break;
case SCHEDULED:
addScheduledLoad(res);
break;
case LAZY:
default:
break;
}