Register the current object with the Synchronization manager for the current transaction

@throws ResourceException.
764918
@Override
    public boolean addSync() throws ResourceException {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "addSync");
        }

        UOWCoordinator uowCoord = mcWrapper.getUOWCoordinator();

        if (uowCoord == null) {
            java.lang.IllegalStateException e = new java.lang.IllegalStateException("addSync: illegal state exception. uowCoord is null");
            Object[] parms = new Object[] { "addSync", e };
            Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms);
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "addSync", e);
            throw e;
        }

        try {
            if (mcWrapper.isConnectionSynchronizationProvider()) {
                throw new NotSupportedException();
            }

            /*
             * This code will remain here just in case we run into this
             * case. We should not be isEnlistmentDisabled in this code.
             *
             * Log a message and return, if isEnlistmentDisabled is true.
             */
            if (mcWrapper.isEnlistmentDisabled()) {

                if (isTracingEnabled && tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "Managed connection isEnlistmentDisabled is true.");
                    Tr.debug(this, tc, "Returning without registering.");
                }

                if (isTracingEnabled && tc.isEntryEnabled()) {
                    Tr.exit(this, tc, "addSync", false);
                }

                return false;

            }

            /*
             * Use our XATransactionWrapper
             */
            EmbeddableWebSphereTransactionManager tranMgr = mcWrapper.pm.connectorSvc.transactionManager;
            tranMgr.registerSynchronization(uowCoord, this);

        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.XATransactionWrapper.addSync",
                                                        "237",
                                                        this);
            Object[] parms = new Object[] { "addSync", e, "ResourceException" };
            Tr.error(tc, "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026", parms);
            ResourceException re = new ResourceException("addSync: caught Exception");
            re.initCause(e);
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "addSync", e);
            throw re;
        }

        if (isTracingEnabled && tc.isEntryEnabled())
            Tr.exit(this, tc, "addSync", true);
        return true;
    }
246460
public void register(T instance) {
		if(!isContained(instance)) {
			registry.add(instance);
			if(current == null) {
				current = instance;
			}
		}
	}
207911
@Override
    public boolean registerRemoteParticipant(String xaResFactoryFilter, Serializable xaResInfo, String globalId) throws SystemException {

        boolean retval = true; // set to false if InvalidState

        final DistributableTransaction tx = getTransactionForID(globalId);

        if (tx != null) {
            // Stop anyone else shifting the ground beneath us
            tx.addAssociation();

            try {
                // Check the transaction state and action as appropriate
                switch (tx.getStatus()) {
                    case Status.STATUS_ACTIVE:
                    case Status.STATUS_MARKED_ROLLBACK:
                        tx.enlistAsyncResource(xaResFactoryFilter, xaResInfo, tx.getXid());
                        break;

                    case Status.STATUS_PREPARING:
                        tx.setRollbackOnly();
                        // NOTE no break

                    default:
                        retval = false; // caller sends InvalidState
                        break;

                } // end switch
            } finally {
                tx.removeAssociation();
            }
        } else {
            retval = false;
        }

        return retval;
    }
819779
@Override
    public boolean addSync() throws ResourceException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { 
            Tr.entry(this, tc, "addSync");
        }

        UOWCoordinator uowCoord = mcWrapper.getUOWCoordinator();

        if (uowCoord == null) {
            // No transaction context.  Should never happen.
            // removed null check on mcWrapper since it is redundant from the above code (mcWrapper.getUOWCoordinator())
            String pmiName = mcWrapper.gConfigProps.cfName;

            Object[] parms = new Object[] { "addSync", pmiName };
            Tr.error(tc, "NO_VALID_TRANSACTION_CONTEXT_J2CA0040", parms); 
            throw new ResourceException("INTERNAL ERROR: No valid transaction context present");

        }

        try {

            //  No need to register for synchronization for unshared/LTC/res-control=Application.
            //  Instead of cleanup being done via after completion it will either happen at close or
            //  commit/rollback which ever happens last.  This will allow the connection to be returned
            //  to the pool prior to the end of the LTC scope allowing better utilization of the connection.
            boolean shareable = mcWrapper.getConnectionManager().shareable();
            if (!shareable && !J2CUtilityClass.isContainerAtBoundary(mcWrapper.pm.connectorSvc.transactionManager)) {
                //Register an instance of a no-transaction wrapper
                // so the TM will create an RRS NativeLocalTranasction.  The wrapper
                // provides "empty" TransactioWrapper and Synchronization behaviors,
                // but indicates to the TM that the LTC requires RRS support.  
                ((LocalTransactionCoordinator) uowCoord).enlistSynchronization(new RRSNoTransactionWrapper());

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { 
                    Tr.exit(this, tc, "addSync", "returning without registering.");
                }
                return false;
            } else { // Register a synchronization with the Transaction Manager
                ((LocalTransactionCoordinator) uowCoord).enlistSynchronization(this);
                mcWrapper.markRRSLocalTransactionWrapperInUse();
                registeredForSync = true;
            }
        } catch (ResourceException e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ejs.j2c.RRSLocalTransactionWrapper.addSync", "594", this);
            Object[] parms = new Object[] { "addSync", e, "Exception" };
            Tr.error(tc, "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026", parms);
            throw e;
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ejs.j2c.RRSLocalTransactionWrapper.addSync", "605", this);
            Object[] parms = new Object[] { "addSync", e, "Exception" };
            Tr.error(tc, "REGISTER_WITH_SYNCHRONIZATION_EXCP_J2CA0026", parms);
            ResourceException re = new ResourceException("addSync: caught Exception");
            re.initCause(e);
            throw re;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { 
            Tr.exit(this, tc, "addSync", registeredForSync);
        }

        return registeredForSync;

    }
