if my above observation is correct
It depends. You may as well include everything in distribution and only configure each installation to use what it needs. Possible reasons for going with plugins are:
- You charge your plugins separately and don't want to give away features for free
- Your plugins are "heavy" in some way, e.g. there are lots of them or they have a significant size.
If those reasons do not apply to your case, you may think of a simpler solution.
how to have above kind of plugin structure with Java/Java EE?
If you're OK with rolling your own simplest solution, here is the general scheme:
- In app's configuration (which can be *.properties file or a record in DB, whichever works better for your users, because they should be able to change it), add a property which contains a path to plugins directory
- Define and expose plugin API - a set of interfaces which a plugin must implement to allow application to invoke this plugin
- Write custom ClassLoader which uses the property from #1 and maybe checks if each plugin properly implements your API
- Load your plugins' classes and resources using this class loader
- Invoke plugins' functions via interfaces of plugin API or, if plugin consists of resources only, include those as needed
are there any frameworks in Java that supports above kind of thing?
Yes. Googling for "java plugin framework" reveals some.
Other questions on the topic:
- Best way to build a Plugin system with JavaBest way to build a Plugin system with Java
- Java plugin framework choiceJava plugin framework choice
- How to create a pluginable Java program?How to create a pluginable Java program?
- Java Web application “plugin” architectureJava Web application “plugin” architecture
Update:
To load JSP files (or any files), use classloader as described above: see getResource and getResourceAsStream methods.
Update 2:
After meditating some more, I see you just need to conditionally include a JSP into another JSP. This is not "pluggable UI components" or anything like that, it's just conditional inclusion. There are no frameworks for that since it's just about 4-6 lines of code. It seems like you think it's more complex than it actually is.
I think this will do:
- have a property in a file (or in DB) which tells which plugin should be used
- assign a value of this property to a variable, say
String plugin = ... - pass it to your JSP:
request.setAttribute("plugin", plugin);or something similar - use it like
<jsp:include page="${plugin}" flush="true" />
Could be wrong in syntax, but the point should be clear. Hope it helps.