Support Questions
Find answers, ask questions, and share your expertise

how to inject interface when i try to bulid custom processor

Highlighted

how to inject interface when i try to bulid custom processor

New Contributor
 i'm trying to make custom processor that can control bulletins of nifi.
 but reportingContext is return null.. if i cannot use @Autowired how can i solve this problem ?
 help me about this issue thank you. 




   private ReportingContext reportingContext;
    private BulletinRepository bulletinRepository;
    

    @Override
    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
        FlowFile flowFile = session.get();
    ComponentLog logger = getLogger();
        /*if ( flowFile == null ) {
            return;
        }*/
    bulletinRepository = reportingContext.getBulletinRepository();
    ArrayList<Bulletin> bulletinsList = new ArrayList<>();

    int bulletinsFound = 0;
    long previousBulletinId = 0;

     do{
     bulletinsFound = 0;
         final BulletinQuery queryProcessor1= new BulletinQuery.Builder().sourceType(ComponentType.PROCESSOR).after(previousBulletinId).build();

         List<Bulletin> bulletinsThisQuery = bulletinRepository.findBulletins(queryProcessor1);

         if(bulletinsThisQuery != null && bulletinsThisQuery.size() > 0){
             bulletinsFound = bulletinsThisQuery.size();
             previousBulletinId = bulletinsThisQuery.get(0).getId(); /** Retrieve bulletin id*/
             bulletinsList.addAll(bulletinsThisQuery); 

         }
     }
     while(bulletinsFound > 0 && bulletinsList.size() < 100);
    }