Package tigase.server

Class AbstractComponentRegistrator<E extends ServerComponent>

    • Field Detail

      • components

        protected java.util.Map<java.lang.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 Detail

      • AbstractComponentRegistrator

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

      • 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​(java.lang.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 java.lang.String newPacketId​(java.lang.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.