/** 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 stop(StopContext context) {
   JPA_LOGGER.stoppingService("Persistence Unit", pu.getScopedPersistenceUnitName());
   if (entityManagerFactory != null) {
     WritableServiceBasedNamingStore.pushOwner(
         context.getController().getServiceContainer().subTarget());
     try {
       entityManagerFactory.close();
     } finally {
       entityManagerFactory = null;
       pu.setTempClassLoaderFactory(null);
       WritableServiceBasedNamingStore.popOwner();
     }
   }
 }
 @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();
   }
 }