1017513
public void register(Client client) {
        Exceptions.checkNotClosed(this.closed.get(), this);
        Preconditions.checkNotNull(client, "client");
        synchronized (this.clients) {
            if (!this.clients.contains(client)) {
                this.clients.add(client);
                client.updateGenerations(this.currentGeneration.get(), this.oldestGeneration.get());
            }
        }

        log.info("{} Registered {}.", TRACE_OBJECT_ID, client);
    }
903838
public void acquire() 
    { 
        if (_hasAcquired)
            return;

        // Deliver the onAcquire event to registered listeners
        for (ResourceEvents resourceListener : _listeners)
            resourceListener.onAcquire();

        // Register this ResourceContext with associated container context
        _containerContext.addResourceContext(this, _bean);

        // Set the flag to indicate resources have been acquired.
        _hasAcquired = true;
    }
236604
public void register() {
		try {
			objectName = consObjectName(domain, type, keysString);
			MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
			mbs.registerMBean(this, objectName);
		} catch (Exception e) {
			objectName = null;
			throw new RuntimeException(e);
		}
	}
956568
public void registerWithPropertiesManager() {
        try {
            main.getFileManager().registerFileDir(propertiesFile.getParentFile().toPath(),
                    propertiesFile.getName(), this);
        } catch (IOException e) {
            error("Unable to register ");
        }
    }
1085230
void register(ResourceMonitorImpl monitorImpl) throws IOException
   {
      Path path = monitorImpl.getResourcePath();
      registerAll(path, monitorImpl);
   }
166213
public void registerGenerator(String clazz) {

		ResourceGenerator generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(clazz);

		if (null == generator.getResolver()) {
			throw new IllegalStateException("The getResolver() method must return something at " + clazz);
		}

		ResourceGeneratorResolver resolver = generator.getResolver();

		// Checks if another generator is already define with the same resolver
		for (ResourceGeneratorResolver resourceGeneratorResolver : resolverRegistry) {
			if (resourceGeneratorResolver.isSameAs(resolver)) {
				String generatorName = generator.getClass().getName();
				if (!clazz.equals(generatorName)) {
					String errorMsg = "Cannot register the generator of class " + generator.getClass().getName()
							+ " since the same resolver is being used by " + generatorName
							+ ". Please specify a different resolver in the getResolver() method.";
					throw new IllegalStateException(errorMsg);
				}
			}
		}

		// Warns the user about if the generator override a built-in generator
		Set<ResourceGeneratorResolver> commonResolvers = commonGenerators.keySet();
		for (ResourceGeneratorResolver commonGeneratorResolver : commonResolvers) {
			if (commonGeneratorResolver.isSameAs(resolver)) {
				String generatorName = generator.getClass().getName();
				LOGGER.warn("The custom generator '" + generatorName + "' override a built-in generator");
			}
		}

		initGenerator(generator);
	}
434600
public void start() throws ResourceException {
    
    if (!deliveryActive.get()) {
      VertxPlatformFactory.instance().getOrCreateVertx(config, this);    
      VertxPlatformFactory.instance().addVertxHolder(this);
    }
    setup();
  }
1101086
public function register()
    {
        // The system resource manager is used to resolve various system resource types.
        // It also implements the resolver interface which may be used by other components adding system resource types.
        $this->app->singleton('df.system.resource', function ($app) {
            return new SystemResourceManager($app);
        });

        $this->app->resolving('df.service', function (ServiceManager $df) {
            // Add the system service
            $df->addType(new ServiceType([
                    'name'              => 'system',
                    'label'             => 'System Management',
                    'description'       => 'Service supporting management of the system.',
                    'group'             => ServiceTypeGroups::SYSTEM,
                    'singleton'         => true,
                    'config_handler'    => Config::class,
                    'factory'           => function ($config) {
                        return new System($config);
                    },
                    'access_exceptions' => [
                        [
                            'verb_mask' => 31, //Allow all verbs
                            'resource'  => 'admin/session',
                        ],
                        [
                            'verb_mask' => 2, //Allow POST only
                            'resource'  => 'admin/password',
                        ],
                        [
                            'verb_mask' => 1,
                            'resource'  => 'environment',
                        ]
                    ],
                ]
            ));
        });
    }
