openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars-Fredrik Smedberg <itsme...@gmail.com>
Subject Re: Question on @ApplicationScoped beans
Date Mon, 14 Apr 2014 19:52:59 GMT
Hi Mark

So if I understood it correctly  @ApplicationScoped bean just @Inject
MyExtension myExt... and the MyExtension class could just examine the
classes and their annotation in the ProcessAnnotatedType event (as I
already do)?

Thanks for pointing that out, will try it out, it will also simplify the
code I think

Thanks again!

Regards
Lars-Fredrik
On Apr 14, 2014 9:46 PM, "Mark Struberg" <struberg@yahoo.de> wrote:

> Hi Lars!
>
> you don't need to do this.
>
>
> You should be able to @Inject the Extension in any bean you like. And if
> your Extension has a getter with the found beans, then you will have direct
> access.
> This is perfectly conform to the spec and must work on all containers. We
> use the same trick in DeltaSpike.
>
> LieGrue,
> strub
>
>   On Monday, 14 April 2014, 17:36, Lars-Fredrik Smedberg <
> itsmeden@gmail.com> wrote:
>
> Hi Mark
> Sorry I misunderstood you. We want to at startup create a JAXBContext for
> all classes that has a specific annotation. This JAXBContext we later want
> to use in a specific factory class in a @Produces method.
> The version we have now initialize an @ApplicationScoped bean in
> AfterbeanDiscovery and sets the found classes in a method call to that
> bean.
> Regards
> Lars-Fredrik
> On Apr 14, 2014 5:23 PM, "Mark Struberg" <struberg@yahoo.de> wrote:
>
> Hi!
>
> Again: You should NOT fire a CDI event in AfterBeanDiscovery. The reason
> is that the Contexts may not have been started at this stage.
> E.g. you will not find any @SessionScoped contextual instance that way...
>
> Maybe you start explaining the use case you have. What is the problem you
> like to solve?
>
>
> LieGrue,
> strub
>
>
>   On Monday, 14 April 2014, 16:33, Lars-Fredrik Smedberg <
> itsmeden@gmail.com> wrote:
>
> Hi again
>
> Maybe I was not all clear in my question. My question is:
>
> - In my extension class, when observering CDI container events when (when
> observing what type of events) is it okay to fire an CDI event that will
> reach all CDI managed beans observing the same event?
>
> Regards
> Lars-Fredrik Smedberg
>
>
>
>
> On Fri, Apr 11, 2014 at 3:39 PM, Lars-Fredrik Smedberg <itsmeden@gmail.com
> > wrote:
>
> Hi Mark
>
> So I could fire a CDI event in the AfterDeploymentValidation method in my
> CDI Extension and @Observe the same type of event in my @ApplicationScoped
> bean? Is there any possibility that the CDI event will be fired and not
> seen by the bean in this case? I don't know the details here about when I
> can fire the events and who will see them if its done in a CDI Extension
> during startup.
>
> Thanks for the help so far
>
> Regards
> Lars-Fredrik
>
>
> On Fri, Apr 11, 2014 at 3:33 PM, Mark Struberg <struberg@yahoo.de> wrote:
>
> simply via a CDI event probably?
>
> LieGrue,
> strub
>
>   On Friday, 11 April 2014, 15:30, Lars-Fredrik Smedberg <
> itsmeden@gmail.com> wrote:
>
> Hi Mark
>
> Thanks for the answer. Its a shared WAS environment so we will see what
> happens when we do a "hard" restart of all EARs in that WAS.
>
> If I have CDI extension that needs to communicate to the application all
> classes with a certain annotation, how would you suggest to do that
> without doing it the way I do it now, that is initialize a bean in a CDI
> extension in AfterDeploymentValidation?
>
> Regards
> Lars-Fredrik
>
>
> On Fri, Apr 11, 2014 at 2:19 PM, Mark Struberg <struberg@yahoo.de> wrote:
>
> Nope, this MUST NOT happen.
>
> Otoh it's also not supported to initialize any bean in
> AfterDeploymentValidation, as only _after_ that event all the contexts will
> get started.
>
> It's by incident that the ApplicationContext is already started before in
> OWB - but there is nothing in the spec which guarantees this!
>
> It might be some classloader issue as well. I'd open a PMR for it.
>
> LieGrue,
> strub
>
>   On Friday, 11 April 2014, 10:19, Lars-Fredrik Smedberg <
> itsmeden@gmail.com> wrote:
>
> Hi!
>
> We have an @ApplicationScoped bean that is first created in a CDI
> Extension (in a method that @Observes AfterDeploymentValidation) .
> After creation the method calls an init-method (together with some data
> collected in a method @Observes ProcessAnnotatedType) on the
> @ApplicationScoped bean which internally sets a flag. This flag is checked
> by all business methods on the bean (a flag that marks the
> bean as initialized).
>
> There are no other method that explicitly sets the flag to false, the only
> time the flag is false is when the bean has been created the first
> time.
>
> We are running WAS 8.5.5.1 and see in our trace logs that after some time
> the flag is false which indicates that the @ApplicationScoped
> bean has been recreated.
>
> Questions:
>
> - Can @ApplicationScoped beans be recycled/reinitialized somehow? And if
> so under what circumstances?
>
> Regards
> Lars-Fredrik
>
>
>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>
>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>
>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>
>
>
>
>

Mime
View raw message