1 23 24 25 package com.sun.enterprise.deployment.node; 26 27 import com.sun.enterprise.deployment.xml.PersistenceTagNames; 28 import com.sun.enterprise.deployment.PersistenceUnitDescriptor; 29 30 import java.util.Map ; 31 import java.util.HashMap ; 32 33 import org.xml.sax.Attributes ; 34 35 39 public class PersistenceUnitNode extends DeploymentDescriptorNode { 40 41 44 private Map <String , String > dispatchTable; 45 46 54 public PersistenceUnitNode() { 55 if (handlers != null) handlers.clear(); 59 initDispatchTable(); 60 } 61 62 @Override public void startElement( 63 XMLElement element, Attributes attributes) { 64 if (PersistenceTagNames.PROPERTY.equals(element.getQName())) { 65 assert(attributes.getLength() == 2); 66 assert(attributes.getIndex(PersistenceTagNames.PROPERTY_NAME) != 67 -1); 68 assert(attributes.getIndex(PersistenceTagNames.PROPERTY_VALUE) != 69 -1); 70 PersistenceUnitDescriptor persistenceUnitDescriptor = (PersistenceUnitDescriptor) getDescriptor(); 71 String propName = attributes.getValue( 72 PersistenceTagNames.PROPERTY_NAME); 73 String propValue = attributes.getValue( 74 PersistenceTagNames.PROPERTY_VALUE); 75 persistenceUnitDescriptor.addProperty(propName, propValue); 76 return; 77 } 78 super.startElement(element, attributes); 79 } 80 81 90 protected Map getDispatchTable() { 91 return dispatchTable; 92 } 93 94 99 private void initDispatchTable() { 100 assert(dispatchTable == null); 101 102 Map <String , String > table = new HashMap <String , String >(); 105 106 table.put(PersistenceTagNames.NAME, "setName"); 109 table.put(PersistenceTagNames.TRANSACTION_TYPE, "setTransactionType"); 110 table.put(PersistenceTagNames.DESCRIPTION, "setDescription"); 111 table.put(PersistenceTagNames.PROVIDER, "setProvider"); 112 table.put(PersistenceTagNames.JTA_DATA_SOURCE, "setJtaDataSource"); 113 table.put(PersistenceTagNames.NON_JTA_DATA_SOURCE, 114 "setNonJtaDataSource"); 115 table.put(PersistenceTagNames.MAPPING_FILE, "addMappingFile"); 116 table.put(PersistenceTagNames.JAR_FILE, "addJarFile"); 117 table.put(PersistenceTagNames.EXCLUDE_UNLISTED_CLASSES, "setExcludeUnlistedClasses"); 118 table.put(PersistenceTagNames.CLASS, "addClass"); 119 this.dispatchTable = table; 120 } 121 122 } 123 | Popular Tags |