Sharing an application context between two WARs?

前端 未结 7 1178
执笔经年
执笔经年 2020-12-30 08:26

Is there a way to share an app-context between two deployed wars? One war needs to wire-in the services of another, and I don\'t know where to start with this.

7条回答
  •  星月不相逢
    2020-12-30 08:49

    You could possibly bind a context to JNDI if it doesn't exist.

    The price for this is that each webapp's context somehow has to be aware that it might not be the primary.

    Also, you need to be really careful about race conditions, e.g.

    • first webapp starts, detects that there is no context
    • first webapp starts to build the context
    • second webapp starts, detects that there is no context
    • second webapp starts to build the context
    • first webapp finishes to build the context, binds it
    • second webapp finishes to build the context, binds it
    • congratulations, you have lost all beans from the context of the first webapp

提交回复
热议问题