synchronized (sipStack) { Iterator it = sipStack.getSipProviders(); while (it.hasNext()) { SipProviderImpl provider = (SipProviderImpl) it.next(); if (provider.sipListener != null && provider.sipListener != sipListener) throw new TooManyListenersException(); } } if (LogWriter.needsLogging) sipStack.logMessage("add SipListener " + sipListener); this.sipListener = sipListener; synchronized (sipStack) { Iterator it = sipStack.getSipProviders(); while (it.hasNext()) { SipProviderImpl provider = (SipProviderImpl) it.next(); provider.sipListener = sipListener; } } }
if (sipStack.sipListener == null) { sipStack.sipListener = sipListener; } else if (sipStack.sipListener != sipListener) { throw new TooManyListenersException( "Stack already has a listener. Only one listener per stack allowed"); }  if (sipStack.isLoggingEnabled()) sipStack.getLogWriter().logDebug("add SipListener " + sipListener); this.sipListener = sipListener;  }
    public void addSipListener(SipListener sipListener)            throws TooManyListenersException {        synchronized (sipStack) {            Iterator it = sipStack.getSipProviders();            while (it.hasNext()) {                SipProviderImpl provider = (SipProviderImpl) it.next();                if (provider.sipListener != null                        && provider.sipListener != sipListener)                    throw new TooManyListenersException();            }        }        if (LogWriter.needsLogging)            sipStack.logMessage("add SipListener " + sipListener);        this.sipListener = sipListener;        synchronized (sipStack) {            Iterator it = sipStack.getSipProviders();            while (it.hasNext()) {                SipProviderImpl provider = (SipProviderImpl) it.next();                provider.sipListener = sipListener;            }        }    }