[ 
https://issues.apache.org/jira/browse/NIFI-2020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15368796#comment-15368796
 ] 

ASF GitHub Bot commented on NIFI-2020:
--------------------------------------

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

    https://github.com/apache/nifi/pull/564#discussion_r70157635
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java
 ---
    @@ -212,12 +279,40 @@ public void process(OutputStream out) throws 
IOException {
     
         @OnScheduled
         public void setup(final ProcessContext context) {
    -        Object specJson = null;
    -        if(context.getProperty(JOLT_SPEC).isSet() && 
!SORTR.getValue().equals(context.getProperty(JOLT_TRANSFORM).getValue())){
    -            specJson = 
JsonUtils.jsonToObject(context.getProperty(JOLT_SPEC).getValue(), 
DEFAULT_CHARSET);
    +
    +        try{
    +            Object specJson = null;
    +
    +            if(context.getProperty(MODULES).isSet()){
    +                customClassLoader = 
ClassLoaderUtils.getCustomClassLoader(context.getProperty(MODULES).getValue(),this.getClass().getClassLoader(),getJarFilenameFilter());
    +            }else{
    +                customClassLoader = null;
    +            }
    +
    +            if(context.getProperty(JOLT_SPEC).isSet() && 
!SORTR.getValue().equals(context.getProperty(JOLT_TRANSFORM).getValue())){
    +                specJson = 
JsonUtils.jsonToObject(context.getProperty(JOLT_SPEC).getValue(), 
DEFAULT_CHARSET);
    +            }
    +
    +            
if(CUSTOMR.getValue().equals(context.getProperty(JOLT_TRANSFORM).getValue())){
    +                transform = 
TransformFactory.getCustomTransform(customClassLoader,context.getProperty(CUSTOM_CLASS).getValue(),
 specJson);
    +            }else {
    +                transform = 
TransformFactory.getTransform(customClassLoader != null? customClassLoader : 
this.getClass().getClassLoader(),
    +                                                            
context.getProperty(JOLT_TRANSFORM).getValue(), specJson);
    +            }
    +
    +        } catch (Exception ex){
    +            getLogger().error("Unable to setup processor",ex);
             }
    -        transform = 
TransformFactory.getTransform(context.getProperty(JOLT_TRANSFORM).getValue(), 
specJson);
    +
         }
     
    +    protected FilenameFilter getJarFilenameFilter(){
    --- End diff --
    
    Another spot where lambdas could be (but don't have to be) used


> Enhance JoltTransformJSON processor to support custom transforms
> ----------------------------------------------------------------
>
>                 Key: NIFI-2020
>                 URL: https://issues.apache.org/jira/browse/NIFI-2020
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Core Framework
>    Affects Versions: 1.0.0
>            Reporter: Yolanda M. Davis
>            Assignee: Yolanda M. Davis
>             Fix For: 1.0.0
>
>
> Jolt supports additional custom transforms via fully-qualified Java 
> classnames. Would like to provide the ability to support custom 
> transformation (via drop in jars) for the Jolt Transform processor.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to