Results 1 to 3 of 3
Thread: Factory loading class...help?
- 10-14-2008, 09:07 AM #1
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Factory loading class...help?
Hi Members,
Hope you would be doing great. And coming to my topic.
I have a factory loading class, on changing my input parameter factory loading has to be done.
My code:
// instance declaration
Line 1: private static BugTrackerFactory instance;
Line 2: public static synchronized FactoryClass getInstance(String className)
Line 3: {
Line 4: //instance = null; (
Line 5: //only if 'instance' is == 'null', it creates a new instance
Line 6: if ( instance == null )
Line 7: {
Line 8: instance = new FactoryClass(className); // constructor call with single argument
Line 9: }
return instance;
}
Note: here in this code, when i change the className(input parameter), with the new class name, the instance is not getting 'null', instead it is holding the instance of the previous class. For this i have declared the instance as 'null', in the code(line number 4), within the constructor method... is it right way of coding.
Please do suggest me some useful tips in this.
Regards,
Prabhu.
- 10-14-2008, 09:15 AM #2
please specify the Whole code .. i think the static is the culprit and i can see you have commented line 4 is it same in the code too.
- 10-14-2008, 02:20 PM #3
Similar Threads
-
Loading a class within a different class
By nick2price in forum New To JavaReplies: 1Last Post: 05-30-2008, 07:19 AM -
Help with class loading in java
By mathias in forum New To JavaReplies: 1Last Post: 07-31-2007, 08:51 PM -
Secure FTP Factory 7.0
By vglass in forum Java SoftwareReplies: 0Last Post: 07-20-2007, 01:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks