@Override public synchronized void notifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable e ) { if ( this.subscriptionState.equals ( subscriptionState ) && this.subscriptionError == e ) { return; } this.subscriptionState = subscriptionState; this.subscriptionError = e; final ListenerInfo[] listeners = ItemSyncController.this.listeners.values ().toArray ( new ListenerInfo[this.listeners.size ()] ); this.itemManager.getExecutor ().execute ( new Runnable () { @Override public void run () { for ( final ListenerInfo listenerInfo : listeners ) { try { listenerInfo.getListener ().notifySubscriptionChange ( subscriptionState, e ); } catch ( final Exception e ) { logger.info ( "Failed to notify listener subscription change", e ); } } } } ); }
public synchronized void add ( final ItemUpdateListener listener ) { if ( !this.listeners.containsKey ( listener ) ) { this.listeners.put ( listener, new ListenerInfo ( listener ) ); final SubscriptionState state = this.subscriptionState; final Throwable error = this.subscriptionError; final Variant value = this.cachedValue; final Map<String, Variant> attributes = new HashMap<String, Variant> ( this.cachedAttributes ); logger.trace ( "Sending out cache values - itemId: {}, state: {}, value: {}, attributes: {}", new Object[] { this.itemId, state, value, attributes } ); // send the initial update this.itemManager.getExecutor ().execute ( new Runnable () { @Override public void run () { listener.notifySubscriptionChange ( state, error ); listener.notifyDataChange ( value, attributes, true ); } } ); sync ( false ); } }
@Override public synchronized void notifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable e ) { if ( this.subscriptionState.equals ( subscriptionState ) && this.subscriptionError == e ) { return; } this.subscriptionState = subscriptionState; this.subscriptionError = e; final ListenerInfo[] listeners = ItemSyncController.this.listeners.values ().toArray ( new ListenerInfo[this.listeners.size ()] ); this.itemManager.getExecutor ().execute ( new Runnable () { @Override public void run () { for ( final ListenerInfo listenerInfo : listeners ) { try { listenerInfo.getListener ().notifySubscriptionChange ( subscriptionState, e ); } catch ( final Exception e ) { logger.info ( "Failed to notify listener subscription change", e ); } } } } ); }
public synchronized void add ( final ItemUpdateListener listener ) { if ( !this.listeners.containsKey ( listener ) ) { this.listeners.put ( listener, new ListenerInfo ( listener ) ); final SubscriptionState state = this.subscriptionState; final Throwable error = this.subscriptionError; final Variant value = this.cachedValue; final Map<String, Variant> attributes = new HashMap<String, Variant> ( this.cachedAttributes ); logger.trace ( "Sending out cache values - itemId: {}, state: {}, value: {}, attributes: {}", new Object[] { this.itemId, state, value, attributes } ); // send the initial update this.itemManager.getExecutor ().execute ( new Runnable () { @Override public void run () { listener.notifySubscriptionChange ( state, error ); listener.notifyDataChange ( value, attributes, true ); } } ); sync ( false ); } }
this.itemManager.getExecutor ().execute ( new Runnable () {
this.itemManager.getExecutor ().execute ( new Runnable () {