geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r561821 [6/12] - in /geronimo/sandbox/j2g: ./ configurator/ doc/ plugins/ plugins/org.apache.geronimo.j2g.common/ plugins/org.apache.geronimo.j2g.descriptors/ plugins/org.apache.geronimo.j2g.descriptors/src/ plugins/org.apache.geronimo.j2g....
Date Wed, 01 Aug 2007 15:05:17 GMT
Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java?view=diff&rev=561821&r1=561820&r2=561821
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java (original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java Wed Aug  1 08:05:12 2007
@@ -1,496 +1,496 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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.j2g.resources.jms;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.j2g.common.IFileMigration;
-import org.apache.geronimo.j2g.common.IOutput;
-import org.apache.geronimo.j2g.common.Tool;
-import org.apache.geronimo.j2g.util.resources.Constants;
-import org.apache.geronimo.j2g.util.resources.xml.XMLConversionHelper;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-
-/**
- * Class which implement the JMS Source File Migration 
- */
-public class JMSResourcesTool implements IFileMigration {
-
-    // Initialization of the IOutput for JMSResourcesTool class
-    IOutput out = Tool.getCurrent().getOutput();
-    // Initialization of the logger for JMSResourcesTool class
-    Log logger = LogFactory.getLog(JMSResourcesTool.class);
-
-    /**
-     * mgration method from jms jboss discripters to geronimo discriptors
-     * 
-     * @param sourceFile :
-     *            jms jboss discriptor file
-     * @return status of the migration
-     */
-    public boolean migrate(File sourceFile, File rootDirectory) {
-        // read any *-servise files and then migrate that to the geronimo jms
-        // resources
-        boolean migrated = false;
-            String directoryName = sourceFile.getParent();
-            String jbossJMSFileName = sourceFile.getName();
-            logger.debug("JMS resources Directory Name ==> " + directoryName);
-            logger.debug("jboss jms file Name ==> " + jbossJMSFileName);
-            // Checking wether file is a valid jbossmq-destinations-service.xml
-            // file
-            if (jbossJMSFileName.equals(Constants.JBOSS_VALID_JMS_DESTINATIONS_SERVICES_XML_FILE)) {
-                logger.debug("Searching for jboss-ds.xml file inside the current directory");
-                if (XMLConversionHelper.isFileExists(directoryName,
-                        Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE)) {
-                    logger.debug("jboss jms connection factory xml file Name ==> "
-                            + Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE);
-                    File jbossJMSDestinationServicesFile = new File(directoryName,
-                            Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE);
-                    logger.debug("Converting Jboss jms files in " + directoryName);
-                    try {
-                        Document jbossJMSConnectioFactoryDocument = null;
-                        try{
-                        jbossJMSConnectioFactoryDocument = XMLConversionHelper
-                                .getJbossDocument(jbossJMSDestinationServicesFile);
-                        } catch (DocumentException e){
-                        	out.error(JMSResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
-            						+ jbossJMSDestinationServicesFile.getAbsolutePath()
-            						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
-            						+ e.getMessage());
-                        	throw e;
-                        }
-                        Document jbossJMSDestinationServicesDocument = null;
-                        try {
-                        	jbossJMSDestinationServicesDocument = XMLConversionHelper
-                                .getJbossDocument(sourceFile);
-                        } catch(DocumentException e){
-                        	out.error(JMSResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
-            						+ sourceFile.getAbsolutePath()
-            						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
-            						+ e.getMessage());
-                        	throw e;
-                        }
-                        Document geronimoDocument = migrationFromJboss2Geronimo(
-                                jbossJMSDestinationServicesDocument.getRootElement(),
-                                jbossJMSConnectioFactoryDocument.getRootElement());
-                        String geronimoJMSFileName = directoryName + File.separator
-                                + Constants.GERONIMO_JMS_PLAN_FILE;
-                        // check whether the file already exists if so
-                        // back up that and save that or check the req
-                        // This was done at the upper level of the tool
-                        XMLConversionHelper.saveGeronimoDocument(geronimoJMSFileName,
-                                geronimoDocument);
-                        migrated = true;
-                        out.info(JMSResourcesTool.class.getSimpleName(), "The JMS Resource File Migration Complete !!!\n");
-                    } catch(DocumentException ignore){
-                    } catch (IOException e) {
-                        out.error(JMSResourcesTool.class.getSimpleName(), "IO exception " + e.getMessage());
-                    }
-                } else {
-                    out.error(JMSResourcesTool.class.getSimpleName(), "Inorder to continue the JMS Resources Tool the "
-                            + Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE
-                            + " needs to be present in the working directory ");
-                }
-            }
-
-        return migrated;
-    }
-
-    /**
-     * Accepts the jboss side Elements that holdes the discripter infomation and
-     * return the geronimo discripter
-     * 
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return created geronimo Document
-     */
-    private Document migrationFromJboss2Geronimo(Element jbossJMSDestinationServicesElement,
-            Element jbossJMSConnectioFactoryElement) {
-        Document newGeronimoDocument = null;
-        if (XMLConversionHelper.containSubElement(jbossJMSConnectioFactoryElement,
-                "tx-connection-factory")) {
-            Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
-                    jbossJMSConnectioFactoryElement, "tx-connection-factory");
-            Element jndi_nameElement = XMLConversionHelper.obtainSubElement(
-                    tx_connection_factoryElement, "jndi-name");
-            String jndi_nameString = jndi_nameElement.getText();
-            Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument(
-                    Constants.NAMESPACE_CONNECTOR, "connector", Constants.JMS_RESOURCE_TOOL,
-                    jndi_nameString, Constants.NAMESPACE_ENV);
-            newGeronimoDocument = addResourceAdapterElement(geronimoDocument,
-                    jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
-
-        } else {
-            out
-               .error(JMSResourcesTool.class.getSimpleName(), "The supplied jboss-ds.xml file does not contain the nessesary tx-connection-factory details");
-        }
-        return newGeronimoDocument;
-    }
-
-    /**
-     * Add the resource adapter element to the geronimodocument
-     * 
-     * @param geronimoDocument
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return geronimo document with added resource adapter
-     */
-    private Document addResourceAdapterElement(Document geronimoDocument,
-            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
-        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
-        Element resourceAdapterElement = DocumentHelper.createElement(new QName("resourceadapter",
-                rootNamespace));
-        Element resourceAdapter_instanceElement = DocumentHelper.createElement(new QName(
-                "resourceadapter-instance", rootNamespace));
-        Element resourceAdapter_nameElement = DocumentHelper.createElement(new QName(
-                "resourceadapter-name", rootNamespace));
-        Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
-                jbossJMSConnectioFactoryElement, "tx-connection-factory");
-        if (XMLConversionHelper.containSubElementWithAttribute(tx_connection_factoryElement,
-                "config-property", "name", "JmsProviderAdapterJNDI")) {
-            Element config_propertyElement = XMLConversionHelper.obtainSubElementWithAttribute(
-                    tx_connection_factoryElement, "config-property", "name",
-                    "JmsProviderAdapterJNDI");
-            String name = XMLConversionHelper.obtainNameFromJNDINAME(config_propertyElement
-                    .getText());
-            resourceAdapter_nameElement.addText(name);
-        } else {
-            resourceAdapter_nameElement.addText("MY JMS Resource");
-        }
-        resourceAdapter_instanceElement.add(resourceAdapter_nameElement);
-        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
-                "config-property-setting", "tcp://localhost:61616", "name", "ServerURL",
-                rootNamespace));
-        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
-                "config-property-setting", "geronimo", "name", "UserName", rootNamespace));
-        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
-                "config-property-setting", "geronimo", "name", "Password", rootNamespace));
-        Namespace namingNamespace = new Namespace("naming", Constants.NAMESPACE_GERONIMO_NAMING);
-        Element workmanagerElement = DocumentHelper.createElement(new QName("workmanager",
-                namingNamespace));
-        workmanagerElement.add(XMLConversionHelper.createSibling("gbean-link",
-                "DefaultWorkManager", namingNamespace));
-        resourceAdapter_instanceElement.add(workmanagerElement);
-        resourceAdapterElement.add(resourceAdapter_instanceElement);
-        //Add outboundresource adapters and adminobjects (check what are
-        // the mapping that exist for those things)
-        Element outboundresourceElement = addOutBoundResourcesAdapterElement(geronimoDocument,
-                jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
-        resourceAdapterElement.add(outboundresourceElement);
-        geronimoDocument.getRootElement().add(resourceAdapterElement);
-        geronimoDocument = addAdminObjectElement(geronimoDocument,
-                jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
-        return geronimoDocument;
-    }
-
-    /**
-     * Add the outbound resource adapter to the geronimo document
-     * 
-     * @param geronimoDocument
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return geronimo document with the added outbound resource adapter
-     */
-    private Element addOutBoundResourcesAdapterElement(Document geronimoDocument,
-            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
-        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
-        Element outbound_resourceAdapterElement = DocumentHelper.createElement(new QName(
-                "outbound-resourceadapter", rootNamespace));
-        Element connection_definitionElement = DocumentHelper.createElement(new QName(
-                "connection-definition", rootNamespace));
-        Element connectionfactory_interfaceElement = DocumentHelper.createElement(new QName(
-                "connectionfactory-interface", rootNamespace));
-        connectionfactory_interfaceElement.addText("javax.jms.ConnectionFactory");
-        Element connectiondefinition_instanceElement = DocumentHelper.createElement(new QName(
-                "connectiondefinition-instance", rootNamespace));
-        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling("name",
-                "MyConnectionFactory", rootNamespace));
-        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling(
-                "implemented-interface", "javax.jms.QueueConnectionFactory", rootNamespace));
-        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling(
-                "implemented-interface", "javax.jms.TopicConnectionFactory", rootNamespace));
-        Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
-                jbossJMSConnectioFactoryElement, "tx-connection-factory");
-        if (checkConnectionMangerDetailsExistsInJboss(tx_connection_factoryElement)) {
-            connectiondefinition_instanceElement.add(connectionMangerDetailsExistsInJboss(
-                    tx_connection_factoryElement, rootNamespace));
-        } else {
-            connectiondefinition_instanceElement
-                    .add(createDefaultConnectionManagerElement(rootNamespace));
-        }
-        connection_definitionElement.add(connectionfactory_interfaceElement);
-        connection_definitionElement.add(connectiondefinition_instanceElement);
-        outbound_resourceAdapterElement.add(connection_definitionElement);
-        return outbound_resourceAdapterElement;
-    }
-
-    /**
-     * add the admin objects to the currently existing geronimo document
-     * 
-     * @param geronimoDocument
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return return the geronimo document which contains the admin objects
-     */
-    private Document addAdminObjectElement(Document geronimoDocument,
-            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
-
-        Iterator elementIterator = jbossJMSDestinationServicesElement.elementIterator();
-        while (elementIterator.hasNext()) {
-            Element itElement = (Element) elementIterator.next();
-            if (itElement.getName().equals("mbean")) {
-                String queueOrTopic = null;
-                String queueOrTopicName = null;
-                String newQueueOrTopicName = null;
-                Iterator attribIterator = itElement.attributeIterator();
-                while (attribIterator.hasNext()) {
-                    Attribute itAttribute = (Attribute) attribIterator.next();
-                    if (itAttribute.getName().equals("code")) {
-                        if (itAttribute.getData().equals(Constants.TOPIC_CLASS_JBOSS)) {
-                            queueOrTopic = "topic";
-                        }
-                        if (itAttribute.getData().equals(Constants.QUEUE_CLASS_JBOSS)) {
-                            queueOrTopic = "queue";
-                        }
-                    } else if (itAttribute.getName().equals("name")) {
-                        queueOrTopicName = (String) itAttribute.getData();
-                        newQueueOrTopicName = queueOrTopicName.substring(queueOrTopicName
-                                .indexOf("name=") + 5, queueOrTopicName.length());
-                    }
-                }
-                if (queueOrTopic.equals("queue")) {
-                    geronimoDocument = addTopicElement(geronimoDocument, newQueueOrTopicName);
-                }
-                if (queueOrTopic.equals("topic")) {
-                    geronimoDocument = addQueueElement(geronimoDocument, newQueueOrTopicName);
-                }
-                boolean securityCheck = checkForSecurityConfIndideMBeanElement(itElement);
-                if (securityCheck) {
-                    logger
-                            .warn("destination JBoss descriptor has the SecurityConf attribute inside the MBean Element "
-                                    + "which are decoded");
-                }
-            }
-        }
-        return geronimoDocument;
-    }
-
-    /**
-     * check wether the passed mbean element have any security configuration
-     * details
-     * 
-     * @param itElement
-     *            passesd mbean element
-     * @return boolean wether contains or not
-     */
-    private boolean checkForSecurityConfIndideMBeanElement(Element itElement) {
-        return XMLConversionHelper.containSubElementWithAttribute(itElement, "attribute", "name",
-                "SecurityConf");
-    }
-
-    /**
-     * add the topic element to the existing geronimo document
-     * 
-     * @param geronimoDocument
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return geronimo document with the topic element added as a admin object
-     */
-    private Document addTopicElement(Document geronimoDocument, String topicName) {
-        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
-        Element adminobjectElement = DocumentHelper.createElement(new QName("adminobject",
-                rootNamespace));
-        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-interface",
-                "javax.jms.Topic", rootNamespace));
-        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-class",
-                "org.activemq.message.ActiveMQTopic", rootNamespace));
-        Element adminobject_instanceElement = DocumentHelper.createElement(new QName(
-                "adminobject-instance", rootNamespace));
-        adminobject_instanceElement.add(XMLConversionHelper.createSibling(
-                "message-destination-name", topicName, rootNamespace));
-        adminobject_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
-                "config-property-setting", " Mytopic", "name", "PhysicalName", rootNamespace));
-        adminobjectElement.add(adminobject_instanceElement);
-        geronimoDocument.getRootElement().add(adminobjectElement);
-        return geronimoDocument;
-    }
-
-    /**
-     * add queue elament to the geronimo existing document
-     * 
-     * @param geronimoDocument
-     * @param jbossJMSDestinationServicesElement
-     * @param jbossJMSConnectioFactoryElement
-     * @return the geronimo document by adding the Queue as a admin object
-     */
-    private Document addQueueElement(Document geronimoDocument, String queueName) {
-        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
-        Element adminobjectElement = DocumentHelper.createElement(new QName("adminobject",
-                rootNamespace));
-        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-interface",
-                "javax.jms.Queue", rootNamespace));
-        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-class",
-                "org.activemq.message.ActiveMQTopic", rootNamespace));
-        Element adminobject_instanceElement = DocumentHelper.createElement(new QName(
-                "adminobject-instance", rootNamespace));
-        adminobject_instanceElement.add(XMLConversionHelper.createSibling(
-                "message-destination-name", queueName, rootNamespace));
-        adminobject_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
-                "config-property-setting", " MyQueue", "name", "PhysicalName", rootNamespace));
-        adminobjectElement.add(adminobject_instanceElement);
-        geronimoDocument.getRootElement().add(adminobjectElement);
-        return geronimoDocument;
-    }
-
-    /**
-     * Creates a default connection manager elements with the defaults values
-     * 
-     * @param environmentNamespace
-     * @return default commection manager elament
-     */
-    public Element createDefaultConnectionManagerElement(Namespace environmentNamespace) {
-        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
-                "connectionmanager", environmentNamespace));
-        Element local_transactionElement = DocumentHelper.createElement(new QName(
-                "local-transaction", environmentNamespace));
-        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
-                environmentNamespace));
-        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
-                environmentNamespace));
-        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
-                environmentNamespace));
-        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
-                "blocking-timeout-milliseconds", environmentNamespace));
-        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
-                "idle-timeout-minutes", environmentNamespace));
-        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
-                environmentNamespace));
-        max_sizeElement.addText("10");
-        min_sizeElement.addText("0");
-        blocking_timeout_millisecondsElement.addText("5000");
-        idle_timeout_minutesElement.addText("30");
-        single_poolElement.add(max_sizeElement);
-        single_poolElement.add(min_sizeElement);
-        single_poolElement.add(blocking_timeout_millisecondsElement);
-        single_poolElement.add(idle_timeout_minutesElement);
-        single_poolElement.add(match_oneElement);
-        connectionmanagerElement.add(local_transactionElement);
-        connectionmanagerElement.add(single_poolElement);
-        return connectionmanagerElement;
-    }
-
-    /**
-     * check wether the connection manager details are there at the jboss side
-     * 
-     * @param jbossJMSConnectioFactoryElement
-     * @return boolean check of the existance
-     */
-    private boolean checkConnectionMangerDetailsExistsInJboss(Element tx_connection_factoryElement) {
-        boolean check = false;
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "min-pool-size")) {
-            check = true;
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "max-pool-size")) {
-            check = true;
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
-                "blocking-timeout-millis")) {
-            check = true;
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
-                "idle-timeout-minutes")) {
-            check = true;
-        }
-        return check;
-    }
-
-    /**
-     * this method created the connection manager element refering the existing
-     * elements at the jboss side
-     * 
-     * @param jbossJMSConnectioFactoryElement
-     * @return connectionMangerElement
-     */
-    private Element connectionMangerDetailsExistsInJboss(Element tx_connection_factoryElement,
-            Namespace environmentNamespace) {
-        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
-                "connectionmanager", environmentNamespace));
-        Element local_transactionElement = DocumentHelper.createElement(new QName(
-                "local-transaction", environmentNamespace));
-        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
-                environmentNamespace));
-        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
-                environmentNamespace));
-        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
-                environmentNamespace));
-        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
-                "blocking-timeout-milliseconds", environmentNamespace));
-        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
-                "idle-timeout-minutes", environmentNamespace));
-        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
-                environmentNamespace));
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "max-pool-size")) {
-            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
-                    "max-pool-size").getText();
-            max_sizeElement.addText(value);
-        } else {
-            max_sizeElement.addText("10");
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "min-pool-size")) {
-            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
-                    "min-pool-size").getText();
-            min_sizeElement.addText(value);
-        } else {
-            min_sizeElement.addText("0");
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
-                "blocking-timeout-millis")) {
-            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
-                    "blocking-timeout-millis").getText();
-            blocking_timeout_millisecondsElement.addText(value);
-        } else {
-            blocking_timeout_millisecondsElement.addText("5000");
-        }
-        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
-                "idle-timeout-minutes")) {
-            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
-                    "idle-timeout-minutes").getText();
-            idle_timeout_minutesElement.addText(value);
-        } else {
-            idle_timeout_minutesElement.addText("30");
-        }
-        single_poolElement.add(max_sizeElement);
-        single_poolElement.add(min_sizeElement);
-        single_poolElement.add(blocking_timeout_millisecondsElement);
-        single_poolElement.add(idle_timeout_minutesElement);
-        single_poolElement.add(match_oneElement);
-        connectionmanagerElement.add(local_transactionElement);
-        connectionmanagerElement.add(single_poolElement);
-        return connectionmanagerElement;
-    }
-
-}
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.j2g.resources.jms;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.j2g.common.IFileMigration;
+import org.apache.geronimo.j2g.common.IOutput;
+import org.apache.geronimo.j2g.common.Tool;
+import org.apache.geronimo.j2g.util.resources.Constants;
+import org.apache.geronimo.j2g.util.resources.xml.XMLConversionHelper;
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+/**
+ * Class which implement the JMS Source File Migration 
+ */
+public class JMSResourcesTool implements IFileMigration {
+
+    // Initialization of the IOutput for JMSResourcesTool class
+    IOutput out = Tool.getCurrent().getOutput();
+    // Initialization of the logger for JMSResourcesTool class
+    Log logger = LogFactory.getLog(JMSResourcesTool.class);
+
+    /**
+     * mgration method from jms jboss discripters to geronimo discriptors
+     * 
+     * @param sourceFile :
+     *            jms jboss discriptor file
+     * @return status of the migration
+     */
+    public boolean migrate(File sourceFile, File rootDirectory) {
+        // read any *-servise files and then migrate that to the geronimo jms
+        // resources
+        boolean migrated = false;
+            String directoryName = sourceFile.getParent();
+            String jbossJMSFileName = sourceFile.getName();
+            logger.debug("JMS resources Directory Name ==> " + directoryName);
+            logger.debug("jboss jms file Name ==> " + jbossJMSFileName);
+            // Checking wether file is a valid jbossmq-destinations-service.xml
+            // file
+            if (jbossJMSFileName.equals(Constants.JBOSS_VALID_JMS_DESTINATIONS_SERVICES_XML_FILE)) {
+                logger.debug("Searching for jboss-ds.xml file inside the current directory");
+                if (XMLConversionHelper.isFileExists(directoryName,
+                        Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE)) {
+                    logger.debug("jboss jms connection factory xml file Name ==> "
+                            + Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE);
+                    File jbossJMSDestinationServicesFile = new File(directoryName,
+                            Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE);
+                    logger.debug("Converting Jboss jms files in " + directoryName);
+                    try {
+                        Document jbossJMSConnectioFactoryDocument = null;
+                        try{
+                        jbossJMSConnectioFactoryDocument = XMLConversionHelper
+                                .getJbossDocument(jbossJMSDestinationServicesFile);
+                        } catch (DocumentException e){
+                        	out.error(JMSResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
+            						+ jbossJMSDestinationServicesFile.getAbsolutePath()
+            						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
+            						+ e.getMessage());
+                        	throw e;
+                        }
+                        Document jbossJMSDestinationServicesDocument = null;
+                        try {
+                        	jbossJMSDestinationServicesDocument = XMLConversionHelper
+                                .getJbossDocument(sourceFile);
+                        } catch(DocumentException e){
+                        	out.error(JMSResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
+            						+ sourceFile.getAbsolutePath()
+            						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
+            						+ e.getMessage());
+                        	throw e;
+                        }
+                        Document geronimoDocument = migrationFromJboss2Geronimo(
+                                jbossJMSDestinationServicesDocument.getRootElement(),
+                                jbossJMSConnectioFactoryDocument.getRootElement());
+                        String geronimoJMSFileName = directoryName + File.separator
+                                + Constants.GERONIMO_JMS_PLAN_FILE;
+                        // check whether the file already exists if so
+                        // back up that and save that or check the req
+                        // This was done at the upper level of the tool
+                        XMLConversionHelper.saveGeronimoDocument(geronimoJMSFileName,
+                                geronimoDocument);
+                        migrated = true;
+                        out.info(JMSResourcesTool.class.getSimpleName(), "The JMS Resource File Migration Complete !!!\n");
+                    } catch(DocumentException ignore){
+                    } catch (IOException e) {
+                        out.error(JMSResourcesTool.class.getSimpleName(), "IO exception " + e.getMessage());
+                    }
+                } else {
+                    out.error(JMSResourcesTool.class.getSimpleName(), "Inorder to continue the JMS Resources Tool the "
+                            + Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE
+                            + " needs to be present in the working directory ");
+                }
+            }
+
+        return migrated;
+    }
+
+    /**
+     * Accepts the jboss side Elements that holdes the discripter infomation and
+     * return the geronimo discripter
+     * 
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return created geronimo Document
+     */
+    private Document migrationFromJboss2Geronimo(Element jbossJMSDestinationServicesElement,
+            Element jbossJMSConnectioFactoryElement) {
+        Document newGeronimoDocument = null;
+        if (XMLConversionHelper.containSubElement(jbossJMSConnectioFactoryElement,
+                "tx-connection-factory")) {
+            Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
+                    jbossJMSConnectioFactoryElement, "tx-connection-factory");
+            Element jndi_nameElement = XMLConversionHelper.obtainSubElement(
+                    tx_connection_factoryElement, "jndi-name");
+            String jndi_nameString = jndi_nameElement.getText();
+            Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument(
+                    Constants.NAMESPACE_CONNECTOR, "connector", Constants.JMS_RESOURCE_TOOL,
+                    jndi_nameString, Constants.NAMESPACE_ENV);
+            newGeronimoDocument = addResourceAdapterElement(geronimoDocument,
+                    jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
+
+        } else {
+            out
+               .error(JMSResourcesTool.class.getSimpleName(), "The supplied jboss-ds.xml file does not contain the nessesary tx-connection-factory details");
+        }
+        return newGeronimoDocument;
+    }
+
+    /**
+     * Add the resource adapter element to the geronimodocument
+     * 
+     * @param geronimoDocument
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return geronimo document with added resource adapter
+     */
+    private Document addResourceAdapterElement(Document geronimoDocument,
+            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
+        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
+        Element resourceAdapterElement = DocumentHelper.createElement(new QName("resourceadapter",
+                rootNamespace));
+        Element resourceAdapter_instanceElement = DocumentHelper.createElement(new QName(
+                "resourceadapter-instance", rootNamespace));
+        Element resourceAdapter_nameElement = DocumentHelper.createElement(new QName(
+                "resourceadapter-name", rootNamespace));
+        Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
+                jbossJMSConnectioFactoryElement, "tx-connection-factory");
+        if (XMLConversionHelper.containSubElementWithAttribute(tx_connection_factoryElement,
+                "config-property", "name", "JmsProviderAdapterJNDI")) {
+            Element config_propertyElement = XMLConversionHelper.obtainSubElementWithAttribute(
+                    tx_connection_factoryElement, "config-property", "name",
+                    "JmsProviderAdapterJNDI");
+            String name = XMLConversionHelper.obtainNameFromJNDINAME(config_propertyElement
+                    .getText());
+            resourceAdapter_nameElement.addText(name);
+        } else {
+            resourceAdapter_nameElement.addText("MY JMS Resource");
+        }
+        resourceAdapter_instanceElement.add(resourceAdapter_nameElement);
+        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", "tcp://localhost:61616", "name", "ServerURL",
+                rootNamespace));
+        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", "geronimo", "name", "UserName", rootNamespace));
+        resourceAdapter_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", "geronimo", "name", "Password", rootNamespace));
+        Namespace namingNamespace = new Namespace("naming", Constants.NAMESPACE_GERONIMO_NAMING);
+        Element workmanagerElement = DocumentHelper.createElement(new QName("workmanager",
+                namingNamespace));
+        workmanagerElement.add(XMLConversionHelper.createSibling("gbean-link",
+                "DefaultWorkManager", namingNamespace));
+        resourceAdapter_instanceElement.add(workmanagerElement);
+        resourceAdapterElement.add(resourceAdapter_instanceElement);
+        //Add outboundresource adapters and adminobjects (check what are
+        // the mapping that exist for those things)
+        Element outboundresourceElement = addOutBoundResourcesAdapterElement(geronimoDocument,
+                jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
+        resourceAdapterElement.add(outboundresourceElement);
+        geronimoDocument.getRootElement().add(resourceAdapterElement);
+        geronimoDocument = addAdminObjectElement(geronimoDocument,
+                jbossJMSDestinationServicesElement, jbossJMSConnectioFactoryElement);
+        return geronimoDocument;
+    }
+
+    /**
+     * Add the outbound resource adapter to the geronimo document
+     * 
+     * @param geronimoDocument
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return geronimo document with the added outbound resource adapter
+     */
+    private Element addOutBoundResourcesAdapterElement(Document geronimoDocument,
+            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
+        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
+        Element outbound_resourceAdapterElement = DocumentHelper.createElement(new QName(
+                "outbound-resourceadapter", rootNamespace));
+        Element connection_definitionElement = DocumentHelper.createElement(new QName(
+                "connection-definition", rootNamespace));
+        Element connectionfactory_interfaceElement = DocumentHelper.createElement(new QName(
+                "connectionfactory-interface", rootNamespace));
+        connectionfactory_interfaceElement.addText("javax.jms.ConnectionFactory");
+        Element connectiondefinition_instanceElement = DocumentHelper.createElement(new QName(
+                "connectiondefinition-instance", rootNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling("name",
+                "MyConnectionFactory", rootNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling(
+                "implemented-interface", "javax.jms.QueueConnectionFactory", rootNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling(
+                "implemented-interface", "javax.jms.TopicConnectionFactory", rootNamespace));
+        Element tx_connection_factoryElement = XMLConversionHelper.obtainSubElement(
+                jbossJMSConnectioFactoryElement, "tx-connection-factory");
+        if (checkConnectionMangerDetailsExistsInJboss(tx_connection_factoryElement)) {
+            connectiondefinition_instanceElement.add(connectionMangerDetailsExistsInJboss(
+                    tx_connection_factoryElement, rootNamespace));
+        } else {
+            connectiondefinition_instanceElement
+                    .add(createDefaultConnectionManagerElement(rootNamespace));
+        }
+        connection_definitionElement.add(connectionfactory_interfaceElement);
+        connection_definitionElement.add(connectiondefinition_instanceElement);
+        outbound_resourceAdapterElement.add(connection_definitionElement);
+        return outbound_resourceAdapterElement;
+    }
+
+    /**
+     * add the admin objects to the currently existing geronimo document
+     * 
+     * @param geronimoDocument
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return return the geronimo document which contains the admin objects
+     */
+    private Document addAdminObjectElement(Document geronimoDocument,
+            Element jbossJMSDestinationServicesElement, Element jbossJMSConnectioFactoryElement) {
+
+        Iterator elementIterator = jbossJMSDestinationServicesElement.elementIterator();
+        while (elementIterator.hasNext()) {
+            Element itElement = (Element) elementIterator.next();
+            if (itElement.getName().equals("mbean")) {
+                String queueOrTopic = null;
+                String queueOrTopicName = null;
+                String newQueueOrTopicName = null;
+                Iterator attribIterator = itElement.attributeIterator();
+                while (attribIterator.hasNext()) {
+                    Attribute itAttribute = (Attribute) attribIterator.next();
+                    if (itAttribute.getName().equals("code")) {
+                        if (itAttribute.getData().equals(Constants.TOPIC_CLASS_JBOSS)) {
+                            queueOrTopic = "topic";
+                        }
+                        if (itAttribute.getData().equals(Constants.QUEUE_CLASS_JBOSS)) {
+                            queueOrTopic = "queue";
+                        }
+                    } else if (itAttribute.getName().equals("name")) {
+                        queueOrTopicName = (String) itAttribute.getData();
+                        newQueueOrTopicName = queueOrTopicName.substring(queueOrTopicName
+                                .indexOf("name=") + 5, queueOrTopicName.length());
+                    }
+                }
+                if (queueOrTopic.equals("queue")) {
+                    geronimoDocument = addTopicElement(geronimoDocument, newQueueOrTopicName);
+                }
+                if (queueOrTopic.equals("topic")) {
+                    geronimoDocument = addQueueElement(geronimoDocument, newQueueOrTopicName);
+                }
+                boolean securityCheck = checkForSecurityConfIndideMBeanElement(itElement);
+                if (securityCheck) {
+                    logger
+                            .warn("destination JBoss descriptor has the SecurityConf attribute inside the MBean Element "
+                                    + "which are decoded");
+                }
+            }
+        }
+        return geronimoDocument;
+    }
+
+    /**
+     * check wether the passed mbean element have any security configuration
+     * details
+     * 
+     * @param itElement
+     *            passesd mbean element
+     * @return boolean wether contains or not
+     */
+    private boolean checkForSecurityConfIndideMBeanElement(Element itElement) {
+        return XMLConversionHelper.containSubElementWithAttribute(itElement, "attribute", "name",
+                "SecurityConf");
+    }
+
+    /**
+     * add the topic element to the existing geronimo document
+     * 
+     * @param geronimoDocument
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return geronimo document with the topic element added as a admin object
+     */
+    private Document addTopicElement(Document geronimoDocument, String topicName) {
+        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
+        Element adminobjectElement = DocumentHelper.createElement(new QName("adminobject",
+                rootNamespace));
+        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-interface",
+                "javax.jms.Topic", rootNamespace));
+        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-class",
+                "org.activemq.message.ActiveMQTopic", rootNamespace));
+        Element adminobject_instanceElement = DocumentHelper.createElement(new QName(
+                "adminobject-instance", rootNamespace));
+        adminobject_instanceElement.add(XMLConversionHelper.createSibling(
+                "message-destination-name", topicName, rootNamespace));
+        adminobject_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", " Mytopic", "name", "PhysicalName", rootNamespace));
+        adminobjectElement.add(adminobject_instanceElement);
+        geronimoDocument.getRootElement().add(adminobjectElement);
+        return geronimoDocument;
+    }
+
+    /**
+     * add queue elament to the geronimo existing document
+     * 
+     * @param geronimoDocument
+     * @param jbossJMSDestinationServicesElement
+     * @param jbossJMSConnectioFactoryElement
+     * @return the geronimo document by adding the Queue as a admin object
+     */
+    private Document addQueueElement(Document geronimoDocument, String queueName) {
+        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
+        Element adminobjectElement = DocumentHelper.createElement(new QName("adminobject",
+                rootNamespace));
+        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-interface",
+                "javax.jms.Queue", rootNamespace));
+        adminobjectElement.add(XMLConversionHelper.createSibling("adminobject-class",
+                "org.activemq.message.ActiveMQTopic", rootNamespace));
+        Element adminobject_instanceElement = DocumentHelper.createElement(new QName(
+                "adminobject-instance", rootNamespace));
+        adminobject_instanceElement.add(XMLConversionHelper.createSibling(
+                "message-destination-name", queueName, rootNamespace));
+        adminobject_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", " MyQueue", "name", "PhysicalName", rootNamespace));
+        adminobjectElement.add(adminobject_instanceElement);
+        geronimoDocument.getRootElement().add(adminobjectElement);
+        return geronimoDocument;
+    }
+
+    /**
+     * Creates a default connection manager elements with the defaults values
+     * 
+     * @param environmentNamespace
+     * @return default commection manager elament
+     */
+    public Element createDefaultConnectionManagerElement(Namespace environmentNamespace) {
+        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
+                "connectionmanager", environmentNamespace));
+        Element local_transactionElement = DocumentHelper.createElement(new QName(
+                "local-transaction", environmentNamespace));
+        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
+                environmentNamespace));
+        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
+                environmentNamespace));
+        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
+                environmentNamespace));
+        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
+                "blocking-timeout-milliseconds", environmentNamespace));
+        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
+                "idle-timeout-minutes", environmentNamespace));
+        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
+                environmentNamespace));
+        max_sizeElement.addText("10");
+        min_sizeElement.addText("0");
+        blocking_timeout_millisecondsElement.addText("5000");
+        idle_timeout_minutesElement.addText("30");
+        single_poolElement.add(max_sizeElement);
+        single_poolElement.add(min_sizeElement);
+        single_poolElement.add(blocking_timeout_millisecondsElement);
+        single_poolElement.add(idle_timeout_minutesElement);
+        single_poolElement.add(match_oneElement);
+        connectionmanagerElement.add(local_transactionElement);
+        connectionmanagerElement.add(single_poolElement);
+        return connectionmanagerElement;
+    }
+
+    /**
+     * check wether the connection manager details are there at the jboss side
+     * 
+     * @param jbossJMSConnectioFactoryElement
+     * @return boolean check of the existance
+     */
+    private boolean checkConnectionMangerDetailsExistsInJboss(Element tx_connection_factoryElement) {
+        boolean check = false;
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "min-pool-size")) {
+            check = true;
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "max-pool-size")) {
+            check = true;
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
+                "blocking-timeout-millis")) {
+            check = true;
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
+                "idle-timeout-minutes")) {
+            check = true;
+        }
+        return check;
+    }
+
+    /**
+     * this method created the connection manager element refering the existing
+     * elements at the jboss side
+     * 
+     * @param jbossJMSConnectioFactoryElement
+     * @return connectionMangerElement
+     */
+    private Element connectionMangerDetailsExistsInJboss(Element tx_connection_factoryElement,
+            Namespace environmentNamespace) {
+        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
+                "connectionmanager", environmentNamespace));
+        Element local_transactionElement = DocumentHelper.createElement(new QName(
+                "local-transaction", environmentNamespace));
+        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
+                environmentNamespace));
+        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
+                environmentNamespace));
+        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
+                environmentNamespace));
+        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
+                "blocking-timeout-milliseconds", environmentNamespace));
+        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
+                "idle-timeout-minutes", environmentNamespace));
+        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
+                environmentNamespace));
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "max-pool-size")) {
+            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
+                    "max-pool-size").getText();
+            max_sizeElement.addText(value);
+        } else {
+            max_sizeElement.addText("10");
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement, "min-pool-size")) {
+            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
+                    "min-pool-size").getText();
+            min_sizeElement.addText(value);
+        } else {
+            min_sizeElement.addText("0");
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
+                "blocking-timeout-millis")) {
+            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
+                    "blocking-timeout-millis").getText();
+            blocking_timeout_millisecondsElement.addText(value);
+        } else {
+            blocking_timeout_millisecondsElement.addText("5000");
+        }
+        if (XMLConversionHelper.containSubElement(tx_connection_factoryElement,
+                "idle-timeout-minutes")) {
+            String value = XMLConversionHelper.obtainSubElement(tx_connection_factoryElement,
+                    "idle-timeout-minutes").getText();
+            idle_timeout_minutesElement.addText(value);
+        } else {
+            idle_timeout_minutesElement.addText("30");
+        }
+        single_poolElement.add(max_sizeElement);
+        single_poolElement.add(min_sizeElement);
+        single_poolElement.add(blocking_timeout_millisecondsElement);
+        single_poolElement.add(idle_timeout_minutesElement);
+        single_poolElement.add(match_oneElement);
+        connectionmanagerElement.add(local_transactionElement);
+        connectionmanagerElement.add(single_poolElement);
+        return connectionmanagerElement;
+    }
+
+}

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/jms/JMSResourcesTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java?view=diff&rev=561821&r1=561820&r2=561821
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java (original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java Wed Aug  1 08:05:12 2007
@@ -1,174 +1,174 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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.j2g.resources.mail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.j2g.common.IFileMigration;
-import org.apache.geronimo.j2g.common.IOutput;
-import org.apache.geronimo.j2g.common.Tool;
-import org.apache.geronimo.j2g.util.resources.Constants;
-import org.apache.geronimo.j2g.util.resources.xml.XMLConversionHelper;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
- 
-/**
- * Class which implement the Mail Source File Migration 
- */
-public class MailResourcesTool implements IFileMigration {
-
-    // Initialization of the IOutput for MailResourcesTool class
-    IOutput out = Tool.getCurrent().getOutput();
-    // Initialization of the logger for MailResourcesTool class
-    Log logger = LogFactory.getLog(MailResourcesTool.class);
-    
-    /**
-     * mgration method from jms jboss discripters to geronimo discriptors
-     * 
-     * @param sourceFile :jms jboss d"iscriptor file
-     * @return status of the migration
-     */
-    public boolean migrate(File sourceFile, File rootDirectory) {
-        boolean migrated = false;
-            String directoryName = sourceFile.getParent();
-            String mailFilename = sourceFile.getName();
-            logger.debug("Directory Name ==> " + directoryName
-                    + " jboss mail source file Name ==> " + mailFilename);
-            if (mailFilename.equals(Constants.JBOSS_VALID_MAIL_XML_FILE)) {
-                out.info(MailResourcesTool.class.getSimpleName(), "Converting Jboss mail xml file in " + directoryName);
-                try {
-                    Document jbossDocument = XMLConversionHelper.getJbossDocument(sourceFile);
-                    // check the existance of the plain password
-                    // authentication in the jboss RootElement
-                    if (XMLConversionHelper.containSubElementWithAttribute(XMLConversionHelper
-                            .obtainSubElement(jbossDocument.getRootElement(), "mbean"),
-                            "attribute", "name", "Password")) {
-                        out
-                           .error(MailResourcesTool.class.getSimpleName(), "The mail descripter file "
-                                   + mailFilename
-                                   + " contains the plain text password authentication, Aborting the Process !!!");
-                    } else {
-                        Document geronimoDocument = migrationFromJboss2Geronimo(jbossDocument
-                                .getRootElement());
-                        String geronimoMailFileName = directoryName + File.separator
-                                + Constants.GERONIMO_MAIL_PLAN_FILE;
-                        // check whether the file already exists if so
-                        // back up that and save that or check the req
-                        // This being done at upper level
-                        XMLConversionHelper.saveGeronimoDocument(geronimoMailFileName,
-                                geronimoDocument);
-                        migrated = true;
-                        out.info(MailResourcesTool.class.getSimpleName(), "The Mail Resource File Migration Complete!!!\n");
-                    }
-                } catch (DocumentException e) {
-                	out.error(MailResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
-    						+ sourceFile.getAbsolutePath()
-    						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
-    						+ e.getMessage());
-                } catch (IOException e) {
-                    out.error(MailResourcesTool.class.getSimpleName(), "IO exception " + e.getMessage());
-                }
-            }
-        return migrated;
-    }
-
-    /**
-     * Accepts the jboss side Elements that holdes the discripter infomation and
-     * return the geronimo discripter
-     * 
-     * @param jbossRootElement
-     * @return geronimo plan
-     */
-    private Document migrationFromJboss2Geronimo(Element jbossRootElement) {
-        Element gbeanElament = XMLConversionHelper.obtainSubElement(jbossRootElement, "mbean");
-        Element jbossAttributeElement = XMLConversionHelper.obtainSubElementWithAttribute(
-                gbeanElament, "attribute", "name", "JNDIName");
-        Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument(
-                Constants.NAMESPACE_ENV, "module", Constants.MAIL_RESOURCE_TOOL,
-                jbossAttributeElement.getStringValue(), "");
-        Document newGeronimoDocument = createMailGBean(geronimoDocument, jbossRootElement);
-        return newGeronimoDocument;
-    }
-
-    /**
-     * create the MailGBean element by refering the jboss side mbean elaments
-     * 
-     * @param geronimoDocument
-     * @param jbossRootElement
-     * @return the MailGbean element
-     */
-    private Document createMailGBean(Document geronimoDocument, Element jbossRootElement) {
-        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
-        Element gbeanElement = DocumentHelper.createElement(new QName("gbean", rootNamespace));
-        gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "mailSession"));
-        gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "class",
-                "org.apache.geronimo.mail.MailGBean"));
-        Element attributeElement = DocumentHelper.createElement(new QName("attribute",
-                rootNamespace));
-        attributeElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "properties"));
-        Element gbeanElament = XMLConversionHelper.obtainSubElement(jbossRootElement, "mbean");
-        Element jbossAttributeElement = XMLConversionHelper.obtainSubElementWithAttribute(
-                gbeanElament, "attribute", "name", "Configuration");
-        Element configurationelement = XMLConversionHelper.obtainSubElement(jbossAttributeElement,
-                "configuration");
-        attributeElement.add(DocumentHelper
-                .createCDATA(obtainMailConfigurationString(configurationelement)));
-//                .createText(obtainMailConfigurationString(configurationelement)));
-        gbeanElement.add(attributeElement);
-        geronimoDocument.getRootElement().add(gbeanElement);
-        return geronimoDocument;
-    }
-
-    /**
-     * obtain the mail configuration elemant from the configuration element
-     * 
-     * @param configurationElement
-     * @return sring of mail configuration
-     */
-    private String obtainMailConfigurationString(Element configurationElement) {
-        Iterator elementIterator = configurationElement.elementIterator();
-        String configurationString = "";
-        String name = null;
-        String value = null;
-        while (elementIterator.hasNext()) {
-            Element itElement = (Element) elementIterator.next();
-            if (itElement.getName().equals("property")) {
-                Iterator attribIterator = itElement.attributeIterator();
-                while (attribIterator.hasNext()) {
-                    Attribute itAttribute = (Attribute) attribIterator.next();
-                    if (itAttribute.getName().equals("name")) {
-                        name = itAttribute.getText();
-                    } else if (itAttribute.getName().equals("value")) {
-                        value = itAttribute.getText();
-                    }
-                }
-                configurationString += ("\r\n" + name + "=" + value );
-            }
-        }
-        return configurationString;
-    }
-
-}
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.j2g.resources.mail;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.j2g.common.IFileMigration;
+import org.apache.geronimo.j2g.common.IOutput;
+import org.apache.geronimo.j2g.common.Tool;
+import org.apache.geronimo.j2g.util.resources.Constants;
+import org.apache.geronimo.j2g.util.resources.xml.XMLConversionHelper;
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+ 
+/**
+ * Class which implement the Mail Source File Migration 
+ */
+public class MailResourcesTool implements IFileMigration {
+
+    // Initialization of the IOutput for MailResourcesTool class
+    IOutput out = Tool.getCurrent().getOutput();
+    // Initialization of the logger for MailResourcesTool class
+    Log logger = LogFactory.getLog(MailResourcesTool.class);
+    
+    /**
+     * mgration method from jms jboss discripters to geronimo discriptors
+     * 
+     * @param sourceFile :jms jboss d"iscriptor file
+     * @return status of the migration
+     */
+    public boolean migrate(File sourceFile, File rootDirectory) {
+        boolean migrated = false;
+            String directoryName = sourceFile.getParent();
+            String mailFilename = sourceFile.getName();
+            logger.debug("Directory Name ==> " + directoryName
+                    + " jboss mail source file Name ==> " + mailFilename);
+            if (mailFilename.equals(Constants.JBOSS_VALID_MAIL_XML_FILE)) {
+                out.info(MailResourcesTool.class.getSimpleName(), "Converting Jboss mail xml file in " + directoryName);
+                try {
+                    Document jbossDocument = XMLConversionHelper.getJbossDocument(sourceFile);
+                    // check the existance of the plain password
+                    // authentication in the jboss RootElement
+                    if (XMLConversionHelper.containSubElementWithAttribute(XMLConversionHelper
+                            .obtainSubElement(jbossDocument.getRootElement(), "mbean"),
+                            "attribute", "name", "Password")) {
+                        out
+                           .error(MailResourcesTool.class.getSimpleName(), "The mail descripter file "
+                                   + mailFilename
+                                   + " contains the plain text password authentication, Aborting the Process !!!");
+                    } else {
+                        Document geronimoDocument = migrationFromJboss2Geronimo(jbossDocument
+                                .getRootElement());
+                        String geronimoMailFileName = directoryName + File.separator
+                                + Constants.GERONIMO_MAIL_PLAN_FILE;
+                        // check whether the file already exists if so
+                        // back up that and save that or check the req
+                        // This being done at upper level
+                        XMLConversionHelper.saveGeronimoDocument(geronimoMailFileName,
+                                geronimoDocument);
+                        migrated = true;
+                        out.info(MailResourcesTool.class.getSimpleName(), "The Mail Resource File Migration Complete!!!\n");
+                    }
+                } catch (DocumentException e) {
+                	out.error(MailResourcesTool.class.getSimpleName(), "Error occured while reading xml descriptor "
+    						+ sourceFile.getAbsolutePath()
+    						+ ". It is possible that the migrator cannot download the xml schema or the xml file has incorrect syntax. Nested exception:"
+    						+ e.getMessage());
+                } catch (IOException e) {
+                    out.error(MailResourcesTool.class.getSimpleName(), "IO exception " + e.getMessage());
+                }
+            }
+        return migrated;
+    }
+
+    /**
+     * Accepts the jboss side Elements that holdes the discripter infomation and
+     * return the geronimo discripter
+     * 
+     * @param jbossRootElement
+     * @return geronimo plan
+     */
+    private Document migrationFromJboss2Geronimo(Element jbossRootElement) {
+        Element gbeanElament = XMLConversionHelper.obtainSubElement(jbossRootElement, "mbean");
+        Element jbossAttributeElement = XMLConversionHelper.obtainSubElementWithAttribute(
+                gbeanElament, "attribute", "name", "JNDIName");
+        Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument(
+                Constants.NAMESPACE_ENV, "module", Constants.MAIL_RESOURCE_TOOL,
+                jbossAttributeElement.getStringValue(), "");
+        Document newGeronimoDocument = createMailGBean(geronimoDocument, jbossRootElement);
+        return newGeronimoDocument;
+    }
+
+    /**
+     * create the MailGBean element by refering the jboss side mbean elaments
+     * 
+     * @param geronimoDocument
+     * @param jbossRootElement
+     * @return the MailGbean element
+     */
+    private Document createMailGBean(Document geronimoDocument, Element jbossRootElement) {
+        Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace();
+        Element gbeanElement = DocumentHelper.createElement(new QName("gbean", rootNamespace));
+        gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "mailSession"));
+        gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "class",
+                "org.apache.geronimo.mail.MailGBean"));
+        Element attributeElement = DocumentHelper.createElement(new QName("attribute",
+                rootNamespace));
+        attributeElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "properties"));
+        Element gbeanElament = XMLConversionHelper.obtainSubElement(jbossRootElement, "mbean");
+        Element jbossAttributeElement = XMLConversionHelper.obtainSubElementWithAttribute(
+                gbeanElament, "attribute", "name", "Configuration");
+        Element configurationelement = XMLConversionHelper.obtainSubElement(jbossAttributeElement,
+                "configuration");
+        attributeElement.add(DocumentHelper
+                .createCDATA(obtainMailConfigurationString(configurationelement)));
+//                .createText(obtainMailConfigurationString(configurationelement)));
+        gbeanElement.add(attributeElement);
+        geronimoDocument.getRootElement().add(gbeanElement);
+        return geronimoDocument;
+    }
+
+    /**
+     * obtain the mail configuration elemant from the configuration element
+     * 
+     * @param configurationElement
+     * @return sring of mail configuration
+     */
+    private String obtainMailConfigurationString(Element configurationElement) {
+        Iterator elementIterator = configurationElement.elementIterator();
+        String configurationString = "";
+        String name = null;
+        String value = null;
+        while (elementIterator.hasNext()) {
+            Element itElement = (Element) elementIterator.next();
+            if (itElement.getName().equals("property")) {
+                Iterator attribIterator = itElement.attributeIterator();
+                while (attribIterator.hasNext()) {
+                    Attribute itAttribute = (Attribute) attribIterator.next();
+                    if (itAttribute.getName().equals("name")) {
+                        name = itAttribute.getText();
+                    } else if (itAttribute.getName().equals("value")) {
+                        value = itAttribute.getText();
+                    }
+                }
+                configurationString += ("\r\n" + name + "=" + value );
+            }
+        }
+        return configurationString;
+    }
+
+}

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/mail/MailResourcesTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message