@Override public synchronized void stateChange ( final org.eclipse.scada.core.client.Connection connection, final ConnectionState state, final Throwable error ) { switch ( state ) { case BOUND: if ( !this.connected ) { resyncAllItems (); this.connected = true; } break; default: if ( this.connected ) { disconnectAllItems (); this.connected = false; } break; } }
@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 ConnectionServiceImpl ( final Connection connection, final Integer autoReconnectController, final boolean lazyActivation ) { super ( autoReconnectController, lazyActivation ); // for now we are using the autoReconnectController timeout as lingering timeout ... this.connection = lazyActivation ? new LazyConnectionWrapper ( connection, autoReconnectController ) { @Override protected void performDisconnect () { setShouldConnect ( false ); } @Override protected void performConnect () { setShouldConnect ( true ); } } : connection; setConnection ( this.connection ); this.itemManager = new CountingItemManager ( new ItemManagerImpl ( this.connection ), this.statistics ); this.folderManager = new FolderManager ( this.connection ); this.statistics.setLabel ( ConnectionServiceImpl.GET_ON_IM, "getItemManager called" ); this.statistics.setLabel ( CountingItemManager.REGISTERED_ITEMS, "Registered items" ); }
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 ); } }
public ConnectionServiceImpl ( final Connection connection, final Integer autoReconnectController, final boolean lazyActivation ) { super ( autoReconnectController, lazyActivation ); // for now we are using the autoReconnectController timeout as lingering timeout ... this.connection = lazyActivation ? new LazyConnectionWrapper ( connection, autoReconnectController ) { @Override protected void performDisconnect () { setShouldConnect ( false ); } @Override protected void performConnect () { setShouldConnect ( true ); } } : connection; setConnection ( this.connection ); this.itemManager = new CountingItemManager ( new ItemManagerImpl ( this.connection ), this.statistics ); this.folderManager = new FolderManager ( this.connection ); this.statistics.setLabel ( ConnectionServiceImpl.GET_ON_IM, "getItemManager called" ); this.statistics.setLabel ( CountingItemManager.REGISTERED_ITEMS, "Registered items" ); }
@Override public synchronized void stateChange ( final org.eclipse.scada.core.client.Connection connection, final ConnectionState state, final Throwable error ) { switch ( state ) { case BOUND: if ( !this.connected ) { resyncAllItems (); this.connected = true; } break; default: if ( this.connected ) { disconnectAllItems (); this.connected = false; } break; } }
@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 () {