Destroy all connection factories that are using this connection manager service.

@param svc the connection factory service.
@throws InstanceNotFoundException
@throws MBeanRegistrationException
335885
@Override
    public void destroyConnectionFactories() {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled()) {
            final String pmName;
            if (pm != null)
                pmName = pm.getUniqueId();
            else
                pmName = "factory name not avaiable";
            Tr.entry(this, tc, "destroyConnectionFactories", pmName);
        }

        lock.writeLock().lock();
        try {
            if (pmMBean != null) {
                pmMBean.unregister();
                pmMBean = null;
            }
            if (pm != null) {
                try {
                    pm.serverShutDown();
                    pm = null;
                    cfKeyToCM.clear();
                } catch (Throwable x) {
                    FFDCFilter.processException(x, getClass().getName(), "263", this);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(this, tc, x.getMessage(), CommonFunction.stackTraceToString(x));
                }
            }
        } finally {
            lock.writeLock().unlock();
        }
        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "destroyConnectionFactories");
    }
333563
public boolean removeHandlerFactory(ManagementRequestHandlerFactory instance) {
        for(;;) {
            final ManagementRequestHandlerFactory[] snapshot = updater.get(this);
            final int length = snapshot.length;
            int index = -1;
            for(int i = 0; i < length; i++) {
                if(snapshot[i] == instance) {
                    index = i;
                    break;
                }
            }
            if(index == -1) {
                return false;
            }
            final ManagementRequestHandlerFactory[] newVal = new ManagementRequestHandlerFactory[length - 1];
            System.arraycopy(snapshot, 0, newVal, 0, index);
            System.arraycopy(snapshot, index + 1, newVal, index, length - index - 1);
            if (updater.compareAndSet(this, snapshot, newVal)) {
                return true;
            }
        }
    }
15725
public synchronized void unregisterThrow(ObjectName objName) throws JMException {
		if (mbeanServer == null) {
			throw new JMException("JmxServer has not be started");
		}
		mbeanServer.unregisterMBean(objName);
		registeredCount--;
	}
1014602
@Override
    public final void destroy()
    {
        synchronized (this.connectionMonitor)
        {
            if (this.connection != null)
            {
                this.connection.destroy();
                this.connection = null;
            }
        }
        reset();
    }
203931
public void destroy()
    {
        removeAllListeners();
        if (connectionManager != null)
        {
            if(connectionManager.isInLocalTransaction())
            {
                connectionManager.localRollback();
            }
            connectionManager.releaseConnection();
        }
        this.setClosed(true);

        this.descriptorRepository = null;
        this.pbKey = null;
        this.pbf = null;
        this.connectionManager = null;
        this.dbAccess = null;
        this.objectCache = null;
        this.sequenceManager = null;
        this.sqlGenerator = null;
        this.statementManager = null;
    }
950665
public void unregister(ZKMBeanInfo bean) {
        if(bean==null)
            return;
        String path=mapBean2Path.get(bean);
        try {
            unregister(path,bean);
        }
        catch (InstanceNotFoundException e) {
            LOG.warn("InstanceNotFoundException during unregister usually means more than one Zookeeper server has been running in a single JVM");
            LOG.warn("InstanceNotFoundException during unregister can be safely ignored during automated tests.");
        }
        catch (JMException e) {
            LOG.warn("Error during unregister", e);
        }
        mapBean2Path.remove(bean);
        mapName2Bean.remove(bean.getName());
    }
309241
public final synchronized void stop() {
		LaunchingMessageKind.IJMX0003.format();
		unRegisterMBeans();

		try {
			if (this.jmxConnectorServer != null) {
				this.jmxConnectorServer.stop();
			}
		} catch (IOException e1) {
			// Do nothing
		}
		try {
			UnicastRemoteObject.unexportObject(register, true);
		} catch (NoSuchObjectException e) {
			// Do nothing
		}
	}
894716
public void removeConnector(String doomedConnectorName) throws Exception {
        final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, doomedConnectorName);
        if (isConnector(doomedConnectorName)) {
            remove(address);
        }
        return;
    }
978458
public synchronized void destroy()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "Destroying home ", new Object[] { this, j2eeName });

        if (!enabled) {
            return;
        }

        // F743-1751 - Explicitly destroy singletons since they are not pooled.
        if (ivSingletonBeanO != null)
        {
            try
            {
                ivSingletonBeanO.destroy();
            } catch (Throwable ex)
            {
                FFDCFilter.processException(ex, CLASS_NAME + ".destroy", "809", this);
            }
        }

        if (beanPool != null) {
            beanPool.destroy();
        }

        enabled = false;

        if (pmiBean != null) {
            container.pmiFactory.removePmiModule(pmiBean); // d146239.14
        }
    }
105767
@Override
    public void destroy()
    {
        if (indexManager != null)
        {
            indexManager.close();
        }
        if (schemaManager != null)
        {
            schemaManager.dropSchema();
        }
        schemaManager = null;
        externalProperties = null;

        for (Object connectionPool : hostPools.values())
        {
            if (connectionPool != null && connectionPool.getClass().isAssignableFrom(ConnectionPool.class))
            {
                ((ConnectionPool) connectionPool).close(true);
            }
        }
        ((CassandraRetryService) hostRetryService).shutdown();
    }
630206
@Unbind
    public void unbindFactory(Factory factory) {
        try {
            lock.lock();
            InstanceDeclaration declaration = getDeclarationByFactory(factory);
            if (declaration != null) {
                LOGGER.info("Disposing instance created by");
                declaration.dispose();
                declarations.remove(declaration);
            }
        } finally {
            lock.unlock();
        }
    }
1062749
public void destroy() throws SIResourceException, SIException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "destroy");

    // Drive destroy against the associated MQLink object
    if(_mqLinkObject != null)
      _mqLinkObject.destroy();
    
   
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "destroy");
  }
