tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kay Wrobel <kay.wro...@gmx.net>
Subject Re: CDI Injecting parameterized types
Date Tue, 29 Oct 2013 17:40:27 GMT
I shall try that.

On 10/29/2013 11:04 AM, Romain Manni-Bucau wrote:
> Maybe give it a try on the snapshot, the issue didn't pop out when
> starting the container on the 1.6.0-SNAPSHOT
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2013/10/29 Kay Wrobel <kay.wrobel@gmx.net>:
>> Here is a test project: https://github.com/kwrobel/WebApplication1
>>
>> I uploaded a new commit that uses the @Inject annotation inside
>> ui.bean.AbstractController
>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/AbstractController.java>
>> instead of ui.bean.MyTestController
>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/MyTestController.java>.
>> I just double-checked my statement that it works with GlassFish and, yes, it
>> works with GlassFish 3.1.2. You can browse the history
>> <https://github.com/kwrobel/WebApplication1/commit/ba43070d0de4941ab0a4fa84ec0655f11bedd14c>
>> to see the latest change as explained below.
>>
>>
>>
>> On 10/29/2013 12:59 AM, Mark Struberg wrote:
>>> I would need a bit more code to understand the problem.
>>> E.g. how the DiscountCodeFacade does look like.
>>> Ideally a small sample project.
>>>
>>> The message in the log indicates that OWB cannot find a Bean for the
>>> InjectionPoint.
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>>
>>>
>>> ----- Original Message -----
>>>> From: Kay Wrobel <kay.wrobel@gmx.net>
>>>> To: users@tomee.apache.org
>>>> Cc:
>>>> Sent: Monday, 28 October 2013, 23:06
>>>> Subject: Re: CDI Injecting parameterized types
>>>>
>>>> Interesting that this topic has come up. I just tried to roll out a
>>>> change to my project where I have following situation:
>>>> Currently, I have an AbstractController and then a Controller for each
>>>> entity class. On the EJB side of things, I have an AbstractFacade and an
>>>> entity Facade for each entity, each annotated with @Stateless. Right
>>>> now, I am injecting an EntityFacade object into an EntityController and
>>>> then hand off the actual object to a variable that sits inside the
>>>> AbstractController. I wanted to change that behavior and perform the
>>>> injection right inside the abstract controller class. To give you a more
>>>> concrete example, this is how it looks like now:
>>>>
>>>> AbstractController.java:
>>>>>    public abstract class AbstractController<T> {
>>>>>
>>>>>        private AbstractFacade<T> ejbFacade;
>>>>>
>>>>>        public AbstractController() {
>>>>>        }
>>>>>
>>>>>        protected AbstractFacade<T> getFacade() {
>>>>>            return ejbFacade;
>>>>>        }
>>>>>
>>>>>        protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>>>            this.ejbFacade = ejbFacade;
>>>>>        }
>>>>>    }
>>>> CustomerController.java:
>>>>>    @Named(value = "discountCodeController")
>>>>>    @ViewAccessScoped
>>>>>    public class DiscountCodeController extends
>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>
>>>>>    *    @Inject**
>>>>>    **    private DiscountCodeFacade ejbFacade;**
>>>>>    *
>>>>>        @PostConstruct
>>>>>        public void init() {
>>>>>            super.setFacade(ejbFacade);
>>>>>        }
>>>>>
>>>>>    }
>>>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>>>
>>>> AbstractController.java:
>>>>>    public abstract class AbstractController<T> {
>>>>>
>>>>>    *    @Inject**
>>>>>    **    private AbstractFacade<T> ejbFacade;**
>>>>>    *
>>>>>        public AbstractController() {
>>>>>        }
>>>>>
>>>>>        public AbstractController(Class<T> itemClass) {
>>>>>            this.itemClass = itemClass;
>>>>>        }
>>>>>    }
>>>> DiscountController.java:
>>>>>    @Named(value = "discountCodeController")
>>>>>    @ViewAccessScoped
>>>>>    public class DiscountCodeController extends
>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>
>>>>>        public DiscountCodeController() {
>>>>>            super(DiscountCode.class);
>>>>>        }
>>>>>
>>>>>    }
>>>> Notice how I am injecting an AbstractFacade<T> inside
>>>> AbstractController<T>. This works in Glassfish but fails in
>>>> Tomee/OpenEJB.
>>>>
>>>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>>>
>>>> Any input from you guys?
>>>>
>>>>
>>>>
>>>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>>>    I needed it for other reasons. Globally while not using producers
it
>>>>> should
>>>>>    work.
>>>>>    Le 28 oct. 2013 22:21, "Chris Owens"
>>>> <ctag+openejb@chris-owens.com> a
>>>>>    écrit :
>>>>>
>>>>>>    Thank you, that code is very helpful.  I was hoping to be able
to do
>>>>>> it
>>>>>>    without the use of an additional qualifier.
>>>>>>
>>>>>>
>>>>>>
>>>>>>    --
>>>>>>    View this message in context:
>>>>>>
>>>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>>>>>>    Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>


Mime
View raw message