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
ConstructorsConstructorDescriptionRegisterCalculatorFactoryDecorator(IGenericCalculatorFactory decoratedFactory) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionbuildCalculator(org.palladiosimulator.metricspec.MetricDescription metric, org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint, CalculatorProbeSet probeConfiguration) Creates a new Calculator for the given MetricDescriptionvoidfinish()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, removeObserverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.palladiosimulator.commons.designpatterns.IAbstractObservable
addObserver, removeObserverMethods inherited from interface org.palladiosimulator.probeframework.calculator.IObservableCalculatorRegistry
getObservers
-
Constructor Details
-
RegisterCalculatorFactoryDecorator
Default constructor. Decorates given factory by a register.- Parameters:
decoratedFactory- The calculator factory to be decorated.
-
-
Method Details
-
getDecoratedFactory
Gets the decorated factory.- Returns:
- The
ICalculatorFactorythat is decorated by this instance.
-
getRegisteredCalculators
Gets the currently registered calculators.- Specified by:
getRegisteredCalculatorsin interfaceICalculatorRegistryAccess- 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 useICalculatorRegistryAccess.getCalculatorsForMeasuringPoint(MeasuringPoint)and filter the resulting collection manually for the desired base metric.- Specified by:
getCalculatorByMeasuringPointAndMetricDescriptionin interfaceICalculatorRegistryAccess- Parameters:
mp- AMeasuringPointinstance which is associated with a calculator.metric- AMetricDescriptiondenoting the metric the calculator is accepting.- Returns:
- A
Calculatorinstance associated with the given measuring point and metric, ornullif no matchingCalculatoris 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:
getCalculatorsForMeasuringPointin interfaceICalculatorRegistryAccess- Parameters:
measuringPoint- AMeasuringPointinstance which is associated with a calculator.- Returns:
- An UNMODIFIABLE @
CollectionofCalculators which are associated with the given measuring point, might be empty but nevernull. - 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:
buildCalculatorin interfaceIGenericCalculatorFactory- Parameters:
metric- the metric which is calculated based on the probe measurements.measuringPoint- the measuring point where this calculator is usedprobeConfiguration- the configuration of probes required by the calculator of the metric.- Returns:
- the desired calculator
-