1 17 package org.apache.geronimo.connector.deployment; 18 19 import javax.xml.namespace.QName ; 20 21 import org.apache.geronimo.xbeans.geronimo.GerConnectorType; 22 import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType; 23 import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType; 24 import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType; 25 import org.apache.xmlbeans.XmlCursor; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 32 public class ConnectorPlanRectifier { 33 34 private static final Log log = LogFactory.getLog(ConnectorPlanRectifier.class); 35 36 private static final QName VERSION_QNAME = new QName ("", "version"); 37 private static final QName GLOBAL_JNDI_NAME_QNAME = new QName (ConnectorModuleBuilder.GERCONNECTOR_NAMESPACE, "global-jndi-name"); 38 private static final QName CREDENTIAL_INTERFACE_QNAME = new QName (ConnectorModuleBuilder.GERCONNECTOR_NAMESPACE, "credential-interface"); 39 40 41 static void rectifyPlan(GerConnectorType gerConnector) { 42 boolean updated = false; 43 XmlCursor cursor = gerConnector.newCursor(); 44 try { 45 updated = cursor.removeAttribute(VERSION_QNAME); 46 } finally { 47 cursor.dispose(); 48 } 49 GerResourceadapterType[] resourceAdapters = gerConnector.getResourceadapterArray(); 50 for (int i = 0; i < resourceAdapters.length; i++) { 51 GerResourceadapterType resourceAdapter = resourceAdapters[i]; 52 if (resourceAdapter.isSetOutboundResourceadapter()) { 53 GerConnectionDefinitionType[] connectionDefinitions = resourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(); 54 for (int j = 0; j < connectionDefinitions.length; j++) { 55 GerConnectionDefinitionType connectionDefinition = connectionDefinitions[j]; 56 GerConnectiondefinitionInstanceType[] connectiondefinitionInstances = connectionDefinition.getConnectiondefinitionInstanceArray(); 57 for (int k = 0; k < connectiondefinitionInstances.length; k++) { 58 GerConnectiondefinitionInstanceType connectiondefinitionInstance = connectiondefinitionInstances[k]; 59 cursor = connectiondefinitionInstance.newCursor(); 60 try { 61 if (cursor.toFirstChild()) { 62 if (cursor.toNextSibling(GLOBAL_JNDI_NAME_QNAME)) { 63 cursor.removeXml(); 64 updated = true; 65 } 66 if (cursor.toNextSibling(CREDENTIAL_INTERFACE_QNAME)) { 67 cursor.removeXml(); 68 updated = true; 69 } 70 } 71 } finally { 72 cursor.dispose(); 73 } 74 } 75 } 76 } 77 } 78 if (updated) { 79 log.warn("Your connector plan has obsolete elements or attributes in it. Please remove version attributes, global-jndi-name elements, and credential-interface elements"); 80 } 81 } 82 83 } 84 | Popular Tags |