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
ConstructorDescriptionRegisterCalculatorFactoryDecorator
(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 MetricDescriptionvoid
finish()
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
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
ICalculatorFactory
that is decorated by this instance.
-
getRegisteredCalculators
Gets the currently registered calculators.- Specified by:
getRegisteredCalculators
in 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:
getCalculatorByMeasuringPointAndMetricDescription
in interfaceICalculatorRegistryAccess
- Parameters:
mp
- AMeasuringPoint
instance which is associated with a calculator.metric
- AMetricDescription
denoting the metric the calculator is accepting.- Returns:
- A
Calculator
instance associated with the given measuring point and metric, ornull
if no matchingCalculator
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 interfaceICalculatorRegistryAccess
- Parameters:
measuringPoint
- AMeasuringPoint
instance which is associated with a calculator.- Returns:
- An UNMODIFIABLE @
Collection
ofCalculator
s 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:
buildCalculator
in 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
-