John,Ilja and Layne
Sorry I still didn't state the question clearly. So here it goes again:
For an example, in Xalan document, the authors ask the user to "The SAX, DOM, and JAVAX interfaces are in xml-apis.jar. These interfaces are shared by a number of tools (Xalan-Java, Xerces-Java, etc.), so placing them in a separate JAR simplifies coordination and reduces risk of duplication. Be sure to put both JAR files (and xercesImpl.jar or another JAXP 1.2-compliant XML parser) on your classpath!"
Obviously, Xalan utilize SAX and DOM interface in xml-apis.jar and I am responsible for providing an implementation of those XML parsers(Xerces or JAXP). Since Xalan doesn't depend on certain implementation, I could possibly write my own JAXP 1.2-compliant XML parser and use it. Bottom line is, Xalan doesn't know what implementation I am using.
So John: I can't have a string param for my factory method since I don't know what derived class to instantiate. I want the return type changes as I changes the actual implementation I use(again, without changing anything in factory class).
Ilja: I assume that some sort of Factory class will decide about the actual implementation to use. But the factory class shouldn't have that knowledge hard wired. That means, when I decide to use another implemenation, I don't need to change anything in the Factory class. In the case of Xalan, I can replace the parser from Xerces to my own parser and Xalan can pick it up.
Layne: I understand that my question is kinda vague and maybe the pattern to use is not Abstract Factory. What I want to achieve is something like the way Xalan utilize XML parser interface. Let's say Xalan is my user class and it get a XML parser via some sort of factory class. The factory class shall return Xalan the available implemenation of XML parser interface based on certain rules. The rules should be flexible such that the facotry won't know what particular concrete class to call until run time. That way it can return any kind of implemenation without change the code.
Sorry for my English if you guys still don't know what I am talking about.
[ June 17, 2003: Message edited by: Shuai Liu ]