FileDocCategorySizeDatePackage
MessageListenerNode.javaAPI DocGlassfish v2 API5258Fri May 04 22:31:40 BST 2007com.sun.enterprise.deployment.node.connector

MessageListenerNode

public class MessageListenerNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode
This node is responsible for handling the Connector DTD related message-listener XML tag
author
Sheetal Vartak
version

Fields Summary
private com.sun.enterprise.deployment.MessageListener
msgListener
Constructors Summary
public MessageListenerNode()

    
      
	registerElementHandler(new XMLElement(ConnectorTagNames.ACTIVATION_SPEC),
			       ActivationSpecNode.class); 
	
    
Methods Summary
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        if (msgListener == null) {
            msgListener = (MessageListener) DescriptorFactory.getDescriptor(getXMLPath());
        } 
        return msgListener;
    
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(ConnectorTagNames.MSG_LISTENER_TYPE, "setMessageListenerType");
	return table;
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, com.sun.enterprise.deployment.Descriptor descriptor)
write the descriptor class to a DOM tree and return it

param
parent node for the DOM tree
param
the descriptor to write
return
the DOM tree top node


        if (! (descriptor instanceof InboundResourceAdapter)) {
            throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
        }
	Iterator msgListeners = ((InboundResourceAdapter)descriptor).getMessageListeners().iterator();
	if (!msgListeners.hasNext()) {
	    throw new RuntimeException("There must be at least one messagelistener for this inbound resource adapter");
	}
	//message listeners
	for (;msgListeners.hasNext();) {
	    MessageListener msgListener = (MessageListener) msgListeners.next();
	    Node msgListenerNode = appendChild(parent, ConnectorTagNames.MSG_LISTENER);
	    appendTextChild(msgListenerNode, ConnectorTagNames.MSG_LISTENER_TYPE, msgListener.getMessageListenerType());  
	
	    //activation spec node
	    ActivationSpecNode actSpecNode = new ActivationSpecNode();
	    msgListenerNode = actSpecNode.writeDescriptor(msgListenerNode, msgListener);
	}
	return parent;