protected BeanOCallDispatchToken callDispatchEventListeners
                    (int dispatchEventCode,
                     BeanOCallDispatchToken token)
    {
        DispatchEventListenerManager dispatchEventListenerManager = container.ivDispatchEventListenerManager; // d646413.2
        DispatchEventListenerCookie[] dispatchEventListenerCookies = null;
        EJBMethodMetaData methodMetaData = null;
        BeanOCallDispatchToken retToken = null;
        boolean doBeforeDispatch = false;
        boolean doAfterDispatch = false;

        // first check if listeners are active, if not skip everything else ...
        if (dispatchEventListenerManager != null &&
            dispatchEventListenerManager.dispatchEventListenersAreActive()) // @539186C, d646413.2
        {
            final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
            if (isTraceOn && tc.isEntryEnabled())
                Tr.entry(tc, "callDispatchEventListeners: " + dispatchEventCode + ", " + this);

            // if one of the "before" callbacks
            //
            // Build temporary EJBMethodInfo object to represent this callback method.
            // If no dispatch cookies assigned to this bean, create new cookie array.
            // If no dispatch context on thread, this is not method dispatch, but rather
            // is end of tran processing.
            //
            if (dispatchEventCode == DispatchEventListener.BEFORE_EJBACTIVATE ||
                dispatchEventCode == DispatchEventListener.BEFORE_EJBLOAD ||
                dispatchEventCode == DispatchEventListener.BEFORE_EJBSTORE ||
                dispatchEventCode == DispatchEventListener.BEFORE_EJBPASSIVATE) {
                methodMetaData = buildTempEJBMethodMetaData(dispatchEventCode, home.getBeanMetaData());
                retToken = new BeanOCallDispatchToken(); // return value to communicate between "before" and "after" call
                retToken.setMethodMetaData(methodMetaData); // save away methodMetaData object for "after" call

                // d646413.2 - Check if a dispatch context was already created
                // for this bean by EJSContainer.preInvoke.
                EJSDeployedSupport s = EJSContainer.getMethodContext();
                if (s != null && s.beanO == this) // d646413.2
                {
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "using dispatch context from method context");
                    // use cookie array already assigned to bean for "after" callback
                    dispatchEventListenerCookies = s.ivDispatchEventListenerCookies; // @MD11200.6A
                }

                if (dispatchEventListenerCookies == null)
                {
                    // create new cookie array - @MD11200.6A
                    dispatchEventListenerCookies = dispatchEventListenerManager.getNewDispatchEventListenerCookieArray(); // @MD11200.6A
                    doBeforeDispatch = true; // must drive beforeDispatch to collect cookies from event listeners - // @MD11200.6A
                    retToken.setDoAfterDispatch(true); /*
                                                        * since doing beforeDispatch on "before" callback, must issue afterDispatch
                                                        * during "after" callback
                                                        */
                }

                // save cookie array in token for "after" call
                retToken.setDispatchEventListenerCookies(dispatchEventListenerCookies); // @MD11200.6A
            }
            // else if one of the "after" callbacks
            //
            // get methodInfo and dispatch cookies from input token
            // plus check "afterDispatch" flag to see if beforeDispatch was issued
            // when "before" callback was done and if we now have to do afterDispatch
            // call to finish up
            else if (dispatchEventCode == DispatchEventListener.AFTER_EJBACTIVATE ||
                     dispatchEventCode == DispatchEventListener.AFTER_EJBLOAD ||
                     dispatchEventCode == DispatchEventListener.AFTER_EJBSTORE ||
                     dispatchEventCode == DispatchEventListener.AFTER_EJBPASSIVATE) {
                methodMetaData = token.getMethodMetaData(); // @MD11200.6A
                doAfterDispatch = token.getDoAfterDispatch(); // @MD11200.6A d621610
                dispatchEventListenerCookies = token.getDispatchEventListenerCookies(); // @MD11200.6A
            }

            if (doBeforeDispatch) { // @MD11200.6A
                dispatchEventListenerManager.callDispatchEventListeners(DispatchEventListener.BEGIN_DISPATCH, dispatchEventListenerCookies, methodMetaData); // @MD11200.6A
            } // @MD11200.6A

            dispatchEventListenerManager.callDispatchEventListeners(dispatchEventCode, dispatchEventListenerCookies, methodMetaData); // @MD11200.6A

            if (doAfterDispatch) { // @MD11200.6A
                dispatchEventListenerManager.callDispatchEventListeners(DispatchEventListener.END_DISPATCH, dispatchEventListenerCookies, methodMetaData); // @MD11200.6A
            } // @MD11200.6A
            if (isTraceOn && tc.isEntryEnabled()) { // @MD11200.6A
                Tr.exit(tc, "callDispatchEventListeners", retToken); // @MD11200.6A
            } // @MD11200.6A

        } // if listeners are active
        return retToken;
    }
