Package org.opensaml.profile.action.impl

# Class PopulateMetricContext

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.impl.PopulateMetricContext

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `ProfileAction`

public class PopulateMetricContext extends AbstractProfileAction
An action that populates a `MetricContext` child of the `ProfileRequestContext` with a set of rules for activating timer measurements and counters on associated objects during the execution of a profile request.

Unlike a more typical "lookup strategy" design used in most other places, the strategy function supplied is free, and indeed expected, to directly manipulate the created child context directly rather than returning the data to use. The function may return false to indicate a lack of success, but this is merely logged.

A side effect of this action is the incrementing of a counter corresponding to the profile running.

Event:
  `EventIds.PROCEED_EVENT_ID`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private class`
`PopulateMetricContext.NullFunction`
Default function to remove the context from the tree when no metrics are installed.

## Field Summary

Fields
Modifier and Type
Field
Description
`private String`
`counterName`
Counter to increment on execution.
`private final org.slf4j.Logger`
`log`
Class logger.
`private Function<ProfileRequestContext,Boolean>`
`metricStrategy`
Strategy function for establishing metric mappings to apply.

## Constructor Summary

Constructors
Constructor
Description
`PopulateMetricContext()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doExecute(ProfileRequestContext profileRequestContext)`
Performs this action.
`protected void`
`doInitialize()`
`void`
`setCounterName(String name)`
Set a counter name to increment.
`void`
`setMetricStrategy(Function<ProfileRequestContext,Boolean> strategy)`
Set strategy to establish the metric mappings to use.

### Methods inherited from class org.opensaml.profile.action.AbstractProfileAction

`doPostExecute, doPostExecute, doPreExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplier`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

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

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### counterName

@Nullable private String counterName
Counter to increment on execution.

### metricStrategy

@NonnullAfterInit private Function<ProfileRequestContext,Boolean> metricStrategy
Strategy function for establishing metric mappings to apply.

## Constructor Details

### PopulateMetricContext

public PopulateMetricContext()

## Method Details

### setCounterName

public void setCounterName(@Nullable String name)
Set a counter name to increment.

Parameters:
  `name` - counter name
Since:
  5.0.0

### setMetricStrategy

public void setMetricStrategy(@Nullable Function<ProfileRequestContext,Boolean> strategy)
Set strategy to establish the metric mappings to use.

Parameters:
  `strategy` - timer mapping strategy

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractInitializableComponent`
Throws:
  `ComponentInitializationException`

### doExecute

protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext)
Performs this action. Actions must override this method to perform their work.

Overrides:
  `doExecute` in class `AbstractProfileAction`
Parameters:
  `profileRequestContext` - the current IdP profile request context