Spring Framework Integration
4/8/24Less than 1 minute
Spring Framework Integration
The DSF uses some of the Spring Framework's functionality. When deployed, every process plugin exists in its own Spring context. Process plugins require Spring Beans with prototype
scope for all classes which either extend or implement the following classes/interfaces:
Activity
DefaultUserTaskListener
ExecutionListener
MessageActivity
MessageEndEvent
MessageIntermediateThrowEvent
MessageSendTask
ServiceTask
UserTaskListener
A Spring-Framework configuration class located in the spring/config
directory is expected to provide the Spring Beans. If you are unfamiliar with the Spring Framework, you can find more information in Java-based Container Configuration of the Spring Framework documentation, specifically the topics Using the @Bean Annotation and Using the @Configuration Annotation.
Below is an example of a Spring configuration class:
@Configuration
public class TutorialConfig
{
@Value("${dev.dsf.process.tutorial.loggingEnabled:false}")
@ProcessDocumentation(description = "Set to true to enable logging", required = false, processNames = PROCESS_NAME_FULL_DIC)
private boolean loggingEnabled; //environment variable
@Value("${dev.dsf.process.tutorial.userVote:false}")
@ProcessDocumentation(description = "Set to true to enable users to vote", required = false, processNames = PROCESS_NAME_FULL_VOTING_PROCESS)
private boolean userVote; //environment variable
//register classes with default constructor as prototype beans
@Bean
public static ActivityPrototypeBeanCreator activityPrototypeBeanCreator()
{
return new ActivityPrototypeBeanCreator(HelloCosMessage.class, CosTask.class, HelloHrpMessage.class,
HrpTask.class, GoodbyeDicMessage.class, StartVotingProcess.class, SelectTargets.class, StartVote.class,
SaveUserVote.class, AutomatedVote.class, PrepareReturnVote.class, ReturnVote.class,
SaveVotingResult.class, SaveTimeoutResult.class, AggregateResults.class);
}
//register classes with custom constructor as prototype beans
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public DicTask dicTask()
{
return new DicTask(loggingEnabled);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public DecideWhetherUserVote decideWhetherUserVote()
{
return new DecideWhetherUserVote(userVote);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public UserVoteListener userVoteListener()
{
return new UserVoteListener();
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public SetCorrelationKeyListener setCorrelationKeyListener()
{
return new SetCorrelationKeyListener();
}
}