Skip to content

Support actions with transition via choice/junction pseudostate #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jvalkeal opened this issue Sep 10, 2015 · 4 comments
Closed

Support actions with transition via choice/junction pseudostate #108

jvalkeal opened this issue Sep 10, 2015 · 4 comments
Labels
type/enhancement Is an enhancement request
Milestone

Comments

@jvalkeal
Copy link
Contributor

jvalkeal commented Sep 10, 2015

This Pseudostate should not have any actions associated with it but it might make sense to have Action with transition leading into and out from the state itself.

@jvalkeal jvalkeal added the type/enhancement Is an enhancement request label Sep 10, 2015
@rgreig
Copy link

rgreig commented May 3, 2017

This would be very useful. In many cases in the choice pseudostate, you might have a relatively expensive calculation to perform to determine the target state you want to go into. If you try to do this on guards you end up executing that expensive operation multiple times. If you can execute an action going into the pseudostate, you can make it much more efficient by doing all the logic once and setting a variable or adding a field to the header, and then the guards become trivial.

I have read the UML spec for this (2.5) and I don't believe this goes against anything in the spec.

@jvalkeal
Copy link
Contributor Author

jvalkeal commented May 4, 2017

What I've been thinking is to add actions to source, first, then and last methods.

ChoiceTransitionConfigurer<S, E> source(S source);
ChoiceTransitionConfigurer<S, E> source(S source, Action<S, E> action);
ChoiceTransitionConfigurer<S, E> source(S source, Action<S, E> action, Action<S, E> error);

ChoiceTransitionConfigurer<S, E> first(S target, Guard<S, E> guard);
ChoiceTransitionConfigurer<S, E> first(S target, Guard<S, E> guard, Action<S, E> action);
ChoiceTransitionConfigurer<S, E> first(S target, Guard<S, E> guard, Action<S, E> action, Action<S, E> error);

Then javaconfig would look like:

.withChoice()
	.source(TestStates.S3, sIToChoice())
	.first(TestStates.S30, s30Guard(), choiceToS30())
	.then(TestStates.S31, s31Guard())
	.then(TestStates.S32, s32Guard())
	.last(TestStates.S33, choiceToS33(), choiceToS33Error());

With uml you'd just add behaviours to those incoming/outgoing transitions so it looks a bit simpler to configure. I didn't see no reason why outgoing vertex could not have action as well.

@jvalkeal jvalkeal changed the title Support action with transition via choice pseudostate Support actions with transition via choice/junction pseudostate May 5, 2017
@jvalkeal jvalkeal added this to the 1.2.5.RELEASE milestone May 5, 2017
jvalkeal added a commit to jvalkeal/spring-statemachine that referenced this issue May 5, 2017
- Adding support for javaconfig/uml to define
  actions for transitions leading out from a
  choice or junction states.
- Support for action for incoming transition is
  already implemented as it is defined as normal
  transition.
- Fixes spring-projects#108
@jvalkeal
Copy link
Contributor Author

jvalkeal commented May 5, 2017

Merged per cec0d24

@jvalkeal jvalkeal closed this as completed May 5, 2017
jvalkeal added a commit to jvalkeal/spring-statemachine that referenced this issue May 5, 2017
- Adding support for javaconfig/uml to define
  actions for transitions leading out from a
  choice or junction states.
- Support for action for incoming transition is
  already implemented as it is defined as normal
  transition.
- Backport spring-projects#108
- Relates spring-projects#307
@gaurav11007
Copy link

gaurav11007 commented Mar 22, 2018

@jvalkeal :

.withChoice()
.source(TestStates.S3, sIToChoice()) // Here sIToChoice is action for source,right?
.first(TestStates.S30, s30Guard(), choiceToS30())
.then(TestStates.S31, s31Guard())
.then(TestStates.S32, s32Guard())
.last(TestStates.S33, choiceToS33(), choiceToS33Error());

Is this functionality ( Action for Source ) available? If yes then which version? action for guards is available but I am unable to find action for the choice source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Is an enhancement request
Projects
None yet
Development

No branches or pull requests

3 participants