Uploaded image for project: 'WildFly Arquillian'
  1. WildFly Arquillian
  2. WFARQ-186

ArquillianService relies on deprecated MSC API to get the DeploymentUnit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      See the TODOs:
       

          // TODO: This listener based solution is still too hacky. Proper integration should be:
          // TODO: 1) either parentController service will expose DU retrieval via public method
          // TODO: 2) or this listener based solution will be replaced with WildFly Extension based solution
          private static class ArquillianListener implements LifecycleListener {
              private final ServiceTarget serviceTarget;
      
              private ArquillianListener(final ServiceTarget serviceTarget) {
                  this.serviceTarget = serviceTarget;
              }
      
              @Override
              public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
                  final ServiceName serviceName = controller.getName();
                  if (!JBOSS_DEPLOYMENT.isParentOf(serviceName))
                      return;
                  final String simpleName = serviceName.getSimpleName();
      
                  if (event == LifecycleEvent.DOWN && simpleName.equals(Phase.DEPENDENCIES.toString())) {
                      // DOWN event can happen multiple times during service lifecycle so this is handled
                      // in ArquillianConfigBuilder.handleParseAnnotations(depUnit) method below.
                      ServiceName parentName = serviceName.getParent();
                      ServiceController<?> parentController = controller.getServiceContainer().getService(parentName);
                      DeploymentUnit depUnit = (DeploymentUnit) parentController.getValue(); // TODO: eliminate deprecated API usage
                      ArquillianConfigBuilder.handleParseAnnotations(depUnit);
                  } else if (event == LifecycleEvent.UP && simpleName.equals(Phase.INSTALL.toString())) {
                      ServiceName parentName = serviceName.getParent();
                      ServiceController<?> parentController = controller.getServiceContainer().getService(parentName);
                      DeploymentUnit depUnit = (DeploymentUnit) parentController.getValue(); // TODO: eliminate deprecated API usage
                      Map<String, ArquillianConfig.TestClassInfo> testClasses = ArquillianConfigBuilder.getClasses(depUnit);
                      if (testClasses != null) {
                          String duName = ArquillianConfigBuilder.getName(depUnit);
                          ServiceName arqConfigSN = ServiceName.JBOSS.append("arquillian", "config", duName);
                          ServiceBuilder<ArquillianConfig> builder = (ServiceBuilder<ArquillianConfig>) serviceTarget
                                  .addService(arqConfigSN);
                          ArquillianConfig arqConfig = new ArquillianConfig(arqConfigSN, testClasses,
                                  builder.requires(ArquillianService.SERVICE_NAME),
                                  builder.requires(parentController.getName()));
                          arqConfig.addDeps(builder, controller);
                          builder.setInstance(arqConfig);
                          builder.install();
                          log.infof("Arquillian deployment detected: %s", arqConfig);
                      }
                  }
              }
          }
      

      This blocks WFCORE-6942.

      Note there may be other code like this; this is just what I spotted when poking a bit.

      This isn't super-urgent. I started poking at WFCORE-6942 for non-urgent reasons.

              Unassigned Unassigned
              bstansbe@redhat.com Brian Stansberry
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: