Hi it depends the type, if the ServletContext for a war it should be the same - even if the spec doesn't require it. Can you print the instance you get just to ensure?
In any case you have MyService being application scoped so you can store any state there without any static variable. Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2017-05-29 10:18 GMT+02:00 tonywestonuk <[email protected]>: > Hi , > > Im using CDI1.1 initializers and destroyer methods: > > > @ApplicationScoped > public class MyService { > > public void init(@Observes @Initialized(ApplicationScoped.class) obj){ > System.out.println("***INIT "+System.identityHashCode(this)); > } > > public void destroy(@Observes @Destroyed(ApplicationScoped.class) obj){ > System.out.println("***Destroy "+System.identityHashCode(this)); > } > > } > > > In the logs, it shows different identityHashCodes, even though MyService is > ApplicationScoped. > This causes problems if I need to clean up instance variables. > > Is this a bug? Or, should I tidy up instance variables in a different way? > I dont really like using static variables. > > > > > -- > View this message in context: http://tomee-openejb.979440. > n4.nabble.com/CDI-Observes-ApplicationScoped-class-tp4681766.html > Sent from the TomEE Users mailing list archive at Nabble.com. >
