Enumeration en = getServletConfig().getInitParameterNames();
thorugh calling the getServletConfig() method we can access the getInitParameterNames().Can anyone give some explanation please?
Object/Class chaining can be a double-edged sword so be careful. It is quite easy to do via the Singleton patern, or factories,
but you will have to be careful with the instantiation or creation of too many temporary objects.
William P O'Sullivan wrote:Object/Class chaining can be a double-edged sword so be careful. It is quite easy to do via the Singleton patern, or factories,
This has nothing at all to do with singletons or factories. Any object that is returned from a method can be chained in this manner.
William P O'Sullivan wrote:Not quite true, each Object in the chain must declare a public method corresponding to the next entry.
Each class must have the method, of course. What's your point? It still has nothing at all to do with singletons.
Each method could instantiate a brand new Object as well, so without full access to the API, quite dangerous.
Not at all. Regardless of how the methods are called, they will do the exact same thing. The methods have no knowledge of whether they were called as part of a chain or not.
Matthew Brown wrote:It's not writing a method within a method, though. It's just calling a method on whatever was returned by the first method.
What you've got there is exactly equivalent to:
except that you don't get to keep a reference to the ServletConfig to use again later.
Thanks for the reply i got it.....