Preacher
Junior Member  
Java games rock!
|
 |
«
Posted
2004-01-12 12:20:58 » |
|
Hi i'm developing a 3D Chess game aimed at a young age group for a college project and i'm interested in making a pluggable architecture such as in eclispe. This is my first serious attempt at developing a complete software product so i have only a few shaky ideas about how to implement a pluggable architecture. My only idea so far is to have all plugs register to a central module to receive events, same as Java event model, and each plug implement a plugEventListener etc to handle custom events such as MoveEvent, PropertyChangeEvent etc.  I woudl really appreciate comments and ideas from people more experienced in these issues as i would really like to implement a pluggable interface. Thanks
|
|
|
|
|
Breakfast
|
 |
«
Reply #1 - Posted
2004-01-12 12:45:08 » |
|
What exactly do you mean by a pluggable architecture? What do you want it to do?
|
|
|
|
|
Jeff
|
 |
«
Reply #2 - Posted
2004-01-13 01:12:59 » |
|
Plugins in java are handled through dynamic calss loading. Its best that each plug-in have its own class loader because that way you can avoid potential name-sapce clashes.
Generally what someone does is define a FooPlugin interface that defines the functions all plug-ins need to implement as well as a naming convention for plugins to make them easy to seperate from the support classes in the same calss path.
On start-up, you search each class loader's classpath for all classes that match the naming convention. Yo uthen instacen thsoe classes and check to see that they implement for FooPlugin inetrface. If thats true you add them to a plug-in list for use by your app.
Thats it in a nutshell. There are lots of details you need to cover but thats the over-all process.
NOW having said that, we have ALREADy released a generic plug-in system into Open Source you can use if you like. Its the in net.java.games.jutils package thats part of the JInput project.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Preacher
Junior Member  
Java games rock!
|
 |
«
Reply #3 - Posted
2004-01-13 09:02:56 » |
|
Alright sounds good, i'll do a bit of research and give it a try  Breakfast im want to develop a chess game that myself or other developers can easily add extra components such as a board editor, or a game analyzer etc. The game will be aimed at a young demographic so i want the user to be able to add in these plug-ins very easily, say just drop a .jar file into a specified folder and the game, at start up automatically detects them, verifiies them and adds them. Thats it really so if you have anything to add it would be a great help 
|
|
|
|
|
Orangy Tang
|
 |
«
Reply #4 - Posted
2004-01-13 10:19:25 » |
|
I do something pretty similar with S-Type, all the actors (player, bullets, enemies etc.) are dynamically loaded by the editor and placed, ready to be loaded in proper when you start an actual game.
However I havn't had to use different classloaders, mainly because I assume different sets of actors live in their own package anyway. I simply set the plugins dir to be included in the classpath, and any new actor classes can just be dropped in.
Unlike Jeff's method, I don't have a naming convention (at least, not one thats required) and instead just have a text file that lists all the actor classes to use. I find this more handy because then you can just edit the file to choose which ones to load or not. This way is simpler to implement, but might not be as suitable depending on what you're looking for.
|
|
|
|
Breakfast
|
 |
«
Reply #5 - Posted
2004-01-13 12:25:12 » |
|
You could up the user-friendliness of this by perhaps adding a graphical front-end to the option file editing.
Maybe you would also want to create a standard Pluggable type interface that all your plug-ins will need to implement, perhaps containing some metadata and the like that you can use to create menus so people can switch on or off different plugins as necessary.
It seems to me that you will be helping yourself in this if you keep your design as clean and OO as possible, too.
|
|
|
|
|
swpalmer
|
 |
«
Reply #6 - Posted
2004-01-13 13:49:32 » |
|
NOW having said that, we have ALREADy released a generic plug-in system into Open Source you can use if you like. Its the in net.java.games.jutils package thats part of the JInput project.
More accurately it is in the JUtils project which is used by JInput. Find it in Games-Core
|
|
|
|
blahblahblahh
|
 |
«
Reply #7 - Posted
2004-01-13 14:08:35 » |
|
Have a look at jedit.org - jedit has a plugins architecture for adding all sorts of functionality to the editor. Depending upon how much customizablity you want, this might be a good model to follow. Note that it makes extensive use of BSH (a java-syntax scripting language which enables you to write simplified java code, and program more quickly).
Ditto Netbeans etc, which has it's own plugins arch.
|
malloc will be first against the wall when the revolution comes...
|
|
|
blahblahblahh
|
 |
