On Wed, May 27, 2009 at 3:34 PM, Gavin King <gavin.king(a)gmail.com> wrote:
(1) an Observer could be registered multiple times with diff event bindings
Ah, I thought it couldn't, because BeanManager.addObserver took no binding
information. I now see that Event.addOberver() uses the bindings of the
(2) adding a type variable doesn't help you, since it just gets erased
You can't do T.class in Java :-)
Good point. Is the parameterization of addObserver just to ensure that
Observer<T> is registered for Class<T>?
So if an observer can be added for an event with different bindings, why
shouldn't it be possible to remove it from observing the event with a
specific binding? I presume that's what Event.resumeObserver() does, i.e.
removes that observer for the Event's bindings. It seems reasonable to want
to do that independent of whether you have an event, through the
On Wed, May 27, 2009 at 1:06 PM, Clint Popetz <cpopetz(a)gmail.com> wrote:
> Now that I'm thinking about it, I wrote "the observer should be removed
> all events for which it is registered" but because addObserver() is typed
> Observer<T>, and because you can't implement the same interface twice
> with different parameterizations) any given instance can only be
> once. Well, it could be registered more than once, but the
> (and possibly the spec) could prohibit that, because it's meaningless.
> In that case, I have no problem with the semantics of removeObserver.
> the <?> means I'd have to rewrite a lot of observer storage/lookup code,
> it's not symmetric with addObserver(), so I wonder what the advantage of
> wildcard is.
> On Wed, May 27, 2009 at 2:35 PM, Gavin King <gavin.king(a)gmail.com>
>> yes, that's what it means, though I must admit that when I made that
>> change it was not totally clear to me that it was the right thing to
>> do :-/
>> Probably needs a bit more discussion...
>> On Wed, May 27, 2009 at 11:59 AM, Clint Popetz <cpopetz(a)gmail.com>
>> > Hi,
>> > The spec defines BeanManager.removeObserver to have a wildcard type:
>> > public void removeObserver(Observer<?> observer);
>> > and says "The container must stop sending event notifications to the
>> > deregistered observer." Does that sentence, taken with the wildcard
>> > type,
>> > imply that the observer should be removed for all events for which it
>> > registered? Currently ManagerImpl implements storage of observers as
>> > map
>> > from EventType -> Observer, which means removal of an observer without
>> > knowing its event type would be linear in # observers, unless I change
>> > the
>> > implementation.
>> > Thanks,
>> > -Clint
>> > --
>> > Clint Popetz
>> > http://42lines.net
>> > Scalable Web Application Development
>> > _______________________________________________
>> > webbeans-dev mailing list
>> > webbeans-dev(a)lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/webbeans-dev
>> Gavin King
> Clint Popetz
> Scalable Web Application Development
Scalable Web Application Development