Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder02.blueworldhosting.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx09.iad.POSTED!not-for-mail From: Daniel Pitts User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Interface with implied Constructor References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 18 Message-ID: X-Complaints-To: abuse@newsrazor.net NNTP-Posting-Date: Wed, 10 Jul 2013 21:52:32 UTC Date: Wed, 10 Jul 2013 14:52:31 -0700 X-Received-Bytes: 1644 Xref: csiph.com comp.lang.java.programmer:24726 On 7/10/13 7:06 AM, Stefan Ram wrote: > Daniel Pitts writes: >> Another way to handle this is to have some sort of injection where you > > If Java would not forbid this, from the JVM POV, one would write: The injection itself is not on the interface, but on the concrete type. The OP was asking about specifying it on the interface, because it was desired to have the code automatically inject it. Using reflection on the concrete type does allow this, and there are libraries out there specifically to handle this. I mentioned two, Guice and Spring. There are probably others as well. > > interface example > { public void ( final java.lang.String example )... }; > > . (Maybe some other JVM language even allows this.) >