Package tigase.server

Class AbstractComponentRegistrator<E extends ServerComponent>

java.lang.Object
tigase.server.BasicComponent
tigase.server.AbstractComponentRegistrator<E>
All Implemented Interfaces:
ClusteredComponentIfc, Configurable, XMPPService, ConfigurationChangedAware, Initializable, ComponentRegistrator, ServerComponent, VHostListener
Direct Known Subclasses:
ClusterController, ConfiguratorAbstract, StatisticsCollector, VHostManager, XMPPServiceCollector

public abstract class AbstractComponentRegistrator<E extends ServerComponent> extends BasicComponent implements ComponentRegistrator
This is an archetype of a special types of classes which collect some data from Tigase components or provide these data to components. They normally do not process normall packets and are usually accessed by admins via ad-hoc commands. Good examples of such components are StatisticsCollector or Configurator.
Extensions of these class can process packets addresses to the component via processPacket(Packet packet, Queue<Packet> results) method. Alternatively scripting API can be used via ad-hoc commands.
The class does not have any queues buffering packets or separate threads for packets processing. All packets are processed from MessageRouter threads via processPacket(Packet packet, Queue<Packet> results) method. Hence this is important that processing implemented in extensions to the class does not take long time. In particular no DB processing is expected.
Created: Tue Nov 22 22:57:44 2005
Author:
Artur Hefczyc
  • Field Details

    • components

      protected Map<String,E extends ServerComponent> components
      A collection of server components which implement special interface, related to the functionality provided by extension of the class.
  • Constructor Details

    • AbstractComponentRegistrator

      public AbstractComponentRegistrator()
      Creates a new AbstractComponentRegistrator instance.
  • Method Details

    • componentAdded

      public abstract void componentAdded(E component) throws ConfigurationException
      Method provides a callback mechanism signaling that a new component implementing special interface has been added to the internal components collection.
      Parameters:
      component - is a reference to the component just added to the collection.
      Throws:
      ConfigurationException
    • componentRemoved

      public abstract void componentRemoved(E component)
      Method provides a callback mechanism signaling that a component implementing special interface has been removed from the internal components collection.
      Parameters:
      component - is a reference to the component removed from the collection.
    • isCorrectType

      public abstract boolean isCorrectType(ServerComponent component)
      Method checks whether the component provides as method parameter is correct type that is implements special interface or extends special class. Result of the method determines whether the component can be added to the internal components collection.
      Parameters:
      component - is a reference to the component being checked.
      Returns:
      a boolean value of true if the component is of a correct type and false otherwise.
    • addComponent

      public boolean addComponent(ServerComponent component) throws ConfigurationException
      Method checks whether the component is of a correct type, adds it to the internal components collection and calls componentAdded(...) callback.
      Specified by:
      addComponent in interface ComponentRegistrator
      Parameters:
      component - a reference to the component which is being added to the intenal collection.
      Returns:
      a boolean value of true if the component has been added to the internal collection and false otherwise.
      Throws:
      ConfigurationException
    • deleteComponent

      public boolean deleteComponent(ServerComponent component)
      Method removes specified component from the internal components collection and calls componentRemoved(...) callback method.
      Specified by:
      deleteComponent in interface ComponentRegistrator
      Parameters:
      component - is a reference to the component being removed.
      Returns:
      a boolean value of true if the component has been removed from the internal collection and false otherwise.
    • getComponent

      public E getComponent(String name)
      Method returns a component for a specified component name from internal components collection or null of there is no such component in the collection.
      Parameters:
      name - is a String value of the component name.
      Returns:
      a reference to the component found in the internal collection or null if no component has been found.
    • newPacketId

      public String newPacketId(String prefix)
      Method generates and returns an unique packet ID. The ID is unique within running Tigase instance. The method can be overwritten to change the generation of the packet ID.
      Parameters:
      prefix - is a String value of the ID profix or null if no prefix is necessary.
      Returns:
      a String instance of a new packet ID.
    • release

      public void release()
      Description copied from interface: ServerComponent
      Method called when component is being stopped and unloaded.
      Specified by:
      release in interface ServerComponent
      Overrides:
      release in class BasicComponent