583379
protected void unsetFactoryProvider(ChannelFactoryProvider provider) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "Remove factory provider; " + provider);
        }

        this.chfw.deregisterFactories(provider);
    }
336726
private void destroyEndpointMBeans() {
        for (Map.Entry<String, ServiceRegistration<DynamicMBean>> mbean : endpointMBeans.entrySet()) {
            String mbeanName = mbean.getKey();
            endpointMBeans.remove(mbeanName);
            mbean.getValue().unregister();
        }
    }
347704
public void purgePoolContents() throws ResourceException {
        if (tc.isEntryEnabled()) {
            Tr.entry(this, tc, "purgePoolContents", gConfigProps.cfName);
        }
        ArrayList<MCWrapper> destroyMCWrappeList = new ArrayList<MCWrapper>();
        synchronized (destroyMCWrapperListLock) {
            for (int j = 0; j < gConfigProps.getMaxFreePoolHashSize(); ++j) {
                synchronized (freePool[j].freeConnectionLockObject) {
                    /*
                     * If a connection gets away, by setting fatalErrorNotificationTime will
                     * guaranty when the connection is returned to the free pool, it will be
                     */
                    freePool[j].incrementFatalErrorValue(j);
                    /*
                     * Move as many connections as we can in the free pool to the destroy list
                     */
                    if (freePool[j].mcWrapperList.size() > 0) {
                        //freePool[j][i].removeCleanupAndDestroyAllFreeConnections();
                        int mcWrapperListIndex = freePool[j].mcWrapperList.size() - 1;
                        for (int k = mcWrapperListIndex; k >= 0; --k) {
                            MCWrapper mcw = (MCWrapper) freePool[j].mcWrapperList.remove(k);
                            if (!mcw.isMarkedForPurgeDestruction()) {
                                mcw.setPoolState(0);
                                mcw.markForPurgeDestruction();
                                destroyMCWrappeList.add(mcw);
                                --freePool[j].numberOfConnectionsAssignedToThisFreePool;
                            }
                        }
                    }
                } // end free lock
            } //end for j
        } //end syc for destroyMCWrapperListLock
        if (localConnection_ != null) {
            boolean purgeTLS = false;
            /*
             * We can purge connections in the connection pool if we are not in thread sensitive code.
             */
            updateToTLSPoolInProgress.set(true); // set to true for pausing pool.
            synchronized (updateToTLSPoolInProgressLockObject) {
                try {
                    sleep(20);
                } catch (InterruptedException e) {
                }
                if (activeTLSRequest.get() > 0) {
                    try {
                        sleep(100);
                    } catch (InterruptedException e) {
                    }
                    if (activeTLSRequest.get() > 0) {
                        // We can not purge tls
                        if (tc.isDebugEnabled()) {
                            Tr.debug(this, tc, "To many active requests to search tls, active request value is " + activeRequest.get());
                        }
                    } else {
                        purgeTLS = true;
                    }
                } else {
                    purgeTLS = true;
                }
                if (purgeTLS) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "Searching tls for a connections to purge.");
                    }
                    Iterator<Entry<MCWrapper, ArrayList<MCWrapper>>> it = tlsArrayLists.entrySet().iterator();
                    while (it.hasNext()) {
                        Entry<MCWrapper, ArrayList<MCWrapper>> e = it.next();
                        MCWrapper mcw = e.getKey();
                        if (mcw.getPoolState() == MCWrapper.ConnectionState_freeTLSPool) {
                            ArrayList<MCWrapper> mh = e.getValue();
                            mh.remove(mcw);
                            tlsArrayLists.remove(mcw);
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                ((com.ibm.ejs.j2c.MCWrapper) mcw).setThreadID(((com.ibm.ejs.j2c.MCWrapper) mcw).getThreadID() + "-purge-removed");
                                Tr.debug(this, tc, "removed mcWrapper from thread local " + mcw);
                            }
                            if (!mcw.isMarkedForPurgeDestruction()) {
                                mcw.setPoolState(0);
                                mcw.markForPurgeDestruction();
                                destroyMCWrappeList.add(mcw);
                            }
                        }
                    }
                }
                updateToTLSPoolInProgress.set(false); // set to false for releasing pool.
                updateToTLSPoolInProgressLockObject.notifyAll();
            }
        }
        /*
         * we need to cleanup and destroy connections in the local destroy list.
         */
        for (int i = 0; i < destroyMCWrappeList.size(); ++i) {
            MCWrapper mcw = destroyMCWrappeList.get(i);
            freePool[0].cleanupAndDestroyMCWrapper(mcw);
            this.totalConnectionCount.decrementAndGet();
        }
        if (tc.isEntryEnabled()) {
            Tr.exit(this, tc, "purgePoolContents");
        }
    }
99939
public void deregister() {
		if(objectName == null) {
			return;
		}
		
		try {
			MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
			if (mbs.isRegistered(objectName)) {
				mbs.unregisterMBean(objectName);
			}
			objectName = null;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
914519
static void terminateClient( IMessagingClient client, String errorMessage, Logger logger ) {

		try {
			logger.fine( "The reconfigurable client is requesting its internal connection to be closed." );
			if( client != null )
				client.closeConnection();

		} catch( Exception e ) {
			logger.warning( errorMessage + " " + e.getMessage());
			Utils.logException( logger, e );

		} finally {
			// "unregisterService" was not merged with "closeConnection"
			// on purpose. What is specific to JMX is restricted to this class
			// and this bundle. Sub-classes may use "closeConnection" without
			// any side effect on the JMX part.
			if( client instanceof JmxWrapperForMessagingClient )
				((JmxWrapperForMessagingClient) client).unregisterService();
		}
	}