Plugin Development Guide
This is a new work-in-progress guide on how to write a plugin for Azureus.
- 1 Introduction
- 2 How do I get started?
- 3 Step-by-step guide
What things can a plugin do?
A lot of things. :) For something to technically be a plugin, it just needs to do a couple of things so that Azureus recognises it as one.
Plugins are essentially individual programs which are provided with a mechanism to interact with Azureus. They are Java programs which define an "entry" point to allow Azureus to use it as a plugin. So when we say plugins can do anything - generally speaking, they can. They have the whole of the Java API to interact with.
However, what plugins can do with Azureus is limited to the API's provided. Plugins can add table columns, menu items, present new views of information, generate config sections, manage downloads (including adding new ones), change settings, write extension messages to communicate with other peers, interact with other plugins - doing a lot of things which Azureus does).
Azureus doesn't just provide a large number of methods to interact with it, it also provides a large number of convenient utilities - like the ability to prompt the user for information (regardless of what interface the user might be using), a generic downloader facility (being able to download from HTTP, handling authentication, downloading from BitTorrent, specifying retry mechanisms)...
How do I know what's available to me?
The best guide at the moment is the Javadoc documentation that is available. The best approach to have is to decide what you want your plugin to do, and then see if Azureus provides you a way to do it. You can also post in the forum if you have any questions.
What if Azureus doesn't provide me with a way to do what I want?
Again, on the forum. Since I started writing plugins in Azureus, I have extended the plugin API so that plugins have a lot more control over many things. If you think the plugin API is lacking anything (either minor or major changes), you can make requests in the forum to be added.
How do I get started?
To get started, you will need to be able to program in Java and have a decent Java editor - if you're not familiar with writing Java programs, you will probably struggle. If you've programmed in an object-orientated language before, you might find that it's not too difficult to program in Java.
When you write your plugin, you will need to compile against the Azureus code itself, which is provided in a single JAR file. You need to use either the main Azureus2.jar file or a JAR file containing just the interfaces which make up the plugin API (both of which are available here).
If you write any plugins which need to interact with SWT objects, then you will need to use the swt.jar file that is in the Azureus directory too.
This section describes gradual development of an example plugin, which includes more and more functionality. It's not necessary for you to follow all steps to know how to write a plugin, but later sections may refer to previous sections.
Rather than naming the plugin something like "ExamplePlugin", I've called it Aizen, because Aizen wears glasses, and you can trust a man with glasses...
- Preparing an environment in Eclipse.
- Writing a blank plugin.
- Running the plugin.
- Building the plugin.
- How plugins work with Azureus.
- Storing data and changing config settings.
- Defining plugin text.
- Creating a configuration page.
- Alerts and logging.
User Interface (basic)
- Adding download listeners.
- Manipulating download objects.
- Manipulating torrents.
- Storing values on objects.
- Adding torrents and downloads.
User Interface (advanced)
- More interesting things to do with menus and tables.
- Getting text input and sending messages to users.
- Providing interface-specific behaviour.
- Creating a status entry.
- Creating log views and using views.