Reputation: 105
I'm pretty new to java and javafx 2. What I'd like to do is an application that is basically a container for separate "modules" that can be added later.
The main application should be some sort of content browser that scans for modules in a folder. Then, you can select the desired module (e.g., a small game) and open it INSIDE the main application (like a frame). I'd also like it if I could have an option to go full-screen (module only, without the main application). The main application and the modules should also be able to communicate (e.g., sending settings like "difficulty" or "starting level" and receiving scores/results).
Do you have any idea how I should go about achieving modularity (without losing inter-communication)?
I tried to look it up on Google but I'm probably unaware of the correct technical terminology... so, any help would be appreciated!
Note: I'm a GUI noob (most of my programming experience is CLI-based and rather low-level).
Edit: Weird, it removes "hi!" from the first line... I guess there are rules that force us to be rude ;)...
Upvotes: 2
Views: 225
Reputation: 3511
Have a look at the ServiceLoader class in Java 6+, there is plenty of documentation for it on the interweb but the gist of it is that you can ask it for implementations of an interface found on the classpath that are configured. You could have the following interface for example:
interface AppPlugin {
Node getContentNode();
String getName();
}
Plugins would then need to implement this interface and be configured to be loaded by the ServiceLoader. Check out the tutorial here:
http://weblogs.java.net/blog/timboudreau/archive/2008/08/simple_dependen.html
Upvotes: 1