public synchronized void start(StartContext startContext) throws StartException {
    try {
      final ServiceContainer container = startContext.getController().getServiceContainer();

      deploymentMD = getDeployer().deploy(container);
      if (deploymentMD.getCfs().length != 1) {
        throw ConnectorLogger.ROOT_LOGGER.cannotStartDs();
      }
      sqlDataSource =
          new WildFlyDataSource(
              (javax.sql.DataSource) deploymentMD.getCfs()[0], jndiName.getAbsoluteJndiName());
      DS_DEPLOYER_LOGGER.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]);
      CommonDeploymentService cdService = new CommonDeploymentService(deploymentMD);
      final ServiceName cdServiceName = CommonDeploymentService.getServiceName(jndiName);
      startContext
          .getController()
          .getServiceContainer()
          .addService(cdServiceName, cdService)
          // The dependency added must be the JNDI name which for subsystem resources is an alias.
          // This service
          // is also used in deployments where the capability service name is not registered for the
          // service.
          .addDependency(getServiceName(jndiName))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
    } catch (Throwable t) {
      throw ConnectorLogger.ROOT_LOGGER.deploymentError(t, dsName);
    }
  }
  @Override
  public synchronized void start(StartContext context) throws StartException {
    ServiceController<?> controller = context.getController();
    LOGGER.tracef("Starting: %s in mode %s", controller.getName(), controller.getMode());
    try {
      ServiceContainer serviceContainer = context.getController().getServiceContainer();

      // Setup the OSGi {@link Framework} properties
      SubsystemState subsystemState = injectedSubsystemState.getValue();
      Map<String, Object> props = new HashMap<String, Object>(subsystemState.getProperties());
      setupIntegrationProperties(context, props);

      // Register the URLStreamHandlerFactory
      Module coreFrameworkModule =
          ((ModuleClassLoader) FrameworkBuilder.class.getClassLoader()).getModule();
      Module.registerURLStreamHandlerFactoryModule(coreFrameworkModule);
      Module.registerContentHandlerFactoryModule(coreFrameworkModule);

      ServiceTarget serviceTarget = context.getChildTarget();
      JAXPServiceProvider.addService(serviceTarget);
      ResolverService.addService(serviceTarget);
      RepositoryService.addService(serviceTarget);

      Activation activation = subsystemState.getActivationPolicy();
      Mode initialMode = (activation == Activation.EAGER ? Mode.ACTIVE : Mode.LAZY);

      // Configure the {@link Framework} builder
      FrameworkBuilder builder = FrameworkBuilderFactory.create(props, initialMode);
      builder.setServiceContainer(serviceContainer);
      builder.setServiceTarget(serviceTarget);

      builder.createFrameworkServices(serviceContainer, true);
      builder.registerIntegrationService(FrameworkPhase.CREATE, new BundleLifecycleIntegration());
      builder.registerIntegrationService(
          FrameworkPhase.CREATE, new FrameworkModuleIntegration(props));
      builder.registerIntegrationService(FrameworkPhase.CREATE, new ModuleLoaderIntegration());
      builder.registerIntegrationService(
          FrameworkPhase.CREATE, new SystemServicesIntegration(resource, extensions));
      builder.registerIntegrationService(FrameworkPhase.INIT, new BootstrapBundlesIntegration());
      builder.registerIntegrationService(
          FrameworkPhase.INIT, new PersistentBundlesIntegration(deploymentTracker));

      // Install the services to create the framework
      builder.installServices(FrameworkPhase.CREATE, serviceTarget, verificationHandler);

      if (activation == Activation.EAGER) {
        builder.installServices(FrameworkPhase.INIT, serviceTarget, verificationHandler);
        builder.installServices(FrameworkPhase.ACTIVE, serviceTarget, verificationHandler);
      }

      // Create the framework activator
      FrameworkActivator.create(builder);

    } catch (Throwable th) {
      throw MESSAGES.startFailedToCreateFrameworkServices(th);
    }
  }
  /** Start */
  @Override
  public void start(StartContext context) throws StartException {
    try {
      Connector cmd = mdr.getValue().getResourceAdapter(deployment);
      File root = mdr.getValue().getRoot(deployment);

      Activation localRaXml = getRaxml();
      cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(localRaXml, cmd);

      String id = ((ModifiableResourceAdapter) raxml).getId();
      final ServiceName raServiceName;
      if (id == null || id.trim().isEmpty()) {
        raServiceName = ConnectorServices.getResourceAdapterServiceName(raName);
        this.connectorServicesRegistrationName = raName;
      } else {
        raServiceName = ConnectorServices.getResourceAdapterServiceName(id);
        this.connectorServicesRegistrationName = id;
      }
      final WildFlyRaXmlDeployer raDeployer =
          new WildFlyRaXmlDeployer(
              context.getChildTarget(),
              connectorXmlDescriptor.getUrl(),
              raName,
              root,
              module.getClassLoader(),
              cmd,
              localRaXml,
              deploymentServiceName);

      raDeployer.setConfiguration(config.getValue());

      WritableServiceBasedNamingStore.pushOwner(duServiceName);
      ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
      try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
        raxmlDeployment = raDeployer.doDeploy();
      } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
        WritableServiceBasedNamingStore.popOwner();
      }
      value = new ResourceAdapterDeployment(raxmlDeployment, raName, raServiceName);
      managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
      registry.getValue().registerResourceAdapterDeployment(value);
      context
          .getChildTarget()
          .addService(
              raServiceName,
              new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter()))
          .addDependency(deploymentServiceName)
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
    } catch (Throwable t) {
      cleanupStartAsync(context, raName, deploymentServiceName, t);
    }
  }
  @Override
  public void start(StartContext context) throws StartException {
    final URL url = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getUrl();
    deploymentName =
        connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getDeploymentName();
    final File root = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getRoot();
    DEPLOYMENT_CONNECTOR_LOGGER.debugf("DEPLOYMENT name = %s", deploymentName);
    final AS7RaDeployer raDeployer =
        new AS7RaDeployer(
            context.getChildTarget(),
            url,
            deploymentName,
            root,
            classLoader,
            cmd,
            ijmd,
            deploymentServiceName);
    raDeployer.setConfiguration(config.getValue());

    ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
      WritableServiceBasedNamingStore.pushOwner(duServiceName);
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
      raDeployment = raDeployer.doDeploy();
      deploymentName = raDeployment.getDeploymentName();
    } catch (Throwable t) {
      unregisterAll(deploymentName);
      throw MESSAGES.failedToStartRaDeployment(t, deploymentName);
    } finally {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
      WritableServiceBasedNamingStore.popOwner();
    }

    if (raDeployer.checkActivation(cmd, ijmd)) {
      DEPLOYMENT_CONNECTOR_LOGGER.debugf("Activating: %s", deploymentName);

      ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(deploymentName);
      value = new ResourceAdapterDeployment(raDeployment, deploymentName, raServiceName);

      managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
      registry.getValue().registerResourceAdapterDeployment(value);

      context
          .getChildTarget()
          .addService(
              raServiceName,
              new ResourceAdapterService(
                  deploymentName, raServiceName, value.getDeployment().getResourceAdapter()))
          .setInitialMode(Mode.ACTIVE)
          .install();
    } else {
      DEPLOYMENT_CONNECTOR_LOGGER.debugf("Not activating: %s", deploymentName);
    }
  }
 @Override
 public void run() {
   try {
     zooKeeperServer.startup();
     zooKeeperServer.getServerCnxnFactory().start();
     startContext.complete();
     log.info("Zookeeper started at " + binding.getValue().getSocketAddress());
   } catch (Throwable e) {
     startContext.failed(new StartException(e));
     log.error("Zookeeper failed to start at " + binding.getValue().getSocketAddress());
   }
 }
 @Override
 public void start(StartContext context) throws StartException {
   if (serviceContainer != null) {
     throw new IllegalStateException("External Module Service already started");
   }
   serviceContainer = context.getController().getServiceContainer();
 }
  @Override
  public synchronized void start(final StartContext context) throws StartException {
    File dir = new File(dataDir).getAbsoluteFile();

    try {
      zooKeeperServer = new ZooKeeperServer(dir, dir, (int) tickTime);

      ServerCnxnFactory serverCnxnFactory =
          ServerCnxnFactory.createFactory(binding.getValue().getSocketAddress(), 5);
      zooKeeperServer.setServerCnxnFactory(serverCnxnFactory);

      context.asynchronous();
      executor.getValue().execute(new ZooKeeperServerRunner(zooKeeperServer, context));
    } catch (IOException e) {
      context.failed(new StartException(e));
    }
  }
