Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-23 Thread Mark Struberg
Having no beans.xml (aka implicit bean archive) or a 
bean-discovery-mode="annotated" will make the 'Type discovery' have only pick 
up concrete classes which are annotated with a 'bean defining annotation'.
And thus we can only fire a ProcessAnnoatedType event for those classes. We 
don't know about the others at this stage.

We don't get any PAT for interfaces, enums, abstract classes, classes without 
explicit CDI scope, etc
That's the reason you e.g. cannot use a DeltaSpike @MessageBundle or 
DeltaSpike-Data in such bean archives.

That is that way as of CDI-1.1 and it's also TCK tested.

Note that per spec if you have an Extension in a jar then you MUST add a 
beans.xml if you have CDI beans in that jar.
In other words: a jar with an Extension is NOT an implicit bean archive. 

I'm pretty sure all this is well defined. But feel free to post on the spec 
list if you think there are some vaguely defined corner cases.

LieGrue,
strub


> Am 23.07.2017 um 16:09 schrieb Eric Covener :
> 
> On Sun, Jul 23, 2017 at 8:13 AM, John D. Ament  wrote:
>> We should probably review on cdi-dev.  I believe the intention behind
>> saying "classes discovered"  [1] is to indicate that its for all classes,
>> not just eligible beans.  Here's a use case: I have framework specific
>> classes, where the developer isn't required to add a scope.  Framework adds
>> the scope for them.  To do that, they use bean-discovery-mode=annotated and
>> PAT will add the dependent or other scope as appropriate.
>> 
>> [1]:
>> https://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#process_annotated_type
>> 
>> On Sat, Jul 22, 2017 at 5:40 PM Mark Struberg 
>> wrote:
>> 
>>> In that case Romain is right.
>>> 
>>> In an implicit BDA you only get PAT if the class has a bean defining
>>> annotation.
>>> Thats the reason we introduced all+trim.
> 
> 
> John alluded to changing, not adding, a beans.xml in the OP, so IIUC
> if it did not contain bean-discovery-mode=all + trim  then it seems to
> me that the type should have been processed.



Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-23 Thread Romain Manni-Bucau
While you accept scanning is undefined - Im not sure it can integrate the
spec cause all containers do it differently, even a single container can
have multiple modes :s - then a type was discovered means nothing except
for beans no?


Le 23 juil. 2017 16:09, "Eric Covener"  a écrit :

> On Sun, Jul 23, 2017 at 8:13 AM, John D. Ament 
> wrote:
> > We should probably review on cdi-dev.  I believe the intention behind
> > saying "classes discovered"  [1] is to indicate that its for all classes,
> > not just eligible beans.  Here's a use case: I have framework specific
> > classes, where the developer isn't required to add a scope.  Framework
> adds
> > the scope for them.  To do that, they use bean-discovery-mode=annotated
> and
> > PAT will add the dependent or other scope as appropriate.
> >
> > [1]:
> > https://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#process_annotated_type
> >
> > On Sat, Jul 22, 2017 at 5:40 PM Mark Struberg  >
> > wrote:
> >
> >> In that case Romain is right.
> >>
> >> In an implicit BDA you only get PAT if the class has a bean defining
> >> annotation.
> >> Thats the reason we introduced all+trim.
>
>
> John alluded to changing, not adding, a beans.xml in the OP, so IIUC
> if it did not contain bean-discovery-mode=all + trim  then it seems to
> me that the type should have been processed.
>


Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-23 Thread Eric Covener
On Sun, Jul 23, 2017 at 8:13 AM, John D. Ament  wrote:
> We should probably review on cdi-dev.  I believe the intention behind
> saying "classes discovered"  [1] is to indicate that its for all classes,
> not just eligible beans.  Here's a use case: I have framework specific
> classes, where the developer isn't required to add a scope.  Framework adds
> the scope for them.  To do that, they use bean-discovery-mode=annotated and
> PAT will add the dependent or other scope as appropriate.
>
> [1]:
> https://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#process_annotated_type
>
> On Sat, Jul 22, 2017 at 5:40 PM Mark Struberg 
> wrote:
>
>> In that case Romain is right.
>>
>> In an implicit BDA you only get PAT if the class has a bean defining
>> annotation.
>> Thats the reason we introduced all+trim.


John alluded to changing, not adding, a beans.xml in the OP, so IIUC
if it did not contain bean-discovery-mode=all + trim  then it seems to
me that the type should have been processed.


Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-23 Thread John D. Ament
We should probably review on cdi-dev.  I believe the intention behind
saying "classes discovered"  [1] is to indicate that its for all classes,
not just eligible beans.  Here's a use case: I have framework specific
classes, where the developer isn't required to add a scope.  Framework adds
the scope for them.  To do that, they use bean-discovery-mode=annotated and
PAT will add the dependent or other scope as appropriate.

[1]:
https://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#process_annotated_type

On Sat, Jul 22, 2017 at 5:40 PM Mark Struberg 
wrote:

> In that case Romain is right.
>
> In an implicit BDA you only get PAT if the class has a bean defining
> annotation.
> Thats the reason we introduced all+trim.
>
> LieGrue,
> Strub
>
> > Am 21.07.2017 um 21:37 schrieb Romain Manni-Bucau  >:
> >
> > Cause the scanning by itself is undefined, you can not scan skip not bean
> > types and be spec compliant.
> >
> >
> > Le 21 juil. 2017 21:26, "John D. Ament"  a écrit
> :
> >
> >> Errr I'm not sure what you mean.  The spec states this "before it reads
> the
> >> declared annotations" so I'm not sure why you think it needs to have a
> bean
> >> defining annotation.
> >>
> >> John
> >>
> >> On Fri, Jul 21, 2017 at 3:21 PM Romain Manni-Bucau <
> rmannibu...@gmail.com>
> >> wrote:
> >>
> >>> Hmm, interesting edge case. For me it should be ignored until you make
> it
> >>> scanned using @Dependent or so. But fear it is quite undefined or
> >>> "interpretable"
> >>>
> >>> Le 21 juil. 2017 21:10, "John D. Ament"  a
> écrit
> >> :
> >>>
>  I do something really lazy, I have an extension that has this method
> on
> >>> it:
> 
>  public void findEntities(@Observes @WithAnnotations(Entity.class)
>  ProcessAnnotatedType pat)
> 
>  which just looks for entity classes.  They're not going to be CDI
> >> beans,
>  but they are annotated types.  Per the spec,
>  https://docs.jboss.org/cdi/api/2.0/javax/enterprise/inject/spi/
>  ProcessAnnotatedType.html
>  ,
>  the event should get fired, even if there are no bean defining
> >>> annotations.
> 
>  Switching beans.xml to use bean-discovery-mode=all fixes it, but I'd
> >>> prefer
>  to not discover these as beans.
> 
>  Using a 
> >>> does
>  fix it. But either way, my understanding is that PAT is always fired,
> >> for
>  all classes found within a bean archive.
> 
>  John
> 
> >>>
> >>
>
>


Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-21 Thread John D. Ament
Errr I'm not sure what you mean.  The spec states this "before it reads the
declared annotations" so I'm not sure why you think it needs to have a bean
defining annotation.

John

On Fri, Jul 21, 2017 at 3:21 PM Romain Manni-Bucau 
wrote:

> Hmm, interesting edge case. For me it should be ignored until you make it
> scanned using @Dependent or so. But fear it is quite undefined or
> "interpretable"
>
> Le 21 juil. 2017 21:10, "John D. Ament"  a écrit :
>
> > I do something really lazy, I have an extension that has this method on
> it:
> >
> > public void findEntities(@Observes @WithAnnotations(Entity.class)
> > ProcessAnnotatedType pat)
> >
> > which just looks for entity classes.  They're not going to be CDI beans,
> > but they are annotated types.  Per the spec,
> > https://docs.jboss.org/cdi/api/2.0/javax/enterprise/inject/spi/
> > ProcessAnnotatedType.html
> > ,
> > the event should get fired, even if there are no bean defining
> annotations.
> >
> > Switching beans.xml to use bean-discovery-mode=all fixes it, but I'd
> prefer
> > to not discover these as beans.
> >
> > Using a 
> does
> > fix it. But either way, my understanding is that PAT is always fired, for
> > all classes found within a bean archive.
> >
> > John
> >
>


Re: OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-21 Thread Romain Manni-Bucau
Hmm, interesting edge case. For me it should be ignored until you make it
scanned using @Dependent or so. But fear it is quite undefined or
"interpretable"

Le 21 juil. 2017 21:10, "John D. Ament"  a écrit :

> I do something really lazy, I have an extension that has this method on it:
>
> public void findEntities(@Observes @WithAnnotations(Entity.class)
> ProcessAnnotatedType pat)
>
> which just looks for entity classes.  They're not going to be CDI beans,
> but they are annotated types.  Per the spec,
> https://docs.jboss.org/cdi/api/2.0/javax/enterprise/inject/spi/
> ProcessAnnotatedType.html
> ,
> the event should get fired, even if there are no bean defining annotations.
>
> Switching beans.xml to use bean-discovery-mode=all fixes it, but I'd prefer
> to not discover these as beans.
>
> Using a  does
> fix it. But either way, my understanding is that PAT is always fired, for
> all classes found within a bean archive.
>
> John
>


OWB 2 not firing ProcessAnnotatedType for all bean classes

2017-07-21 Thread John D. Ament
I do something really lazy, I have an extension that has this method on it:

public void findEntities(@Observes @WithAnnotations(Entity.class)
ProcessAnnotatedType pat)

which just looks for entity classes.  They're not going to be CDI beans,
but they are annotated types.  Per the spec,
https://docs.jboss.org/cdi/api/2.0/javax/enterprise/inject/spi/ProcessAnnotatedType.html
,
the event should get fired, even if there are no bean defining annotations.

Switching beans.xml to use bean-discovery-mode=all fixes it, but I'd prefer
to not discover these as beans.

Using a  does
fix it. But either way, my understanding is that PAT is always fired, for
all classes found within a bean archive.

John