开发者

Parsley: how to share instance between 2 Parsley configurations?

I got 2 parsley configurations for my 2 elements.

A.xml

<fx:Declarations>
    <!--Presenters-->
    <presenters:ScenarioDefinitionPresenter id="scenarioDefinitionPresenter"/>

    <!--Manager-->
    <managers:ScenarioDefinitionManager/>

    <!--service-->      
    <services:ScenarioDefinitionServiceImpl id="scenarioDefinitionService" />
</fx:Declarations>

B.xml

开发者_如何学Python
<fx:Declarations>
    <!--Presenters-->
    <presenters:TemplatePresenter/>
    <presenters:ScenarioDefinitionPresenter id="scenarioDefinitionPresenter"/>
</fx:Declarations>

My question is how to make that the "scenarioDefinitionPresenter" in both config share the same instance?

Thanks!


Well, that depends on how you 'architected' your Parsley configs. In Parsley, if you have a 'root' config with that presenter, it will be shared in all child configs as well (unless you specify otherwise).

From the look of it, it seems that you have 2 siblings (2 children under root) that have different contexts. My suggestion is that you make a config in the main application file and add your presenter there. From here, you don't need to specify the presenter in the child contexts, only need to set the injections where needed and Parsley does the rest.


Specify the required class in your root context config file and you can use the same instance in all your modules.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