Class GuiceChainrInstantiator

  • All Implemented Interfaces:
    ChainrInstantiator

    public class GuiceChainrInstantiator
    extends java.lang.Object
    implements ChainrInstantiator
    This class allows Transforms specified in Chainr spec files to be loaded via Guice. This is primarily used for Custom Java Transforms that need additional information.

    It requires a GuiceModule, because it creates an Injector for each SpecTransform it processes.

    If your app is using Guice, you can either pass in your "existing" Module (if you can), or create a Guice Module with just the dependencies that the Transforms require. The latter approach keeps scope contained, and make it easier to unit test your Transforms.

    Note this does require that you "know" what Transforms you are using and what they depend on.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.inject.Injector nonSpecInjector  
      private com.google.inject.Module parentModule  
    • Constructor Summary

      Constructors 
      Constructor Description
      GuiceChainrInstantiator​(com.google.inject.Module parentModule)  
    • Field Detail

      • parentModule

        private final com.google.inject.Module parentModule
      • nonSpecInjector

        private final com.google.inject.Injector nonSpecInjector
    • Constructor Detail

      • GuiceChainrInstantiator

        public GuiceChainrInstantiator​(com.google.inject.Module parentModule)
        Parameters:
        parentModule - Guice module that will be used to create an injector to instantiate Transform classes