public AbstractConnectionDevice ( final BundleContext context, final String id, final NioProcessor processor, final ScheduledExecutorService executor, final String itemPrefix ) { this.id = id; this.processor = processor; this.context = context; this.itemPrefix = itemPrefix; this.executor = executor; this.itemFactory = new DataItemFactory ( context, executor, getItemId ( null ) ); this.stateItem = this.itemFactory.createInput ( "state", Collections.<String, Variant> emptyMap () ); this.connectionItem = this.itemFactory.createInput ( "connection", Collections.<String, Variant> emptyMap () ); }
@Override public WriteHandlerItem createInputOutput ( final String localId, final Map<String, Variant> properties, final WriteHandler writeHandler ) { return createOutput ( localId, properties, writeHandler ); }
@Override public synchronized void dispose () { disposeAllItems (); } }
@Override public synchronized DataItemCommand createCommand ( final String localId, final Map<String, Variant> properties ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final DataItemCommand newItem = new DataItemCommand ( getId ( localId ), this.executor ); registerItem ( item, localId, fixProperties ( properties ) ); return newItem; } else if ( item instanceof DataItemCommand ) { return (DataItemCommand)item; } return null; }
protected void registerItem ( final DataItem newItem, final String localId, final Map<String, Variant> properties ) { final Dictionary<String, String> props = new Hashtable<String, String> (); fillProperties ( properties, props ); final ServiceRegistration<DataItem> handle = this.context.registerService ( DataItem.class, newItem, props ); this.items.put ( localId, newItem ); this.itemRegs.put ( localId, handle ); }
protected void performDispose () { disconnect (); this.stateItem.updateData ( Variant.valueOf ( "DISPOSED" ), null, null ); if ( this.connector != null ) { this.connector.dispose (); this.connector = null; } this.itemFactory.dispose (); if ( this.createdExecutor != null ) { this.createdExecutor.shutdown (); } }
public Statistics ( final DataItemFactory itemFactory, final int size ) { this.stateItem = itemFactory.createInput ( "state", null ); this.timeoutStateItem = itemFactory.createInput ( "timeout", null ); this.lastUpdateItem = itemFactory.createInput ( "lastUpdate", null ); this.lastTimeDiffItem = itemFactory.createInput ( "lastDiff", null ); this.avgDiffItem = itemFactory.createInput ( "avgDiff", null ); this.checksumErrorsItem = itemFactory.createInput ( "checksumErrors", null ); this.sizeItem = itemFactory.createInput ( "size", null ); this.sizeItem.updateData ( Variant.valueOf ( size ), null, null ); this.lastUpdate = System.currentTimeMillis (); this.diffBuffer = new CircularFifoBuffer ( 20 ); }
@Override public synchronized DataItemCommand createCommand ( final String localId, final Map<String, Variant> properties ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final DataItemCommand newItem = new DataItemCommand ( getId ( localId ), this.executor ); registerItem ( item, localId, fixProperties ( properties ) ); return newItem; } else if ( item instanceof DataItemCommand ) { return (DataItemCommand)item; } return null; }
protected void registerItem ( final DataItem newItem, final String localId, final Map<String, Variant> properties ) { final Dictionary<String, String> props = new Hashtable<String, String> (); fillProperties ( properties, props ); final ServiceRegistration<DataItem> handle = this.context.registerService ( DataItem.class, newItem, props ); this.items.put ( localId, newItem ); this.itemRegs.put ( localId, handle ); }
@Override public synchronized void dispose () { if ( this.disposed ) { return; } logger.info ( "Disposing: {}", this ); this.disposed = true; if ( this.configurator != null ) { this.configurator.stop (); } if ( this.statistics != null ) { this.statistics.dispose (); } if ( this.blockItemFactory != null ) { this.blockItemFactory.dispose (); } if ( this.variables != null ) { for ( final Variable reg : this.variables ) { reg.stop ( this.context ); } } }
public synchronized AttributeWriteHandlerItem createOutput ( final String localId, final Map<String, Variant> properties, final AttributeWriteHandler writeHandler ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final AttributeWriteHandlerItem newItem = new AttributeWriteHandlerItem ( id, writeHandler, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else if ( item instanceof AttributeWriteHandlerItem ) { return (AttributeWriteHandlerItem)item; } else { return null; } }
public AbstractRequestBlock ( final BundleContext context, final Executor executor, final String mainTypeName, final String variablePrefix, final String blockPrefix, final boolean enableStatistics, final long period, final int requestSize, final long timeoutQuietPeriod, final boolean eager ) { this.context = context; this.variablePrefix = variablePrefix; this.blockPrefix = blockPrefix; this.timeoutQuietPeriod = timeoutQuietPeriod; this.eager = eager; this.period = period; this.blockItemFactory = new DataItemFactory ( context, executor, blockPrefix ); this.settingVariablesItem = this.blockItemFactory.createInput ( "settingVariables", null ); if ( enableStatistics ) { this.statistics = new Statistics ( this.blockItemFactory, requestSize ); } else { this.statistics = null; } this.configurator = new RequestBlockConfigurator ( this, mainTypeName ); }
@Override public WriteHandlerItem createInputOutput ( final String localId, final Map<String, Variant> properties, final WriteHandler writeHandler ) { return createOutput ( localId, properties, writeHandler ); }
@Override public synchronized void dispose () { disposeAllItems (); } }
public synchronized AttributeWriteHandlerItem createOutput ( final String localId, final Map<String, Variant> properties, final AttributeWriteHandler writeHandler ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final AttributeWriteHandlerItem newItem = new AttributeWriteHandlerItem ( id, writeHandler, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else if ( item instanceof AttributeWriteHandlerItem ) { return (AttributeWriteHandlerItem)item; } else { return null; } }
public synchronized WriteHandlerItem createOutput ( final String localId, final Map<String, Variant> properties, final WriteHandler writeHandler ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final WriteHandlerItem newItem = new WriteHandlerItem ( id, writeHandler, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else { if ( item instanceof WriteHandlerItem ) { return (WriteHandlerItem)item; } else { return null; } } }
public synchronized WriteHandlerItem createOutput ( final String localId, final Map<String, Variant> properties, final WriteHandler writeHandler ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final WriteHandlerItem newItem = new WriteHandlerItem ( id, writeHandler, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else { if ( item instanceof WriteHandlerItem ) { return (WriteHandlerItem)item; } else { return null; } } }
@Override public synchronized DataItemInputChained createInput ( final String localId, final Map<String, Variant> properties ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final DataItemInputChained newItem = new DataItemInputChained ( id, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else { if ( item instanceof DataItemInputChained ) { return (DataItemInputChained)item; } else { return null; } } }
@Override public synchronized DataItemInputChained createInput ( final String localId, final Map<String, Variant> properties ) { final DataItem item = this.items.get ( localId ); if ( item == null ) { final String id = getId ( localId ); final DataItemInputChained newItem = new DataItemInputChained ( id, this.executor ); registerItem ( newItem, localId, fixProperties ( properties ) ); return newItem; } else { if ( item instanceof DataItemInputChained ) { return (DataItemInputChained)item; } else { return null; } } }