Skip to content

Instantly share code, notes, and snippets.

@StefanHeimberg
Created December 12, 2015 21:38
Show Gist options
  • Save StefanHeimberg/d0616ef7c3f594204db2 to your computer and use it in GitHub Desktop.
Save StefanHeimberg/d0616ef7c3f594204db2 to your computer and use it in GitHub Desktop.
// https://rmannibucau.wordpress.com/2015/03/10/cdi-and-startup/
@ApplicationScoped
public class ProvisioningDataForApplicationLifecycle {
private final Map<String, User> users = new HashMap<>(); // + getter
public void init(@Observes @Initialized(ApplicationScoped.class) Object init) {
users.put("cdi", new User("cdi", "1.1"));
users.put("deltaspike", new User("deltaspike", "1.3"));
}
public void destroy(@Observes @Destroyed(ApplicationScoped.class) Object init) {
users.clear();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment