FileDocCategorySizeDatePackage
InterceptorBindingNode.javaAPI DocGlassfish v2 API9653Fri May 04 22:31:40 BST 2007com.sun.enterprise.deployment.node.ejb

InterceptorBindingNode

public class InterceptorBindingNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode

Fields Summary
private com.sun.enterprise.deployment.MethodDescriptor
businessMethod
private boolean
needsOverloadResolution
Constructors Summary
public InterceptorBindingNode()


      
        super();
    
Methods Summary
public booleanendElement(com.sun.enterprise.deployment.node.XMLElement element)
receives notification of the end of an XML element by the Parser

param
element the xml tag identification
return
true if this node is done processing the XML sub tree


        if (EjbTagNames.INTERCEPTOR_ORDER.equals(element.getQName())) {

            InterceptorBindingDescriptor desc = (InterceptorBindingDescriptor)
                getDescriptor();
            desc.setIsTotalOrdering(true);

        } else if (EjbTagNames.METHOD_PARAMS.equals(element.getQName())) {
            // this means we have an empty method-params element
            // which means this method has no input parameter
            if (businessMethod.getParameterClassNames() == null) {
                businessMethod.setEmptyParameterClassNames();
            }
        }else if( EjbTagNames.METHOD.equals(element.getQName()) ) {

            InterceptorBindingDescriptor bindingDesc = 
                (InterceptorBindingDescriptor) getDescriptor();
            businessMethod.setEjbClassSymbol(MethodDescriptor.EJB_BEAN);
            bindingDesc.setBusinessMethod(businessMethod);
            
            if( needsOverloadResolution ) {
                bindingDesc.setNeedsOverloadResolution(true);
            }

            businessMethod = null;
            needsOverloadResolution = false;

        }

        return super.endElement(element);
    
protected java.util.MapgetDispatchTable()
all sub-implementation of this class can use a dispatch table to map xml element to method name on the descriptor class for setting the element value.

return
the map with the element name as a key, the setter method as a value

        Map table =  super.getDispatchTable();

        table.put(EjbTagNames.EJB_NAME, "setEjbName");
        table.put(EjbTagNames.INTERCEPTOR_CLASS, "appendInterceptorClass");
        table.put(EjbTagNames.EXCLUDE_DEFAULT_INTERCEPTORS, 
                  "setExcludeDefaultInterceptors");
        table.put(EjbTagNames.EXCLUDE_CLASS_INTERCEPTORS, 
                  "setExcludeClassInterceptors");

        return table;
    
public voidsetElementValue(com.sun.enterprise.deployment.node.XMLElement element, java.lang.String value)


        if( EjbTagNames.METHOD_NAME.equals(element.getQName()) ) {
            businessMethod.setName(value);
        } else if( EjbTagNames.METHOD_PARAM.equals(element.getQName()) ) {
            if( (value != null) && (value.trim().length() > 0) ) {
                businessMethod.addParameterClass(value.trim());
            }
        } else {
            super.setElementValue(element, value);
        }

    
public voidstartElement(com.sun.enterprise.deployment.node.XMLElement element, org.xml.sax.Attributes attributes)


        if( EjbTagNames.METHOD.equals(element.getQName()) ) {

            businessMethod = new MethodDescriptor();
            // Assume we need overloaded method resolution until we
            // encounter at least one method-param element.
            needsOverloadResolution = true;

        } else if( EjbTagNames.METHOD_PARAMS.equals(element.getQName()) ) {

            // If there's a method-params element, regardless of whether there
            // are any <method-param> sub-elements, there's no overload
            // resolution needed.
            needsOverloadResolution = false;

        }
          
        super.startElement(element, attributes);
    
public voidwriteBindings(org.w3c.dom.Node parent, com.sun.enterprise.deployment.EjbDescriptor ejbDesc)
Write interceptor bindings for this ejb.

param
parent node in the DOM tree
param
the descriptor to write


        List<EjbInterceptor> classInterceptors = ejbDesc.getInterceptorChain();
        if( classInterceptors.size() > 0 ) {
            writeTotalOrdering(parent, classInterceptors, ejbDesc, null);
        }

        Map<MethodDescriptor, List<EjbInterceptor>> methodInterceptorsMap =
            ejbDesc.getMethodInterceptorsMap();

        for(MethodDescriptor nextMethod : methodInterceptorsMap.keySet()) {

            List<EjbInterceptor> interceptors = 
                methodInterceptorsMap.get(nextMethod);
            
            if(interceptors.isEmpty()) {
                writeExclusionBinding(parent, ejbDesc, nextMethod);
            } else {
                writeTotalOrdering(parent, interceptors, ejbDesc, nextMethod);
            }

        }

        return;
    
private voidwriteExclusionBinding(org.w3c.dom.Node parent, com.sun.enterprise.deployment.EjbDescriptor ejbDesc, com.sun.enterprise.deployment.MethodDescriptor method)


        Node bindingNode = appendChild(parent, 
                                       EjbTagNames.INTERCEPTOR_BINDING);

        appendTextChild(bindingNode, EjbTagNames.EJB_NAME, 
                        ejbDesc.getName());

        appendTextChild(bindingNode, EjbTagNames.EXCLUDE_CLASS_INTERCEPTORS,
                        "true");

        MethodNode methodNode = new MethodNode();

        // Write out method description. void methods will be written
        // out using an empty method-params element so they will not
        // be interpreted as overloaded when processed.
        methodNode.writeJavaMethodDescriptor
            (bindingNode, EjbTagNames.INTERCEPTOR_BUSINESS_METHOD, method,
             true);
                                             
    
private voidwriteTotalOrdering(org.w3c.dom.Node parent, java.util.List interceptors, com.sun.enterprise.deployment.EjbDescriptor ejbDesc, com.sun.enterprise.deployment.MethodDescriptor method)


        Node bindingNode = appendChild(parent, 
                                       EjbTagNames.INTERCEPTOR_BINDING);

        appendTextChild(bindingNode, EjbTagNames.EJB_NAME, 
                        ejbDesc.getName());

        Node totalOrderingNode = appendChild(bindingNode,
                                             EjbTagNames.INTERCEPTOR_ORDER);
        for(EjbInterceptor next : interceptors) {

            appendTextChild(totalOrderingNode, EjbTagNames.INTERCEPTOR_CLASS,
                            next.getInterceptorClassName());
        }

        if( method != null ) {
            
            MethodNode methodNode = new MethodNode();

            // Write out method description. void methods will be written
            // out using an empty method-params element so they will not
            // be interpreted as overloaded when processed.
            methodNode.writeJavaMethodDescriptor
                (bindingNode, EjbTagNames.INTERCEPTOR_BUSINESS_METHOD, method,
                 true);

        }