Hi i'm developing a 3D Chess game aimed at a young age groupfor 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

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.

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

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

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.

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.

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).

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.

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

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.

Quote

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.

...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

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org