Example #8
0
 @Override
 public synchronized void start(StartContext context) throws StartException {
   serviceTarget = context.getChildTarget();
   arqService.registerArquillianConfig(this);
   for (String testClass : testClasses) {
     ServiceTargetAssociation.setServiceTarget(testClass, serviceTarget);
   }
 }
 @Override
 public void start(StartContext context) throws StartException {
   LOGGER.infoFrameworkImplementation(implementationVersion);
   serviceTarget = context.getChildTarget();
   LOGGER.debugf("Framework properties");
   for (Entry<String, Object> entry : properties.entrySet()) {
     LOGGER.debugf(" %s = %s", entry.getKey(), entry.getValue());
   }
 }
Example #10
0
 public static TransactionManager getTransactionManager(StartContext context) {
   @SuppressWarnings("unchecked")
   ServiceController<TransactionManager> service =
       (ServiceController<TransactionManager>)
           context
               .getController()
               .getServiceContainer()
               .getService(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER);
   return service == null ? null : service.getValue();
 }
Example #11
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) {}
        });
  }
Example #12
0
 @Override
 public void start(StartContext context) {
   this.container = context.getController().getServiceContainer();
   this.dispatcher =
       this.dispatcherFactory
           .getValue()
           .<SingletonContext<T>>createCommandDispatcher(this.singletonServiceName, this);
   this.registration =
       this.registrationFactory.getValue().createRegistration(this.singletonServiceName, this);
   this.started = true;
 }
