• Post Reply Bookmark Topic Watch Topic
  • New Topic

plugin architecture  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys


i have a problem in front of me .i have a set of api's and it has to be made plugin compatible i.e. plugin architecture should be layered on top of these APIs . how do i go about it. which is the best way to implement it.
please help me out ..
 
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
search google for osgi.you can also search the java docs for different levels of extensibility it offers.
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You provide little information on what exactly you're trying to do, but a simple plugin architecture might consist of the following:
- You define an interface, which all plugins need to implement. In addition to the functional methods, there should also be a name that you can retrieve, so that you can present the plugin to the user, if necessary.
- You define how your program will know what plugins there are, e.g. they could be opened through a menu, or all classes in a particular directory could be used as plugins.
- For loading, you'd want a custom ClassLoader that knows about the special directory, because for security reasons the plugins should not be part of the classpath (see next point).
- you should create a SecurityManager for the code loaded through your classloader, because code external to the application should not considered trustworthy. (Who knows where it comes from.)
- At program startup, your app can iterate through the above-defined directory, load and instantiate all classses it finds through the ClasssLoader, and, if they implement your plugin interface, store them somewhere for use in your app.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can review how others have done it. For example, check how JEdit implements it's plugin support. Eclipse also supports plugins (and may have better documentation). Both are open source so you can look at the code after reading the documentation.
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some general background, google for papers on "Dependency Inversion" and "Dependency Injection" ... two ideas that play very nicely with plugins.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!