/** * create a new data item structure. * <p> * Note that the item is initially connected to the item manager provided. * You must call {@link #unregister()} when you want to clear the * subscription with the item on the server. * * @param itemId * the id of the item to register * @param itemManager * the item manager to which the item will register */ public DataItem ( final String itemId, final ItemManager itemManager ) { this ( itemId ); if ( itemManager != null ) { register ( itemManager ); } }
private void disconnect () { if ( this.connectionService != null ) { this.connectionService = null; } if ( this.dataItem != null ) { this.dataItem.deleteObservers (); this.dataItem.unregister (); this.dataItem = null; } }
protected void performNotifyDataChange ( final Variant value, final Map<String, Variant> attributes, final boolean cache ) { handlePerformNotifyDataChange ( value, attributes, cache ); }
private void bind () { if ( this.service != null && this.itemId != null ) { final ItemManager im = this.service.getItemManager (); this.dataItem = new DataItem ( this.itemId ); this.dataItem.addObserver ( this.observer = createObserver () ); this.dataItem.register ( im ); } }
@Override protected synchronized void unbindConnection () { super.unbindConnection (); if ( this.dataItem != null ) { if ( this.listener != null ) { this.dataItem.deleteObserver ( this.observer ); this.dataItem.unregister (); } this.dataItem = null; } fireListenerChange ( null ); }
public void register ( final ItemManager itemManager ) { if ( this.itemManager == itemManager ) { return; } unregister (); this.itemManager = itemManager; this.itemManager.addItemUpdateListener ( this.itemId, this.listener ); }
protected void handlePerformNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { final DataItemValue.Builder newValue = new DataItemValue.Builder ( this.value ); newValue.setSubscriptionState ( subscriptionState ); newValue.setSubscriptionError ( subscriptionError ); final DataItemValue oldValue = this.value; this.value = newValue.build (); setChanged (); try { notifyObservers ( this.value ); this.propertySupport.firePropertyChange ( PROP_VALUE, oldValue, this.value ); } catch ( final Throwable e ) { logger.warn ( "Failed to notify subscription change", e ); } }
protected void performNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { handlePerformNotifySubscriptionChange ( subscriptionState, subscriptionError ); }
@Override public void notifyDataChange ( final Variant value, final Map<String, Variant> attributes, final boolean cache ) { DataItem.this.performNotifyDataChange ( value, attributes, cache ); }
private void bind () { if ( this.service != null && this.itemId != null ) { final ItemManager im = this.service.getItemManager (); this.dataItem = new DataItem ( this.itemId ); this.dataItem.addObserver ( this.observer = createObserver () ); this.dataItem.register ( im ); } }
public void register ( final ItemManager itemManager ) { if ( this.itemManager == itemManager ) { return; } unregister (); this.itemManager = itemManager; this.itemManager.addItemUpdateListener ( this.itemId, this.listener ); }
protected void handlePerformNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { final DataItemValue.Builder newValue = new DataItemValue.Builder ( this.value ); newValue.setSubscriptionState ( subscriptionState ); newValue.setSubscriptionError ( subscriptionError ); final DataItemValue oldValue = this.value; this.value = newValue.build (); setChanged (); try { notifyObservers ( this.value ); this.propertySupport.firePropertyChange ( PROP_VALUE, oldValue, this.value ); } catch ( final Throwable e ) { logger.warn ( "Failed to notify subscription change", e ); } }
protected void performNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { handlePerformNotifySubscriptionChange ( subscriptionState, subscriptionError ); }
@Override public void notifyDataChange ( final Variant value, final Map<String, Variant> attributes, final boolean cache ) { DataItem.this.performNotifyDataChange ( value, attributes, cache ); }
@Override protected synchronized void bindConnection ( final ConnectionService connectionService ) { super.bindConnection ( connectionService ); if ( connectionService != null ) { this.dataItem = new DataItem ( this.item.getId () ); if ( this.listener != null ) { this.dataItem.addObserver ( this.observer ); this.dataItem.register ( connectionService.getItemManager () ); } } }
protected synchronized void unbind () { this.observer = null; if ( this.dataItem != null ) { this.dataItem.unregister (); this.dataItem.deleteObservers (); handleUpdate ( null, DataItemValue.DISCONNECTED ); } }
/** * create a new data item structure. * <p> * Note that the item is initially connected to the item manager provided. * You must call {@link #unregister()} when you want to clear the * subscription with the item on the server. * * @param itemId * the id of the item to register * @param itemManager * the item manager to which the item will register */ public DataItem ( final String itemId, final ItemManager itemManager ) { this ( itemId ); if ( itemManager != null ) { register ( itemManager ); } }
setChanged (); newValue.setAttributes ( new HashMap<String, Variant> ( attributes ) ); setChanged (); setChanged (); newValue.setValue ( value ); notifyObservers ( this.value ); this.propertySupport.firePropertyChange ( PROP_VALUE, oldValue, this.value );
protected void performNotifyDataChange ( final Variant value, final Map<String, Variant> attributes, final boolean cache ) { handlePerformNotifyDataChange ( value, attributes, cache ); }
protected synchronized void setConnection ( final ConnectionService connectionService ) { disconnect (); if ( connectionService instanceof org.eclipse.scada.da.connection.provider.ConnectionService ) { this.connectionService = (org.eclipse.scada.da.connection.provider.ConnectionService)connectionService; this.dataItem = new DataItem ( this.item.getId () ); this.dataItem.addObserver ( this ); this.dataItem.register ( this.connectionService.getItemManager () ); } // at the end we are disconnected ... notify as last operation if ( this.connectionService == null ) { notifyChange ( DataItemValue.DISCONNECTED ); } }