Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 75546 invoked from network); 19 Mar 2007 17:44:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Mar 2007 17:44:56 -0000 Received: (qmail 73428 invoked by uid 500); 19 Mar 2007 17:45:01 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 73332 invoked by uid 500); 19 Mar 2007 17:45:01 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 73106 invoked by uid 99); 19 Mar 2007 17:45:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Mar 2007 10:44:59 -0700 X-ASF-Spam-Status: No, hits=-97.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME,URI_NOVOWEL X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Mar 2007 10:44:44 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B8CF61A9852; Mon, 19 Mar 2007 10:43:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r520023 [7/10] - in /geronimo/sandbox/j2g: ./ bin/ doc/ src/ src/common/ src/common/META-INF/ src/common/src/ src/common/src/org/ src/common/src/org/apache/ src/common/src/org/apache/apps/ src/common/src/org/apache/apps/j2gmigrator/ src/con... Date: Mon, 19 Mar 2007 17:43:49 -0000 To: scm@geronimo.apache.org From: pmcmahan@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070319174357.B8CF61A9852@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml (added) +++ geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,44 @@ +/** + * 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. + */ + + + + + + j2g + application + 1.0 + ear + + + + + + + + + + + + + + + + + + + Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/geronimo-application.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml (added) +++ geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,44 @@ +/** + * 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. + */ + + + + + + securiyDomain + amila + messaging + + mailservice.sar + + + hibanate.sar + + + admin + amila + rasika + + + manager + sandakith + sris + + + \ No newline at end of file Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test-resources/jboss-app.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java (added) +++ geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java Mon Mar 19 10:43:27 2007 @@ -0,0 +1,43 @@ +/** + * 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.apps.j2gmigrator.descriptors.app; + +import junit.framework.TestCase; + +import java.io.File; + +import org.apache.apps.j2gmigrator.descriptors.DescriptorsTool; +import org.apache.apps.j2gmigrator.descriptors.app.ApplicationDescriptorTool; + + +/** + * Author: amila + * Date: Aug 31, 2006 + */ +public class TestApplicationDescriptorTool extends TestCase { + + public void testMigrate() { + DescriptorsTool descriptorsTool = new DescriptorsTool(); + String jbossApplicatinXmlFile = "test-resources/jboss-app.xml"; + ApplicationDescriptorTool applicationDescriptorTool = new ApplicationDescriptorTool(); + applicationDescriptorTool.migrate(new File(jbossApplicatinXmlFile)); + + System.out.println("Migrated..."); + } + + +} Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/app/TestApplicationDescriptorTool.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/jms-plugin/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/META-INF/MANIFEST.MF (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007 @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Jms_plugin Plug-in +Bundle-SymbolicName: jms_plugin; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: ibm +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + com.ibm.j2g, + com.ibm.j2g.resources, + com.ibm.j2g.util +Eclipse-LazyStart: true +Bundle-ClassPath: . Added: geronimo/sandbox/j2g/src2/jms-plugin/build.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/build.properties?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/build.properties (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/build.properties Mon Mar 19 10:43:27 2007 @@ -0,0 +1,21 @@ +/** + * 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. + */ + source.. = src/ +output.. = classes/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ Propchange: geronimo/sandbox/j2g/src2/jms-plugin/build.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/build.properties ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/build.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,23 @@ +/** + * 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. + */ + + + + + + + Propchange: geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/plugin.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties Mon Mar 19 10:43:27 2007 @@ -0,0 +1,30 @@ +/** + * 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. + */ + # Set root logger level to DEBUG and its only appender to console. +commons-logging.rootLogger=INFO + +#define loggers +#pluging logger +lcommons-logging.logger.com.ibm.j2g= DEBUG,console + +# console is set to be a ConsoleAppender. +commons-logging.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +commons-logging.appender.console.layout=org.apache.log4j.PatternLayout +#commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p %l - %m%n +commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p - %m%n \ No newline at end of file Propchange: geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java Mon Mar 19 10:43:27 2007 @@ -0,0 +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.apps.j2gmigrator.resources.jms; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +import org.apache.apps.j2gmigrator.IFileMigration; +import org.apache.apps.j2gmigrator.IOutput; +import org.apache.apps.j2gmigrator.Tool; +import org.apache.apps.j2gmigrator.resources.utils.Constants; +import org.apache.apps.j2gmigrator.resources.xmlutil.XMLConversionHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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) { + // 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("Errors occurs while reading xml descriptor " + + jbossJMSDestinationServicesFile.getAbsolutePath() + + ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:" + + e.getMessage()); + throw e; + } + Document jbossJMSDestinationServicesDocument = null; + try { + jbossJMSDestinationServicesDocument = XMLConversionHelper + .getJbossDocument(sourceFile); + } catch(DocumentException e){ + out.error("Errors occurs while reading xml descriptor " + + sourceFile.getAbsolutePath() + + ". It is possible that the migrator cannot download an xml schema or xml file has a wrong 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("The JMS Resource File Migration Complete !!!\n"); + } catch(DocumentException ignore){ + } catch (IOException e) { + out.error("IO exception " + e.getMessage()); + } + } else { + out.error("Inorder to continue the JMS Resources Tool the " + + Constants.JBOSS_VALID_JMS_CONNECTION_FACTORY_XML_FILE + + " need to present in 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("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/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/src/org/apache/apps/j2gmigrator/resources/jms/JMSResourcesTool.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,127 @@ +/** + * 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. + */ + + + + + console.jms + SampleResourceGroup + 1.0 + rar + + + + geronimo + activemq-broker + car + + + + + + + + My JMS Resources + + + tcp://localhost:61616 + + + geronimo + + + geronimo + + + 105 + JMS Configuration [DRAFT (1.1)] + DefaultWorkManager + + + + + + + javax.jms.ConnectionFactory + + + MyConnectionFactory + + javax.jms.QueueConnectionFactory + + + javax.jms.TopicConnectionFactory + + + + + + + 10 + 0 + + 5000 + + + 0 + + + + + + + + + + + + javax.jms.Topic + + + org.activemq.message.ActiveMQTopic + + + + MyTopic + + + MyTopic + + + + + + + javax.jms.Queue + + + org.activemq.message.ActiveMQQueue + + + + 106 + JMS Configuration [DRAFT (1.1)] + MyQueue + + + MyQueue + + + + Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/geronimo-jms-resource-plan.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,111 @@ +/** + * 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. + */ + + + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + -1 + + + + + + + + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jbossmq-destinations-service.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,79 @@ +/** + * 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. + */ + + + + + + + + + + + + + + DefaultJMSProvider + + org.jboss.jms.jndi.JNDIProviderAdapter + + + java:/XAConnectionFactory + + java:/XAConnectionFactory + + java:/XAConnectionFactory + + + + + + jboss:service=XidFactory + StdJMSPool + + org.jboss.jms.asf.StdServerSessionPoolFactory + + + + + + JmsXA + + jms-ra.rar + org.jboss.resource.adapter.jms.JmsConnectionFactory + javax.jms.Topic + java:/DefaultJMSProvider + 11 + + JmsXARealm + + + Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-ds.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,139 @@ +/** + * 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. + */ + + + + + + j2g + jms + 1.0 + jar + + + + j2g + jms + 1.0 + jar + + + + + + DefaultJMSProvider + tcp://localhost:61616 + geronimo + geronimo + + DefaultWorkManager + + + + + javax.jms.ConnectionFactory + + MyConnectionFactory + javax.jms.QueueConnectionFactory + javax.jms.TopicConnectionFactory + + + + 11 + 0 + 5000 + 30 + + + + + + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + testTopic + MyQueue + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + securedTopic + MyQueue + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + testDurableTopic + MyQueue + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + testQueue + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + A + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + B + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + C + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + D + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + ex + Mytopic + + + Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test-apps/jms/jms-geronimo-plan.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java (added) +++ geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java Mon Mar 19 10:43:27 2007 @@ -0,0 +1,48 @@ +/** + * 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.apps.j2gmigrator.resources.jms.test; + +import java.io.File; + +import org.apache.apps.j2gmigrator.resources.ResourcesTool; +import org.apache.apps.j2gmigrator.resources.jms.JMSResourcesTool; +import org.apache.apps.j2gmigrator.resources.utils.Constants; + +import junit.framework.TestCase; + +/** + * Test Case for the JMSResouresTool + */ +public class JMSResouresToolTestCase extends TestCase { + + @Override //the setup method + protected void setUp() throws Exception { + // To set the IOutput intialize the DescripterTool + ResourcesTool desTool = new ResourcesTool(); + super.setUp(); + } + + // Test for JMS Resources Migration + public void testJMSResourcesFileMigration() { + String fileLocation = Constants.TEST_RESOURCES_DIRECTORY + "jms/" + + Constants.JBOSS_VALID_JMS_DESTINATIONS_SERVICES_XML_FILE; + File file = new File(fileLocation); + JMSResourcesTool jmsResourcesTool = new JMSResourcesTool(); + boolean result = jmsResourcesTool.migrate(file); + assertTrue(result); + } +} Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/jms-plugin/test/org/apache/apps/j2gmigrator/resources/jms/test/JMSResouresToolTestCase.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/mail-plugin/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/mail-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/mail-plugin/META-INF/MANIFEST.MF (added) +++ geronimo/sandbox/j2g/src2/mail-plugin/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007 @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Mail_plugin Plug-in +Bundle-SymbolicName: mail_plugin; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: ibm +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + com.ibm.j2g, + com.ibm.j2g.resources, + com.ibm.j2g.util +Eclipse-LazyStart: true +Bundle-ClassPath: . Added: geronimo/sandbox/j2g/src2/mail-plugin/build.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/mail-plugin/build.properties?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/mail-plugin/build.properties (added) +++ geronimo/sandbox/j2g/src2/mail-plugin/build.properties Mon Mar 19 10:43:27 2007 @@ -0,0 +1,21 @@ +/** + * 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. + */ + source.. = src/ +output.. = classes/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ Propchange: geronimo/sandbox/j2g/src2/mail-plugin/build.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/mail-plugin/build.properties ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/mail-plugin/build.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml (added) +++ geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml Mon Mar 19 10:43:27 2007 @@ -0,0 +1,24 @@ +/** + * 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. + */ + + + + + + + + Propchange: geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/mail-plugin/plugin.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties (added) +++ geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties Mon Mar 19 10:43:27 2007 @@ -0,0 +1,30 @@ +/** + * 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. + */ + # Set root logger level to DEBUG and its only appender to console. +commons-logging.rootLogger=INFO + +#define loggers +#pluging logger +lcommons-logging.logger.com.ibm.j2g= DEBUG,console + +# console is set to be a ConsoleAppender. +commons-logging.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +commons-logging.appender.console.layout=org.apache.log4j.PatternLayout +#commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p %l - %m%n +commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p - %m%n \ No newline at end of file Propchange: geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/j2g/src2/mail-plugin/src/commons-logging.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/j2g/src2/mail-plugin/src/org/apache/apps/j2gmigrator/resources/mail/MailResourcesTool.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/mail-plugin/src/org/apache/apps/j2gmigrator/resources/mail/MailResourcesTool.java?view=auto&rev=520023 ============================================================================== --- geronimo/sandbox/j2g/src2/mail-plugin/src/org/apache/apps/j2gmigrator/resources/mail/MailResourcesTool.java (added) +++ geronimo/sandbox/j2g/src2/mail-plugin/src/org/apache/apps/j2gmigrator/resources/mail/MailResourcesTool.java Mon Mar 19 10:43:27 2007 @@ -0,0 +1,175 @@ +/** + * 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.apps.j2gmigrator.resources.mail; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +import org.apache.apps.j2gmigrator.IFileMigration; +import org.apache.apps.j2gmigrator.IOutput; +import org.apache.apps.j2gmigrator.Tool; +import org.apache.apps.j2gmigrator.resources.utils.Constants; +import org.apache.apps.j2gmigrator.resources.xmlutil.XMLConversionHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.Node; +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 discriptor file + * @return status of the migration + */ + public boolean migrate(File sourceFile) { + 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("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("The mail discripter file " + + mailFilename + + " contains the plain text password authentocation, 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("The Mail Resource File Migration Complete !!!\n"); + } + } catch (DocumentException e) { + out.error("Errors occurs while reading xml descriptor " + + sourceFile.getAbsolutePath() + + ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:" + + e.getMessage()); + } catch (IOException e) { + out.error("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; + } + +}