Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: Richard Maher Newsgroups: comp.lang.java.programmer Subject: Re: Interface with implied Constructor Date: Wed, 10 Jul 2013 17:55:13 +0800 Organization: Aioe.org NNTP Server Lines: 23 Message-ID: References: NNTP-Posting-Host: jOhPn0KFjrxwuMc9OPMmCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:24722 On 7/10/2013 12:41 PM, Daniel Pitts wrote: > On 7/9/13 3:41 AM, Richard Maher wrote: > > Another way to handle this is to have some sort of injection where you > pass in only objects the class requires. For instance, Guice will let > you annotate a class and it will manage creating the instance for you, > injecting any objects (either via constructors or setters) that the > object needs. Spring beans will do similar things, but is more common > in web frameworks than GUIs. > I've settled on a compromise. I will attempt to pass a single argument "sessionAmbience" to the loaded class and if I get a MethodNotFound et al Exception then I'll degrade to an empty Constructor. The Tier3SessinAmbience Interface will describe all of the getters that are available to the loaded class to assist in providing the functionality that is required to implement the first Interface I described in the OP. If the user's code doesn't need all of the lovely goodies available for context then that's fine. Cheers Richard