@Override @SuppressWarnings("unchecked") public void fillWriteRecipe(PVWriterDirector director, WriteRecipeBuilder builder) { synchronized(lock) { this.director = director; for (Map.Entry<String, WriteExpression<T>> entry : expressions.entrySet()) { WriteExpression<T> writeExpression = entry.getValue(); director.connectExpression(writeExpression); } } }
static <T> PVWriterDirector<T> prepareDirector(PVWriterConfiguration<T> writerConfiguration) { PVWriterDirector<T> writerDirector = new PVWriterDirector<T>(writerConfiguration.pvWriter, writerConfiguration.writeFunction, writerConfiguration.dataSource, PVManager.getAsyncWriteExecutor(), writerConfiguration.notificationExecutor, PVManager.getReadScannerExecutorService(), writerConfiguration.timeout, writerConfiguration.timeoutMessage, writerConfiguration.exceptionHandler); writerDirector.connectExpression(writerConfiguration.writeExpression); writerConfiguration.pvWriter.setWriteDirector(writerDirector); return writerDirector; }
/** * Adds the expression to the map. * * @param expression the expression to be added * @return this expression */ public WriteMap<T> add(WriteExpression<T> expression) { synchronized(lock) { if (expression.getName() == null) { throw new NullPointerException("Expression has a null name"); } if (expressions.containsKey(expression.getName())) { throw new IllegalArgumentException("MapExpression already contain an expression named '" + expression.getName() + "'"); } getMapOfWriteFunction().getMapUpdateCollector().writeValue(MapUpdate.addWriteFunction(expression.getName(), expression.getWriteFunction())); expressions.put(expression.getName(), expression); if (director != null) { director.connectExpression(expression); } return this; } }