This content has been marked as final.
Show 1 reply
-
1. Re: How to create singletons?
shoeb1981 Dec 4, 2007 7:18 AM (in response to aidndev)It is an interesting question. Following might be helpful
Before creating an instance of the singleton class, check if it exists in the system.properties. If it doesn't, create the instance and put that instance into system.properties map.
For ex:
if (System.properties.get("Single")==null) {
Singleton single = new Singleton();
System.properties.put("single", single);
}
Second approach could be this:
Don't put the class in the classpath. Write your own classloader and specify the absolute location of the class. This way app server wouldn't be able to load the class automatically.
Hope that helps