1 23 24 package com.sun.enterprise.deployment.node.runtime.web; 25 26 import java.util.Map ; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.Element ; 29 30 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor; 31 import com.sun.enterprise.deployment.runtime.web.CacheHelper; 32 import com.sun.enterprise.deployment.runtime.web.WebProperty; 33 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 34 import com.sun.enterprise.deployment.node.XMLElement; 35 36 41 public class CacheHelperNode extends WebRuntimeNode { 42 43 public CacheHelperNode() { 44 45 registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY), 46 WebPropertyNode.class, "addWebProperty"); 47 } 48 49 57 protected boolean setAttributeValue(XMLElement elementName, XMLElement attributeName, String value) { 58 RuntimeDescriptor descriptor = (RuntimeDescriptor) getRuntimeDescriptor(); 59 if (descriptor==null) { 60 throw new RuntimeException ("Trying to set values on a null descriptor"); 61 } 62 if (attributeName.getQName().equals(RuntimeTagNames.NAME)) { 63 descriptor.setAttributeValue(CacheHelper.NAME, value); 64 return true; 65 } else 66 if (attributeName.getQName().equals(RuntimeTagNames.CLASS_NAME)) { 67 descriptor.setAttributeValue(CacheHelper.CLASS_NAME, value); 68 return true; 69 } 70 return false; 71 } 72 73 81 public Node writeDescriptor(Node parent, String nodeName, CacheHelper descriptor) { 82 83 Element cacheHelper = (Element ) super.writeDescriptor(parent, nodeName, descriptor); 84 85 WebProperty[] properties = descriptor.getWebProperty(); 87 if (properties.length>0) { 88 WebPropertyNode wpn = new WebPropertyNode(); 89 wpn.writeDescriptor(cacheHelper, RuntimeTagNames.PROPERTY, properties); 90 } 91 92 setAttribute(cacheHelper, RuntimeTagNames.NAME, (String ) descriptor.getAttributeValue(CacheHelper.NAME)); 94 setAttribute(cacheHelper, RuntimeTagNames.CLASS_NAME, (String ) descriptor.getAttributeValue(CacheHelper.CLASS_NAME)); 95 96 return cacheHelper; 97 } 98 } 99 | Popular Tags |