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:
AbstractTaskMessageSend
AbstractServiceDelegate
DefaultUserTaskListener
ProcessPluginDeploymentStateListener
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
{
@Autowired
private ProcessPluginApi api; //instance will be injected at runtime
@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 as prototype beans
@Bean
@Scope(SCOPE_PROTOTYPE)
public DicTask dicTask()
{
return new DicTask(api, loggingEnabled);
}
@Bean
@Scope(SCOPE_PROTOTYPE)
public DecideWhetherUserVote decideWhetherUserVote()
{
return new DecideWhetherUserVote(api, userVote);
}
@Bean
@Scope(SCOPE_PROTOTYPE)
public HelloCosMessage helloCosMessage()
{
return new HelloCosMessage(api);
}
@Bean
@Scope(SCOPE_PROTOTYPE)
public UserVoteListener userVoteListener()
{
return new UserVoteListener(api);
}
}