geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r289304 - in /geronimo/trunk/modules/connector-builder/src: java/org/apache/geronimo/connector/deployment/ test-data/data/ test/org/apache/geronimo/connector/deployment/
Date Thu, 15 Sep 2005 20:04:36 GMT
Author: djencks
Date: Thu Sep 15 13:04:31 2005
New Revision: 289304

URL: http://svn.apache.org/viewcvs?rev=289304&view=rev
Log:
GERONIMO-956 add backwards compatibility back in

Added:
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorPlanRectifier.java
    geronimo/trunk/modules/connector-builder/src/test-data/data/old-schema-plan.xml
Modified:
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
    geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?rev=289304&r1=289303&r2=289304&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Thu Sep 15 13:04:31 2005
@@ -39,6 +39,7 @@
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.Reference;
+import javax.xml.namespace.QName;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
@@ -107,6 +108,7 @@
 import org.apache.geronimo.xbeans.j2ee.ResourceadapterType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
 
 /**
  * @version $Rev$ $Date$
@@ -122,7 +124,7 @@
     private final List defaultParentId;
     private final Repository repository;
     private final Kernel kernel;
-    private static final String GERCONNECTOR_NAMESPACE = GerConnectorDocument.type.getDocumentElementName().getNamespaceURI();
+    static final String GERCONNECTOR_NAMESPACE = GerConnectorDocument.type.getDocumentElementName().getNamespaceURI();
 
     public ConnectorModuleBuilder(URI[] defaultParentId,
                                   int defaultMaxSize,
@@ -184,7 +186,7 @@
         }
         GerConnectorType gerConnector = null;
         try {
-            // load the geronimo-application-client.xml from either the supplied plan or
from the earFile
+            // load the geronimo connector plan from either the supplied plan or from the
earFile
             try {
                 if (plan instanceof XmlObject) {
                     gerConnector = (GerConnectorType) SchemaConversionUtils.getNestedObjectAsType((XmlObject)
plan,
@@ -210,6 +212,7 @@
                 throw new DeploymentException("A connector module must be deployed using
a Geronimo deployment plan" +
                         " (either META-INF/geronimo-ra.xml in the RAR file or a standalone
deployment plan passed to the deployer).");
             }
+            ConnectorPlanRectifier.rectifyPlan(gerConnector);
             gerConnector = (GerConnectorType) SchemaConversionUtils.convertToGeronimoServiceSchema(gerConnector);
             //for workmanager
             gerConnector = (GerConnectorType) SchemaConversionUtils.convertToGeronimoNamingSchema(gerConnector);
@@ -229,6 +232,7 @@
         List parentId = ServiceConfigBuilder.getParentID(gerConnector.getParentId(), gerConnector.getImportArray());
         return new ConnectorModule(standAlone, configId, parentId, moduleFile, targetPath,
connector, gerConnector, specDD);
     }
+
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws
DeploymentException {
         GerConnectorType vendorConnector = (GerConnectorType) module.getVendorDD();

Added: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorPlanRectifier.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorPlanRectifier.java?rev=289304&view=auto
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorPlanRectifier.java
(added)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorPlanRectifier.java
Thu Sep 15 13:04:31 2005
@@ -0,0 +1,83 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.connector.deployment;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.xbeans.geronimo.GerConnectorType;
+import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType;
+import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class ConnectorPlanRectifier {
+
+    private static final Log log = LogFactory.getLog(ConnectorPlanRectifier.class);
+
+    private static final QName VERSION_QNAME = new QName("", "version");
+    private static final QName GLOBAL_JNDI_NAME_QNAME = new QName(ConnectorModuleBuilder.GERCONNECTOR_NAMESPACE,
"global-jndi-name");
+    private static final QName CREDENTIAL_INTERFACE_QNAME = new QName(ConnectorModuleBuilder.GERCONNECTOR_NAMESPACE,
"credential-interface");
+
+
+    static void rectifyPlan(GerConnectorType gerConnector) {
+        boolean updated = false;
+        XmlCursor cursor = gerConnector.newCursor();
+        try {
+            updated = cursor.removeAttribute(VERSION_QNAME);
+        } finally {
+            cursor.dispose();
+        }
+        GerResourceadapterType[] resourceAdapters = gerConnector.getResourceadapterArray();
+        for (int i = 0; i < resourceAdapters.length; i++) {
+            GerResourceadapterType resourceAdapter = resourceAdapters[i];
+            if (resourceAdapter.isSetOutboundResourceadapter()) {
+            GerConnectionDefinitionType[] connectionDefinitions = resourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray();
+                for (int j = 0; j < connectionDefinitions.length; j++) {
+                    GerConnectionDefinitionType connectionDefinition = connectionDefinitions[j];
+                    GerConnectiondefinitionInstanceType[] connectiondefinitionInstances =
connectionDefinition.getConnectiondefinitionInstanceArray();
+                    for (int k = 0; k < connectiondefinitionInstances.length; k++) {
+                        GerConnectiondefinitionInstanceType connectiondefinitionInstance
= connectiondefinitionInstances[k];
+                        cursor = connectiondefinitionInstance.newCursor();
+                        try {
+                            if (cursor.toFirstChild()) {
+                                if (cursor.toNextSibling(GLOBAL_JNDI_NAME_QNAME)) {
+                                    cursor.removeXml();
+                                    updated = true;
+                                }
+                                if (cursor.toNextSibling(CREDENTIAL_INTERFACE_QNAME)) {
+                                    cursor.removeXml();
+                                    updated = true;
+                                }
+                            }
+                        } finally {
+                            cursor.dispose();
+                        }
+                    }
+                }
+            }
+        }
+        if (updated) {
+            log.info("Your connector plan has obsolete elements or attributes in it.  Please
remove version attributes, global-jndi-name elements, and credential-interface elements");
+        }
+    }
+
+}

Added: geronimo/trunk/modules/connector-builder/src/test-data/data/old-schema-plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/test-data/data/old-schema-plan.xml?rev=289304&view=auto
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/test-data/data/old-schema-plan.xml (added)
+++ geronimo/trunk/modules/connector-builder/src/test-data/data/old-schema-plan.xml Thu Sep
15 13:04:31 2005
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004-2005 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector"
+    version="1.5"
+    configId="org/apache/geronimo/j2ee/deployment/test"
+    parentId="org/apache/geronimo/Server">
+
+    <resourceadapter>
+        <resourceadapter-instance>
+            <resourceadapter-name>testRA</resourceadapter-name>
+            <config-property-setting name="RAStringProperty">NewStringValue</config-property-setting>
+            <workmanager>
+                <gbean-link>DefaultWorkManager</gbean-link>
+            </workmanager>
+        </resourceadapter-instance>
+        <outbound-resourceadapter>
+            <connection-definition>
+                <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
+                <connectiondefinition-instance>
+                    <name>FirstTestOutboundConnectionFactory</name>
+                    <config-property-setting name="OutboundStringProperty1">newvalue1</config-property-setting>
+                    <config-property-setting name="OutboundStringProperty3">newvalue2</config-property-setting>
+                    <connectionmanager>
+                        <container-managed-security/>
+                        <xa-transaction>
+                            <transaction-caching/>
+                        </xa-transaction>
+                        <partitioned-pool>
+                            <max-size>10</max-size>
+                            <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
+                            <match-one/>
+                            <partition-by-subject/>
+                        </partitioned-pool>
+                    </connectionmanager>
+                    <global-jndi-name>foo</global-jndi-name>
+                </connectiondefinition-instance>
+                <connectiondefinition-instance>
+                    <name>SecondTestOutboundConnectionFactory</name>
+                    <config-property-setting name="OutboundStringProperty4">newvalue3</config-property-setting>
+                    <config-property-setting name="OutboundStringProperty1">newvalue4</config-property-setting>
+                    <connectionmanager>
+                        <container-managed-security/>
+                        <xa-transaction>
+                            <transaction-caching/>
+                        </xa-transaction>
+                        <partitioned-pool>
+                            <max-size>10</max-size>
+                            <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
+                            <match-one/>
+                            <partition-by-subject/>
+                        </partitioned-pool>
+                    </connectionmanager>
+                    <credential-interface>bar</credential-interface>
+                </connectiondefinition-instance>
+            </connection-definition>
+            <connection-definition>
+                <connectionfactory-interface>org.apache.geronimo.connector.mock.ConnectionFactoryExtension</connectionfactory-interface>
+                <connectiondefinition-instance>
+                    <name>ThirdTestOutboundConnectionFactory</name>
+                    <config-property-setting name="OutboundStringProperty1">StringValue3</config-property-setting>
+                    <connectionmanager>
+                        <container-managed-security/>
+                        <xa-transaction>
+                            <transaction-caching/>
+                        </xa-transaction>
+                        <partitioned-pool>
+                            <max-size>10</max-size>
+                            <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
+                            <match-one/>
+                            <partition-by-subject/>
+                        </partitioned-pool>
+                    </connectionmanager>
+                    <global-jndi-name>foo</global-jndi-name>
+                    <credential-interface>bar</credential-interface>
+                </connectiondefinition-instance>
+            </connection-definition>
+        </outbound-resourceadapter>
+    </resourceadapter>
+
+    <adminobject>
+        <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface>
+        <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class>
+        <adminobject-instance>
+            <message-destination-name>tweedledee</message-destination-name>
+            <config-property-setting name="Tweedle">Dee-value</config-property-setting>
+        </adminobject-instance>
+        <adminobject-instance>
+            <message-destination-name>tweedledum</message-destination-name>
+            <config-property-setting name="Tweedle">Dum-value</config-property-setting>
+        </adminobject-instance>
+    </adminobject>
+
+    <!--normally this is in the j2ee-server-plan.xml.  It is included here so the gbeans
can start in unit tests-->
+    <gbean name="ConnectionTracker" class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinatorGBean">
+    </gbean>
+
+    <gbean name="DefaultWorkManager" class="org.apache.geronimo.connector.work.GeronimoWorkManagerGBean">
+        <attribute name="syncMaximumPoolSize">10</attribute>
+        <attribute name="startMaximumPoolSize">10</attribute>
+        <attribute name="scheduledMaximumPoolSize">10</attribute>
+        <reference name="TransactionContextManager"><gbean-name>*:name=TransactionContextManager,*</gbean-name></reference>
+    </gbean>
+
+    <gbean name="TransactionManager" class="org.apache.geronimo.transaction.manager.TransactionManagerImplGBean">
+        <attribute name="defaultTransactionTimeoutSeconds">10</attribute>
+        <references name="ResourceManagers">
+            <pattern><gbean-name>*:j2eeType=JCAManagedConnectionFactory,*</gbean-name></pattern>
+            <pattern><gbean-name>*:j2eeType=MessageDrivenBean,*</gbean-name></pattern>
+        </references>
+    </gbean>
+
+    <gbean name="TransactionContextManager" class="org.apache.geronimo.transaction.context.TransactionContextManagerGBean">
+        <reference name="TransactionManager"><gbean-name>*:name=TransactionManager,*</gbean-name></reference>
+        <reference name="XidImporter"><gbean-name>*:name=TransactionManager,*</gbean-name></reference>
+    </gbean>
+
+</connector>

Modified: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java?rev=289304&r1=289303&r2=289304&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java
(original)
+++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/PlanParsingTest.java
Thu Sep 15 13:04:31 2005
@@ -5,6 +5,7 @@
 import junit.framework.TestCase;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
+import org.apache.geronimo.xbeans.geronimo.GerConnectorType;
 import org.apache.geronimo.xbeans.j2ee.ConnectorDocument;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -94,6 +95,23 @@
         } catch (XmlException e) {
             //expected
         }
+    }
+
+    public void testRectifyPlan() throws Exception {
+        File resourcePlan = new File(basedir, "src/test-data/data/old-schema-plan.xml");
+        assertTrue(resourcePlan.exists());
+
+        XmlObject plan = SchemaConversionUtils.parse(resourcePlan.toURL());
+        GerConnectorDocument doc = (GerConnectorDocument) plan.changeType(GerConnectorDocument.type);
+        if (doc == null) {
+            doc = (GerConnectorDocument) plan;
+        }
+        GerConnectorType gerConnector = doc.getConnector();
+        ConnectorPlanRectifier.rectifyPlan(gerConnector);
+        gerConnector = (GerConnectorType) SchemaConversionUtils.convertToGeronimoServiceSchema(gerConnector);
+        //for workmanager
+        gerConnector = (GerConnectorType) SchemaConversionUtils.convertToGeronimoNamingSchema(gerConnector);
+            SchemaConversionUtils.validateDD(doc);
     }
 
 }



Mime
View raw message