@Tags(value={"script","invoke","groovy","python","jython","jruby","ruby","javascript","js","lua","luaj"}) @CapabilityDescription(value="Experimental - Invokes a script engine for a Processor defined in the given script. The script must define a valid class that implements the Processor interface, and it must set a variable \'processor\' to an instance of the class. Processor methods such as onTrigger() will be delegated to the scripted Processor instance. Also any Relationships or PropertyDescriptors defined by the scripted processor will be added to the configuration dialog. Experimental: Impact of sustained usage not yet verified.") @DynamicProperty(name="A script engine property to update", value="The value to set it to", supportsExpressionLanguage=true, description="Updates a script engine property specified by the Dynamic Property\'s key with the value specified by the Dynamic Property\'s value") @SeeAlso(value=ExecuteScript.class) public class InvokeScriptedProcessor extends AbstractScriptProcessor
| Modifier and Type | Field and Description |
|---|---|
private AtomicReference<Processor> |
processor |
private ScriptEngine |
scriptEngine |
private AtomicBoolean |
scriptNeedsReload |
private AtomicReference<Collection<ValidationResult>> |
validationResults |
descriptors, engineQ, isInitialized, modules, MODULES, REL_FAILURE, REL_SUCCESS, SCRIPT_BODY, SCRIPT_ENGINE, SCRIPT_FILE, scriptBody, scriptEngineConfiguratorMap, scriptEngineFactoryMap, scriptEngineName, scriptPath| Constructor and Description |
|---|
InvokeScriptedProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext context)
Invokes the validate() routine provided by the script, allowing for custom validation code.
|
Set<Relationship> |
getRelationships()
Returns the valid relationships for this processor.
|
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
Returns a PropertyDescriptor for the given name.
|
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors()
Returns a list of property descriptors supported by this processor.
|
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue)
Handles changes to this processor's properties.
|
void |
onTrigger(ProcessContext context,
ProcessSessionFactory sessionFactory)
Invokes the onTrigger() method of the scripted processor.
|
private boolean |
reloadScript(String scriptBody)
Reloads the script Processor.
|
private boolean |
reloadScriptBody(String scriptBody)
Reloads the script defined by the given string
|
private boolean |
reloadScriptFile(String scriptPath)
Reloads the script located at the given path
|
void |
setup() |
void |
setup(ProcessContext context)
Performs setup operations when the processor is scheduled to run.
|
void |
stop() |
createResources, createScriptEngine, createScriptEngineModuleClassLoader, isFile, setup, setupEnginesgetControllerServiceLookup, getIdentifier, getLogger, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPropertyDescriptor, getPropertyDescriptors, validateprivate final AtomicReference<Processor> processor
private final AtomicReference<Collection<ValidationResult>> validationResults
private AtomicBoolean scriptNeedsReload
private ScriptEngine scriptEngine
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentpropertyDescriptorName - used to lookup if any property descriptors exist for that name@OnScheduled public void setup(ProcessContext context)
context - the context in which to perform the setup operationspublic void setup()
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentdescriptor - of the modified propertyoldValue - non-null property value (previous)newValue - the new property value or if null indicates the propertyprivate boolean reloadScriptFile(String scriptPath)
scriptPath - the path to the script file to be loadedprivate boolean reloadScriptBody(String scriptBody)
scriptBody - the contents of the script to be loadedprivate boolean reloadScript(String scriptBody)
scriptBody - An input stream associated with the script contentprotected Collection<ValidationResult> customValidate(ValidationContext context)
customValidate in class AbstractScriptProcessorcontext - The validation context to be passed into the custom validate methodpublic void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
context - provides access to convenience methods for obtaining
property values, delaying the scheduling of the processor, provides
access to Controller Services, etc.sessionFactory - provides access to a ProcessSessionFactory, which
can be used for accessing FlowFiles, etc.ProcessException - if the scripted processor's onTrigger() method throws an exception@OnStopped public void stop()
stop in class AbstractScriptProcessorCopyright © 2017 Apache NiFi Project. All rights reserved.