Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How to design application that supports plugins

 
Ranch Hand
Posts: 603
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I need to build application that has some general functionally (like collecting data analyzing and such .. )
But there is apart in the application that needs to communicated with third party application this third party
Application can be from different every time , that is will use different communication protocol and will have slight different
Interface.
How can I design this section of the application? I was thinking that it will use plugins , that every third party application will
Have its own plugin that will implement interface and I will have this well defined interface in the application side that always
Will know what to expect.
What do you think? Is there any pattern for this kind of task?
Thanks
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a good solution, and actually a typical cluster of patterns:

- you use the Strategy pattern to make the thirdparty library exchangable
- the implementations for the single libraries will probably need to use the Adapter pattern to adapt their specific API to the generell plugin API, and
- you will probably use some kind of Dependency Injection to tell the code which strategy to use

Does that help?
 
Meir Yan
Ranch Hand
Posts: 603
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn�t understand the third part , I do know the strategy pattern and the adapter .
But the injection part I didn�t understand
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you worked with JDBC? That's an interesting design example because Sun defined a bunch of interfaces but didn't provide any implementation. The database vendor has to provide implementations that actually connect to a database. So in some sense, databases are plug-ins.

The JDBC spec tells the database vendor to manage everything starting from a static block in the driver class. When you say Class.forName(driver) that block executes, registers itself with JDBC and configures whatever it needs for the rest of the run. After that the driver can create instances of classes that implement ResultSet and so on.

That initialization is nifty but a little too magical for my tastes. Class.forName doesn't usually do anything quite so significant. I prefer the kind of injections mentioned in the paper Peer suggested.

At the high end of plug-in modules is OSGi. It's probably way beyond what you need now, but a bit of reading on it may give you some ideas.
[ August 24, 2007: Message edited by: Stan James ]
 
Meir Yan
Ranch Hand
Posts: 603
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the fast reply
well yes i did worked with jdbc , and yes it seams this is what i need
as a simple implementation , do you know links so i can read about it ?
now im reading the :http://www.martinfowler.com/articles/injection.html
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!