@Override
    public final synchronized void destroy() {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.entry(tc, "destroy");
        }

        if (state == DESTROYED) {
            return;
        }

        // For Singleton, 'destroy' is where the bean is removed and destroyed.
        // Remove time should include calling any lifecycle callbacks.   d626533.1
        long removeStartTime = -1;
        if (pmiBean != null) {
            removeStartTime = pmiBean.initialTime(EJBPMICollaborator.REMOVE_RT);
        }

        setState(PRE_DESTROY);

        if (ivCallbackKind == CallbackKind.InvocationContext) {
            InterceptorMetaData imd = home.beanMetaData.ivInterceptorMetaData;
            InterceptorProxy[] proxies = imd.ivPreDestroyInterceptors;
            if (proxies != null) {
                try {
                    // There is no need to push/pop CMD because singletons are
                    // always destroyed as part of uninstallBean, which uses
                    // ComponentMetaDataCollaborator.
                    callTransactionalLifecycleInterceptors(proxies, LifecycleInterceptorWrapper.MID_PRE_DESTROY); // F743-1751
                } catch (Throwable t) {
                    FFDCFilter.processException(t, CLASS_NAME + ".destroy", "824", this);

                    if (isTraceOn && tc.isDebugEnabled()) {
                        Tr.debug(tc, "destroy caught exception", new Object[] { this, t });
                    }
                }
            }
        }

        // Change the state to destroyed.
        setState(DESTROYED);

        // Release any JCDI creational contexts that may exist.         F743-29174
        this.releaseManagedObjectContext();

        // For Singleton, 'destroy' is where the bean is removed and destroyed.
        // Update both counters and end remove time.                     d626533.1
        if (pmiBean != null) {
            // TODO : When PMI stops counting beanDestroyed as remove... then add next line
            //         pmiBean.beanRemoved();
            pmiBean.beanDestroyed();
            pmiBean.finalTime(EJBPMICollaborator.REMOVE_RT, removeStartTime);
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "destroy");
        }
    }
@ Override public final synchronized void destroy ( ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "destroy" ) ; } if ( state == DESTROYED ) { return ; } long removeStartTime = - 1 ; if ( pmiBean != null ) { removeStartTime = pmiBean . initialTime ( EJBPMICollaborator . REMOVE_RT ) ; } setState ( PRE_DESTROY ) ; if ( ivCallbackKind == CallbackKind . InvocationContext ) { InterceptorMetaData imd = home . beanMetaData . ivInterceptorMetaData ; InterceptorProxy [ ] proxies = imd . ivPreDestroyInterceptors ; if ( proxies != null ) { try { callTransactionalLifecycleInterceptors ( proxies , LifecycleInterceptorWrapper . MID_PRE_DESTROY ) ; } catch ( Throwable t ) { FFDCFilter . processException ( t , CLASS_NAME + ".destroy" , "824" , this ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "destroy caught exception" , new Object [ ] { this , t } ) ; } } } } setState ( DESTROYED ) ; this . releaseManagedObjectContext ( ) ; if ( pmiBean != null ) { pmiBean . beanDestroyed ( ) ; pmiBean . finalTime ( EJBPMICollaborator . REMOVE_RT , removeStartTime ) ; } if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "destroy" ) ; } }
Destroy this <code>CMSingletonBeanO</code> instance. Note, for Singleton
EJBs, the EJB 3.1 specification requires that the Singleton should NOT be
discarded when as a result of a unchecked or system exception. Also, the
only time a Singleton should be destroyed is when the application is being
stopped.