在Guice自定义范围中播种对象

时间:2016-08-02 14:24:07

标签: java dependency-injection scope command-line-interface guice

在CLI应用程序中,我实现了自己的自定义范围,名为Map。范围用于执行标准导入作业的类的实例。例如,(function (clusterData, batchSize, done) { var myMap = new Map(); var i = 0; (function nextBatch() { for (data of clusterData.slice(i, i+batchSize)) { myMap.set(data.attributes.PropertyAddress, data); } i += batchSize; if (i < clusterData.length) { setTimeout(nextBatch, 0); } else { done(myMap); } })(); })(this._clusterData, 1000, function (result) { // All done this._DistClusterData = result; // continue here with other stuff you want to do with it. }.bind(this)); 将导入@ImporterScope模型(代表XML),UserImporter将导入User等。

使用Guice,如何将对象实例注入范围?除了实现之外,我的目标是能够在范围内ScheduleImporter Schedule和/或@Inject 到处并获取特定实例。

0 个答案:

没有答案
相关问题