protected BeanOCallDispatchToken callDispatchEventListeners ( int dispatchEventCode , BeanOCallDispatchToken token ) { DispatchEventListenerManager dispatchEventListenerManager = container . ivDispatchEventListenerManager ; DispatchEventListenerCookie [ ] dispatchEventListenerCookies = null ; EJBMethodMetaData methodMetaData = null ; BeanOCallDispatchToken retToken = null ; boolean doBeforeDispatch = false ; boolean doAfterDispatch = false ; if ( dispatchEventListenerManager != null && dispatchEventListenerManager . dispatchEventListenersAreActive ( ) ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "callDispatchEventListeners: " + dispatchEventCode + ", " + this ) ; if ( dispatchEventCode == DispatchEventListener . BEFORE_EJBACTIVATE || dispatchEventCode == DispatchEventListener . BEFORE_EJBLOAD || dispatchEventCode == DispatchEventListener . BEFORE_EJBSTORE || dispatchEventCode == DispatchEventListener . BEFORE_EJBPASSIVATE ) { methodMetaData = buildTempEJBMethodMetaData ( dispatchEventCode , home . getBeanMetaData ( ) ) ; retToken = new BeanOCallDispatchToken ( ) ; retToken . setMethodMetaData ( methodMetaData ) ; EJSDeployedSupport s = EJSContainer . getMethodContext ( ) ; if ( s != null && s . beanO == this ) { if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "using dispatch context from method context" ) ; dispatchEventListenerCookies = s . ivDispatchEventListenerCookies ; } if ( dispatchEventListenerCookies == null ) { dispatchEventListenerCookies = dispatchEventListenerManager . getNewDispatchEventListenerCookieArray ( ) ; doBeforeDispatch = true ; retToken . setDoAfterDispatch ( true ) ; } retToken . setDispatchEventListenerCookies ( dispatchEventListenerCookies ) ; } else if ( dispatchEventCode == DispatchEventListener . AFTER_EJBACTIVATE || dispatchEventCode == DispatchEventListener . AFTER_EJBLOAD || dispatchEventCode == DispatchEventListener . AFTER_EJBSTORE || dispatchEventCode == DispatchEventListener . AFTER_EJBPASSIVATE ) { methodMetaData = token . getMethodMetaData ( ) ; doAfterDispatch = token . getDoAfterDispatch ( ) ; dispatchEventListenerCookies = token . getDispatchEventListenerCookies ( ) ; } if ( doBeforeDispatch ) { dispatchEventListenerManager . callDispatchEventListeners ( DispatchEventListener . BEGIN_DISPATCH , dispatchEventListenerCookies , methodMetaData ) ; } dispatchEventListenerManager . callDispatchEventListeners ( dispatchEventCode , dispatchEventListenerCookies , methodMetaData ) ; if ( doAfterDispatch ) { dispatchEventListenerManager . callDispatchEventListeners ( DispatchEventListener . END_DISPATCH , dispatchEventListenerCookies , methodMetaData ) ; } if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "callDispatchEventListeners" , retToken ) ; } } return retToken ; }
LIDB2775-23.1