Hi Arne,

Theorically (understand purely technically and not from a spec point of
view) we could make it CDI beans in the sense we could instantiate them
(with some hack to get a cdi instance of the enclosing class(es)) but then
it can't be injected so the only potential usage would be observers,
extensions  - as in cdi se -, or cdi aware instances of any "task"
(Runnable and friends), i.e. beans who are consumers but not consumed by
other beans.

>From a spec point of view a managed bean definition first sentence is: "It
is not an inner class." so it is pretty clear and we are good on that
aspect.

The main issue - and the one I hit - is about our logging when the
anonymous class can't be loaded. We log a warning (#18) which makes the
startup logs looking wrong (I expect only INFO for a valid startup ready to
push in prod). So this thread is mainly enhancing our logging testing the
$[0-9]+ suffix and logging a debug message instead of a warning in such a
case. We can also just reduce the level of this logging probably or make it
configurable in owb.properties. My initial proposal was coming from the
fact the enclosing class has @Vetoed and I wondered if we should inherit it
to the nested (anonymous or not) classes but it is too late in our process
so the pattern test can be saner.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le mar. 31 juil. 2018 à 08:10, Arne Limburg <[email protected]>
a écrit :

> Could still be a static inner class, which may be a CDI-Bean or not?
> If we do such check, we should check name.endsWith("$[any number]"), which
> may never be a static inner class.
>
> Cheers,
> Arne
>
> --
> Arne Limburg ­ Enterprise Architekt
>
>
>
>
>
>
> OPEN KNOWLEDGE GmbH
> Poststraße 1, 26122 Oldenburg
> Tel: +49 441 - 4082-154
> Fax: +49 441 - 4082-111
> [email protected]
> www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> Nächste Konferenz:
>
> Java Forum Nord | Hannover | 13. September 2018
> https://www.openknowledge.de/event/java-forum-nord-2018/
>
> Nächste Akademie:
>
> Software Architecture Summit | Berlin | 10. bis 12. September 2018
>
> https://www.openknowledge.de/event/software-architecture-summit-2018-berlin/
>
> Treffen Sie uns auf weiteren Konferenzen,
> Summits und Events:
> www.openknowledge.de/event
>
>
>
>
> Am 30.07.18, 16:30 schrieb "Romain Manni-Bucau" unter
> <[email protected]>:
>
> >Yep, just through we could use that kind of pattern:
> >
> >try {
> >load();
> >} catch(e) {
> >   if (name.contains("$") log.debug
> >   else log.info
> >}
> >
> >Romain Manni-Bucau
> >@rmannibucau <https://twitter.com/rmannibucau> |  Blog
> ><https://rmannibucau.metawerx.net/> | Old Blog
> ><http://rmannibucau.wordpress.com> | Github
> ><https://github.com/rmannibucau> |
> >LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> ><
> https://www.packtpub.com/application-development/java-ee-8-high-performan
> >ce>
> >
> >
> >Le lun. 30 juil. 2018 à 16:26, Mark Struberg <[email protected]>
> a
> >écrit :
> >
> >> This is a chicken and egg issue.
> >>
> >> a.) we ignore non-static inner classes
> >> b.) we still have to first load them, otherwise we cannot see whether it
> >> is a non-static inner class or not
> >>
> >> Your first mail indicates that we could not load that class. So we have
> >>no
> >> clue that it's a non-static inner class.
> >> Is this the cases you did hit?
> >>
> >> LieGrue,
> >> strub
> >>
> >> > Am 30.07.2018 um 16:21 schrieb Romain Manni-Bucau
> >><[email protected]
> >> >:
> >> >
> >> > Yep but as I mentionned we still log a misleading error for the end
> >> users.
> >> >
> >> > So is the alternative solution so swallow all errors for these
> >>classes,
> >> > whatever it is?
> >> >
> >> > Romain Manni-Bucau
> >> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> > <https://rmannibucau.metawerx.net/> | Old Blog
> >> > <http://rmannibucau.wordpress.com> | Github <
> >> https://github.com/rmannibucau> |
> >> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> >> > <
> >>
> >>
> https://www.packtpub.com/application-development/java-ee-8-high-performan
> >>ce
> >> >
> >> >
> >> >
> >> > Le lun. 30 juil. 2018 à 16:17, Mark Struberg
> >><[email protected]>
> >> a
> >> > écrit :
> >> >
> >> >> Hi Romain!
> >> >>
> >> >> Anonymous classes can not be CDI beans because they always need a
> >> >> 'containing' class.
> >> >> The containing class is always a first param in the ct. Even if you
> >> don't
> >> >> see it.
> >> >> An anonymous class (or a lambda class) is a non-static inner class.
> >>So
> >> it
> >> >> cannot be a CDI bean.
> >> >>
> >> >> So A$1 is NEVER a CDI bean.
> >> >>
> >> >> Liegrue,
> >> >> strub
> >> >>
> >> >>
> >> >>> Am 29.07.2018 um 17:05 schrieb Romain Manni-Bucau <
> >> [email protected]
> >> >>> :
> >> >>>
> >> >>> Hi guys,
> >> >>>
> >> >>> Didn't find anything in the spec so wonder what we want to do @owb.
> >> Here
> >> >> is
> >> >>> the case: I have a class (let say A) with one (or more) anonymous
> >> >> classes.
> >> >>> It will lead to define A$1. Now assume A is @Vetoed, is A$1 @Vetoed
> >> too?
> >> >>>
> >> >>> In current impl it is not but I wonder if it shouldn't by
> >> "inheritance"?
> >> >> In
> >> >>> terms of behavior this is what we do but if $1 can't be loaded cause
> >> of a
> >> >>> missing dependency we will get this kind of line:
> >> >>>
> >> >>> *[AbstractMetaDataDiscovery] Ignoring class [org.test.A$1] because
> >>it
> >> >> could
> >> >>> not be loaded: java.lang.NoClassDefFoundError: org/foo/Bar*
> >> >>>
> >> >>> It is a bit misleading at the end in the logs but I'm not sure at
> >>all
> >> how
> >> >>> we want to enhance that and makes our logs cleaner for such cases.
> >> >>>
> >> >>> Romain Manni-Bucau
> >> >>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> >>> <https://rmannibucau.metawerx.net/> | Old Blog
> >> >>> <http://rmannibucau.wordpress.com> | Github <
> >> >> https://github.com/rmannibucau> |
> >> >>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> >> >>> <
> >> >>
> >>
> >>
> https://www.packtpub.com/application-development/java-ee-8-high-performan
> >>ce
> >> >>>
> >> >>
> >> >>
> >>
> >>
>
>

Reply via email to