Example #13
0
  @Override
  public void start(StartContext context) throws StartException {
    JacORBLogger.ROOT_LOGGER.debugServiceStartup(
        context.getController().getName().getCanonicalName());

    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();

    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to
    // instantiate the POA.
    if (orb != null) {
      try {
        this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
      } catch (Exception e) {
        throw JacORBMessages.MESSAGES.errorResolvingInitRef(this.poaName, e);
      }
    }
    // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    else if (parentPOA != null) {
      try {
        Policy[] poaPolicies = this.createPolicies(parentPOA);
        this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
      } catch (Exception e) {
        throw JacORBMessages.MESSAGES.errorCreatingPOAFromParent(e);
      }
    } else {
      throw JacORBMessages.MESSAGES.invalidPOACreationArgs();
    }

    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
      CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }

    // activate the created POA.
    try {
      this.poa.the_POAManager().activate();
    } catch (Exception e) {
      throw JacORBMessages.MESSAGES.errorActivatingPOA(e);
    }
  }
Example #14
0
  @Override
  public void start(StartContext context) throws StartException {
    log.debugf("Starting Service " + context.getController().getName().getCanonicalName());

    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();

    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to
    // instantiate the POA.
    if (orb != null) {
      try {
        this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
      } catch (Exception e) {
        throw new StartException("Failed to resolve initial reference " + this.poaName, e);
      }
    }
    // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    else if (parentPOA != null) {
      try {
        Policy[] poaPolicies = this.createPolicies(parentPOA);
        this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
      } catch (Exception e) {
        throw new StartException("Failed to create POA from parent POA", e);
      }
    } else {
      throw new StartException(
          "Unable to instantiate POA: either the running ORB or the parent POA must be specified");
    }

    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
      CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }

    // activate the created POA.
    try {
      this.poa.the_POAManager().activate();
    } catch (Exception e) {
      throw new StartException("Failed to activate POA", e);
    }
  }
