aspose file tools
The moose likes Java in General and the fly likes Interface implementation dependency resolver Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Interface implementation dependency resolver" Watch "Interface implementation dependency resolver" New topic
Author

Interface implementation dependency resolver

Pratap koritala
Ranch Hand

Joined: Sep 27, 2006
Posts: 251
Hi,

There are some Interfaces and implementation classes.
Some classes would be having dependency on the interface implementation,
If it would have been spring Framework, It will find the interface implementation and assigns implementation class to it.

In the following Spring will find Ishape implementation and assigns it to IShape.


Without Spring,

I need to declare like,


But, the above code is having actual implementation this.shape = new ShapeImpl(); class with-in the code. Is there a way to do without spring using plain java.

Something,like this.shape = createObject(IShape.class) . But,haven't got good Idea about implementation of createObject.

Any help would be appreciated.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sure, use a factory, or create an object using forName()/newInstance(), or...
Pratap koritala
Ranch Hand

Joined: Sep 27, 2006
Posts: 251
createObject need to find the implementation class of the interface and then intailize.
Intailizing from classname is fine,But I can't able to find API for finding interface implementaiton class

Can you elaborate more on factory?

Thanks for reply,I would be searching on factory pattern.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface implementation dependency resolver
 
Similar Threads
Help with Model View Control concept
when should i use abstract class and when i should i interfaces
doubt in abstract class and methods
Polymorphism question
Polymorphism