CDI bean that goes up with the application

2

Is there a way to start a CDI bean next to the application

I have the following bean:

@ApplicationScoped
@Named
public class MyBean implements Serializable {

    @Inject
    private Helper helper;

    @PostConstruct
    public void init() {
        helper.doThings();
    }

}

I would like it to be started together with the application, when it is deployed.

I'm using weld-servlet as a cdi implementation and tomcat7:

<dependency>
    <groupId>org.jboss.weld.servlet</groupId>
    <artifactId>weld-servlet</artifactId>
    <version>${weld-servlet.version}</version>
    <scope>compile</scope>
</dependency>
    
asked by anonymous 17.08.2018 / 21:08

0 answers