public static Operator buildOperator ( OperatorDesc operatorDesc , MetricRegistry metricRegistry , String planPath , FeedPartition feedPartition ) { Operator operator = null ; NitFactory nitFactory = new NitFactory ( ) ; NitDesc nitDesc = nitDescFromDynamic ( operatorDesc ) ; try { if ( nitDesc . getSpec ( ) == NitDesc . NitSpec . GROOVY_CLOSURE ) { operator = new GroovyOperator ( ( Closure ) nitFactory . construct ( nitDesc ) ) ; } else { operator = nitFactory . construct ( nitDesc ) ; } } catch ( NitException e ) { throw new RuntimeException ( e ) ; } operator . setProperties ( operatorDesc . getParameters ( ) ) ; operator . setMetricRegistry ( metricRegistry ) ; operator . setPartitionId ( feedPartition . getPartitionId ( ) ) ; String myName = operatorDesc . getName ( ) ; if ( myName == null ) { myName = operatorDesc . getTheClass ( ) ; if ( myName . indexOf ( "." ) > - 1 ) { String [ ] parts = myName . split ( "\\." ) ; myName = parts [ parts . length - 1 ] ; } } operator . setPath ( planPath + "." + myName ) ; return operator ; }
OperatorDesc can describe local reasources URL loaded resources and dynamic resources like groovy code . This method instantiates an Operator based on the OperatorDesc .