Using older non-annotation based implementation
Prev | Chapter 17. Writing Plugin Code | Next

## Using older non-annotation based implementation

The class declaration should look like this (assuming you implement just packet processor):

    public class Message extends XMPPProcessor
       implements XMPPProcessorIfc

The first thing to create is the plugin ID. This is a unique string which you put in the configuration file to tell the server to load and use the plugin. In most cases you can use XMLNS if the plugin wants packets with elements with a very specific name space. Of course there is no guarantee there is no other packet for this specific XML element too. As I want to process all messages and I don’t want to spend whole day on thinking about a cool ID let’s say our ID is: 'message'.

A plugin informs about it’s ID using following code:

    private static final String ID = "message";
    public String id() { return ID; }

As I mentioned before such a plugin receives only this kind of packets for processing which it is interested in. My plugin is interested only in packets with <message/> elements and only if they are in "jabber:client" namespace. To indicate all supported elements and namespaces we have to add 2 more methods:

    public String[] supElements() {
      return new String[] {"message"};
    }

    public String[] supNamespaces()	{
      return new String[] {"jabber:client"};
    }

Prev | Up | Next
Chapter 17. Writing Plugin Code | Home | Implementation of processing method