3 Replies Latest reply on Feb 12, 2018 11:47 PM by Jörg Hoh

    service injection with parameter

    brolinuk

      I am trying to call AWS S3 bucket from our AEM. I have created an S3Manager class/service to to wrap it. which will be injected/referenced from wherever needed. This is working fine, but requires to create AmazonS3Client instance each time when I need to upload or download a file.

       

      I am trying to initialise the amazonS3Client in the constructor instead, so I don't need to create so many instance.

       

      private AmazonS3Client amazonS3Client;

      public S3Manager(){

        String externalId = sitemapService.getAssumeRoleId();
         String roleArn = sitemapService.getRoleArn();


         amazonS3Client = getAmazonS3Client(externalId, roleArn);
      }

       

      SitemapService is another service I created to read the OSGI config (from xml or the console). The way I am doing seems not working, I am getting following exception, when initialisation try to run  sitemapService.getAssumeRoleId();

      Error during instantiation of the implementation object (java.lang.NullPointerException)

       

      I assume at the point of running, sitemapservice has not been injected yet. Is there a way, I can assure that sitemapservice injection is completed before initialise S3Manager? Or there is better way to achieve what I am looking for. Thanks