Singleton class to be shared among multiple portlets

后端 未结 3 933
广开言路
广开言路 2021-01-06 20:24

I have a couple of Singleton classes in a Liferay application that hold several configuration parameters and a ServiceLocator with instances to WebServices I need to consume

3条回答
  •  渐次进展
    2021-01-06 20:52

    Alexander's answer gives the general answer that's true with or without Liferay in mind.

    Liferay (as you mention it) adds another option to this: ServiceBuilder. You'll end up with the actual instances contained in exactly one web application, and you'll have an interfacing jar that you can distribute with every dependent application. This way you can more easily update your implementation: It's easy to hot-deploy new and updated web applications to your application server - it's harder to update code that's living on the global classpath.

    The global classpath (Alexander's answer) however brings you immediate success while ServiceBuilder comes with its own learning curve and introduces some more dependencies. I don't mind those dependencies, but your mileage might vary. Decide for yourself

提交回复
热议问题