Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

How can I make use of Singleton class in multiple modules

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am basically having, 3 modules in my application.

1. opint-core-data
2. opint-odata-service
3. opint-proc-service

I'd like to have a Singleton class(to use for caching mechanism). I have created ScenarioDataProvider.java in opint-core-data module, which is a dependency in both opint-odata-service and opint-proc-service modules.

Below is the code snippet of my Singleton class.


Code snippet, where I try to get the instance of Singleton from opint-proc-service module:



Code snippet, where I try to get the instance of Singleton from opint-proc-service module:




Whenever I try to get the instance of Singleton, from opint-odata-service and opint-proc-service, two instances are getting created. One for each module.
But I would like to have only one instance available, through out the application, between multiple modules.

Can someone please assist me on how I can have one singleton instance of ScenarioDataProvider through out the application, and between multiple modules?
 
Saloon Keeper
Posts: 14692
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please continue the topic here.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic