1 Reply Latest reply on Apr 8, 2014 9:48 AM by asotobu

    Configuration of an Arquillian Extension

    asotobu

      Hello I am developing an extension and I need that users configure some parameters. I have done next steps:

       

      Create a MocoConfigurator class which listens for arquillian descriptor:

       

          @Inject
          @ApplicationScoped
          private InstanceProducer<MocoConfiguration> configurationProvider;
          
          public void configure(@Observes ArquillianDescriptor arquillianDescriptor) {
              
              Map<String, String> config = arquillianDescriptor.extension(EXTENSION_NAME).getExtensionProperties();
              configurationProvider.set(MocoConfiguration.fromMap(config));
          }
      

       

      Then I have added MocoConfiguration class to extension archive:

       

      @Override
        public Archive<?> createAuxiliaryArchive() {
      
         return ShrinkWrap.create(JavaArchive.class, "arquillian-moco.jar")
                    .addClass(ReflectionHelper.class)
                    .addPackage(Moco.class.getPackage())
                    .addPackage(MocoRemoteExtension.class.getPackage())
                    .addClass(MocoConfiguration.class)
                    .addAsServiceProvider(RemoteLoadableExtension.class, MocoRemoteExtension.class);
      
        }
      

       

      Then in extension class I have registered the observer:

       

      @Override
        public void register(ExtensionBuilder builder) {
      
        builder.service(ApplicationArchiveProcessor.class,
        MocoDependencyArchiveProcessor.class);
        builder.service(AuxiliaryArchiveAppender.class,
        MocoArchiveAppender.class);
      
        builder.observer(MocoConfigurator.class);
      
        }
      

       

      The instance is required in container side so I have added next line on a class that is executed in remote side.

       

      @Inject
      private Instance<MocoConfiguration> config;
      

       

       

      The problem is that when I use this code the class is not executed but no error is thrown, but if I comment the previous line and I hardcoded the port then it works, so it seems I have missed something to do so this can work on remote side. Am I wrong= What I have missed?

       

      Thank you so much for your help.

       

      And finally I have added the information inside arquillian.xml (which is configured to use Servlet protocol).

       

      The problem is that although the information is loaded correctly

        • 1. Re: Configuration of an Arquillian Extension
          asotobu

          Bartosz has noted me the solution. In container remote part you cannot inject configuration values, so the workaround is put these properties into a properties file, send to remote part and then in remote part deserialize the file into a class again.