1 23 24 package com.sun.enterprise.deployment.node.runtime; 25 26 import java.util.Map ; 27 import java.util.HashMap ; 28 import java.util.logging.Level ; 29 30 import com.sun.enterprise.deployment.Descriptor; 31 import com.sun.enterprise.deployment.node.DescriptorFactory; 32 import com.sun.enterprise.deployment.node.XMLElement; 33 import com.sun.enterprise.deployment.runtime.IASPersistenceManagerDescriptor; 34 import com.sun.enterprise.deployment.runtime.PersistenceManagerInUse; 35 import com.sun.enterprise.deployment.runtime.web.Servlet; 36 import com.sun.enterprise.deployment.util.DOLUtils; 37 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 38 39 import com.sun.enterprise.deployment.runtime.common.DefaultResourcePrincipal; 41 import com.sun.enterprise.deployment.runtime.common.EjbRef; 42 import com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor; 43 import com.sun.enterprise.deployment.runtime.common.ResourceEnvRef; 44 import com.sun.enterprise.deployment.runtime.common.ResourceRef; 45 import com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping; 46 import com.sun.enterprise.deployment.runtime.connector.MapElement; 47 import com.sun.enterprise.deployment.runtime.connector.Principal; 48 import com.sun.enterprise.deployment.runtime.connector.ResourceAdapter; 49 import com.sun.enterprise.deployment.runtime.connector.RoleMap; 50 import com.sun.enterprise.deployment.runtime.web.Cache; 51 import com.sun.enterprise.deployment.runtime.web.CacheHelper; 52 import com.sun.enterprise.deployment.runtime.web.CacheMapping; 53 import com.sun.enterprise.deployment.runtime.web.ClassLoader; 54 import com.sun.enterprise.deployment.runtime.web.ConstraintField; 55 import com.sun.enterprise.deployment.runtime.web.CookieProperties; 56 import com.sun.enterprise.deployment.runtime.web.DefaultHelper; 57 import com.sun.enterprise.deployment.runtime.web.JspConfig; 58 import com.sun.enterprise.deployment.runtime.web.LocaleCharsetInfo; 59 import com.sun.enterprise.deployment.runtime.web.LocaleCharsetMap; 60 import com.sun.enterprise.deployment.runtime.web.ManagerProperties; 61 import com.sun.enterprise.deployment.runtime.web.SessionConfig; 62 import com.sun.enterprise.deployment.runtime.web.SessionManager; 63 import com.sun.enterprise.deployment.runtime.web.SessionProperties; 64 import com.sun.enterprise.deployment.runtime.web.StoreProperties; 65 import com.sun.enterprise.deployment.runtime.web.WebProperty; 66 import com.sun.enterprise.deployment.runtime.web.WebProperty; 67 68 74 public class RuntimeDescriptorFactory { 75 76 77 static Map descriptorClasses; 78 79 80 protected RuntimeDescriptorFactory() { 81 } 82 83 private static void initMapping() { 84 descriptorClasses = new HashMap (); 85 86 register(new XMLElement(RuntimeTagNames.PROPERTY), WebProperty.class); 88 register(new XMLElement(RuntimeTagNames.COOKIE_PROPERTIES), CookieProperties.class); 89 register(new XMLElement(RuntimeTagNames.LOCALE_CHARSET_MAP), LocaleCharsetMap.class); 90 register(new XMLElement(RuntimeTagNames.LOCALE_CHARSET_INFO), LocaleCharsetInfo.class); 91 register(new XMLElement(RuntimeTagNames.MANAGER_PROPERTIES), ManagerProperties.class); 92 register(new XMLElement(RuntimeTagNames.SERVLET), Servlet.class); 93 register(new XMLElement(RuntimeTagNames.SESSION_CONFIG), SessionConfig.class); 94 register(new XMLElement(RuntimeTagNames.SESSION_MANAGER), SessionManager.class); 95 register(new XMLElement(RuntimeTagNames.JSP_CONFIG), JspConfig.class); 96 register(new XMLElement(RuntimeTagNames.CACHE_MAPPING), CacheMapping.class); 97 register(new XMLElement(RuntimeTagNames.CACHE_HELPER), CacheHelper.class); 98 register(new XMLElement(RuntimeTagNames.CACHE), Cache.class); 99 register(new XMLElement(RuntimeTagNames.CLASS_LOADER), ClassLoader .class); 100 register(new XMLElement(RuntimeTagNames.STORE_PROPERTIES), StoreProperties.class); 101 register(new XMLElement(RuntimeTagNames.SESSION_PROPERTIES), SessionProperties.class); 102 register(new XMLElement(RuntimeTagNames.DEFAULT_HELPER), DefaultHelper.class); 103 register(new XMLElement(RuntimeTagNames.EJB_REF), EjbRef.class); 104 register(new XMLElement(RuntimeTagNames.RESOURCE_REF), ResourceRef.class); 105 register(new XMLElement(RuntimeTagNames.RESOURCE_ENV_REF), ResourceEnvRef.class); 106 register(new XMLElement(RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL), DefaultResourcePrincipal.class); 107 register(new XMLElement(RuntimeTagNames.CONSTRAINT_FIELD), ConstraintField.class); 108 109 register(new XMLElement(RuntimeTagNames.PM_DESCRIPTOR), IASPersistenceManagerDescriptor.class); 111 register(new XMLElement(RuntimeTagNames.PM_INUSE), PersistenceManagerInUse.class); 112 113 register(new XMLElement(RuntimeTagNames.PRINCIPAL), Principal.class); 115 register(new XMLElement(RuntimeTagNames.BACKEND_PRINCIPAL), Principal.class); 116 register(new XMLElement(RuntimeTagNames.MAP_ELEMENT), MapElement.class); 117 register(new XMLElement(RuntimeTagNames.ROLE_MAP), RoleMap.class); 118 register(new XMLElement(RuntimeTagNames.RESOURCE_ADAPTER), ResourceAdapter.class); 119 120 register(new XMLElement(RuntimeTagNames.PRINCIPAL_NAME), PrincipalNameDescriptor.class); 122 register(new XMLElement(RuntimeTagNames.SECURITY_ROLE_MAPPING), SecurityRoleMapping.class); 123 } 124 130 public static void register(XMLElement xmlPath, Class clazz) { 131 if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { 132 DOLUtils.getDefaultLogger().fine("Register " + clazz + " to handle " + xmlPath.getQName()); 133 } 134 descriptorClasses.put(xmlPath.getQName(), clazz); 135 } 136 137 140 public static Class getDescriptorClass(String xmlPath) { 141 String s = xmlPath; 142 do { 143 if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) { 144 DOLUtils.getDefaultLogger().finer("looking for " + xmlPath + " in " + descriptorClasses); 145 } 146 if (descriptorClasses.containsKey(xmlPath)) { 147 return (Class ) descriptorClasses.get(xmlPath); 148 } 149 if (xmlPath.indexOf('/')!=-1) { 150 xmlPath = xmlPath.substring(xmlPath.indexOf('/')+1); 151 } else { 152 xmlPath=null; 153 } 154 } while (xmlPath!=null); 155 156 if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { 157 DOLUtils.getDefaultLogger().fine("No descriptor registered for " + s); 158 } 159 return null; 160 } 161 162 166 public static Object getDescriptor(String xmlPath) { 167 168 try { 169 Class c = getDescriptorClass(xmlPath); 170 if (c!=null) { 171 return c.newInstance(); 172 } 173 } catch (Throwable t) { 174 t.printStackTrace(); 175 } 176 return null; 177 } 178 179 static { 180 initMapping(); 181 } 182 } 183 | Popular Tags |