@EventDriven @InputRequirement(value=INPUT_ALLOWED) @Tags(value={"script","groovy","groovyx"}) @CapabilityDescription(value="Experimental Extended Groovy script processor. The script is responsible for handling the incoming flow file (transfer to SUCCESS or remove, e.g.) as well as any flow files created by the script. If the handling is incomplete or incorrect, the session will be rolled back.") @Restricted(restrictions=@Restriction(requiredPermission=EXECUTE_CODE,explanation="Provides operator the ability to execute arbitrary code assuming all permissions that NiFi has.")) @SeeAlso(classNames="org.apache.nifi.processors.script.ExecuteScript") @DynamicProperty(name="A script engine property to update", value="The value to set it to", expressionLanguageScope=FLOWFILE_ATTRIBUTES, description="Updates a script engine property specified by the Dynamic Property\'s key with the value specified by the Dynamic Property\'s value. Use `CTL.` to access any controller services, `SQL.` to access any DBCPServices, `RecordReader.` to access RecordReaderFactory instances, or `RecordWriter.` to access any RecordSetWriterFactory instances.") public class ExecuteGroovyScript extends AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
private static class |
ExecuteGroovyScript.AccessMap
simple HashMap with exception on access of non-existent key
|
| Modifier and Type | Field and Description |
|---|---|
static PropertyDescriptor |
ADD_CLASSPATH |
(package private) String |
addClasspath |
(package private) Class<groovy.lang.Script> |
compiled |
private List<PropertyDescriptor> |
descriptors |
static PropertyDescriptor |
FAIL_STRATEGY |
static String |
GROOVY_CLASSPATH |
(package private) String |
groovyClasspath |
private static String |
PRELOADS |
static Relationship |
REL_FAILURE |
static Relationship |
REL_SUCCESS |
private Set<Relationship> |
relationships |
static PropertyDescriptor |
SCRIPT_BODY |
static PropertyDescriptor |
SCRIPT_FILE |
(package private) String |
scriptBody |
(package private) File |
scriptFile |
(package private) long |
scriptLastModified |
(package private) groovy.lang.GroovyShell |
shell |
static String[] |
VALID_FAIL_STRATEGY |
| Constructor and Description |
|---|
ExecuteGroovyScript() |
| Modifier and Type | Method and Description |
|---|---|
private File |
asFile(String f) |
private void |
callScriptStatic(String method,
ProcessContext context) |
protected Collection<ValidationResult> |
customValidate(ValidationContext context)
Let's do validation by script compile at this point.
|
(package private) groovy.lang.Script |
getGroovyScript() |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
Returns a PropertyDescriptor for the given name.
|
List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
private void |
onCommitSQL(Map<String,Object> SQL)
before commit SQL services
|
private void |
onFailSQL(Map<String,Object> SQL)
exception SQL services
|
private void |
onFinitSQL(Map<String,Object> SQL)
finalize SQL services.
|
private void |
onInitSQL(Map<String,Object> SQL)
init SQL variables from DBCP services
|
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue)
Hook method allowing subclasses to eagerly react to a configuration
change for the given property descriptor.
|
void |
onScheduled(ProcessContext context)
Performs setup operations when the processor is scheduled to run.
|
void |
onStopped(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession _session) |
void |
onUnscheduled(ProcessContext context) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, validatepublic static final String GROOVY_CLASSPATH
private static final String PRELOADS
public static final PropertyDescriptor SCRIPT_FILE
public static final PropertyDescriptor SCRIPT_BODY
public static String[] VALID_FAIL_STRATEGY
public static final PropertyDescriptor FAIL_STRATEGY
public static final PropertyDescriptor ADD_CLASSPATH
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
private List<PropertyDescriptor> descriptors
private Set<Relationship> relationships
File scriptFile
String scriptBody
String addClasspath
String groovyClasspath
volatile groovy.lang.GroovyShell shell
volatile Class<groovy.lang.Script> compiled
volatile long scriptLastModified
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic final List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprivate void callScriptStatic(String method, ProcessContext context) throws IllegalAccessException, InvocationTargetException
protected Collection<ValidationResult> customValidate(ValidationContext context)
customValidate in class AbstractConfigurableComponentcontext - provides a mechanism for obtaining externally managed values, such as property values and supplies convenience methods for operating on those valuespublic 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 property was removed@OnScheduled public void onScheduled(ProcessContext context)
context - the context in which to perform the setup operations@OnUnscheduled public void onUnscheduled(ProcessContext context)
@OnStopped public void onStopped(ProcessContext context)
private void onInitSQL(Map<String,Object> SQL) throws SQLException
SQLExceptionprivate void onCommitSQL(Map<String,Object> SQL) throws SQLException
SQLExceptionprivate void onFinitSQL(Map<String,Object> SQL)
public void onTrigger(ProcessContext context, ProcessSession _session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentpropertyDescriptorName - used to lookup if any property descriptors exist for that nameCopyright © 2022 Apache NiFi Project. All rights reserved.