From ebfa86a0cae5c68c58ec71b46d6d7a3bb3f58690 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Sat, 13 Feb 2016 15:32:18 +0000 Subject: [PATCH] Initial config error model and spi - Move into a generic fail fast configuration error model with better exception messages. - Initial move into a public SPI for state machine configuration pojo classes. - new StateMachineModelVerifier interface for generic model verifying. - Relates #103 - Relates #172 - Work is done together for above issues mostly because they relate to each others for config error handling. Meaning we can't really verify configuration if we don't have a proper model describing actual config model. --- .../config/AbstractStateMachineFactory.java | 24 +- .../config/ObjectStateMachineFactory.java | 8 +- .../config/StateMachineBuilder.java | 6 +- .../config/StateMachineConfig.java | 8 +- .../builders/StateMachineConfigBuilder.java | 5 +- .../StateMachineConfigurationBuilder.java | 4 +- .../builders/StateMachineStateBuilder.java | 5 +- .../StateMachineTransitionBuilder.java | 8 +- .../builders/StateMachineTransitions.java | 271 ------------------ .../StateMachineConfiguration.java | 8 +- .../StateMachineFactoryConfiguration.java | 8 +- .../AbstractTransitionConfigurer.java | 4 +- .../DefaultChoiceTransitionConfigurer.java | 6 +- .../DefaultConfigurationConfigurer.java | 4 +- ...aultDistributedStateMachineConfigurer.java | 4 +- .../DefaultForkTransitionConfigurer.java | 4 +- .../DefaultJoinTransitionConfigurer.java | 4 +- .../DefaultSecurityConfigurer.java | 4 +- .../configurers/DefaultStateConfigurer.java | 6 +- .../statemachine/config/model/ChoiceData.java | 70 +++++ .../model/DefaultStateMachineModel.java | 60 ++++ .../MalformedConfigurationException.java | 113 ++++++++ .../config/{ => model}/StateData.java | 11 +- .../StateMachineConfigurationConfig.java | 5 +- .../config/model/StateMachineModel.java | 48 ++++ .../StateMachineStates.java | 5 +- .../config/model/StateMachineTransitions.java | 89 ++++++ .../config/model/TransitionData.java | 148 ++++++++++ .../model/verifier/BaseStructureVerifier.java | 85 ++++++ .../CompositeStateMachineModelVerifier.java | 46 +++ .../DefaultStateMachineModelVerifier.java | 33 +++ .../verifier/StateMachineModelVerifier.java | 36 +++ .../support/AbstractCompositeItems.java | 75 +++++ .../support/OrderedCompositeItem.java | 117 ++++++++ .../config/ConfigurationErrorTests.java | 91 ++++++ .../config/ManualBuilderTests.java | 6 +- .../DefaultStateConfigurerTests.java | 4 +- 37 files changed, 1097 insertions(+), 336 deletions(-) delete mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitions.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/ChoiceData.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/DefaultStateMachineModel.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/MalformedConfigurationException.java rename spring-statemachine-core/src/main/java/org/springframework/statemachine/config/{ => model}/StateData.java (95%) rename spring-statemachine-core/src/main/java/org/springframework/statemachine/config/{builders => model}/StateMachineConfigurationConfig.java (96%) create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineModel.java rename spring-statemachine-core/src/main/java/org/springframework/statemachine/config/{builders => model}/StateMachineStates.java (87%) create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineTransitions.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/BaseStructureVerifier.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/CompositeStateMachineModelVerifier.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/DefaultStateMachineModelVerifier.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/StateMachineModelVerifier.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/support/AbstractCompositeItems.java create mode 100644 spring-statemachine-core/src/main/java/org/springframework/statemachine/support/OrderedCompositeItem.java create mode 100644 spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ConfigurationErrorTests.java diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java index 92e932ea..5512f68f 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,16 @@ import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.access.StateMachineAccess; import org.springframework.statemachine.access.StateMachineFunction; import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; -import org.springframework.statemachine.config.builders.StateMachineStates; -import org.springframework.statemachine.config.builders.StateMachineTransitions; -import org.springframework.statemachine.config.builders.StateMachineTransitions.ChoiceData; -import org.springframework.statemachine.config.builders.StateMachineTransitions.TransitionData; +import org.springframework.statemachine.config.model.ChoiceData; +import org.springframework.statemachine.config.model.DefaultStateMachineModel; +import org.springframework.statemachine.config.model.StateData; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineModel; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; +import org.springframework.statemachine.config.model.TransitionData; +import org.springframework.statemachine.config.model.verifier.CompositeStateMachineModelVerifier; +import org.springframework.statemachine.config.model.verifier.StateMachineModelVerifier; import org.springframework.statemachine.ensemble.DistributedStateMachine; import org.springframework.statemachine.listener.StateMachineListener; import org.springframework.statemachine.region.Region; @@ -97,6 +102,10 @@ public abstract class AbstractStateMachineFactory extends LifecycleObjectS private String beanName; + // TODO: we want to make this configurable via annotation model + // so that user can turn it off or customise + private final StateMachineModelVerifier verifier = new CompositeStateMachineModelVerifier(); + /** * Instantiates a new enum state machine factory. * @@ -119,6 +128,9 @@ public abstract class AbstractStateMachineFactory extends LifecycleObjectS @SuppressWarnings("unchecked") @Override public StateMachine getStateMachine() { + // TODO: should pass model into constructor + StateMachineModel model = new DefaultStateMachineModel<>(stateMachineConfigurationConfig, stateMachineStates, stateMachineTransitions); + verifier.verify(model); // shared DefaultExtendedState defaultExtendedState = new DefaultExtendedState(); diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/ObjectStateMachineFactory.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/ObjectStateMachineFactory.java index a196a95e..b86ee7ca 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/ObjectStateMachineFactory.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/ObjectStateMachineFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ import org.springframework.statemachine.ExtendedState; import org.springframework.statemachine.ObjectStateMachine; import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; -import org.springframework.statemachine.config.builders.StateMachineStates; -import org.springframework.statemachine.config.builders.StateMachineTransitions; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.statemachine.region.Region; import org.springframework.statemachine.state.ObjectState; import org.springframework.statemachine.state.PseudoState; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineBuilder.java index d0766c30..09bc2e94 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineBuilder.java @@ -21,17 +21,17 @@ import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.StateMachineException; import org.springframework.statemachine.config.builders.StateMachineConfigBuilder; import org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer; import org.springframework.statemachine.config.builders.StateMachineConfigurer; import org.springframework.statemachine.config.builders.StateMachineStateBuilder; import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; -import org.springframework.statemachine.config.builders.StateMachineStates; import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AnnotationBuilder; import org.springframework.statemachine.config.common.annotation.ObjectPostProcessor; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; /** * {@code StateMachineBuilder} provides a builder pattern for diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineConfig.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineConfig.java index e6116944..4a90e1e3 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineConfig.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateMachineConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package org.springframework.statemachine.config; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; -import org.springframework.statemachine.config.builders.StateMachineStates; -import org.springframework.statemachine.config.builders.StateMachineTransitions; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; public class StateMachineConfig { diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigBuilder.java index 97849333..821a6a08 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,9 @@ package org.springframework.statemachine.config.builders; import org.springframework.statemachine.config.StateMachineConfig; import org.springframework.statemachine.config.common.annotation.AbstractConfiguredAnnotationBuilder; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; public class StateMachineConfigBuilder extends diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationBuilder.java index 9e95b469..04913371 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,8 @@ import org.springframework.statemachine.config.configurers.DefaultDistributedSta import org.springframework.statemachine.config.configurers.DefaultSecurityConfigurer; import org.springframework.statemachine.config.configurers.DistributedStateMachineConfigurer; import org.springframework.statemachine.config.configurers.SecurityConfigurer; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; import org.springframework.statemachine.ensemble.StateMachineEnsemble; import org.springframework.statemachine.listener.StateMachineListener; import org.springframework.statemachine.security.SecurityRule; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStateBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStateBuilder.java index bb93b770..7ebe0a05 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStateBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStateBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,13 @@ package org.springframework.statemachine.config.builders; import java.util.ArrayList; import java.util.Collection; -import org.springframework.statemachine.config.StateData; import org.springframework.statemachine.config.common.annotation.AbstractConfiguredAnnotationBuilder; import org.springframework.statemachine.config.common.annotation.AnnotationBuilder; import org.springframework.statemachine.config.common.annotation.ObjectPostProcessor; import org.springframework.statemachine.config.configurers.DefaultStateConfigurer; import org.springframework.statemachine.config.configurers.StateConfigurer; +import org.springframework.statemachine.config.model.StateData; +import org.springframework.statemachine.config.model.StateMachineStates; /** * {@link AnnotationBuilder} for {@link StateMachineStates}. diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java index 8a22b0b4..0e97de28 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,6 @@ import java.util.List; import java.util.Map; import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.builders.StateMachineTransitions.ChoiceData; -import org.springframework.statemachine.config.builders.StateMachineTransitions.TransitionData; import org.springframework.statemachine.config.common.annotation.AbstractConfiguredAnnotationBuilder; import org.springframework.statemachine.config.common.annotation.AnnotationBuilder; import org.springframework.statemachine.config.common.annotation.ObjectPostProcessor; @@ -39,6 +37,10 @@ import org.springframework.statemachine.config.configurers.ForkTransitionConfigu import org.springframework.statemachine.config.configurers.InternalTransitionConfigurer; import org.springframework.statemachine.config.configurers.JoinTransitionConfigurer; import org.springframework.statemachine.config.configurers.LocalTransitionConfigurer; +import org.springframework.statemachine.config.model.ChoiceData; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineTransitions; +import org.springframework.statemachine.config.model.TransitionData; import org.springframework.statemachine.guard.Guard; import org.springframework.statemachine.security.SecurityRule; import org.springframework.statemachine.transition.TransitionKind; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitions.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitions.java deleted file mode 100644 index c56bd4d6..00000000 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitions.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.statemachine.config.builders; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.guard.Guard; -import org.springframework.statemachine.security.SecurityRule; -import org.springframework.statemachine.transition.TransitionKind; - -/** - * Data object for transitions. - * - * @author Janne Valkealahti - * - * @param the type of state - * @param the type of event - */ -public class StateMachineTransitions { - - private final Collection> transitions; - private final Map>> choices; - private final Map> forks; - private final Map> joins; - - /** - * Instantiates a new state machine transitions. - * - * @param transitions the transitions - * @param choices the choices - * @param forks the forks - * @param joins the joins - */ - public StateMachineTransitions(Collection> transitions, - Map>> choices, Map> forks, Map> joins) { - this.transitions = transitions; - this.choices = choices; - this.forks = forks; - this.joins = joins; - } - - /** - * Gets the transitions. - * - * @return the transitions - */ - public Collection> getTransitions() { - return transitions; - } - - /** - * Gets the choices. - * - * @return the choices - */ - public Map>> getChoices() { - return choices; - } - - /** - * Gets the forks. - * - * @return the forks - */ - public Map> getForks() { - return forks; - } - - /** - * Gets the joins. - * - * @return the joins - */ - public Map> getJoins() { - return joins; - } - - /** - * A simple data object keeping transition related configs in a same place. - * - * @param the type of state - * @param the type of event - */ - public static class TransitionData { - private final S source; - private final S target; - private final S state; - private final E event; - private final Long period; - private final Collection> actions; - private final Guard guard; - private final TransitionKind kind; - private final SecurityRule securityRule; - - /** - * Instantiates a new transition data. - * - * @param source the source - * @param target the target - * @param state the state - * @param event the event - * @param period the period - * @param actions the actions - * @param guard the guard - * @param kind the kind - * @param securityRule the security rule - */ - public TransitionData(S source, S target, S state, E event, Long period, Collection> actions, - Guard guard, TransitionKind kind, SecurityRule securityRule) { - this.source = source; - this.target = target; - this.state = state; - this.event = event; - this.period = period; - this.actions = actions; - this.guard = guard; - this.kind = kind; - this.securityRule = securityRule; - } - - /** - * Gets the source. - * - * @return the source - */ - public S getSource() { - return source; - } - - /** - * Gets the target. - * - * @return the target - */ - public S getTarget() { - return target; - } - - /** - * Gets the state. - * - * @return the state - */ - public S getState() { - return state; - } - - /** - * Gets the event. - * - * @return the event - */ - public E getEvent() { - return event; - } - - /** - * Gets the period. - * - * @return the period - */ - public Long getPeriod() { - return period; - } - - /** - * Gets the actions. - * - * @return the actions - */ - public Collection> getActions() { - return actions; - } - - /** - * Gets the guard. - * - * @return the guard - */ - public Guard getGuard() { - return guard; - } - - /** - * Gets the kind. - * - * @return the kind - */ - public TransitionKind getKind() { - return kind; - } - - /** - * Gets the security rule. - * - * @return the security rule - */ - public SecurityRule getSecurityRule() { - return securityRule; - } - } - - /** - * A simple data object keeping choice related configs in a same place. - * - * @param the type of state - * @param the type of event - */ - public static class ChoiceData { - private final S source; - private final S target; - private final Guard guard; - - /** - * Instantiates a new choice data. - * - * @param source the source - * @param target the target - * @param guard the guard - */ - public ChoiceData(S source, S target, Guard guard) { - this.source = source; - this.target = target; - this.guard = guard; - } - - /** - * Gets the source. - * - * @return the source - */ - public S getSource() { - return source; - } - - /** - * Gets the target. - * - * @return the target - */ - public S getTarget() { - return target; - } - - /** - * Gets the guard. - * - * @return the guard - */ - public Guard getGuard() { - return guard; - } - } - -} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineConfiguration.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineConfiguration.java index a21a3f5c..20446fb6 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineConfiguration.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,12 +35,12 @@ import org.springframework.statemachine.config.ObjectStateMachineFactory; import org.springframework.statemachine.config.StateMachineConfig; import org.springframework.statemachine.config.StateMachineConfigurerAdapter; import org.springframework.statemachine.config.builders.StateMachineConfigBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineConfigurer; -import org.springframework.statemachine.config.builders.StateMachineStates; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AbstractImportingAnnotationConfiguration; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurer; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineFactoryConfiguration.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineFactoryConfiguration.java index 5e7f1aac..e2866c50 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineFactoryConfiguration.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configuration/StateMachineFactoryConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,11 @@ import org.springframework.statemachine.config.StateMachineConfig; import org.springframework.statemachine.config.StateMachineConfigurerAdapter; import org.springframework.statemachine.config.StateMachineFactory; import org.springframework.statemachine.config.builders.StateMachineConfigBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; -import org.springframework.statemachine.config.builders.StateMachineStates; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AbstractImportingAnnotationConfiguration; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurer; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.util.ClassUtils; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java index fa62f85e..c5475a8c 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ import java.util.Collection; import org.springframework.statemachine.action.Action; import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.statemachine.guard.Guard; import org.springframework.statemachine.security.SecurityRule; import org.springframework.statemachine.security.SecurityRule.ComparisonType; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultChoiceTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultChoiceTransitionConfigurer.java index a9577ede..39fc63c2 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultChoiceTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultChoiceTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +20,9 @@ import java.util.List; import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; -import org.springframework.statemachine.config.builders.StateMachineTransitions.ChoiceData; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.ChoiceData; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.statemachine.guard.Guard; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultConfigurationConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultConfigurationConfigurer.java index e9e87689..b78e01d1 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultConfigurationConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultConfigurationConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.TaskScheduler; import org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; import org.springframework.statemachine.listener.StateMachineListener; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultDistributedStateMachineConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultDistributedStateMachineConfigurer.java index 97b7a868..2a2d6051 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultDistributedStateMachineConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultDistributedStateMachineConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ package org.springframework.statemachine.config.configurers; import org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; import org.springframework.statemachine.ensemble.StateMachineEnsemble; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultForkTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultForkTransitionConfigurer.java index a923dab3..5683f8d9 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultForkTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultForkTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import java.util.List; import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineTransitions; /** * Default implementation of a {@link ForkTransitionConfigurer}. diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultJoinTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultJoinTransitionConfigurer.java index 904fd446..43da0cef 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultJoinTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultJoinTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ import java.util.List; import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineTransitions; /** * Default implementation of a {@link JoinTransitionConfigurer}. diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultSecurityConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultSecurityConfigurer.java index 2c4cbb2d..600d7c1a 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultSecurityConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultSecurityConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.springframework.statemachine.config.configurers; import org.springframework.security.access.AccessDecisionManager; import org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; import org.springframework.statemachine.security.SecurityRule; import org.springframework.statemachine.security.SecurityRule.ComparisonType; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurer.java index d9e65d01..ec58bd02 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,11 +24,11 @@ import java.util.Set; import java.util.UUID; import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.StateData; import org.springframework.statemachine.config.builders.StateMachineStateBuilder; import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; -import org.springframework.statemachine.config.builders.StateMachineStates; import org.springframework.statemachine.config.common.annotation.AnnotationConfigurerAdapter; +import org.springframework.statemachine.config.model.StateData; +import org.springframework.statemachine.config.model.StateMachineStates; import org.springframework.statemachine.state.PseudoStateKind; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/ChoiceData.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/ChoiceData.java new file mode 100644 index 00000000..3a5813a2 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/ChoiceData.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +import org.springframework.statemachine.guard.Guard; + +/** + * A simple data object keeping choice related configs in a same place. + * + * @param the type of state + * @param the type of event + */ +public class ChoiceData { + private final S source; + private final S target; + private final Guard guard; + + /** + * Instantiates a new choice data. + * + * @param source the source + * @param target the target + * @param guard the guard + */ + public ChoiceData(S source, S target, Guard guard) { + this.source = source; + this.target = target; + this.guard = guard; + } + + /** + * Gets the source. + * + * @return the source + */ + public S getSource() { + return source; + } + + /** + * Gets the target. + * + * @return the target + */ + public S getTarget() { + return target; + } + + /** + * Gets the guard. + * + * @return the guard + */ + public Guard getGuard() { + return guard; + } +} \ No newline at end of file diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/DefaultStateMachineModel.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/DefaultStateMachineModel.java new file mode 100644 index 00000000..9439d9d4 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/DefaultStateMachineModel.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +/** + * Default implementation of a {@link StateMachineModel}. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public class DefaultStateMachineModel extends StateMachineModel { + + private final StateMachineConfigurationConfig configuration; + private final StateMachineStates states; + private final StateMachineTransitions transitions; + + /** + * Instantiates a new default state machine model. + * + * @param configuration the configuration + * @param states the states + * @param transitions the transitions + */ + public DefaultStateMachineModel(StateMachineConfigurationConfig configuration, StateMachineStates states, + StateMachineTransitions transitions) { + this.configuration = configuration; + this.states = states; + this.transitions = transitions; + } + + @Override + public StateMachineConfigurationConfig getConfiguration() { + return configuration; + } + + @Override + public StateMachineStates getStates() { + return states; + } + + @Override + public StateMachineTransitions getTransitions() { + return transitions; + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/MalformedConfigurationException.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/MalformedConfigurationException.java new file mode 100644 index 00000000..94252225 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/MalformedConfigurationException.java @@ -0,0 +1,113 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +import java.io.IOException; + +import org.springframework.statemachine.StateMachineException; + +/** + * Generic exception indicating ill-formed state machine configuration. + * + * @author Janne Valkealahti + * + */ +public class MalformedConfigurationException extends StateMachineException { + + private static final long serialVersionUID = -1658322647044177891L; + + private StringBuilder trace; + + /** + * Instantiates a new malformed configuration exception. + * + * @param e the e + */ + public MalformedConfigurationException(IOException e) { + super(e); + } + + /** + * Instantiates a new malformed configuration exception. + * + * @param message the message + * @param e the e + */ + public MalformedConfigurationException(String message, Exception e) { + super(message, e); + } + + /** + * Instantiates a new malformed configuration exception. + * + * @param message the message + * @param cause the cause + */ + public MalformedConfigurationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Instantiates a new malformed configuration exception. + * + * @param message the message + */ + public MalformedConfigurationException(String message) { + super(message); + } + + /** + * Instantiates a new malformed configuration exception. + * + * @param message the message + * @param infos the infos + */ + public MalformedConfigurationException(String message, String... infos) { + super(message); + for (String info : infos) { + addTrace(info); + } + } + + @Override + public String getMessage() { + if (trace == null) return super.getMessage(); + StringBuilder buffer = new StringBuilder(512); + buffer.append(super.getMessage()); + if (buffer.length() > 0) { + buffer.append('\n'); + } + buffer.append("Statemachine trace:"); + buffer.append(trace); + return buffer.toString(); + } + + /** + * Adds a trace info into this exception. + * + * @param info the info + */ + public void addTrace(String info) { + if (info == null) { + throw new IllegalArgumentException("info cannot be null."); + } + if (trace == null) { + trace = new StringBuilder(256); + } + trace.append('\n'); + trace.append(info); + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateData.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateData.java similarity index 95% rename from spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateData.java rename to spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateData.java index 74162987..62f32c94 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/StateData.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateData.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.statemachine.config; +package org.springframework.statemachine.config.model; import java.util.Collection; import org.springframework.statemachine.action.Action; +import org.springframework.statemachine.config.StateMachineFactory; import org.springframework.statemachine.state.PseudoStateKind; import org.springframework.statemachine.state.State; @@ -61,7 +62,7 @@ public class StateData { public Collection getDeferred() { return deferred; } - + public void setDeferred(Collection deferred) { this.deferred = deferred; } @@ -69,7 +70,7 @@ public class StateData { public Collection> getEntryActions() { return entryActions; } - + public void setEntryActions(Collection> entryActions) { this.entryActions = entryActions; } @@ -77,7 +78,7 @@ public class StateData { public Collection> getExitActions() { return exitActions; } - + public void setExitActions(Collection> exitActions) { this.exitActions = exitActions; } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationConfig.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineConfigurationConfig.java similarity index 96% rename from spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationConfig.java rename to spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineConfigurationConfig.java index dc2ee950..3bd899a0 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineConfigurationConfig.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineConfigurationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.statemachine.config.builders; +package org.springframework.statemachine.config.model; import java.util.List; @@ -21,6 +21,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.TaskScheduler; import org.springframework.security.access.AccessDecisionManager; +import org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder; import org.springframework.statemachine.ensemble.StateMachineEnsemble; import org.springframework.statemachine.listener.StateMachineListener; import org.springframework.statemachine.security.SecurityRule; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineModel.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineModel.java new file mode 100644 index 00000000..93ab7cc8 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineModel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +/** + * Base abstract SPI class for state machine configuration. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public abstract class StateMachineModel { + + /** + * Gets the configuration config. + * + * @return the configuration config + */ + public abstract StateMachineConfigurationConfig getConfiguration(); + + /** + * Gets the states config. + * + * @return the states config + */ + public abstract StateMachineStates getStates(); + + /** + * Gets the transitions config. + * + * @return the transitions config + */ + public abstract StateMachineTransitions getTransitions(); +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStates.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineStates.java similarity index 87% rename from spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStates.java rename to spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineStates.java index 20aca89a..725de1de 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineStates.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineStates.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.statemachine.config.builders; +package org.springframework.statemachine.config.model; import java.util.Collection; -import org.springframework.statemachine.config.StateData; import org.springframework.statemachine.config.configurers.StateConfigurer; /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineTransitions.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineTransitions.java new file mode 100644 index 00000000..4097c40e --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/StateMachineTransitions.java @@ -0,0 +1,89 @@ +/* + * Copyright 2015-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * Data object for transitions. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public class StateMachineTransitions { + + private final Collection> transitions; + private final Map>> choices; + private final Map> forks; + private final Map> joins; + + /** + * Instantiates a new state machine transitions. + * + * @param transitions the transitions + * @param choices the choices + * @param forks the forks + * @param joins the joins + */ + public StateMachineTransitions(Collection> transitions, + Map>> choices, Map> forks, Map> joins) { + this.transitions = transitions; + this.choices = choices; + this.forks = forks; + this.joins = joins; + } + + /** + * Gets the transitions. + * + * @return the transitions + */ + public Collection> getTransitions() { + return transitions; + } + + /** + * Gets the choices. + * + * @return the choices + */ + public Map>> getChoices() { + return choices; + } + + /** + * Gets the forks. + * + * @return the forks + */ + public Map> getForks() { + return forks; + } + + /** + * Gets the joins. + * + * @return the joins + */ + public Map> getJoins() { + return joins; + } + +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java new file mode 100644 index 00000000..9e0fb987 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java @@ -0,0 +1,148 @@ +/* + * Copyright 2015-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model; + +import java.util.Collection; + +import org.springframework.statemachine.action.Action; +import org.springframework.statemachine.guard.Guard; +import org.springframework.statemachine.security.SecurityRule; +import org.springframework.statemachine.transition.TransitionKind; + +/** + * A simple data object keeping transition related configs in a same place. + * + * @param the type of state + * @param the type of event + */ +public class TransitionData { + private final S source; + private final S target; + private final S state; + private final E event; + private final Long period; + private final Collection> actions; + private final Guard guard; + private final TransitionKind kind; + private final SecurityRule securityRule; + + /** + * Instantiates a new transition data. + * + * @param source the source + * @param target the target + * @param state the state + * @param event the event + * @param period the period + * @param actions the actions + * @param guard the guard + * @param kind the kind + * @param securityRule the security rule + */ + public TransitionData(S source, S target, S state, E event, Long period, Collection> actions, + Guard guard, TransitionKind kind, SecurityRule securityRule) { + this.source = source; + this.target = target; + this.state = state; + this.event = event; + this.period = period; + this.actions = actions; + this.guard = guard; + this.kind = kind; + this.securityRule = securityRule; + } + + /** + * Gets the source. + * + * @return the source + */ + public S getSource() { + return source; + } + + /** + * Gets the target. + * + * @return the target + */ + public S getTarget() { + return target; + } + + /** + * Gets the state. + * + * @return the state + */ + public S getState() { + return state; + } + + /** + * Gets the event. + * + * @return the event + */ + public E getEvent() { + return event; + } + + /** + * Gets the period. + * + * @return the period + */ + public Long getPeriod() { + return period; + } + + /** + * Gets the actions. + * + * @return the actions + */ + public Collection> getActions() { + return actions; + } + + /** + * Gets the guard. + * + * @return the guard + */ + public Guard getGuard() { + return guard; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public TransitionKind getKind() { + return kind; + } + + /** + * Gets the security rule. + * + * @return the security rule + */ + public SecurityRule getSecurityRule() { + return securityRule; + } +} \ No newline at end of file diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/BaseStructureVerifier.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/BaseStructureVerifier.java new file mode 100644 index 00000000..9d63d2df --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/BaseStructureVerifier.java @@ -0,0 +1,85 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model.verifier; + +import java.util.Iterator; + +import org.springframework.statemachine.config.model.MalformedConfigurationException; +import org.springframework.statemachine.config.model.StateData; +import org.springframework.statemachine.config.model.StateMachineModel; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.support.tree.Tree; +import org.springframework.statemachine.support.tree.Tree.Node; +import org.springframework.statemachine.support.tree.TreeTraverser; + +/** + * {@link StateMachineModelVerifier} which verifies a base model structure + * like existence of initial states, etc. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public class BaseStructureVerifier implements StateMachineModelVerifier { + + @Override + public void verify(StateMachineModel model) { + // TODO: just a base root initial state check for now + // further development needed + Iterator>> iterator = buildStateDataIterator(model.getStates()); + while (iterator.hasNext()) { + Node> node = iterator.next(); + if (node.getData() == null) { + boolean initialStateFound = false; + for (Node> n : node.getChildren()) { + StateData data = n.getData(); + if (data.isInitial()) { + initialStateFound = true; + } + } + if (!initialStateFound) { + MalformedConfigurationException exception = new MalformedConfigurationException("Initial state not set"); + for (Node> c : node.getChildren()) { + exception.addTrace(c.getData().toString()); + } + throw exception; + } + } + } + } + + private Iterator>> buildStateDataIterator(StateMachineStates stateMachineStates) { + Tree> tree = new Tree>(); + + for (StateData stateData : stateMachineStates.getStateDatas()) { + Object id = stateData.getState(); + Object parent = stateData.getParent(); + tree.add(stateData, id, parent); + } + + TreeTraverser>> traverser = new TreeTraverser>>() { + @Override + public Iterable>> children(Node> root) { + return root.getChildren(); + } + }; + + Iterable>> postOrderTraversal = traverser.postOrderTraversal(tree.getRoot()); + Iterator>> iterator = postOrderTraversal.iterator(); + return iterator; + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/CompositeStateMachineModelVerifier.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/CompositeStateMachineModelVerifier.java new file mode 100644 index 00000000..65cb7c60 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/CompositeStateMachineModelVerifier.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model.verifier; + +import java.util.Iterator; + +import org.springframework.statemachine.config.model.StateMachineModel; +import org.springframework.statemachine.support.AbstractCompositeItems; + +/** + * Implementation of a {@link StateMachineModelVerifier} backed by a multiple verifiers. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public class CompositeStateMachineModelVerifier extends AbstractCompositeItems> + implements StateMachineModelVerifier { + + public CompositeStateMachineModelVerifier() { + super(); + register(new BaseStructureVerifier()); + } + + @Override + public void verify(StateMachineModel model) { + for (Iterator> iterator = getItems().reverse(); iterator.hasNext();) { + StateMachineModelVerifier verifier = iterator.next(); + verifier.verify(model); + } + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/DefaultStateMachineModelVerifier.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/DefaultStateMachineModelVerifier.java new file mode 100644 index 00000000..6c390ba7 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/DefaultStateMachineModelVerifier.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model.verifier; + +import org.springframework.statemachine.config.model.StateMachineModel; + +/** + * Default implementation of a {@link StateMachineModelVerifier}. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public class DefaultStateMachineModelVerifier implements StateMachineModelVerifier { + + @Override + public void verify(StateMachineModel model) { + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/StateMachineModelVerifier.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/StateMachineModelVerifier.java new file mode 100644 index 00000000..e1b9dc71 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/verifier/StateMachineModelVerifier.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config.model.verifier; + +import org.springframework.statemachine.config.model.StateMachineModel; + +/** + * Strategy interface for implementations verifying {@link StateMachineModel} structures. + * + * @author Janne Valkealahti + * + * @param the type of state + * @param the type of event + */ +public interface StateMachineModelVerifier { + + /** + * Verify a state machine model. + * + * @param model the state machine model + */ + void verify(StateMachineModel model); +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/AbstractCompositeItems.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/AbstractCompositeItems.java new file mode 100644 index 00000000..28e6c507 --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/AbstractCompositeItems.java @@ -0,0 +1,75 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.support; + +import java.util.List; + +/** + * Base implementation for all composite items. + * + * @author Janne Valkealahti + * + * @param the type of the item + */ +public class AbstractCompositeItems { + + /** List of ordered composite items */ + private OrderedCompositeItem items; + + /** + * Constructs instance with an empty item list. + */ + public AbstractCompositeItems() { + items = new OrderedCompositeItem(); + } + + /** + * Sets the list of items. This clears + * all existing items. + * + * @param items the new items + */ + public void setItems(List items) { + this.items.setItems(items); + } + + /** + * Register a new item. + * + * @param item the item + */ + public void register(T item) { + items.add(item); + } + + /** + * Unregister a item. + * + * @param item the item + */ + public void unregister(T item) { + items.remove(item); + } + + /** + * Gets the items. + * + * @return the items + */ + public OrderedCompositeItem getItems() { + return items; + } +} diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/OrderedCompositeItem.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/OrderedCompositeItem.java new file mode 100644 index 00000000..d8675bde --- /dev/null +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/support/OrderedCompositeItem.java @@ -0,0 +1,117 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.support; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; + +import org.springframework.core.Ordered; +import org.springframework.core.annotation.AnnotationAwareOrderComparator; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.core.annotation.Order; + +/** + * Composite item which can be used in other components which + * may want to allow automatic and annotation based ordering. + * Good use case is a list of listeners where user may want + * to place some of them to be processed before the others. + * + * @author Janne Valkealahti + * + * @param the type of the item + */ +public class OrderedCompositeItem { + + private List unordered = new ArrayList(); + private List ordered = new ArrayList(); + private Comparator comparator = new AnnotationAwareOrderComparator(); + private List list = new ArrayList(); + + /** + * Public setter for the listeners. + * + * @param items items + */ + public void setItems(List items) { + unordered.clear(); + ordered.clear(); + for (S s : items) { + add(s); + } + } + + /** + * Register additional item. + * + * @param item item + */ + public void add(S item) { + if (item instanceof Ordered) { + if (!ordered.contains(item)) { + ordered.add(item); + } + } else if (AnnotationUtils.isAnnotationDeclaredLocally(Order.class, item.getClass())) { + if (!ordered.contains(item)) { + ordered.add(item); + } + } else if (!unordered.contains(item)) { + unordered.add(item); + } + Collections.sort(ordered, comparator); + list.clear(); + list.addAll(ordered); + list.addAll(unordered); + } + + /** + * Unregister item. + * + * @param item item + */ + public void remove(S item) { + ordered.remove(item); + unordered.remove(item); + Collections.sort(ordered, comparator); + list.clear(); + list.addAll(ordered); + list.addAll(unordered); + } + + /** + * Public getter for the list of items. The {@link Ordered} items come + * first, followed by any unordered ones. + * + * @return an iterator over the list of items + */ + public Iterator iterator() { + return new ArrayList(list).iterator(); + } + + /** + * Public getter for the list of items in reverse. The {@link Ordered} items + * come last, after any unordered ones. + * + * @return an iterator over the list of items + */ + public Iterator reverse() { + ArrayList result = new ArrayList(list); + Collections.reverse(result); + return result.iterator(); + } +} diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ConfigurationErrorTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ConfigurationErrorTests.java new file mode 100644 index 00000000..53cfcbe5 --- /dev/null +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ConfigurationErrorTests.java @@ -0,0 +1,91 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.statemachine.config; + +import static org.hamcrest.Matchers.isA; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.statemachine.AbstractStateMachineTests; +import org.springframework.statemachine.config.StateMachineBuilder.Builder; +import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; +import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; +import org.springframework.statemachine.config.model.MalformedConfigurationException; + +public class ConfigurationErrorTests extends AbstractStateMachineTests { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Override + protected AnnotationConfigApplicationContext buildContext() { + return new AnnotationConfigApplicationContext(); + } + + @Test + public void testFoo1() { + expectedException.expectCause(isA(MalformedConfigurationException.class)); + context.register(Config1.class); + context.refresh(); + } + + @Test + public void testFoo2() throws Exception { + expectedException.expectCause(isA(MalformedConfigurationException.class)); + Builder builder = StateMachineBuilder.builder(); + builder + .configureStates() + .withStates() + .state("S1") + .state("S2"); + builder + .configureTransitions() + .withExternal() + .source("S1") + .target("S2") + .event("E1"); + + builder.build(); + } + + @Configuration + @EnableStateMachine + public static class Config1 extends StateMachineConfigurerAdapter { + // initial state not set + + @Override + public void configure(StateMachineStateConfigurer states) throws Exception { + states + .withStates() + //.initial("S1") + .state("S1") + .state("S2"); + } + + @Override + public void configure(StateMachineTransitionConfigurer transitions) throws Exception { + transitions + .withExternal() + .source("S1") + .target("S2") + .event("E1"); + } + } + +} diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ManualBuilderTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ManualBuilderTests.java index cd484e87..24a47156 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ManualBuilderTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/ManualBuilderTests.java @@ -33,11 +33,11 @@ import org.springframework.statemachine.StateMachineSystemConstants; import org.springframework.statemachine.TestUtils; import org.springframework.statemachine.config.StateMachineBuilder.Builder; import org.springframework.statemachine.config.builders.StateMachineConfigBuilder; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfig; import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; -import org.springframework.statemachine.config.builders.StateMachineStates; import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitions; +import org.springframework.statemachine.config.model.StateMachineConfigurationConfig; +import org.springframework.statemachine.config.model.StateMachineStates; +import org.springframework.statemachine.config.model.StateMachineTransitions; import org.springframework.statemachine.listener.StateMachineListenerAdapter; import org.springframework.statemachine.state.State; diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurerTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurerTests.java index 738b076a..ab85ec25 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurerTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/configurers/DefaultStateConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ import org.springframework.statemachine.AbstractStateMachineTests.TestEvents; import org.springframework.statemachine.AbstractStateMachineTests.TestExitAction; import org.springframework.statemachine.AbstractStateMachineTests.TestStates; import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.StateData; import org.springframework.statemachine.config.builders.StateMachineStateBuilder; +import org.springframework.statemachine.config.model.StateData; import org.springframework.statemachine.state.PseudoStateKind; public class DefaultStateConfigurerTests {