/*
(non-Javadoc)

@see com.impetus.kundera.loader.ClientLifeCycleManager#destroy()
485508
@Override
    public void destroy()
    {
        indexManager.close();
        if (schemaManager != null)
        {
            schemaManager.dropSchema();
        }
        if (bucket != null)
        {
            LOGGER.info("Closing bucket " + bucket.name() + ".");
            CouchbaseBucketUtils.closeBucket(bucket);
            LOGGER.info("Closed bucket " + bucket.name() + ".");
        }
        if (cluster != null)
        {
            LOGGER.info("Closing connection to couchbase.");
            cluster.disconnect();
            LOGGER.info("Closed connection to couchbase.");
        }
        else
        {
            LOGGER.warn("Can't close connection to Couchbase, it was already disconnected");
        }
        externalProperties = null;
        schemaManager = null;
    }
1257404
@Override
  public void close()
  {
    ServiceManagerClient client = _client;
    _client = null;
    
    if (client != null) {
      client.close();
    }
  }
293031
public void destroy()
    {
        if (_packet!=null)
            _packet.destroy();
        _packet=null;
        if (_getBodyChunk!=null)
            _getBodyChunk.destroy();
        _getBodyChunk=null;
        _in=null;
        _out=null;
    }
677661
public function destroy()
    {
        // Delete from the persistence layer.
        $this->getDataSource()->destroy($this->id);
        // Remove from the registry.
        $this->getFactory()->unregisterEntity($this);
        // Done, garbage collection should do the rest.
    }
741077
public void destroy()
    {
        super.destroy();
        if (m_servletTask != null)
            m_servletTask.free();
        m_servletTask = null;
        ServletTask.destroyServlet();
    }
537791
public static final void destroy() {
		if (CClassLoader.rootLoader == null) {
			return;
		}
		System.out.println("Destroying YAHP ClassLoader Tree");

		CClassLoader.urlLoader = null;

		try {
			Field f = Class.forName("java.lang.Shutdown").getDeclaredField(
					"hooks");
			f.setAccessible(true);
			ArrayList l = (ArrayList) f.get(null);
			for (Iterator it = l.iterator(); it.hasNext();) {
				Object o = it.next();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Field f = Class.forName("java.lang.ApplicationShutdownHooks")
					.getDeclaredField("hooks");
			f.setAccessible(true);
			IdentityHashMap l = (IdentityHashMap) f.get(null);
			for (Iterator it = l.entrySet().iterator(); it.hasNext();) {
				Entry e = (Entry) it.next();
				Thread o = (Thread) e.getKey();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
					continue;
				}
				o = (Thread) e.getValue();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			if ((UIManager.getLookAndFeel() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader()
							.getClass() == CClassLoader.class)) {
				UIManager.setLookAndFeel((LookAndFeel) null);
			}
			Field f = UIManager.class.getDeclaredField("currentLAFState");
			f.setAccessible(true);
			Object lafstate = f.get(null);
			if (lafstate != null) {
				Field fmultiUIDefaults = lafstate.getClass().getDeclaredField(
						"multiUIDefaults");
				fmultiUIDefaults.setAccessible(true);
				Object multiUIDefaults = fmultiUIDefaults.get(lafstate);
				Method clear = multiUIDefaults.getClass().getDeclaredMethod(
						"clear", (Class[]) null);
				clear.setAccessible(true);
				clear.invoke(multiUIDefaults, (Object[]) null);
				Field tbl = lafstate.getClass().getDeclaredField("tables");
				tbl.setAccessible(true);
				Hashtable[] tables = (Hashtable[]) tbl.get(lafstate);
				if (tables != null) {
					for (int i = 0; i < tables.length; i++) {
						Hashtable element = tables[i];
						if (element != null) {
							element.clear();
						}
					}
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Hashtable tb = UIManager.getDefaults();
			Object cl = tb.get("ClassLoader");
			if (cl.getClass() == CClassLoader.class) {
				tb.put("ClassLoader", CClassLoader.rootLoader.getParent());
			}
		} catch (Throwable ignore) {
		}

		Method logFactoryRelease = null;

		try {
			logFactoryRelease = CClassLoader.rootLoader.loadClass(
					"org.apache.commons.logging.LogFactory").getMethod(
					"release", new Class[] { ClassLoader.class });
		} catch (final Throwable ignore) {
		}

		CClassLoader.rootLoader._destroy(logFactoryRelease);
		CClassLoader.mandatoryLoadersMap.clear();
		CClassLoader.rootLoader = null;

		// deregister any sql driver loaded
		try {
			final List deregisterList = new ArrayList();
			for (final Enumeration it = DriverManager.getDrivers(); it
					.hasMoreElements();) {
				final Driver d = (Driver) it.nextElement();

				if ((d != null)
						&& (d.getClass().getClassLoader() != null)
						&& (d.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					deregisterList.add(d);
				}
			}

			for (int i = 0; i < deregisterList.size(); i++) {
				final Driver driver = (Driver) deregisterList.get(i);
				DriverManager.deregisterDriver(driver);
			}
		} catch (final Throwable ignore) {
		}

		// stop dandling thread created with this classloader
		// tested only on sun jdk
		ThreadGroup tg = Thread.currentThread().getThreadGroup();
		while ((tg != null) && (tg.getParent() != null)) {
			tg = tg.getParent();
		}
		List ltg = new ArrayList();
		ltg.add(tg);
		CClassLoader.getThreadGroups(tg, ltg);
		for (int ii = 0; ii < ltg.size(); ii++) {
			try {
				final ThreadGroup g = (ThreadGroup) ltg.get(ii);
				final Field fthreads = ThreadGroup.class
						.getDeclaredField("threads");
				fthreads.setAccessible(true);

				final List toStop = new ArrayList();
				Object threads[] = null;

				if (fthreads.getType() == Vector.class) {
					// in gnu classpath
					threads = ((Vector) fthreads.get(g)).toArray();
				} else {
					// sun
					threads = (Object[]) fthreads.get(g);
				}

				for (int i = 0; i < threads.length; i++) {
					if (threads[i] == null) {
						continue;
					}
					if ((threads[i] != null)
							&& (((Thread) threads[i]).getContextClassLoader() != null)
							&& (((Thread) threads[i]).getContextClassLoader()
									.getClass() == CClassLoader.class)) {
						((Thread) threads[i]).setContextClassLoader(null);
					}
					if ((threads[i] != null)
							&& (threads[i].getClass().getClassLoader() != null)
							&& (threads[i].getClass().getClassLoader()
									.getClass() == CClassLoader.class)) {
						toStop.add((Thread) threads[i]);
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("threadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}
							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("inheritableThreadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}

							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any protection domain referring this loader tree
					try {
						final Field finheritedAccessControlContext = Thread.class
								.getDeclaredField("inheritedAccessControlContext");
						finheritedAccessControlContext.setAccessible(true);

						final Object inheritedAccessControlContext = finheritedAccessControlContext
								.get(threads[i]);

						if (inheritedAccessControlContext != null) {
							final Field fcontext = AccessControlContext.class
									.getDeclaredField("context");
							fcontext.setAccessible(true);

							final Object context[] = (Object[]) fcontext
									.get(inheritedAccessControlContext);

							if (context != null) {
								for (int k = 0; k < context.length; k++) {
									if (context[k] == null) continue;
									final Field fclassloader = ProtectionDomain.class
											.getDeclaredField("classloader");
									fclassloader.setAccessible(true);

									final Object classloader = fclassloader
											.get(context[k]);

									if ((classloader != null)
											&& (classloader.getClass() == CClassLoader.class)) {
										context[k] = null;
									}

									fclassloader.setAccessible(false);
								}
							}

							fcontext.setAccessible(false);
						}

						finheritedAccessControlContext.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}
				}

				fthreads.setAccessible(false);
				for (int i = 0; i < toStop.size(); i++) {
					try {
						final Thread t = (Thread) toStop.get(i);
						final Method stop = t.getClass().getMethod("stop",
								(Class[]) null);
						stop.invoke(t, (Object[]) null);
					} catch (final Throwable ignore) {
					}
				}
			} catch (final Throwable ignore) {
			}
		}
		try{CThreadContext.destroy();}catch(Throwable ignore){}
		System.runFinalization();
		System.gc();
		Introspector.flushCaches();
		System.out.println("Destroying YAHP ClassLoader Tree : done");
	}
1368863
public function destroy()
    {
        // This is not mandatory as GC will free the memory eventually but allows memory to be freed faster
        // by removing circular dependencies.
        if (!empty($this->data)) {
            foreach ($this->data as $data) {
                if ($data instanceof DestroyableObject) {
                    $data->destroy();
                }
            }
        }
        $this->data = [];
        $this->manialinkFactory = null;
    }
752661
@Override
    public void destroy() {
        logger.info("Destroying Servlet Filter: {}", PEP.class);
        m_filters = null;
        m_objectsRESTFilterMatcher = null;
        m_ctxHandler = null;
    }
739929
@Override
    public void destroy()
    {
        if (indexManager != null)
        {
            indexManager.close();
        }
        if (schemaManager != null)
        {
            schemaManager.dropSchema();
        }
        schemaManager = null;
        externalProperties = null;
        releaseConnection(this.session);
        ((Cluster) getConnectionPoolOrConnection()).closeAsync();
    }
914662
public void destroy() {
        JmsUtils.closeSession(session);

        if (connection != null) {
            ConnectionFactoryUtils.releaseConnection(connection, endpointConfiguration.getConnectionFactory(), true);
        }
    }
555828
public void destroy() {
        XmlWebApplicationContext wac = (XmlWebApplicationContext)WebApplicationContextUtils.getWebApplicationContext(_context);
        if (wac != null) {
            _context.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        } else {
            _logger.warning("Nothing more to destroy");
            return;
        }

        _logger.info("<<<< Service Platform(" + _application + ") destruction starting");
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        while (!_manageables.empty()) {
            ObjectName on = _manageables.pop();
            _logger.info("<<<<<<<< MBean(" + on + ") unregistration starting");
            try {
                mbs.unregisterMBean(on);
            } catch (Exception x) {
                _logger.log(Level.WARNING, on.toString());
            }
            _logger.info("<<<<<<<< MBean(" + on + ") unregistration complete");
        }
        while (!_plca.empty()) {
            List<Pair<String, PlatformAware>> plcas = _plca.pop();
            for (Pair<String, PlatformAware> plca: plcas) {
                _logger.info("<<<<<<<< PlatformAware(" + plca.first + '/' + plca.second.getClass().getName() + ") termination starting");
                plca.second.terminate(_application, plca.first);
                _logger.info("<<<<<<<< PlatformAware(" + plca.first + '/' + plca.second.getClass().getName() + ") termination complete");
            }
        }

        // finally, deregisters JDBC driver manually to prevent Tomcat 7 from complaining about memory leaks
        Enumeration<java.sql.Driver> drivers = java.sql.DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            java.sql.Driver driver = drivers.nextElement();
            _logger.info("<<<<<<<< JDBC Driver(" + driver + ") deregistration starting");
            try {
                java.sql.DriverManager.deregisterDriver(driver);
            } catch (java.sql.SQLException x) {
                _logger.log(Level.WARNING, "Error deregistering driver " + driver, x);
            }
            _logger.info("<<<<<<<< JDBC Driver(" + driver + ") deregistration complete");
        }

        for (Iterator<String> it = _registry.keySet().iterator(); it.hasNext();) {
            if (!it.next().startsWith("x!/")) it.remove();
        }
        _registry.remove("x!/ping");
        _registry.remove("x!/list");
        _registry.remove("x!/desc");
        while (!_applc.empty()) {
            _applc.pop().close();
        }
        wac.close();

        _logger.info("<<<< Service Platform(" + _application + ") destruction complete");
    }
125334
@Override
    public void destroy() throws Exception {
        for (final InstanceHolder instanceHolder : this.instances.values()) {
            if (instanceHolder.destructionCallback != null) {
                try {
                    instanceHolder.destructionCallback.run();
                } catch (Exception e) {
                    this.logger.warn(
                            "Destruction callback for bean named '"
                                    + instanceHolder.name
                                    + "' failed.",
                            e);
                }
            }
        }

        this.instances.clear();
    }
1298638
public void destroy() {

        m_attributeName = null;
        m_attributeType = null;
        m_attributeValueViews.clear();
        m_attributeValueViews = null;
        m_dndHandler = null;
        m_entity = null;
        m_entityType = null;
        m_entityBackEnd = null;
        m_widgetService = null;
    }
588305
public synchronized void destroy()
    {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) 
            logger.logp(Level.FINE, CLASS_NAME,"destroy", "entry");

        /*destroying=true;
        
        if (nServicing>0){
        	try {
				this.wait();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				
			}
        }*/
    	
        super.destroy();

        //parent.removeSubContainer(name);    	//PK37449
    	this.requestMapper = null;
    	this.config = null;
    	this.webApp = null;  // PK25527
        
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) 
        	logger.exiting(CLASS_NAME, "destroy");													//569469
    }
620900
public void destroy() {
        DeferredBindingActions.clear();
        if(!disconnected.isEmpty()) {
            disconnected.pop();
        }
        if (getSessionFactory() == null || decNestingCount() > 0 || getParticipate()) {
            return;
        }

        // single session mode
        SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory());
        LOG.debug("Closing single Hibernate session in GrailsDispatcherServlet");
        try {
            disconnected.clear();
            SessionFactoryUtils.closeSession(holder.getSession());
        }
        catch (RuntimeException ex) {
            LOG.error("Unexpected exception on closing Hibernate Session", ex);
        }
    }
1126958
public void destroy()
    {
        if (_selector!=null)
        {
            try{_selector.close();}
            catch(IOException e){ LogSupport.ignore(log,e);}
            _selector=null;
            _buffer=null;
            _flush=null;
            _channel=null;
        }
    }
1160654
public void destroy()
    {
        super.destroy();
        if (_httpMessageWriter!=null)
            _httpMessageWriter.destroy();
        _httpMessageWriter=null;
        _out=null;
    }