«
Reply #8 - Posted
2004-01-13 14:19:52 » |
|
NOW having said that, we have ALREADy released a generic plug-in system into Open Source you can use if you like. Its the in net.java.games.jutils package thats part of the JInput project.
Just had a look - brilliant! I've seen much fuller-featured plugin systems, and this one is currently so lean it's quite rubbish (mainly the lack of metadata, stuff like Breakfast suggested), but it's great to see a serious start on it in j.d.net ...I've requested develop access, since I've made simple plugin systems more times than I care to count, and can *probably* quickly add some useful stuff. There's quite a lot that you can add to a plugin system before you get to the point where you need to sit down and carefully plan the rest of it (e.g. basic "plugin name + description" meta-data is universally desirable)...unless someone else is already doing this.
|
malloc will be first against the wall when the revolution comes...
|
|
|
Preacher
Junior Member  
Java games rock!
|
 |
«
Reply #9 - Posted
2004-01-13 14:58:45 » |
|
Im not getting a bad response  I'd really like to keep the plauggable architecture simple its for a college project (3DChess game) and is not a primary part of the game, so i would like to keep the development time to an absolute minimum. What is the possiblities of implementing a system like java's event listeners? where each pluggin would implement a plug interface and register with the core module to receive events?? Can you create custom events in java that one of your objects can broadcast to all registered listeners??? I'm going to sit down and work through what you all have suggested tonight and get back tomorrow, and thanks very much to everyone who suggested ideas
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Orangy Tang
|
 |
«
Reply #10 - Posted
2004-01-13 16:53:29 » |
|
What is the possiblities of implementing a system like java's event listeners? where each pluggin would implement a plug interface and register with the core module to receive events?? Theres nothing particularly magic about regular event listeners, the event itself is just another object, as is the listener (usually implementing some sort of listener interface). You simply need to create classes or interfaces for the plugin writers to use. Depending on what events you want them to listen to, you might want to have them register themselves or done automatically for them. For chess I assume you'd like to listen for moves, so every plugin could automatically be registered at creation time. Or maybe provide a .register method where it can attach to whatever subsystems it feels like it needs to listen to. Can you create custom events in java that one of your objects can broadcast to all registered listeners? Sure you can, its just another object you make yourself  You just need to define a listener interface to go with it that accepts the event object as a parameter.
|
|
|
|
Preacher
Junior Member  
Java games rock!
|
 |
«
Reply #11 - Posted
2004-01-15 07:59:12 » |
|
Excellent Thnaks v.much one and all 
|
|
|
|
|
Jeff
|
 |
«
Reply #12 - Posted
2004-01-15 19:13:04 » |
|
...I've requested develop access, since I've made simple plugin systems more times than I care to count, and can *probably* quickly add some useful stuff. There's quite a lot that you can add to a plugin system before you get to the point where you need to sit down and carefully plan the rest of it (e.g. basic "plugin name + description" meta-data is universally desirable)...unless someone else is already doing this. Nope we have noone but me working on Jutils so far and I havent done more beyond what I needed. Would love to have you pounding on it. Have you filed a core developer agreement yet? The only coding requirement is that, in modifying Jutils stuff, you not break other core projects that rely on it. Currently thats just JInput. If you are going to make changes that might break JInput, post them first (idea, not code) to the JInput forum so the JInput folks can have input. Thanks JK
|
|
|
|
swpalmer
|
 |
«
Reply #13 - Posted
2004-01-16 00:51:06 » |
|
I was just trying to grab the latest version of junit from CVS but apparently I can't anymore.
update -d -P -A User swpalmer doesn't have <Update> access to project cvs Command Finished.
Weird.
|
|
|
|
|
|
Jeff
|
 |
«
Reply #15 - Posted
2004-01-16 20:58:08 » |
|
I was just trying to grab the latest version of junit from CVS but apparently I can't anymore.
. i added you with observer status. Are you still having probs?
|
|
|
|
Jeff
|
 |
«
Reply #16 - Posted
2004-01-16 21:00:24 » |
|
Check out OSGi - it's not specifically for gaming, but it is specifically intended to provide a dynamic puggable environment: OSGi is a bit different. Its not a plug-in system but an execution environment for little remotely installed applications. Its srot of like a push rather then pull Applet executor with no video model. I actuallyworked on the OSGi "connectd home" demo for Sun 2 or 3 JavaOne's ago.
|
|
|
|
|