Example #15
0
  public synchronized void start(StartContext context) throws StartException {
    try {
      final JMSServerManager jmsServer =
          new JMSServerManagerImpl(
              hornetQServer.getValue(),
              new AS7BindingRegistry(context.getController().getServiceContainer()));

      try {
        // FIXME - we also need the TCCL here in case the JMSServerManager starts the HornetQServer
        final ClassLoader loader = getClass().getClassLoader();
        SecurityActions.setContextClassLoader(loader);
        jmsServer.start();

        // FIXME - this check is a work-around for AS7-3658
        if (!hornetQServer.getValue().getConfiguration().isBackup()) {
          hornetQServer
              .getValue()
              .getRemotingService()
              .allowInvmSecurityOverride(
                  new HornetQPrincipal(
                      HornetQDefaultCredentials.getUsername(),
                      HornetQDefaultCredentials.getPassword()));
        } else {
          hornetQServer
              .getValue()
              .registerActivateCallback(
                  new ActivateCallback() {
                    public void preActivate() {}

                    public void activated() {
                      hornetQServer
                          .getValue()
                          .getRemotingService()
                          .allowInvmSecurityOverride(
                              new HornetQPrincipal(
                                  HornetQDefaultCredentials.getUsername(),
                                  HornetQDefaultCredentials.getPassword()));
                    }

                    public void deActivate() {}
                  });
        }
      } finally {
        SecurityActions.setContextClassLoader(null);
      }
      this.jmsServer = jmsServer;
    } catch (Exception e) {
      throw new StartException(e);
    }
  }
  public synchronized void start(StartContext startContext) throws StartException {
    try {
      final ServiceContainer container = startContext.getController().getServiceContainer();

      CommonDeployment deploymentMD = deployer.deploy(container);
      if (deploymentMD.getCfs().length != 1) {
        throw new StartException("unable to start the ds because it generate more than one cf");
      }
      sqlDataSource = (javax.sql.DataSource) deploymentMD.getCfs()[0];
      log.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]);
    } catch (Throwable t) {
      throw new StartException("Error during the deployment of " + jndiName, t);
    }
  }
  public synchronized void start(StartContext startContext) throws StartException {
    try {
      final ServiceContainer container = startContext.getController().getServiceContainer();

      deploymentMD = getDeployer().deploy(container);
      if (deploymentMD.getCfs().length != 1) {
        throw ConnectorLogger.ROOT_LOGGER.cannotStartDs();
      }
      sqlDataSource =
          new WildFlyDataSource((javax.sql.DataSource) deploymentMD.getCfs()[0], jndiName);
      DS_DEPLOYER_LOGGER.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]);
    } catch (Throwable t) {
      throw ConnectorLogger.ROOT_LOGGER.deploymentError(t, dsName);
    }
  }
 @Override
 public void start(StartContext context) throws StartException {
   try {
     JPA_LOGGER.startingService("Persistence Unit", pu.getScopedPersistenceUnitName());
     pu.setTempClassLoaderFactory(new TempClassLoaderFactoryImpl(classLoader));
     pu.setJtaDataSource(jtaDataSource.getOptionalValue());
     pu.setNonJtaDataSource(nonJtaDataSource.getOptionalValue());
     WritableServiceBasedNamingStore.pushOwner(
         context.getController().getServiceContainer().subTarget());
     this.entityManagerFactory = createContainerEntityManagerFactory();
   } finally {
     pu.setTempClassLoaderFactory(
         null); // release the temp classloader factory (only needed when creating the EMF)
     WritableServiceBasedNamingStore.popOwner();
   }
 }
Example #19
0
 /** {@inheritDoc} */
 public void start(StartContext context) throws StartException {
   final T service = getValue();
   // Handle Start
   log.debugf("Starting Service: %s", context.getController().getName());
   try {
     final Method startMethod = service.getClass().getMethod("start");
     ClassLoader old =
         SecurityActions.setThreadContextClassLoader(service.getClass().getClassLoader());
     try {
       startMethod.invoke(service);
     } finally {
       SecurityActions.resetThreadContextClassLoader(old);
     }
   } catch (NoSuchMethodException e) {
   } catch (Exception e) {
     throw new StartException("Failed to execute legacy service start", e);
   }
 }
