File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes any manual or book about designing some plug-able library like JDBC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "any manual or book about designing some plug-able library like JDBC?" Watch "any manual or book about designing some plug-able library like JDBC?" New topic

any manual or book about designing some plug-able library like JDBC?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
thank you for reading my post
we have an application which some part of it (in term of implementation) changes for each customer and deployment.
I thought that we can develop some interface that cover all of our requirement and develop several implementation for it, for each customer we can use any of those implementations.
what i can not understand is how to design the library to be as plugable and easy to change as JDBC drivers.

is there any manual or help about designing this kind of functionality in an application?

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Google for the Dependency Inversion Principle and Dependency Injection.

And then develop the library iteratively and incrementally, in the presence of a couple of different clients.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
JDBC is a neat example. When we write programs that use JDBC we refer to all the goodies in java.sql. But if you browse to java.sql in the JavaDoc, you'll find that almost everything we use is really an interface. Sun doesn't provide any classes to support connections, resultsets, etc, only interfaces. The different database vendors have to provide classes that implement those interfaces.

We never know the names of those classes, and we never do "new" on them. So how do we get object instances? Through factories or some kind of creation helper.

Your plugin scheme can work the same way. Build a set of interfaces that your application uses for all its business level work. Build a set of implementation classes for each pluggable setup.

"Dependency Injection" is a neat style for doing this kind of thing. An "application assembler" component reads configuration and pushes the proper plugins to components that need them. That way the components have no dependency on the configurator or anything except the interfaces.

Does that answer the right question?

Ha! Ilja sneaked in there while I was typing! You and your cursed short answers!
[ December 16, 2006: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
This is too good an opportunity to plug my own stuff to pass it up, so in a shameless act of self-promotion let me point you to a recent JavaRanch Journal article I've written that deals with the subject of adding a plugin mechanism to Java code.
I agree. Here's the link:
subject: any manual or book about designing some plug-able library like JDBC?
jQuery in Action, 3rd edition