从外部注射和提供服务

时间:2017-07-18 19:32:42

标签: ember.js dependency-injection

我可以从初始化程序向组件注入服务吗?我想在我的应用程序的组件中的任何组件中都有一个属性,它带来了静态配置信息。我知道我可以在组件中执行此操作:

cfgStore: Ember.inject.service('cfgstore-reader')

我可以在intializar中为我的组件添加一个对象:

let cfg = Ember.Object.extend(cfgStore);

export function initialize(application) {
  application.register('cfgstore:main', cfg);
  application.inject("component", "cfgstore", "cfgstore:main");
}

我可以为注射器做同样的事情吗?我可以找到任何样品,它似乎确实有用......

1 个答案:

答案 0 :(得分:1)

您应该可以注入服务:

<property>
    <name>yarn.log-aggregation-enable</name>
    <value>true</value>
</property>

<property>
    <name>yarn.log.server.url</name>
    <value>http://ip-XX.XX.XX.XX:19888/jobhistory/logs</value>
</property>

<property>
    <name>yarn.nodemanager.local-dirs</name>
    <value>/mnt/yarn</value>
    <final>true</final>
</property>

<property>
    <description>Where to store container logs.</description>
    <name>yarn.nodemanager.log-dirs</name>
    <value>/var/log/hadoop-yarn/containers</value>
</property>

<property>
    <description>Where to aggregate logs to.</description>
    <name>yarn.nodemanager.remote-app-log-dir</name>
    <value>/var/log/hadoop-yarn/apps</value>
</property>


<property>
    <name>yarn.log-aggregation.enable-local-cleanup</name>
    <value>true</value>
</property>

<property>
    <name>yarn.scheduler.increment-allocation-mb</name>
    <value>32</value>
</property>

<property>
    <name>yarn.log-aggregation.retain-seconds</name>
    <value>604800</value>
</property>