Example #1
0
 public synchronized void stop(StopContext context) {
   log.debugf("Stopping Arquillian Test Runner");
   try {
     if (jmxTestRunner != null) {
       jmxTestRunner.unregisterMBean(injectedMBeanServer.getValue());
     }
   } catch (Exception ex) {
     log.errorf(ex, "Cannot stop Arquillian Test Runner");
   }
 }
Example #2
0
  public synchronized void start(StartContext context) throws StartException {
    log.debugf("Starting Arquillian Test Runner");

    final MBeanServer mbeanServer = injectedMBeanServer.getValue();
    serviceContainer = context.getController().getServiceContainer();
    serviceTarget = context.getChildTarget();
    try {
      jmxTestRunner = new ExtendedJMXTestRunner();
      jmxTestRunner.registerMBean(mbeanServer);
    } catch (Throwable t) {
      throw new StartException("Failed to start Arquillian Test Runner", t);
    }

    final ArquillianService arqService = this;
    serviceContainer.addListener(
        new AbstractServiceListener<Object>() {

          @Override
          public void serviceStarted(ServiceController<? extends Object> controller) {
            ServiceName serviceName = controller.getName();
            String simpleName = serviceName.getSimpleName();
            if (JBOSS_DEPLOYMENT.isParentOf(serviceName)
                && simpleName.equals(Phase.INSTALL.toString())) {
              ServiceName parentName = serviceName.getParent();
              ServiceController<?> parentController = serviceContainer.getService(parentName);
              DeploymentUnit depUnit = (DeploymentUnit) parentController.getValue();
              ArquillianConfig arqConfig =
                  ArquillianConfigBuilder.processDeployment(arqService, depUnit);
              if (arqConfig != null) {
                log.infof("Arquillian deployment detected: %s", arqConfig);
                ServiceBuilder<ArquillianConfig> builder =
                    arqConfig.buildService(serviceTarget, controller);
                FrameworkActivationProcessor.process(serviceContainer, builder, arqConfig);
                builder.install();
              }
            }
          }

          @Override
          public void serviceStopped(ServiceController<? extends Object> controller) {}
        });
  }