Hi
At this point I'm going to let the OWB team provide feedback. I was able
to reproduce your problem with a simple Arquillian test.
@RunWith(Arquillian.class)
public class FooTest {
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(JavaArchive.class).addClass(FooMaker.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Inject @Named("foo")
private String foo;
@Test
public void testFoo() {
Assert.assertEquals("bobo", foo);
}
}
I tried the following producers, only the last worked (OWB not using method
name or JavaBeans naming conventions)
@Produces @Named
public String getFoo() {
return "bobo";
}
@Produces @Named
public String foo() {
return "bobo";
}
@Produces @Named("foo")
public String foo() {
return "bobo";
}
John
On Mon, Nov 12, 2012 at 6:27 AM, Harald Wellmann <[email protected]>wrote:
> I'm slightly confused...
>
> See CDI Spec 1.0, section 3.3.8:
>
> "The default name for a producer method is the method name, unless the
> method follows the JavaBeans property getter naming convention, in
> which case the default name is the JavaBeans property name."
>
> In my case, the producer method is called "foo()", which is not a
> getter, so the bean name should be "foo". (And this is what I get with
> Weld.) What is the default name generated by OWB in this case?
>
> Best regards,
> Harald
>
> 2012/11/12 John D. Ament <[email protected]>:
> > That is expected behavior. @Named uses javabean naming conventions to
> pick
> > the default name.
> >
> > On Nov 12, 2012 5:05 AM, "Harald Wellmann" <[email protected]>
> wrote:
> >>
> >> I have a producer method
> >>
> >> @Produces @Named
> >> public String foo() { ... }
> >>
> >> and a matching injection point
> >>
> >> @Inject @Named("foo")
> >> private String foo;
> >>
> >> in some other bean.
> >>
> >> With OWB 1.1.6, injection fails, unless @Named("foo") is explicitly
> >> added to the producer method. Is this a known issue?
> >>
> >> Best regards,
> >> Harald
>