Example #20
0
 /**
  * Bind the entry into the injected context.
  *
  * @param context The start context
  * @throws StartException If the entity can not be bound
  */
 public synchronized void start(StartContext context) throws StartException {
   final ServiceBasedNamingStore namingStore = namingStoreValue.getValue();
   ServiceController<?> controller = context.getController();
   this.controller = controller;
   namingStore.add(controller.getName());
   ROOT_LOGGER.tracef(
       "Bound resource %s into naming store %s (service name %s)",
       name, namingStore, controller.getName());
   if (deploymentServiceName != null) {
     // add this controller service name to the related deployment runtime bindings management
     // service, which if stop will release this service too, thus removing the bind
     final Set<ServiceName> duBindingReferences =
         (Set<ServiceName>)
             controller
                 .getServiceContainer()
                 .getService(JndiNamingDependencyProcessor.serviceName(deploymentServiceName))
                 .getValue();
     duBindingReferences.add(controller.getName());
   }
 }
 public void start(final StartContext context) throws StartException {
   ServiceController<?> controller = context.getController();
   LOGGER.tracef("Starting: %s", controller.getName());
   List<Bundle> bundles = new ArrayList<Bundle>(installedBundles);
   Collections.sort(bundles, new BundleComparator());
   for (Bundle bundle : bundles) {
     TypeAdaptor adaptor = (TypeAdaptor) bundle;
     Deployment dep = adaptor.adapt(Deployment.class);
     OSGiMetaData metadata = adaptor.adapt(OSGiMetaData.class);
     if (dep.isAutoStart() && metadata.getFragmentHost() == null) {
       try {
         bundle.start(Bundle.START_ACTIVATION_POLICY);
       } catch (BundleException ex) {
         LOGGER.errorCannotStartBundle(ex, bundle);
       }
     }
   }
   LOGGER.debugf("Started: %s", controller.getName());
   installedBundles = null;
   tracker = null;
 }
