@Override
    public void discard() // PQ57408 Implemented this function
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "discard : " + this);

        // If this is a BeanO for a home (i.e. home field will be null) then
        // the discard should be ignored. Homes work much like singletons in
        // that a system exception from a home method does not cause the
        // home to be discarded. And, since the BeanO is not transitioned
        // to the 'destroyed' state, normal postInvoke will run.           d661866
        if (home == null) {
            if (isTraceOn && tc.isEntryEnabled())
                Tr.exit(tc, "discard : Home beans are never discarded");
            return;
        }

        discarded = true;

        if (state == DESTROYED) {
            if (isTraceOn && tc.isEntryEnabled())
                Tr.exit(tc, "discard : Bean already destroyed");
            return;
        }

        setState(DESTROYED);

        destroyHandleList();

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

        if (pmiBean != null) {
            pmiBean.discardCount(); // F743-27070
            pmiBean.beanDestroyed();
        }

        // If the number of allowed bean instances is limited, then the number
        // of created instances needs to be decremented when an instance is
        // discarded, and the next thread that may be waiting for an instance
        // must be notified.                                               PK20648
        if (ivNumberOfBeansLimited) {
            synchronized (beanPool) {
                --home.ivNumberBeansCreated;
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "discard: BeanPool(" + home.ivNumberBeansCreated +
                                 "/" + home.beanMetaData.ivMaxCreation + ")");
                beanPool.notify();
            }
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "discard");
        }
    }
@ Override public void discard ( ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "discard : " + this ) ; if ( home == null ) { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "discard : Home beans are never discarded" ) ; return ; } discarded = true ; if ( state == DESTROYED ) { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "discard : Bean already destroyed" ) ; return ; } setState ( DESTROYED ) ; destroyHandleList ( ) ; this . releaseManagedObjectContext ( ) ; if ( pmiBean != null ) { pmiBean . discardCount ( ) ; pmiBean . beanDestroyed ( ) ; } if ( ivNumberOfBeansLimited ) { synchronized ( beanPool ) { -- home . ivNumberBeansCreated ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "discard: BeanPool(" + home . ivNumberBeansCreated + "/" + home . beanMetaData . ivMaxCreation + ")" ) ; beanPool . notify ( ) ; } } if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "discard" ) ; } }
Discard this <code>SessionBeanO</code> instance. This method must
be used instead of the destroy method when a uncheck or system
exception occurs to ensure no lifecycle callback (e.g. ejbRemove
or pre-destroy interceptor method) method is invoked as required
by the EJB spec. <p>