As closing an open connection is the only use case there, the worst thing that can happen is that listener will not be removed in the concurrent event (the one we are thinging about to synchronize), but it will happen on next one as every operation the checks it. The question is if sending an even to closed listener can be dangerous? As isClosed is checked quite often it would be good to avoid synchronization, but I'm not able to estimate the risk.
> Nope it was more about the close() and isClosed() method. Another > thing we could do is just use volatile keyword here.. > Bye, > Norman > 2011/2/20 Wojciech Strzałka <[email protected]>: >> >> you mean setDelegatingMailboxListener() ?? >> >> - thinking theoretically - yes >> - practically - I doubt as I don't see a reason why anybody would want >> to change it in the runtime. It's more like single time >> configuration parameter, isn't it? >> >> >>> I think the methods need to be synchronized... wdyt ? >> >>> Bye, >>> Norman >> >>> 2011/2/20 <[email protected]>: >>>> Author: wstrzalka >>>> Date: Sun Feb 20 16:17:31 2011 >>>> New Revision: 1072621 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=1072621&view=rev >>>> Log: >>>> Registering custom DelegatingMailboxListener in StoreMailboxManager >>>> property setter. See IMAP-260 >>>> >>>> Modified: >>>> >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractDelegatingMailboxListener.java >>>> >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java >>>> >>>> Modified: >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractDelegatingMailboxListener.java >>>> URL: >>>> http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractDelegatingMailboxListener.java?rev=1072621&r1=1072620&r2=1072621&view=diff >>>> ============================================================================== >>>> --- >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractDelegatingMailboxListener.java >>>> (original) >>>> +++ >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractDelegatingMailboxListener.java >>>> Sun Feb 20 16:17:31 2011 >>>> @@ -30,6 +30,12 @@ import org.apache.james.mailbox.MailboxS >>>> >>>> public abstract class AbstractDelegatingMailboxListener implements >>>> MailboxListener, MailboxListenerSupport{ >>>> >>>> + private boolean isClosed; >>>> + >>>> + protected AbstractDelegatingMailboxListener() { >>>> + isClosed = false; >>>> + } >>>> + >>>> /** >>>> * Receive the event and dispatch it to the right {@link >>>> MailboxListener} depending on {@link Event#getMailboxPath()} >>>> */ >>>> @@ -72,10 +78,17 @@ public abstract class AbstractDelegating >>>> } >>>> >>>> /** >>>> - * Is never closed >>>> + * Close the listener >>>> + */ >>>> + public void close() { >>>> + isClosed = true; >>>> + } >>>> + >>>> + /** >>>> + * Check if closed >>>> */ >>>> public boolean isClosed() { >>>> - return false; >>>> + return isClosed; >>>> } >>>> >>>> /* >>>> >>>> Modified: >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java >>>> URL: >>>> http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java?rev=1072621&r1=1072620&r2=1072621&view=diff >>>> ============================================================================== >>>> --- >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java >>>> (original) >>>> +++ >>>> james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java >>>> Sun Feb 20 16:17:31 2011 >>>> @@ -111,7 +111,10 @@ public abstract class StoreMailboxManage >>>> * @param delegatingListener >>>> */ >>>> public void >>>> setDelegatingMailboxListener(AbstractDelegatingMailboxListener >>>> delegatingListener) { >>>> + if(this.delegatingListener != null) >>>> + this.delegatingListener.close(); >>>> this.delegatingListener = delegatingListener; >>>> + dispatcher.addMailboxListener(this.delegatingListener); >>>> } >>>> >>>> >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >> >> >> >> -- >> Pozdrowienia, >> Wojciech Strzalka >> >> -- Pozdrowienia, Wojciech Strzałka --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
