dev@glassfish.java.net

ConfigListener parent notification - Re: svn commit: r807 - trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java

From: Amy Roh <Amelia.Roh_at_Sun.COM>
Date: Mon, 08 Sep 2008 17:50:37 -0700

Hi Jerome,

dochez_at_dev.java.net wrote:
> Author: dochez
> Date: 2008-08-27 04:51:34+0000
> New Revision: 807
>
> Modified:
> trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java
>
> Log:
> added parent notification, we could change it to notify the entire config tree up.
>
>
>
> Modified: trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java
> Url: https://hk2.dev.java.net/source/browse/hk2/trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java?view=diff&rev=807&p1=trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java&p2=trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java&r1=806&r2=807
> ==============================================================================
> --- trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java (original)
> +++ trunk/hk2/config/src/java/org/jvnet/hk2/config/Transactions.java 2008-08-27 04:51:34+0000
> @@ -227,6 +227,25 @@
> final UnprocessedChangeEvent unp = new UnprocessedChangeEvent(evt, "no ConfigListener listening to dom element " + dom.getProxyType().getName() );
> unprocessedEvents.add( new UnprocessedChangeEvents(unp) );
> }
> +
> + // we notify the immediate parent.
> + // dochez : should we notify the parent chain up to the root or stop at the first parent.

Can we notify at least up to the second parent?

As described in the issue [1], dynamically created virtual server's
property change does not notify http-service.

[1] https://glassfish.dev.java.net/issues/show_bug.cgi?id=6003

Thanks,
Amy

> + if (dom.parent()!=null && dom.parent().getListeners()!=null) {
> + for (ConfigListener parentListener : dom.parent().getListeners()) {
> + if (!notifiedListeners.contains(parentListener)) {
> + try {
> + // create a new array each time to avoid any potential array changes?
> + UnprocessedChangeEvents unprocessed = parentListener.changed(mEvents.toArray(new PropertyChangeEvent[mEvents.size()]));
> + if (unprocessed != null && unprocessed.size() != 0 ) {
> + unprocessedEvents.add(unprocessed);
> + }
> + } catch (Exception e) {
> + e.printStackTrace();
> + }
> + notifiedListeners.add(parentListener);
> + }
> + }
> + }
> }
> // all the config listeners have been notified, let's see if we have
> // some unprocessed events to notifiy the transation listeners.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe_at_hk2.dev.java.net
> For additional commands, e-mail: commits-help_at_hk2.dev.java.net
>