<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Excellent. I was starting to think
      something was wrong with my comprehension of English. :)<br>
      <br>
      OK, so: <br>
      <ul>
        <li>when firing events through Event&lt;T&gt;, the T determines
          the observers that get called,</li>
        <li>when firing events through BeanManager.fireEvent(), the
          actual type of the payload determines the observers that get
          called.<br>
        </li>
      </ul>
      However, the very last line of 10.3.1 states "If the runtime type
      of the event object contains a type variable, an
      IllegalArgumentException is thrown".  I'm assuming this will be
      removed (or changed so it only applies to BeanManager.fireEvent).
      <br>
      <br>
      Taking this into account, the exception at <a
        href="https://issues.jboss.org/browse/WELD-1189">https://issues.jboss.org/browse/WELD-1189</a>
      shouldn't be thrown, right? The exception is thrown because the
      actual type of the payload - because of type erasure - is
      ArrayList, which Weld then resolves to ArrayList&lt;T&gt;. Since
      the event is fired through @Inject
      Event&lt;List&lt;String&gt;&gt;, Weld should resolve observers
      based on List&lt;String&gt; and not the actual type of the
      payload. Since List&lt;String&gt; doesn't contain a type variable,
      the exception should not be thrown. Correct?<br>
      <br>
      Marko<br>
      <span style="color: rgb(0, 0, 0); font-family: 'Times New Roman';
        font-size: medium; font-style: normal; font-variant: normal;
        font-weight: normal; letter-spacing: normal; line-height:
        normal; orphans: 2; text-align: start; text-indent: 0px;
        text-transform: none; white-space: normal; widows: 2;
        word-spacing: 0px; -webkit-text-size-adjust: auto;
        -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
        255); display: inline !important; float: none; "></span><br>
      <br>
      On 29.8.2012 16:29, Pete Muir wrote:<br>
    </div>
    <blockquote
      cite="mid:EDE4D435-F57C-43AC-A4E6-8685338020F1@redhat.com"
      type="cite">
      <pre wrap="">
On 29 Aug 2012, at 15:21, Marko Lukša wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">
I have been reading the spec about events and I'm a little confused. 

In "Chapter 10. Events", the spec says:
        • An event comprises: - A Java object—the event object
        • The event object acts as a payload
        • An observer method will be notified of an event if the event object is assignable to the observed event type
I understand this to mean that the actual payload is what's important when resolving observer methods. Yet, this is not true when firing events through the Event bean. When firing events through the Event bean, observers are resolved according to the type parameter of the injected Event bean (or the type passed to event.select()) and not the actual type of payload supplied to event.fire(payload) (see <a class="moz-txt-link-freetext" href="https://issues.jboss.org/browse/WELD-672">https://issues.jboss.org/browse/WELD-672</a>).
</pre>
      </blockquote>
      <pre wrap="">
The spec says what you describe, but it's not really very sane, or consistent, as 10.3.1 says "The Event interface provides a method for firing events with a specified combination of type and qualifiers:" but then goes on to ignore the type later on  "The method fire() fires an event with the specified qualifiers and notifies observers, as defined by Section 10.5, “Observer notification”."

Somehow we don't have an issue for this :-(

<a class="moz-txt-link-freetext" href="https://issues.jboss.org/browse/CDI-256">https://issues.jboss.org/browse/CDI-256</a>

</pre>
      <blockquote type="cite">
        <pre wrap="">In WELD, the actual type of the payload is only important when firing events through BeanManager.fireEvent(), which is not even mentioned in "10.3. Firing events". From 10.3, I would expect that the usual way of firing events is through the Event bean, and firing events through the BeanManager is the low-level way of doing it.
</pre>
      </blockquote>
      <pre wrap="">
IMO this is the only sane way to do it.

</pre>
      <blockquote type="cite">
        <pre wrap=""> 

I have a few more questions, but they are all inter-dependent, so it's probably better if you help me resolve this one first, and then I'll move on to the rest.

Marko


_______________________________________________
cdi-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a>
</pre>
      </blockquote>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
  </body>
</html>