Custom Bean deployment for Task/Rest App

Hey Brian,

You can use the fact that the Flowable apps are now Spring Boot apps and you can create your own auto configuration jar with the required logic. You can then put the jar in the classpath of the servlet container you are using (in case this is tomcat in the tomcat libs folder).

What you can do is to create a jar only with you need add a META-INF/spring.factories file in your jar and in it put:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
  com.your.own.package.YourOwnCustomConfiguration

YourOwnCustomConfiguration would be a normal Spring configuration. In that configuration you can create the bean in a normal way. For example:

@Configuration
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
@ConditionalOnBean(ProcessEngine.class)
public class YourOwnConfiguration {

    @Bean
    public CustomBean customBean() {
        // create your bean
    }
}

With @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) your auto configuration would be scanned last. With @ConditionalOnBean(ProcessEngine.class) your auto configuration would be triggered only if the ProcessEngine bean is present.

In case you want to use XML for your configuration you can still create it in a similar fashion.

@Configuration
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
@ConditionalOnBean(ProcessEngine.class)
public class YourOwnConfiguration {

    @Configuration
    @ImportResource("path-to-your.xml")
    public static class XmlImportResourceConfiguration {
        // This class is needed in order to conditionally import the xml (i.e. when the ProcessEngine bean is present)
    }

    @Bean
    public CustomBean customBean() {
        // create your bean
    }
}

NB: In case you need extra dependencies you will need to provide them as well.

Cheers,
Filip

1 Like