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

MethodPermissionNode

public class MethodPermissionNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode
This class handles all the method-permission xml tag information
author
Jerome Dochez
version

Fields Summary
private com.sun.enterprise.deployment.MethodPermissionDescriptor
descriptor
Constructors Summary
public MethodPermissionNode()
Creates new MethodPermissionNode

       
        super();
       registerElementHandler(new XMLElement(EjbTagNames.METHOD), 
                                                            MethodNode.class, "addMethod");                 
    
Methods Summary
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        
       if (descriptor==null) {
            descriptor = (MethodPermissionDescriptor) DescriptorFactory.getDescriptor(getXMLPath());
        }
        return descriptor;
    
public voidsetElementValue(com.sun.enterprise.deployment.node.XMLElement element, java.lang.String value)
receives notiification of the value for a particular tag

param
element the xml element
param
value it's associated value

        if (EjbTagNames.ROLE_NAME.equals(element.getQName())) {
            Role role = new Role(value);
            descriptor.addMethodPermission(new MethodPermission(role));
        } else {
            super.setElementValue(element, value);
        }
    
public voidstartElement(com.sun.enterprise.deployment.node.XMLElement element, org.xml.sax.Attributes attributes)
SAX Parser API implementation, we don't really care for now.

        
        if (EjbTagNames.UNCHECKED.equals(element.getQName())) {
            descriptor.addMethodPermission(MethodPermission.getUncheckedMethodPermission());
        } else 
            super.startElement(element, attributes);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.MethodPermissionDescriptor descriptor, com.sun.enterprise.deployment.EjbDescriptor ejb)
write the descriptor class to a DOM tree and return it

param
parent node in the DOM tree
param
node name for the root element of this xml fragment
param
the descriptor to write
return
the DOM tree top node

        
                    
        Node subNode = super.writeDescriptor(parent, nodeName, descriptor);        
        return writeDescriptorInNode(subNode, descriptor, ejb);
    
public org.w3c.dom.NodewriteDescriptorInNode(org.w3c.dom.Node subNode, com.sun.enterprise.deployment.MethodPermissionDescriptor descriptor, com.sun.enterprise.deployment.EjbDescriptor ejb)
Write the descriptor in a DOM tree which root element is provided

param
subNode the root element for the DOM fragment
param
descriptor the method permisison descriptor
param
ejb the ejb descriptor the above method permission belongs to

        
                    
        writeLocalizedDescriptions(subNode, descriptor);
        
        MethodPermission[] mps = descriptor.getMethodPermissions();
        if (mps.length==0)
            return null;
        
        if (!mps[0].isExcluded()) {
            if (mps[0].isUnchecked()) {
                appendChild(subNode, EjbTagNames.UNCHECKED);
            } else {
                for (int i=0;i<mps.length;i++) {
                    appendTextChild(subNode, EjbTagNames.ROLE_NAME, mps[i].getRole().getName());
                }        
            }
        } 
                
        MethodDescriptor[] methods = descriptor.getMethods();
        MethodNode mn = new MethodNode();
        for (int i=0;i<methods.length;i++) {            
            String ejbName = ejb.getName();
            mn.writeDescriptor(subNode, EjbTagNames.METHOD, methods[i], ejbName);
        }            
        return subNode;