Example #22
0
  @Override
  public synchronized void start(final StartContext context) throws StartException {
    final Runnable task =
        new Runnable() {
          @Override
          public void run() {
            try {
              bridge.setTransactionManager(getTransactionManager(context));
              startBridge();

              context.complete();
            } catch (Throwable e) {
              context.failed(MessagingLogger.ROOT_LOGGER.failedToCreate(e, "JMS Bridge"));
            }
          }
        };
    try {
      executorInjector.getValue().execute(task);
    } catch (RejectedExecutionException e) {
      task.run();
    } finally {
      context.asynchronous();
    }
  }
  @Override
  public void start(final StartContext context) throws StartException {
    final ExecutorService executor = executorInjector.getValue();
    final AccessControlContext accessControlContext =
        AccessController.doPrivileged(GetAccessControlContextAction.getInstance());

    final Runnable task =
        new Runnable() {
          // run async in a background thread
          @Override
          public void run() {
            PrivilegedAction<Void> privilegedAction =
                new PrivilegedAction<Void>() {
                  // run as security privileged action
                  @Override
                  public Void run() {

                    try {
                      PhaseOnePersistenceUnitServiceImpl phaseOnePersistenceUnitService =
                          phaseOnePersistenceUnitServiceInjectedValue.getOptionalValue();
                      WritableServiceBasedNamingStore.pushOwner(deploymentUnitServiceName);

                      // handle phase 2 of 2 of bootstrapping the persistence unit
                      if (phaseOnePersistenceUnitService != null) {
                        JPA_LOGGER.startingPersistenceUnitService(
                            2, pu.getScopedPersistenceUnitName());
                        // indicate that the second phase of bootstrapping the persistence unit has
                        // started
                        phaseOnePersistenceUnitService.setSecondPhaseStarted(true);
                        if (beanManagerInjector.getOptionalValue() != null) {
                          // update the bean manager proxy to the actual CDI bean manager
                          proxyBeanManager = phaseOnePersistenceUnitService.getBeanManager();
                          proxyBeanManager.setDelegate(beanManagerInjector.getOptionalValue());
                        }
                        entityManagerFactory =
                            phaseOnePersistenceUnitService.getEntityManagerFactoryBuilder().build();
                      } else {
                        JPA_LOGGER.startingService(
                            "Persistence Unit", pu.getScopedPersistenceUnitName());
                        // start the persistence unit in one pass (1 of 1)
                        pu.setTempClassLoaderFactory(new TempClassLoaderFactoryImpl(classLoader));
                        pu.setJtaDataSource(jtaDataSource.getOptionalValue());
                        pu.setNonJtaDataSource(nonJtaDataSource.getOptionalValue());

                        if (beanManagerInjector.getOptionalValue() != null) {
                          proxyBeanManager = new ProxyBeanManager();
                          proxyBeanManager.setDelegate(beanManagerInjector.getOptionalValue());
                          properties.getValue().put(CDI_BEAN_MANAGER, proxyBeanManager);
                        }
                        entityManagerFactory = createContainerEntityManagerFactory();
                      }
                      persistenceUnitRegistry.add(getScopedPersistenceUnitName(), getValue());
                      context.complete();
                    } catch (Throwable t) {
                      context.failed(new StartException(t));
                    } finally {
                      pu.setTempClassLoaderFactory(
                          null); // release the temp classloader factory (only needed when creating
                                 // the EMF)
                      WritableServiceBasedNamingStore.popOwner();
                    }
                    return null;
                  }
                };
            WildFlySecurityManager.doChecked(privilegedAction, accessControlContext);
          }
        };

    context.asynchronous();
    executor.execute(task);
  }
 @Override
 public synchronized void start(StartContext context) throws StartException {
   serviceTarget = context.getChildTarget();
   arqService.registerArquillianConfig(this);
 }
  @Override
  public synchronized void start(final StartContext context) throws StartException {
    final ServiceContainer serviceContainer = context.getController().getServiceContainer();

    thread =
        new Thread(
            new Runnable() {

              @Override
              public void run() {
                final ClassLoader oldTccl =
                    WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
                try {
                  try {
                    try {
                      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
                      AccessController.doPrivileged(new SetSelectorAction(contextSelector));
                      applicationClientDeploymentServiceInjectedValue
                          .getValue()
                          .getDeploymentCompleteLatch()
                          .await();
                      NamespaceContextSelector.setDefault(namespaceContextSelectorInjectedValue);

                      try {
                        // perform any additional setup that may be needed
                        for (SetupAction action : setupActions) {
                          action.setup(Collections.<String, Object>emptyMap());
                        }

                        // do static injection etc
                        instance = applicationClientComponent.getValue().createInstance();

                        mainMethod.invoke(null, new Object[] {parameters});
                      } finally {
                        final ListIterator<SetupAction> iterator =
                            setupActions.listIterator(setupActions.size());
                        Throwable error = null;
                        while (iterator.hasPrevious()) {
                          SetupAction action = iterator.previous();
                          try {
                            action.teardown(Collections.<String, Object>emptyMap());
                          } catch (Throwable e) {
                            error = e;
                          }
                        }
                        if (error != null) {
                          throw new RuntimeException(error);
                        }
                      }
                    } catch (Exception e) {
                      ROOT_LOGGER.exceptionRunningAppClient(e, e.getClass().getSimpleName());
                    } finally {
                      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
                    }
                  } finally {
                    if (contextSelector instanceof LazyConnectionContextSelector) {
                      ((LazyConnectionContextSelector) contextSelector).close();
                    }
                  }
                } finally {
                  serviceContainer.shutdown();
                }
              }
            });
    thread.start();
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {
                  @Override
                  public void run() {
                    if (serviceContainer != null) {
                      serviceContainer.shutdown();
                    }
                  }
                }));
  }
  @Override
  public void start(StartContext context) throws StartException {

    processState.setStarting();

    final ProductConfig config = environment.getProductConfig();
    final String prettyVersion = config.getPrettyVersionString();
    ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
    if (ServerLogger.CONFIG_LOGGER.isDebugEnabled()) {
      final Properties properties = System.getProperties();
      final StringBuilder b = new StringBuilder(8192);
      b.append("Configured system properties:");
      for (String property : new TreeSet<String>(properties.stringPropertyNames())) {
        b.append("\n\t")
            .append(property)
            .append(" = ")
            .append(properties.getProperty(property, "<undefined>"));
      }
      ServerLogger.CONFIG_LOGGER.debug(b);
      ServerLogger.CONFIG_LOGGER.debugf("VM Arguments: %s", getVMArguments());
      if (ServerLogger.CONFIG_LOGGER.isTraceEnabled()) {
        b.setLength(0);
        final Map<String, String> env = System.getenv();
        b.append("Configured system environment:");
        for (String key : new TreeSet<String>(env.keySet())) {
          b.append("\n\t").append(key).append(" = ").append(env.get(key));
        }
        ServerLogger.CONFIG_LOGGER.trace(b);
      }
    }
    final ServiceTarget serviceTarget = context.getChildTarget();
    final ServiceController<?> myController = context.getController();
    final ServiceContainer serviceContainer = myController.getServiceContainer();
    futureContainer = new FutureServiceContainer();

    long startTime = this.startTime;
    if (startTime == -1) {
      startTime = System.currentTimeMillis();
    } else {
      this.startTime = -1;
    }

    final BootstrapListener bootstrapListener =
        new BootstrapListener(
            serviceContainer,
            startTime,
            serviceTarget,
            futureContainer,
            prettyVersion + " (Host Controller)");
    bootstrapListener.getStabilityMonitor().addController(myController);

    // The first default services are registered before the bootstrap operations are executed.

    // Install the process controller client
    final ProcessControllerConnectionService processControllerClient =
        new ProcessControllerConnectionService(environment, authCode);
    serviceTarget
        .addService(ProcessControllerConnectionService.SERVICE_NAME, processControllerClient)
        .install();

    // Executor Services
    final HostControllerExecutorService executorService = new HostControllerExecutorService();
    serviceTarget
        .addService(HC_EXECUTOR_SERVICE_NAME, executorService)
        .addAliases(
            ManagementRemotingServices
                .SHUTDOWN_EXECUTOR_NAME) // Use this executor for mgmt shutdown for now
        .install();

    // Install required path services. (Only install those identified as required)
    HostPathManagerService hostPathManagerService = new HostPathManagerService();
    HostPathManagerService.addService(serviceTarget, hostPathManagerService, environment);

    HttpListenerRegistryService.install(serviceTarget);

    // Add product config service
    final Value<ProductConfig> productConfigValue = new ImmediateValue<ProductConfig>(config);
    serviceTarget
        .addService(
            Services.JBOSS_PRODUCT_CONFIG_SERVICE,
            new ValueService<ProductConfig>(productConfigValue))
        .setInitialMode(ServiceController.Mode.ACTIVE)
        .install();

    DomainModelControllerService.addService(
        serviceTarget,
        environment,
        runningModeControl,
        processState,
        bootstrapListener,
        hostPathManagerService);
  }
  public void start(final StartContext context) throws StartException {

    if (configurationPersister == null) {
      throw MESSAGES.persisterNotInjected();
    }
    final ServiceController<?> serviceController = context.getController();
    final ServiceContainer container = serviceController.getServiceContainer();
    final ServiceTarget target = context.getChildTarget();
    final ExecutorService executorService = injectedExecutorService.getOptionalValue();
    ManagementResourceRegistration rootResourceRegistration =
        rootDescriptionProvider != null
            ? ManagementResourceRegistration.Factory.create(rootDescriptionProvider)
            : ManagementResourceRegistration.Factory.create(rootResourceDefinition);
    final ModelControllerImpl controller =
        new ModelControllerImpl(
            container,
            target,
            rootResourceRegistration,
            new ContainerStateMonitor(container),
            configurationPersister,
            processType,
            runningModeControl,
            prepareStep,
            processState,
            executorService,
            expressionResolver,
            authorizer,
            auditLogger);

    // Initialize the model
    initModel(controller.getRootResource(), controller.getRootRegistration());
    this.controller = controller;

    final long bootStackSize = getBootStackSize();
    final Thread bootThread =
        new Thread(
            null,
            new Runnable() {
              public void run() {
                try {
                  try {
                    boot(
                        new BootContext() {
                          public ServiceTarget getServiceTarget() {
                            return target;
                          }
                        });
                  } finally {
                    processState.setRunning();
                  }
                } catch (Throwable t) {
                  container.shutdown();
                  if (t instanceof StackOverflowError) {
                    ROOT_LOGGER.errorBootingContainer(t, bootStackSize, BOOT_STACK_SIZE_PROPERTY);
                  } else {
                    ROOT_LOGGER.errorBootingContainer(t);
                  }
                } finally {
                  bootThreadDone();
                }
              }
            },
            "Controller Boot Thread",
            bootStackSize);
    bootThread.start();
  }
 @Override
 public void start(StartContext startContext) throws StartException {
   ServiceRegistry serviceRegistry = startContext.getController().getServiceContainer();
   createHandlerRegistry =
       new ContextCreateHandlerRegistryImpl(serviceRegistry, startContext.getChildTarget());
 }