You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Harald Wellmann <hw...@gmail.com> on 2012/11/12 11:05:18 UTC

Producer method default name

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

Re: Producer method default name

Posted by Harald Wellmann <hw...@gmail.com>.
Thanks for confirming the problem and filing the ticket.

Best regards,
Harald

Re: Producer method default name

Posted by Arne Limburg <ar...@openknowledge.de>.
Thanks, I'll look at it.

Von: "John D. Ament" <jo...@gmail.com>>
Antworten an: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Datum: Montag, 12. November 2012 13:06
An: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Betreff: Re: Producer method default name

Done!
OWB-719 is out there now.


On Mon, Nov 12, 2012 at 7:02 AM, Arne Limburg <ar...@openknowledge.de>> wrote:
Hi,

Interesting that this did not pop up before. Could one of you please create a Jira issue for that?

Cheers,
Arne

Von: "John D. Ament" <jo...@gmail.com>>
Antworten an: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Datum: Montag, 12. November 2012 12:58
An: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Betreff: Re: Producer method default name

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 <hw...@gmail.com>> 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 <jo...@gmail.com>>:
> That is expected behavior.  @Named uses javabean naming conventions to pick
> the default name.
>
> On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com>> 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



Re: Producer method default name

Posted by "John D. Ament" <jo...@gmail.com>.
Done!
OWB-719 is out there now.


On Mon, Nov 12, 2012 at 7:02 AM, Arne Limburg <arne.limburg@openknowledge.de
> wrote:

>   Hi,
>
>  Interesting that this did not pop up before. Could one of you please
> create a Jira issue for that?
>
>  Cheers,
> Arne
>
>
>     Von: "John D. Ament" <jo...@gmail.com>
> Antworten an: "user@openwebbeans.apache.org" <user@openwebbeans.apache.org
> >
> Datum: Montag, 12. November 2012 12:58
> An: "user@openwebbeans.apache.org" <us...@openwebbeans.apache.org>
> Betreff: Re: Producer method default name
>
>  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 <hw...@gmail.com>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 <jo...@gmail.com>:
>>  > That is expected behavior.  @Named uses javabean naming conventions
>> to pick
>> > the default name.
>> >
>> > On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com>
>> 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
>>
>
>

Re: Producer method default name

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi,

Interesting that this did not pop up before. Could one of you please create a Jira issue for that?

Cheers,
Arne

Von: "John D. Ament" <jo...@gmail.com>>
Antworten an: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Datum: Montag, 12. November 2012 12:58
An: "user@openwebbeans.apache.org<ma...@openwebbeans.apache.org>" <us...@openwebbeans.apache.org>>
Betreff: Re: Producer method default name

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 <hw...@gmail.com>> 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 <jo...@gmail.com>>:
> That is expected behavior.  @Named uses javabean naming conventions to pick
> the default name.
>
> On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com>> 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


Re: Producer method default name

Posted by "John D. Ament" <jo...@gmail.com>.
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 <hw...@gmail.com>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 <jo...@gmail.com>:
> > That is expected behavior.  @Named uses javabean naming conventions to
> pick
> > the default name.
> >
> > On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com>
> 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
>

Re: Producer method default name

Posted by Harald Wellmann <hw...@gmail.com>.
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 <jo...@gmail.com>:
> That is expected behavior.  @Named uses javabean naming conventions to pick
> the default name.
>
> On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com> 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

Re: Producer method default name

Posted by "John D. Ament" <jo...@gmail.com>.
That is expected behavior.  @Named uses javabean naming conventions to pick
the default name.
On Nov 12, 2012 5:05 AM, "Harald Wellmann" <hw...@gmail.com> 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
>