Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1045#discussion_r85119526
  
    --- Diff: 
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/reporting/script/ScriptedReportingTask.java
 ---
    @@ -0,0 +1,197 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.reporting.script;
    +
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +import org.apache.commons.io.IOUtils;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.components.ValidationContext;
    +import org.apache.nifi.components.ValidationResult;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.processors.script.ScriptEngineConfigurator;
    +import org.apache.nifi.processors.script.ScriptUtils;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.util.StringUtils;
    +
    +import javax.script.Bindings;
    +import javax.script.ScriptContext;
    +import javax.script.ScriptEngine;
    +import javax.script.ScriptException;
    +import javax.script.SimpleBindings;
    +import java.io.FileInputStream;
    +import java.io.IOException;
    +import java.nio.charset.Charset;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * A Reporting task whose body is provided by a script (via supported 
JSR-223 script engines)
    + */
    +@Tags({"reporting", "script", "execute", "groovy", "python", "jython", 
"jruby", "ruby", "javascript", "js", "lua", "luaj"})
    +@CapabilityDescription("Provides reporting and status information to a 
script. ReportingContext, ComponentLog, and VirtualMachineMetrics objects are 
made available "
    +        + "as variables (context, log, and vmMetrics, respectively) to the 
script for further processing. The context makes various information available 
such "
    +        + "as events, provenance, bulletins, controller services, process 
groups, Java Virtual Machine metrics, etc.")
    +public class ScriptedReportingTask extends AbstractReportingTask {
    +
    +    protected volatile ScriptUtils scriptUtils = new ScriptUtils();
    +    protected volatile String scriptToRun = null;
    +    protected volatile VirtualMachineMetrics vmMetrics;
    +
    +    /**
    +     * Returns a list of property descriptors supported by this processor. 
The list always includes properties such as
    +     * script engine name, script file name, script body name, script 
arguments, and an external module path. If the
    +     * scripted processor also defines supported properties, those are 
added to the list as well.
    +     *
    +     * @return a List of PropertyDescriptor objects supported by this 
processor
    +     */
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        synchronized (scriptUtils.isInitialized) {
    +            if (!scriptUtils.isInitialized.get()) {
    +                scriptUtils.createResources();
    +            }
    +        }
    +
    +        return Collections.unmodifiableList(scriptUtils.descriptors);
    +    }
    +
    +    /**
    +     * Returns a PropertyDescriptor for the given name. This is for the 
user to be able to define their own properties
    +     * which will be available as variables in the script
    +     *
    +     * @param propertyDescriptorName used to lookup if any property 
descriptors exist for that name
    +     * @return a PropertyDescriptor object corresponding to the specified 
dynamic property name
    +     */
    +    @Override
    +    protected PropertyDescriptor 
getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder()
    +                .name(propertyDescriptorName)
    --- End diff --
    
    This is a good point and applies everywhere for dynamic properties, I think 
we should file a Jira to investigate.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to