4 Replies Latest reply on Apr 26, 2010 7:08 AM by Emanuel Muckenhuber

    controller.uninstall() fails when overriding the KernelControllerContext name

    Emanuel Muckenhuber Master

      When i manully set a name for a KernelControllerContext the uninstallation of contexts does not work properly.

       

      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("test", Object.class.getName());
            
      ObjectName name = new ObjectName("org.jboss:service=test");
            
      KernelControllerContext ctx = new AbstractKernelControllerContext(null, builder.getBeanMetaData(), new Object());
      ctx.setName(name);
      
      getController().install(ctx);
      getController().uninstall(name);
            
      assertNull(getController().getContext(name, null));
      

       

      In this case the context does not get properly uninstalled and ends up in the ERROR state (without any error message - which IMHO is also a bit weird). The name change happens in the "InstallAction" which uses the original name of the BeanMetaData to register the context in the KernelRegistry:

       

      BeanMetaData metaData = context.getBeanMetaData();
      Object name = metaData.getName();
      registry.registerEntry(name, context);
      

       

      Which then changes the controllerContexts back to the name which was defined in the BeanMetaData. Basically you can lookup the correct context, however the context cannot be remove from allContexts in the controller - since the name it got registers now is different from the context name:

       

      controller.uninstall(objectName)
      ...
      ControllerContext context = getRegisteredContextAndInterruptAsynchronousInstall(objectName);
      ....
      unregisterControllerContext(context);
      ....
      Object beanMetaDataName = context.getName();
      allContext.remove(beanMetaDataName);
      

       

      Obviously when i set the original context name before uninstalling this works fine.