Chapter 3. Basic Information
Prev |  | Next

# Chapter 3. Basic Information

Artur Hefczyc <artur.hefczyc@tigase.net> v2.0, June 2014: Reformatted for AsciiDoc. :toc: :numbered: :website: http://tigase.net/ :Date: 2010-04-06 21:22

## Tigase Server Elements

To make it easier to get into the code below are defined basic terms in Tigase server world and there is a brief explanation how the server is designed and implemented. This document also points you to basic interfaces and implementations which can be used as example code reference.

Logically all server code can be divided into 3 kinds of modules: components, plug-ins and connectors.

1. Component is the main element of Tigase server is. Component is a bigger piece of code which can have separate address, can receive and send stanzas, can be configured and respond to numerous events. Sample components implemented for Tigase server are: c2s connection manager, s2s connection manager, session manager, XEP-0114 - external component connection manager, MUC - multi user char rooms.
2. Plug-in is usually small piece of code responsible for processing particular XMPP stanza. It doesn’t have own address. As a result of stanza processing it can produce new XMPP stanzas. Plug-ins are loaded by session manager component or c2s connection manager component. Sample plug-ins are: vCard stanza processing, jabber:iq:register to register new user accounts, presence stanza processing, jabber:iq:auth for non-sasl authentication and so on…​.
3. Connector is a module responsible to for access to data repository like database, LDAP to store and retrieve user data. There are 2 kinds of connectors: authentication connectors and user data connectors. Both of them are independent and can connect to different data sources. Sample connectors are: JDBC database connector, XMLDB - embedded database connector, Drupal database connector, LibreSource database connector.

There is API defined for each kind of above modules and all you have to do is implementation of specific interface. Then the module can be loaded to the server based on configuration settings. There are also available abstract classes implementing these interfaces to make development easier.

Here is a brief list of all interfaces to look at and for more details you have to refer to the guide for specific kind of module.

### Component

This is list of interfaces to look at when you work on a new component:

1. tigase.server.ServerComponent - this is the very basic interface for component. All components must implement it.
2. tigase.server.MessageReceiver - this interface extends `ServerComponent` and is required to implement by components which want to receive data packets like session manager, c2s connection manager and so on…​
3. tigase.conf.Configurable - implementing this interface is required to make it configurable. For each object of this type configuration is pushed to it at any time at runtime. This is necessary to make it possible to change configuration at runtime. Implementation should be careful enough to handle this properly.
4. tigase.disco.XMPPService - Objects of which inherit this interface can respond to "ServiceDiscovery" requests.
5. tigase.stats.StatisticsContainer - Objects which inherits this type can return runtime statistics. Any object can collect job statistics and implementing this interface guarantees that statistics will be presented in consisted way to user who wants to see them.

Instead of implementing above interfaces directly I would recommend to extend one of existing abstract classes which take care of the most of "dirty and boring" stuff. Here is a list the most useful abstract classes:

- tigase.server.AbstractMessageReceiver - implements 4 basic interfaces:

  `ServerComponent`, `MessageReceiver`, `Configurable` and `StatisticsContainer`. It also manages internal data queues using own threads which prevents from dead-locks. It offers even-driven data processing which means whenever packet arrives `abstract void processPacket(Packet packet);` method is called to process it. You have to implement this abstract method in your component. If your component wants to send a packet (in response to data it received for example) it needs to call

      boolean addOutPacket(Packet packet)

  method. This is it, I mean basic implementation.

- tigase.server.ConnectionManager - this is an extension of `AbstractMessageReceiver` abstract class. As its name says this class takes care of all network connection management stuff. If your component needs to send and receive data directly from the network (like c2s connection, s2s connection or external component) you should use this implementation as a basic class. It takes care of all things related to networking, I/O, reconnecting, listening on socket, connecting and so on. If you extend this class you have to expect data coming from to sources: from the `MessageRouter` and this is when

      abstract void processPacket(Packet packet);

  method is called and from network connection and then

      abstract Queue processSocketData(XMPPIOService serv);

  method is called.

### Plug-in

All Tigase plugins currently implemented are located in package: tigase.xmpp.impl. You can use this code as a sample code base. There are 3 types of plug-ins and they are defined in interfaces located in `tigase.xmpp` package:

1. XMPPProcessorIfc - the most important and basic plug-in. This is the most common plug-in type which just processes stanzas in normal mode. It receives packets, processes them on behalf of the user and returns resulting stanzas.
2. XMPPPreprocessorIfc -
3. XMPPPostprocessorIfc -

Prev |  | Next
Chapter 2. Tigase DB Schema Explained | Home | Connector