1 23 24 29 30 package com.sun.enterprise.tools.upgrade.transform; 31 32 33 import java.util.HashMap ; 34 import com.sun.enterprise.tools.upgrade.transform.elements.BaseElement; 35 import com.sun.enterprise.util.i18n.StringManager; 36 40 public class ElementToObjectMapper { 41 42 private static ElementToObjectMapper mapper; 43 private HashMap elementMap; 44 private HashMap keyMap; 45 private HashMap elementStructureMap; 46 StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.transform"); 47 48 private ElementToObjectMapper() { 49 buildMapping(); 50 } 51 public static ElementToObjectMapper getMapper(){ 52 if(mapper == null) 53 mapper = new ElementToObjectMapper(); 54 return mapper; 55 } 56 public BaseElement getElementObject(String element) throws ElementNotFoundException, ClassNotFoundException , 57 InstantiationException , IllegalAccessException { 58 String eleClassName = (String )(elementMap.get(element)); 59 if (eleClassName == null) 60 throw new ElementNotFoundException(element+" "+stringManager.getString("upgrade.transform.elementObjectMapper.elementNotFound")); 61 return (BaseElement)((Class.forName(eleClassName)).newInstance()); 62 } 63 public String getKeyForElement(String element) { 64 return (String )(keyMap.get(element)); 65 } 66 public java.util.List getInsertElementStructure(String element){ 67 return (java.util.List )(this.elementStructureMap.get(element)); 68 } 69 private void buildMapping(){ 70 if(elementMap == null){ 71 elementMap = new HashMap (); 72 } 73 buildKeyMapping(); 74 buildElementStructureMap(); 75 elementMap.put("server", "com.sun.enterprise.tools.upgrade.transform.elements.Server"); 76 elementMap.put("http-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 77 elementMap.put("admin-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 78 elementMap.put("web-container", "com.sun.enterprise.tools.upgrade.transform.elements.GenericContainer"); 79 elementMap.put("ejb-container", "com.sun.enterprise.tools.upgrade.transform.elements.GenericContainer"); 80 elementMap.put("mdb-container", "com.sun.enterprise.tools.upgrade.transform.elements.GenericContainer"); 81 elementMap.put("jms-service", "com.sun.enterprise.tools.upgrade.transform.elements.JMSService"); 82 elementMap.put("log-service", "com.sun.enterprise.tools.upgrade.transform.elements.LogService"); 83 elementMap.put("security-service", "com.sun.enterprise.tools.upgrade.transform.elements.SecurityService"); 84 elementMap.put("transaction-service", "com.sun.enterprise.tools.upgrade.transform.elements.TransactionService"); 85 elementMap.put("java-config", "com.sun.enterprise.tools.upgrade.transform.elements.JavaConfig"); 86 elementMap.put("resources", "com.sun.enterprise.tools.upgrade.transform.elements.Resources"); 87 elementMap.put("applications", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 88 elementMap.put("lifecycle-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 89 elementMap.put("j2ee-application", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 90 elementMap.put("ejb-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 91 elementMap.put("web-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 92 elementMap.put("connector-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 93 elementMap.put("http-listener", "com.sun.enterprise.tools.upgrade.transform.elements.HttpListener"); 94 elementMap.put("mime", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 95 elementMap.put("acl", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 96 elementMap.put("virtual-server-class", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 97 elementMap.put("ssl", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 98 elementMap.put("property", "com.sun.enterprise.tools.upgrade.transform.elements.Property"); 99 elementMap.put("description", "com.sun.enterprise.tools.upgrade.transform.elements.Description"); 100 elementMap.put("virtual-server", "com.sun.enterprise.tools.upgrade.transform.elements.VirtualServer"); 101 elementMap.put("http-qos", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 102 elementMap.put("auth-db", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 103 elementMap.put("iiop-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 104 elementMap.put("orb", "com.sun.enterprise.tools.upgrade.transform.elements.ORB"); 105 elementMap.put("iiop-listener", "com.sun.enterprise.tools.upgrade.transform.elements.IIOPListener"); 106 elementMap.put("ssl-client-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 107 elementMap.put("custom-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 108 elementMap.put("external-jndi-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 109 elementMap.put("jdbc-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 110 elementMap.put("jdbc-connection-pool", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 111 elementMap.put("mail-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 112 elementMap.put("persistence-manager-factory-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 113 elementMap.put("jms-resource", "com.sun.enterprise.tools.upgrade.transform.elements.JMSResource"); 114 elementMap.put("auth-realm", "com.sun.enterprise.tools.upgrade.transform.elements.AuthRealm"); 115 elementMap.put("profiler", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 116 elementMap.put("jvm-options", "com.sun.enterprise.tools.upgrade.transform.elements.JVMOptions"); 117 elementMap.put("server-instance", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 118 119 elementMap.put("domain", "com.sun.enterprise.tools.upgrade.transform.elements.Domain"); 121 elementMap.put("configs", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 122 elementMap.put("config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 123 elementMap.put("admin-object-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 124 elementMap.put("connector-resource", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 125 elementMap.put("resource-adapter-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 126 elementMap.put("connector-connection-pool", "com.sun.enterprise.tools.upgrade.transform.elements.GenericResource"); 127 elementMap.put("jms-host", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 128 elementMap.put("session-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 129 elementMap.put("session-manager", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 130 elementMap.put("manager-properties", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 131 elementMap.put("session-properties", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 132 elementMap.put("store-properties", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 133 elementMap.put("jmx-connector", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 134 elementMap.put("das-config", "com.sun.enterprise.tools.upgrade.transform.elements.DasConfig"); 135 elementMap.put("monitoring-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 136 elementMap.put("module-monitoring-levels", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 137 elementMap.put("availability-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 138 elementMap.put("web-container-availability", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 139 elementMap.put("ejb-container-availability", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 140 elementMap.put("ejb-timer-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 141 elementMap.put("quorum-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 142 elementMap.put("thread-pools", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 143 elementMap.put("thread-pool", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 144 elementMap.put("servers", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 145 elementMap.put("module-log-levels", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 146 elementMap.put("jacc-provider", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 147 elementMap.put("audit-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 148 149 elementMap.put("message-security-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 150 elementMap.put("provider-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 151 elementMap.put("request-policy", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 152 elementMap.put("response-policy", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 153 154 elementMap.put("resource-ref", "com.sun.enterprise.tools.upgrade.transform.elements.ResourceRef"); 156 elementMap.put("application-ref", "com.sun.enterprise.tools.upgrade.transform.elements.ApplicationRef"); 157 158 elementMap.put("clusters", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 159 elementMap.put("cluster", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 160 elementMap.put("server-ref", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 161 162 elementMap.put("system-property", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 163 164 elementMap.put("iiop-cluster", "com.sun.enterprise.tools.upgrade.transform.elements.BaseElement"); 166 elementMap.put("persistence-store", "com.sun.enterprise.tools.upgrade.transform.elements.PersistenceStore"); 167 elementMap.put("iiop-server-instance", "com.sun.enterprise.tools.upgrade.transform.elements.IIOPServerInstance"); 168 elementMap.put("iiop-endpoint", "com.sun.enterprise.tools.upgrade.transform.elements.UnSupportedElement"); 170 171 elementMap.put("node-agents", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 173 elementMap.put("node-agent", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 174 elementMap.put("lb-configs", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 175 elementMap.put("lb-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 176 elementMap.put("cluster-ref", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 177 elementMap.put("health-checker", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 178 elementMap.put("appclient-module", "com.sun.enterprise.tools.upgrade.transform.elements.GenericComponent"); 179 elementMap.put("alert-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 180 elementMap.put("connector-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 181 elementMap.put("alert-subscription", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 182 elementMap.put("listener-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 183 elementMap.put("filter-config", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 184 elementMap.put("access-log", "com.sun.enterprise.tools.upgrade.transform.elements.AccessLog"); 185 elementMap.put("http-access-log", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 186 elementMap.put("request-processing", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 187 elementMap.put("keep-alive", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 188 elementMap.put("connection-pool", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 189 elementMap.put("http-protocol", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 190 elementMap.put("http-file-cache", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 191 elementMap.put("security-map", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 192 elementMap.put("user-group", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 193 elementMap.put("principal", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 194 elementMap.put("backend-principal", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 195 elementMap.put("diagnostic-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 196 elementMap.put("group-management-service", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 197 elementMap.put("management-rules", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 198 elementMap.put("management-rule", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 199 elementMap.put("event", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 200 elementMap.put("load-balancers", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 201 elementMap.put("load-balancer", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 202 elementMap.put("jms-availability", "com.sun.enterprise.tools.upgrade.transform.elements.GenericElement"); 203 } 204 210 private void buildKeyMapping(){ 211 if(keyMap == null){ 212 keyMap = new HashMap (); 213 } 214 keyMap.put("custom-resource", "jndi-name"); 216 keyMap.put("jdbc-resource","pool-name"); 217 keyMap.put("external-jndi-resource", "jndi-name"); 218 keyMap.put("jdbc-connection-pool", "name"); 219 keyMap.put("mail-resource", "jndi-name"); 220 keyMap.put("persistence-manager-factory-resource", "jndi-name"); 221 keyMap.put("jms-resource", "jndi-name"); 222 keyMap.put("admin-object-resource", "jndi-name"); 223 keyMap.put("connector-resource", "jndi-name"); 224 keyMap.put("resource-adapter-config", "name"); 225 keyMap.put("connector-connection-pool", "name"); 226 227 keyMap.put("jms-host", "name"); 228 keyMap.put("server-instance", "name"); 229 keyMap.put("jmx-connector", "name"); 230 keyMap.put("iiop-listener", "id"); 231 keyMap.put("config", "name"); 232 keyMap.put("thread-pool","thread-pool-id"); 233 keyMap.put("cluster","name"); 234 keyMap.put("server-ref","ref"); 235 keyMap.put("resource-ref","ref"); 236 keyMap.put("application-ref","ref"); 237 keyMap.put("jacc-provider","name"); 238 keyMap.put("audit-module","name"); 239 240 keyMap.put("message-security-config","auth-layer"); 241 keyMap.put("provider-config","provider-id"); 242 243 keyMap.put("node-agent","name"); 245 keyMap.put("lb-config","name"); 246 keyMap.put("cluster-ref","ref"); 247 keyMap.put("alert-subscription","name"); 248 keyMap.put("listener-config","listener-class-name"); 249 keyMap.put("filter-config","filter-class-name"); 250 keyMap.put("security-map","name"); 251 keyMap.put("load-balancer","name"); 252 keyMap.put("management-rule","name"); 253 } 254 private void buildElementStructureMap(){ 255 256 if(elementStructureMap == null){ 257 this.elementStructureMap = new HashMap (); 258 } 259 264 elementStructureMap.put("http-service", getListWithElementNames(null)); 265 elementStructureMap.put("iiop-service", getListWithElementNames(new String []{"admin-service"})); 266 267 elementStructureMap.put("http-listener", getListWithElementNames(new String []{"virtual-server"})); 269 elementStructureMap.put("virtual-server", getListWithElementNames(new String []{"request-processing","keep-alive","connection-pool","http-protocol","http-file-cache","property"})); 270 elementStructureMap.put("request-processing", getListWithElementNames(new String []{"keep-alive","connection-pool","http-protocol","http-file-cache","property"})); 271 elementStructureMap.put("keep-alive", getListWithElementNames(new String []{"connection-pool","http-protocol","http-file-cache","property"})); 272 elementStructureMap.put("connection-pool", getListWithElementNames(new String []{"http-protocol","http-file-cache","property"})); 273 elementStructureMap.put("http-protocol", getListWithElementNames(new String []{"http-file-cache","property"})); 274 elementStructureMap.put("http-file-cache", getListWithElementNames(new String []{"property"})); 275 elementStructureMap.put("custom-resource", getListWithElementNames(new String []{})); 278 elementStructureMap.put("external-jndi-resource", getListWithElementNames(new String []{"jdbc-resource","mail-resource","persistence-manager-factory-resource","admin-object-resource","connector-resource","resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 279 elementStructureMap.put("jdbc-resource", getListWithElementNames(new String []{"mail-resource","persistence-manager-factory-resource","admin-object-resource","connector-resource","resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 280 elementStructureMap.put("mail-resource", getListWithElementNames(new String []{"persistence-manager-factory-resource","admin-object-resource","connector-resource","resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 281 elementStructureMap.put("persistence-manager-factory-resource", getListWithElementNames(new String []{"admin-object-resource","connector-resource","resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 282 elementStructureMap.put("admin-object-resource", getListWithElementNames(new String []{"connector-resource","resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 283 elementStructureMap.put("connector-resource", getListWithElementNames(new String []{"resource-adapter-config","jdbc-connection-pool","connector-connection-pool"})); 284 elementStructureMap.put("resource-adapter-config", getListWithElementNames(new String []{"jdbc-connection-pool","connector-connection-pool"})); 285 elementStructureMap.put("jdbc-connection-pool", getListWithElementNames(new String []{"connector-connection-pool"})); 286 287 elementStructureMap.put("description", getListWithElementNames(new String []{})); 289 elementStructureMap.put("jms-service", getListWithElementNames(new String []{"log-service"})); 290 elementStructureMap.put("availability-service", getListWithElementNames(new String []{"thread-pools"})); 291 292 elementStructureMap.put("ssl", getListWithElementNames(new String []{})); 294 elementStructureMap.put("orb", getListWithElementNames(new String []{})); 295 elementStructureMap.put("ssl-client-config", getListWithElementNames(new String []{"iiop-listener"})); 296 297 elementStructureMap.put("jmx-connector", getListWithElementNames(new String []{})); 299 elementStructureMap.put("das-config", getListWithElementNames(new String []{"property"})); 300 301 elementStructureMap.put("session-config", getListWithElementNames(new String []{})); 302 elementStructureMap.put("session-manager", getListWithElementNames(new String []{})); 303 elementStructureMap.put("manager-properties", getListWithElementNames(new String []{})); 304 elementStructureMap.put("ejb-timer-service", getListWithElementNames(new String []{})); 305 elementStructureMap.put("jms-host", getListWithElementNames(new String []{})); 306 elementStructureMap.put("module-log-levels", getListWithElementNames(new String []{})); 307 308 elementStructureMap.put("auth-realm", getListWithElementNames(new String []{})); 310 elementStructureMap.put("jacc-provider", getListWithElementNames(new String []{"audit-module","message-security-config","property"})); 311 elementStructureMap.put("audit-module", getListWithElementNames(new String []{"message-security-config","property"})); 312 elementStructureMap.put("message-security-config",getListWithElementNames(new String []{"property"})); 313 elementStructureMap.put("module-monitoring-levels", getListWithElementNames(new String []{})); 314 315 elementStructureMap.put("profiler", getListWithElementNames(new String []{})); 316 elementStructureMap.put("jvm-options", getListWithElementNames(new String []{"property"})); 317 318 elementStructureMap.put("web-container-availability", getListWithElementNames(new String []{})); 320 elementStructureMap.put("ejb-container-availability", getListWithElementNames(new String []{"jms-availability","property"})); 321 elementStructureMap.put("jms-availability", getListWithElementNames(new String []{"property"})); 322 elementStructureMap.put("security-map", getListWithElementNames(new String []{"property"})); 323 elementStructureMap.put("principal", getListWithElementNames(new String []{})); 324 elementStructureMap.put("user-group", getListWithElementNames(new String []{"backend-principal"})); 326 327 elementStructureMap.put("application-ref", getListWithElementNames(new String []{"system-property" , "property"})); 330 elementStructureMap.put("resource-ref", getListWithElementNames(new String []{"system-property" , "property"})); 331 elementStructureMap.put("system-property" , getListWithElementNames(new String []{ "property"})); 332 333 elementStructureMap.put("principal", getListWithElementNames(new String []{})); 334 335 elementStructureMap.put("alert-service", getListWithElementNames(new String []{"group-management-service","management-rules","system-property","property"})); 337 elementStructureMap.put("group-management-service", getListWithElementNames(new String []{"management-rules","system-property","property"})); 338 elementStructureMap.put("management-rules", getListWithElementNames(new String []{"system-property","property"})); 339 elementStructureMap.put("lb-configs", getListWithElementNames(new String []{"system-property","property"})); 340 elementStructureMap.put("load-balancers", getListWithElementNames(new String []{"","system-property","property"})); 341 elementStructureMap.put("connector-service", getListWithElementNames(new String []{"web-container"})); 342 elementStructureMap.put("alert-subscription", getListWithElementNames(new String []{})); 343 elementStructureMap.put("listener-config", getListWithElementNames(new String []{})); 344 elementStructureMap.put("access-log", getListWithElementNames(new String []{})); 345 elementStructureMap.put("http-access-log", getListWithElementNames(new String []{})); 346 elementStructureMap.put("server-ref", getListWithElementNames(new String []{})); 347 348 } 349 private java.util.List getListWithElementNames(String [] succeedingElements){ 350 java.util.ArrayList eleList = new java.util.ArrayList (); 351 if(succeedingElements != null){ 352 for(int i=0; i<succeedingElements.length; i++){ 353 eleList.add(succeedingElements[i]); 354 } 355 } 356 return eleList; 357 } 358 } 359 | Popular Tags |