371165
protected synchronized void lock(ManagedObject managedObject)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
274413
public void registerAsynchConsumerCallback(
            final AsynchConsumerCallback callback, final int maxActiveMessages,
            final long messageLockExpiry, final int maxBatchSize,
            final OrderingContext extendedMessageOrderingContext)
            throws SISessionUnavailableException, SISessionDroppedException,
            SIConnectionUnavailableException, SIConnectionDroppedException,
            SIIncorrectCallException {

        throw new SibRaNotSupportedException(NLS
                .getString("ASYNCHRONOUS_METHOD_CWSIV0250"));

    }
546049
public void register() throws Exception {
        ChannelFuture future = loop.register(this);
        assert future.isDone();
        Throwable cause = future.cause();
        if (cause != null) {
            PlatformDependent.throwException(cause);
        }
    }
617843
public void commit() throws ResourceException {
        if (tc.isEntryEnabled())
            Tr.entry(this, tc, "commit", ivMC);

        // if the MC marked Stale, it means the user requested a purge pool with an immediate option
        // so don't allow any work on the mc
        if (ivMC._mcStale) {
            if (tc.isDebugEnabled())
                Tr.debug(this, tc, "MC is stale");
            throw new DataStoreAdapterException("INVALID_CONNECTION", AdapterUtil.staleX(), WSRdbSpiLocalTransactionImpl.class);
        }

        if (dsConfig.get().enableMultithreadedAccessDetection) 
            ivMC.detectMultithreadedAccess(); 

        if (!ivMC.isTransactional()) { // do nothing if no enlistment
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "no-op.  Enlistment disabled");
            return;
        }

        if (tc.isDebugEnabled()) {
            String cId = null;
            try {
                cId = ivMC.mcf.getCorrelator(ivMC); 
            } catch (SQLException x) {
                // will just log the exception here and ignore it since its in trace
                Tr.debug(
                         tc,
                         "got an exception trying to get the correlator, exception is: ",
                         x);
            }

            if (cId != null) {
                StringBuffer stbuf = new StringBuffer(200);
                stbuf.append("Correlator: DB2, ID: ");
                stbuf.append(cId);
                stbuf.append(" Transaction : ");
                stbuf.append(this);
                stbuf.append(" COMMIT");

                Tr.debug(this, tc, stbuf.toString());
            }
        }

        ResourceException re = ivStateManager.isValid(WSStateManager.LT_COMMIT);

        if (re == null)
            try 
            {
                // If no work was done during the transaction, the autoCommit value may still
                // be on.  In this case, just no-op, since some drivers like ConnectJDBC 3.1
                // don't allow commit/rollback when autoCommit is on.  

                //  here the autocommit is always false, so we can call commit.
                ivConnection.commit();

                //Note this exception is not caught - This is because
                //  1)  it is of type ResourceException so it can be thrown from the method
                //  2)  if isValid is okay, this should never fail.  If isValid is not okay
                //     an exception is thrown from there
                // Already validated the state in this sync block, so just set it. 
                ivStateManager.transtate = WSStateManager.NO_TRANSACTION_ACTIVE;
            } 
            catch (SQLException se) {
                FFDCFilter.processException(
                                            se,
                                            "com.ibm.ws.rsadapter.spi.WSRdbSpiLocalTransactionImpl.commit",
                                            "139",
                                            this);
                ResourceException x = AdapterUtil.translateSQLException(se, ivMC, true, currClass);
                if (tc.isEntryEnabled())
                    Tr.exit(this, tc, "commit", "Exception");
                throw x;
            }
        else 
        {
            // state change was not valid         

            LocalTransactionException local_tran_excep =
                            new LocalTransactionException(re.getMessage());
            DataStoreAdapterException ds = new DataStoreAdapterException(
                                            "WS_INTERNAL_ERROR",
                                            local_tran_excep,
                                            currClass,
                                            "Cannot commit SPI local transaction.",
                                            "",
                                            local_tran_excep.getMessage());
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "Exception");
            throw ds;
        }

        // Reset so we can deferred enlist in a future global transaction. 
        ivMC.wasLazilyEnlistedInGlobalTran = false; 

        if (tc.isEventEnabled())
            Tr.event(
                     tc,
                     "SPILocalTransaction committed. ManagedConnection state is "
                                     + ivMC.getTransactionStateAsString());

        if (tc.isEntryEnabled())
            Tr.exit(this, tc, "commit");
    }
293800
private static void register(ObjectName objectName, Object mbean) {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    try {
      if (!server.isRegistered(objectName)) {
        server.registerMBean(mbean, objectName);
      }
    } catch (InstanceAlreadyExistsException
        | MBeanRegistrationException | NotCompliantMBeanException e) {
      throw new CacheException("Error registering " + objectName, e);
    }
  }