Class ConfigBasedEnablementStrategy

java.lang.Object
org.chenile.stm.impl.ConfigBasedEnablementStrategy
All Implemented Interfaces:
EnablementStrategy

public class ConfigBasedEnablementStrategy extends Object implements EnablementStrategy
Provides an enablement strategy based on configuration. This requires a configuration provider.
  • Field Details

  • Constructor Details

    • ConfigBasedEnablementStrategy

      public ConfigBasedEnablementStrategy(ConfigProvider configProvider)
    • ConfigBasedEnablementStrategy

      public ConfigBasedEnablementStrategy(ConfigProvider configProvider, String prefix)
  • Method Details

    • setEnabledProperty

      public void setEnabledProperty(String enabledProperty)
    • setAddTransitionProperty

      public void setAddTransitionProperty(String addTransitionProperty)
    • setAddStateProperty

      public void setAddStateProperty(String p)
    • isStateEnabled

      public boolean isStateEnabled(StateDescriptor sd)
      Specified by:
      isStateEnabled in interface EnablementStrategy
    • isEventEnabled

      public boolean isEventEnabled(StateDescriptor sd, EventInformation eventInformation)
      Specified by:
      isEventEnabled in interface EnablementStrategy
      Parameters:
      sd - state descriptor
      eventInformation - - event information
      Returns:

      For every state or event it looks for a property in the configuration which is named after the * state or event. For example to enable state State1 on entity Entity1, we will need Entity1.State1.enabled = true * If this config is missing or set to true then the State is enabled. If it is explicitly set to false * then it is disabled. *

      Similarly, for an event Event1 that belongs to state State1 of entity Entity1 the property * Entity1.State1.Event1.enabled must be explicitly set to false. Else if it is missing or set to true, * then the event is considered enabled.

    • addDynamicTransitions

      public Map<String, Transition> addDynamicTransitions(StateDescriptor sd)
      Specified by:
      addDynamicTransitions in interface EnablementStrategy
      Parameters:
      sd - state descriptor
      Returns:
      Allows for the addition of transitions in the property files.
    • addEventInformationToTransition

      private void addEventInformationToTransition(Transition transition, StateDescriptor sd)
      Parameters:
      transition - - the transition which needs to be enhanced
      sd - the state descriptor to which the transition is attached
    • addMetadataToTransition

      public void addMetadataToTransition(Transition t, StateDescriptor sd)
      Specified by:
      addMetadataToTransition in interface EnablementStrategy
      Parameters:
      t - - the transition
      sd - - the state descriptor Allows for metadata to be added to a transition in property file.
    • getStateInfo

      public StateDescriptor getStateInfo(State state, FlowDescriptor flowDescriptor)
      Specified by:
      getStateInfo in interface EnablementStrategy
    • addDynamicStates

      public Collection<StateDescriptor> addDynamicStates(FlowDescriptor flowInfo)
      Specified by:
      addDynamicStates in interface EnablementStrategy
    • addMetadataToState

      public void addMetadataToState(StateDescriptor sd)
      Specified by:
      addMetadataToState in interface EnablementStrategy
    • propEnabled

      private boolean propEnabled(String prop)