My NetBeans platform application has two nbm modules A and B and one jar project. NB modules have a dependency on a JAR which contains singleton class named Engine. When I access Engine class from module A, Engine object created and returned. So I expect already created Engine object when I call same Engine class from module B. But it creates new Engine object again and return.
===jar module===
Class Engine
{
private static Engine single_instance= null;
private Engine(){}
public static Engine getInstance()
{
if (single_instance == null)
{
single_instance = new Singleton();
}
return single_instance;
}
===module A===
System.out.println(Engine.getInstance());// prints object address 1
===module B===
System.out.println(Engine.getInstance());// prints object address 2
I want to get same object from module B call as well since jar is shared resource among those two modules. What is the correct way of sharing the objects between two nbm s via single jar?