[weld-dev] Dynamic Injection Question

Jordan Ganoff jganoff at gmail.com
Thu Apr 8 21:27:08 EDT 2010


Thanks Pete.  InjectionPoint.getQualifers() works like a charm.

On Thu, Apr 8, 2010 at 11:05 AM, Pete Muir <pmuir at redhat.com> wrote:

> Ah, I see the problem, you are calling ip.*getAnnotated* - this (IMO
> correctly) does not reflect the qualifiers applied via select(), but the
> annotated object. Use ip.getQualifiers() instead.
>
>
> On 8 Apr 2010, at 14:13, Pete Muir wrote:
>
> > I mean, can you file a JIRA and put the code below in it?
> >
> > On 8 Apr 2010, at 14:12, Pete Muir wrote:
> >
> >> Ok, can you write a test case for this?
> >>
> >> On 8 Apr 2010, at 13:23, Jordan Ganoff wrote:
> >>
> >>> I'm using Weld 1.0.1 Final.  You fixed a very similar bug:
> https://jira.jboss.org/jira/browse/WELD-438.  From your comment on the
> JIRA it sounded like the selected annotations were fixed as well but that's
> not the behavior I'm seeing.
> >>>
> >>> On Thu, Apr 8, 2010 at 7:38 AM, Pete Muir <pmuir at redhat.com> wrote:
> >>> Are you using Weld 1.0.1 - I fixed this there IIRC.
> >>>
> >>> On 8 Apr 2010, at 02:45, Jordan Ganoff wrote:
> >>>
> >>>> I was testing out a simple idea for another JMS injection type and ran
> into an issue with Instance.get() and additional select annotations.  The
> InjectionPoint of the producer lacked the additional selected annotations.
>  I'm trying to create a TopicProducer and need to dynamically inject a
> topic.  When the topic producer is invoked the InjectionPoint does not
> contain the JmsDestination (the annotations are only @Inject and @Any, which
> seems like @Inject shouldn't be there either).  Is there a better way to do
> this?
> >>>>
> >>>> Here's the code:
> >>>>
> >>>> @Inject @Any Instance<Topic> anyTopic;
> >>>>
> >>>> @Produces @JmsDestination
> >>>> public TopicPublisher createTopicProducer(InjectionPoint ip, Session
> s) throws JMSException
> >>>> {
> >>>>  Topic t =
> anyTopic.select(ip.getAnnotated().getAnnotation(JmsDestination.class)).get();
> >>>>  return TopicPublisher.class.cast(s.createProducer(t));
> >>>> }
> >>>>
> >>>> ...
> >>>>
> >>>> @Produces
> >>>> @JmsDestination
> >>>> public Topic getTopic(InjectionPoint ip, @Module Context c) throws
> NamingException
> >>>> {
> >>>>  JmsDestination d =
> ip.getAnnotated().getAnnotation(JmsDestination.class);
> >>>>  return (Topic) c.lookup(d.jndiName());
> >>>> }
> >>>>
> >>>> Thanks in advance.
> >>>>
> >>>> P.S. Actual code links:
> >>>>
> >>>> http://gist.github.com/359673
> >>>>
> http://github.com/jganoff/seam3-jms/blob/master/src/main/java/org/jboss/seam/jms/impl/inject/DestinationProducer.java
> >>>> --
> >>>> Jordan Ganoff
> >>>> _______________________________________________
> >>>> weld-dev mailing list
> >>>> weld-dev at lists.jboss.org
> >>>> https://lists.jboss.org/mailman/listinfo/weld-dev
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> Jordan Ganoff
> >>
> >
> >
> > _______________________________________________
> > weld-dev mailing list
> > weld-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/weld-dev
>
>
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>



-- 
Jordan Ganoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20100408/1d5b158c/attachment.html 


More information about the weld-dev mailing list