Originally posted by Henry Lowell: Say I have the following:
Ok, so what I need to do is the following: Using reflection, I need to instantiate ThatInterface with an instance of ThisAndThat class. I can instantiate ThisAndThat with no problem.
You solved your own problem in the text of your post. just take the code that instantiates ThisAndThat and move it into a method that returns ThatInterface. You're probably confused in thinking you need to instantiate ThatInterface which is not possible. The whole idea is to have the caller use the ThatInterface as the type and then the code you have to instantiate ThisAndThat can be moved into a factory method that returns ThisInterface.
In my above example all you would need to do is inject TheOtherThing with ThatFactory using an assembler like Spring or just plain ol' wonderful Java.
(Man I love the way that codes out! Good example Henry!)
Holla at me...<br /><a href="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
Joined: May 29, 2006
Thanks. I find of figured that out just before I got your response. Everything works great. Thanks again!