@Override
 public synchronized void stop(final StopContext context) {
   value.stop();
   value.destroy();
   objStoreBrowser.stop();
   value = null;
 }
  @Override
  public synchronized void start(final StartContext context) throws StartException {

    // JTS expects the TCCL to be set to something that can find the log factory class.
    setContextLoader(ArjunaTransactionManagerService.class.getClassLoader());

    try {
      // Global configuration.
      final CoreEnvironmentBean coreEnvironmentBean = arjPropertyManager.getCoreEnvironmentBean();
      coreEnvironmentBean.setSocketProcessIdPort(
          socketProcessBindingInjector.getValue().getSocketAddress().getPort());
      coreEnvironmentBean.setNodeIdentifier(coreNodeIdentifier);
      coreEnvironmentBean.setSocketProcessIdMaxPorts(coreSocketProcessIdMaxPorts);

      final JTAEnvironmentBean jtaEnvironmentBean = jtaPropertyManager.getJTAEnvironmentBean();
      jtaEnvironmentBean.setLastResourceOptimisationInterface(LastResource.class.getName());
      jtaEnvironmentBean.setXaRecoveryNodes(Collections.singletonList("1"));
      jtaEnvironmentBean.setXaResourceOrphanFilterClassNames(
          Arrays.asList(
              JTATransactionLogXAResourceOrphanFilter.class.getName(),
              JTANodeNameXAResourceOrphanFilter.class.getName()));

      final CoordinatorEnvironmentBean coordinatorEnvironmentBean =
          arjPropertyManager.getCoordinatorEnvironmentBean();
      coordinatorEnvironmentBean.setEnableStatistics(coordinatorEnableStatistics);
      coordinatorEnvironmentBean.setDefaultTimeout(coordinatorDefaultTimeout);

      // Object Store Browser bean
      Map<String, String> objStoreBrowserTypes = new HashMap<String, String>();
      objStoreBrowser = new ObjStoreBrowser();
      objStoreBrowserTypes.put(
          "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction",
          "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");

      final ORB orb = orbInjector.getValue();

      if (orb == null) {
        // No IIOP, stick with JTA mode.
        final com.arjuna.ats.jbossatx.jta.TransactionManagerService service =
            new com.arjuna.ats.jbossatx.jta.TransactionManagerService();
        service.setJbossXATerminator(xaTerminatorInjector.getValue());
        service.setTransactionSynchronizationRegistry(
            new com.arjuna.ats.internal.jta.transaction.arjunacore
                .TransactionSynchronizationRegistryImple());

        jtaEnvironmentBean.setTransactionManagerClassName(
            com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate.class.getName());
        jtaEnvironmentBean.setUserTransactionClassName(
            com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple.class
                .getName());
        jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(
            com.arjuna.ats.internal.jta.transaction.arjunacore
                .TransactionSynchronizationRegistryImple.class.getName());

        try {
          service.create();
        } catch (Exception e) {
          throw new StartException("Transaction manager create failed", e);
        }
        service.start();
        value = service;
      } else {
        // IIOP is enabled, so fire up JTS mode.
        final com.arjuna.ats.jbossatx.jts.TransactionManagerService service =
            new com.arjuna.ats.jbossatx.jts.TransactionManagerService();
        service.setJbossXATerminator(xaTerminatorInjector.getValue());
        service.setTransactionSynchronizationRegistry(
            new com.arjuna.ats.internal.jta.transaction.jts
                .TransactionSynchronizationRegistryImple());

        jtaEnvironmentBean.setTransactionManagerClassName(
            com.arjuna.ats.jbossatx.jts.TransactionManagerDelegate.class.getName());
        jtaEnvironmentBean.setUserTransactionClassName(
            com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
        jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(
            com.arjuna.ats.internal.jta.transaction.arjunacore
                .TransactionSynchronizationRegistryImple.class.getName());
        objStoreBrowserTypes.put(
            "StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple",
            "com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean");

        try {
          service.create();
        } catch (Exception e) {
          throw new StartException("Create failed", e);
        }
        try {
          service.start(orb);
        } catch (Exception e) {
          throw new StartException("Start failed", e);
        }
        value = service;
      }

      try {
        objStoreBrowser.setTypes(objStoreBrowserTypes);
        objStoreBrowser.start();
      } catch (Exception e) {
        throw new StartException("Failed to configure object store browser bean", e);
      }
      // todo: JNDI bindings
    } finally {
      setContextLoader(null);
    }
  }