Class AbstractComponent

java.lang.Object
org.hobbit.core.components.AbstractComponent
All Implemented Interfaces:
Closeable, AutoCloseable, Component
Direct Known Subclasses:
AbstractCommandReceivingComponent

public abstract class AbstractComponent extends Object implements Component
This abstract class implements basic functionalities of a hobbit component.
Author:
Michael Röder (roeder@informatik.uni-leipzig.de)
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ

      public static final int NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ
      Maximum number of retries that are executed to connect to RabbitMQ.
      See Also:
    • START_WAITING_TIME_BEFORE_RETRY

      public static final long START_WAITING_TIME_BEFORE_RETRY
      Time, the system waits before retrying to connect to RabbitMQ. Note that this time will be multiplied with the number of already failed tries.
      See Also:
    • hobbitSessionId

      private String hobbitSessionId
    • outgoingDataQueuefactory

      protected RabbitQueueFactory outgoingDataQueuefactory
      Factory for creating outgoing data queues.
    • incomingDataQueueFactory

      protected RabbitQueueFactory incomingDataQueueFactory
      Factory for creating outgoing data queues.
    • rabbitMQHostName

      protected String rabbitMQHostName
      The host name of the RabbitMQ broker.
    • connectionFactory

      protected com.rabbitmq.client.ConnectionFactory connectionFactory
      The factory that can be used to create additional connections. However, in most cases it is sufficient to create a new channel using the already existing incomingDataQueueFactory and outgoingDataQueuefactory objects.
    • configuration

      protected HobbitConfiguration configuration
      Configuration that is used by this component.
  • Constructor Details

    • AbstractComponent

      public AbstractComponent()
      Default constructor. It will create a configuration object that is solely relying on environment variables. This is the same as using the following lines of code:
       HobbitConfiguration configuration = new HobbitConfiguration();
       configuration.addConfiguration(new EnvironmentConfiguration());
       AbstractComponent component = new AbstractComponent();
       component.setConfiguration(configuration);
       
  • Method Details

    • init

      public void init() throws Exception
      Description copied from interface: Component
      This method initializes the component.
      Specified by:
      init in interface Component
      Throws:
      Exception - if an error occurs during the initialization
    • createConnection

      protected com.rabbitmq.client.Connection createConnection() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getHobbitSessionId

      public String getHobbitSessionId()
    • generateSessionQueueName

      public String generateSessionQueueName(String queueName)
    • getConfiguration

      public HobbitConfiguration getConfiguration()
      Returns:
      the configuration
    • setConfiguration

      public void setConfiguration(HobbitConfiguration configuration)
      Description copied from interface: Component
      Setter for the configuration that the component should make use of.
      Specified by:
      setConfiguration in interface Component
      Parameters:
      configuration - the configuration that is used by this component