2017-10-14 15 views

Répondre

4

Oui, il y a.
C'est ce que je l'utilise quand je besoin d'un singleton, l'application scope haricot a commencé le Deploy:

import javax.ejb.Singleton; 
import javax.ejb.Startup; 
import javax.enterprise.context.ApplicationScoped; 
import javax.inject.Named; 
import javax.annotation.PostConstruct; 

@Named("myBean") 
@ApplicationScoped 
@Startup 
@Singleton 
public class MyBean { 
    @PostConstruct 
    public void postConstruct() {} 
} 

La méthode postConstruct est ajouté si vous avez besoin de code à exécuter en dehors de l'initialisation.