Class RegisterCalculatorFactoryDecorator

java.lang.Object
org.palladiosimulator.commons.designpatterns.AbstractObservable<CalculatorRegistryListener>
org.palladiosimulator.probeframework.calculator.RegisterCalculatorFactoryDecorator
All Implemented Interfaces:
org.palladiosimulator.commons.designpatterns.IAbstractObservable<CalculatorRegistryListener>, ICalculatorRegistryAccess, IGenericCalculatorFactory, IObservableCalculatorRegistry

public class RegisterCalculatorFactoryDecorator extends org.palladiosimulator.commons.designpatterns.AbstractObservable<CalculatorRegistryListener> implements IGenericCalculatorFactory, IObservableCalculatorRegistry
Decorates an existing ICalculatorFactory by a register for its calculators. In case a calculator is registered in this register, this factory directly returns the calculator from it. Otherwise, a new calculator is instantiated, put into the register, and returned. Furthermore, this class provides convenience methods for cleaning up calculators (detach their probes and cleaning the register; c.f., finish method). Clients can register with this class to be notified upon registrations of new calculators(@see CalculatorRegistryListener).
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    buildCalculator(org.palladiosimulator.metricspec.MetricDescription metric, org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint, CalculatorProbeSet probeConfiguration)
    Creates a new Calculator for the given MetricDescription
    void
    Cleans up all registered calculators informing each calculator about being unregistered and subsequently cleaning the register.
    getCalculatorByMeasuringPointAndMetricDescription(org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint mp, org.palladiosimulator.metricspec.MetricDescription metric)
    Convenience method to get the calculator that is associated with the given measuring point and metric.

    Important note: If a base metric such as 'Response Time' is passed here, and an 'Response Time Tuple' calculator is available at the given measuring point it is NOT found by the current implementation of this method, since these are different metric (base metric vs.
    getCalculatorsForMeasuringPoint(org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint)
    Convenience method to get all calculators associated with the given measuring point.
    Gets the decorated factory.
    Gets the currently registered calculators.

    Methods inherited from class org.palladiosimulator.commons.designpatterns.AbstractObservable

    addObserver, getEventDispatcher, getObservers, removeAllObserver, removeObserver

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.palladiosimulator.commons.designpatterns.IAbstractObservable

    addObserver, removeObserver

    Methods inherited from interface org.palladiosimulator.probeframework.calculator.IObservableCalculatorRegistry

    getObservers
  • Constructor Details

    • RegisterCalculatorFactoryDecorator

      public RegisterCalculatorFactoryDecorator(IGenericCalculatorFactory decoratedFactory)
      Default constructor. Decorates given factory by a register.
      Parameters:
      decoratedFactory - The calculator factory to be decorated.
  • Method Details

    • getDecoratedFactory

      public IGenericCalculatorFactory getDecoratedFactory()
      Gets the decorated factory.
      Returns:
      The ICalculatorFactory that is decorated by this instance.
    • getRegisteredCalculators

      public Collection<Calculator> getRegisteredCalculators()
      Gets the currently registered calculators.
      Specified by:
      getRegisteredCalculators in interface ICalculatorRegistryAccess
      Returns:
      An unmodifiable collection containing the currently registered calculators.
    • getCalculatorByMeasuringPointAndMetricDescription

      public Calculator getCalculatorByMeasuringPointAndMetricDescription(org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint mp, org.palladiosimulator.metricspec.MetricDescription metric)
      Convenience method to get the calculator that is associated with the given measuring point and metric.

      Important note: If a base metric such as 'Response Time' is passed here, and an 'Response Time Tuple' calculator is available at the given measuring point it is NOT found by the current implementation of this method, since these are different metric (base metric vs. metric set)!.
      In such a case, better use ICalculatorRegistryAccess.getCalculatorsForMeasuringPoint(MeasuringPoint) and filter the resulting collection manually for the desired base metric.
      Specified by:
      getCalculatorByMeasuringPointAndMetricDescription in interface ICalculatorRegistryAccess
      Parameters:
      mp - A MeasuringPoint instance which is associated with a calculator.
      metric - A MetricDescription denoting the metric the calculator is accepting.
      Returns:
      A Calculator instance associated with the given measuring point and metric, or null if no matching Calculator is found.
      See Also:
    • getCalculatorsForMeasuringPoint

      public Collection<Calculator> getCalculatorsForMeasuringPoint(org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint)
      Convenience method to get all calculators associated with the given measuring point.
      Specified by:
      getCalculatorsForMeasuringPoint in interface ICalculatorRegistryAccess
      Parameters:
      measuringPoint - A MeasuringPoint instance which is associated with a calculator.
      Returns:
      An UNMODIFIABLE @Collection of Calculators which are associated with the given measuring point, might be empty but never null.
      See Also:
    • finish

      public void finish()
      Cleans up all registered calculators informing each calculator about being unregistered and subsequently cleaning the register.
    • buildCalculator

      public Calculator buildCalculator(org.palladiosimulator.metricspec.MetricDescription metric, org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint, CalculatorProbeSet probeConfiguration)
      Creates a new Calculator for the given MetricDescription
      Specified by:
      buildCalculator in interface IGenericCalculatorFactory
      Parameters:
      metric - the metric which is calculated based on the probe measurements.
      measuringPoint - the measuring point where this calculator is used
      probeConfiguration - the configuration of probes required by the calculator of the metric.
      Returns:
      the desired calculator