@Override public String getId () { return this.itemInformation.getName (); }
public DataItemInformationBase ( final DataItemInformation information ) { super (); this.id = information.getName (); this.ioDirection = EnumSet.copyOf ( information.getIODirection () ); }
@Override public void disposeItem ( final DataItem item ) { this.itemMap.remove ( item.getInformation ().getName () ); }
@Override public void dataChanged ( final DataItem item, final Variant value, final Map<String, Variant> attributes, final boolean cache ) { logger.debug ( "Data changed - itemId: {}, value: {}, attributes: {}, cache: {}", new Object[] { item.getInformation ().getName (), value, attributes, cache } ); final ItemChangeListener listener; if ( ( listener = this.listener ) != null ) { listener.dataChanged ( item.getInformation ().getName (), value, attributes, cache ); } }
@Override public synchronized void disposeItem ( final DataItem dataItem ) { final String itemId = dataItem.getInformation ().getName (); if ( this.items.get ( itemId ) != dataItem ) { return; } this.items.remove ( itemId ); unregisterItem ( dataItem ); }
@Override public synchronized void disposeItem ( final DataItem dataItem ) { final String itemId = dataItem.getInformation ().getName (); if ( this.items.get ( itemId ) != dataItem ) { return; } this.items.remove ( itemId ); unregisterItem ( dataItem ); }
public synchronized String findEntry ( final DataItem item ) { for ( final Iterator<Map.Entry<String, Entry>> i = this.entryMap.entrySet ().iterator (); i.hasNext (); ) { final String itemId = item.getInformation ().getName (); final Map.Entry<String, Entry> entry = i.next (); if ( entry.getValue () instanceof DataItemEntryCommon ) { if ( ( (DataItemEntryCommon)entry.getValue () ).getId () == itemId ) { return entry.getKey (); } } } return null; }
/** * Create new item descriptor * * @param item * the data item, must not be <code>null</code> * @param attributes * the optional describing attributes, may be <code>null</code> */ public ItemDescriptor ( final DataItem item, final Map<String, Variant> attributes ) { this.item = item; this.itemId = item.getInformation ().getName (); if ( attributes != null ) { this.attributes = new HashMap<String, Variant> ( attributes ); } else { this.attributes = Collections.emptyMap (); } }
private void registerItem ( final DataItem newItem ) { final DataItem oldItem = this.itemMap.put ( newItem.getInformation ().getName (), newItem ); if ( oldItem != null ) { disposeItem ( oldItem ); } }
public synchronized boolean remove ( final DataItem item ) { for ( final Iterator<Map.Entry<String, Entry>> i = this.entryMap.entrySet ().iterator (); i.hasNext (); ) { final String itemId = item.getInformation ().getName (); final Map.Entry<String, Entry> entry = i.next (); if ( entry.getValue () instanceof DataItemEntryCommon ) { if ( ( (DataItemEntryCommon)entry.getValue () ).getId () == itemId ) { i.remove (); notifyRemove ( entry.getKey () ); return true; } } } return false; }
public String getName ( final ItemDescriptor descriptor ) { try { return descriptor.getItem ().getInformation ().getName (); } catch ( final Throwable e ) { return null; } }
public boolean add ( final String name, final DataItemInformation itemInformation, final Map<String, Variant> attributes ) { if ( itemInformation == null || itemInformation.getName () == null ) { throw new NullPointerException ( "Item must have an id" ); } synchronized ( this ) { if ( !this.entryMap.containsKey ( name ) ) { final Entry entry = new DataItemEntryCommon ( name, itemInformation, attributes ); this.entryMap.put ( name, entry ); notifyAdd ( entry ); return true; } else { return false; } } }
private <T extends DataItem> T registerItem ( final T item, final Map<String, Variant> properties ) { final Dictionary<?, ?> localProperties = new Hashtable<Object, Object> ( 0 ); final String itemId = item.getInformation ().getName (); // remove old item first final DataItem oldItem = this.items.remove ( itemId ); if ( oldItem != null ) { this.objectPool.removeService ( itemId, oldItem ); } this.items.put ( itemId, item ); this.objectPool.addService ( itemId, item, localProperties ); return item; }
private <T extends DataItem> T registerItem ( final T item, final Map<String, Variant> properties ) { final Dictionary<?, ?> localProperties = new Hashtable<Object, Object> ( 0 ); final String itemId = item.getInformation ().getName (); // remove old item first final DataItem oldItem = this.items.remove ( itemId ); if ( oldItem != null ) { this.objectPool.removeService ( itemId, oldItem ); } this.items.put ( itemId, item ); this.objectPool.addService ( itemId, item, localProperties ); return item; }
protected void unregisterItem ( final DataItem dataItem ) { this.objectPool.removeService ( dataItem.getInformation ().getName (), dataItem ); }
protected void unregisterItem ( final DataItem dataItem ) { this.objectPool.removeService ( dataItem.getInformation ().getName (), dataItem ); }
@Override public synchronized void wakeup () { logger.info ( "Wakeup item: {} - currentState: {}", getInformation ().getName (), this.suspended ); if ( !this.suspended ) { return; } this.suspended = false; this.controller.getIoManager ().wakeupItem ( this.opcItemId ); }
@Override public synchronized void suspend () { logger.info ( "Suspend item: {} - currentState: {}", getInformation ().getName (), this.suspended ); if ( this.suspended ) { return; } this.suspended = true; this.controller.getIoManager ().suspendItem ( this.opcItemId ); }
@Override public void register ( final HiveCommon hive, final FolderCommon rootFolder, final String description ) { final Map<String, Variant> attributes = new HashMap<String, Variant> (); hive.registerItem ( this.averageItem ); attributes.put ( "description", Variant.valueOf ( description + " - Average value" ) ); rootFolder.add ( this.averageItem.getInformation ().getName (), this.averageItem, attributes ); attributes.clear (); hive.registerItem ( this.totalItem ); attributes.put ( "description", Variant.valueOf ( description + " - Total counter" ) ); rootFolder.add ( this.totalItem.getInformation ().getName (), this.totalItem, attributes ); try { this.exportInstance = this.mbs.registerMBean ( this.export, makeName ( hive.getHiveId () + ".stats", this.itemId ) ); } catch ( final Exception e ) { logger.warn ( "Failed to export statistics", e ); } }
@Override public void stop ( final BundleContext context ) { if ( this.item == null ) { return; } this.itemPool.removeService ( this.item.getInformation ().getName (), this.item ); for ( final Attribute attr : this.attributes ) { attr.stop (); } this.item = null; }