geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r520023 [6/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 GMT
Added: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml (added)
+++ geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,245 @@
+/**
+ *  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.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE ejb-jar PUBLIC
+      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+   <display-name>CMP 2.0 Lab Jar</display-name>
+
+   <enterprise-beans>
+      <session>
+         <description>JUnit Session Bean Test Runner</description>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <home>net.sourceforge.junitejb.EJBTestRunnerHome</home>
+         <remote>net.sourceforge.junitejb.EJBTestRunner</remote>
+         <ejb-class>net.sourceforge.junitejb.EJBTestRunnerBean</ejb-class>
+         <session-type>Stateless</session-type>
+         <transaction-type>Bean</transaction-type>
+      </session>
+
+      <entity>
+         <display-name>Organization Entity Bean</display-name>
+         <ejb-name>OrganizationEJB</ejb-name>
+
+         <local-home>org.jboss.docs.cmp2.crimeportal.OrganizationHome</local-home>
+         <local>org.jboss.docs.cmp2.crimeportal.Organization</local>
+         <ejb-class>org.jboss.docs.cmp2.crimeportal.OrganizationBean</ejb-class>
+
+         <persistence-type>Container</persistence-type>
+         <prim-key-class>java.lang.String</prim-key-class>
+         <reentrant>False</reentrant> 
+         <cmp-version>2.x</cmp-version>
+         <abstract-schema-name>organization</abstract-schema-name>
+
+         <cmp-field><field-name>name</field-name></cmp-field>
+         <cmp-field><field-name>description</field-name></cmp-field>
+
+         <primkey-field>name</primkey-field>
+      </entity>
+
+      <entity>
+         <display-name>Gangster Entity Bean</display-name>
+         <ejb-name>GangsterEJB</ejb-name>
+
+         <local-home>org.jboss.docs.cmp2.crimeportal.GangsterHome</local-home>
+         <local>org.jboss.docs.cmp2.crimeportal.Gangster</local>
+         <ejb-class>org.jboss.docs.cmp2.crimeportal.GangsterBean</ejb-class>
+
+         <persistence-type>Container</persistence-type>
+         <prim-key-class>java.lang.Integer</prim-key-class>
+         <reentrant>False</reentrant> 
+         <cmp-version>2.x</cmp-version>
+         <abstract-schema-name>gangster</abstract-schema-name>
+         
+         <cmp-field><field-name>gangsterId</field-name></cmp-field>
+         <cmp-field><field-name>name</field-name></cmp-field>
+         <cmp-field><field-name>nickName</field-name></cmp-field>
+         <cmp-field><field-name>badness</field-name></cmp-field>
+         
+         <primkey-field>gangsterId</primkey-field>
+
+         <query>
+            <query-method>
+               <method-name>findBadDudes</method-name>
+               <method-params><method-param>int</method-param></method-params>
+            </query-method>
+            <ejb-ql><![CDATA[
+               SELECT OBJECT(g)
+               FROM gangster g
+               WHERE g.badness > ?1
+            ]]></ejb-ql>
+         </query>
+
+         <query>
+            <query-method>
+               <method-name>ejbSelectBoss</method-name>
+               <method-params>
+                  <method-param>java.lang.String</method-param>
+               </method-params>
+            </query-method>
+            <ejb-ql><![CDATA[
+               SELECT DISTINCT underling.organization.theBoss
+               FROM gangster underling
+               WHERE underling.name = ?1 OR underling.nickName = ?1
+            ]]></ejb-ql>
+         </query>
+      </entity>
+
+      <entity>
+         <display-name>Job Entity Bean</display-name>
+         <ejb-name>JobEJB</ejb-name>
+
+         <local-home>org.jboss.docs.cmp2.crimeportal.JobHome</local-home>
+         <local>org.jboss.docs.cmp2.crimeportal.Job</local>
+         <ejb-class>org.jboss.docs.cmp2.crimeportal.JobBean</ejb-class>
+
+         <persistence-type>Container</persistence-type>
+         <prim-key-class>java.lang.String</prim-key-class>
+         <reentrant>False</reentrant> 
+         <cmp-version>2.x</cmp-version>
+         <abstract-schema-name>job</abstract-schema-name>
+         
+         <cmp-field><field-name>name</field-name></cmp-field>
+         <cmp-field><field-name>score</field-name></cmp-field>
+         <cmp-field><field-name>setupCost</field-name></cmp-field>
+         
+         <primkey-field>name</primkey-field>
+      </entity>
+   </enterprise-beans>
+
+   <relationships>
+      <ejb-relation>
+         <ejb-relation-name>Organization-Gangster</ejb-relation-name>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>org-has-gangsters</ejb-relationship-role-name>
+
+            <multiplicity>One</multiplicity> 
+
+            <relationship-role-source> 
+               <ejb-name>OrganizationEJB</ejb-name> 
+            </relationship-role-source> 
+            
+            <cmr-field>
+               <cmr-field-name>memberGangsters</cmr-field-name> 
+               <cmr-field-type>java.util.Set</cmr-field-type> 
+            </cmr-field> 
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>gangster-belongs-to-org</ejb-relationship-role-name>
+            
+            <multiplicity>Many</multiplicity> 
+            <cascade-delete/>
+            
+            <relationship-role-source>   
+               <ejb-name>GangsterEJB</ejb-name> 
+            </relationship-role-source> 
+          
+            <cmr-field> 
+               <cmr-field-name>organization</cmr-field-name>
+            </cmr-field> 
+         </ejb-relationship-role> 
+      </ejb-relation> 
+
+      <ejb-relation>
+         <ejb-relation-name>Gangster-Jobs</ejb-relation-name>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>gangster-has-jobs</ejb-relationship-role-name>
+
+            <multiplicity>Many</multiplicity> 
+
+            <relationship-role-source> 
+               <ejb-name>GangsterEJB</ejb-name> 
+            </relationship-role-source> 
+            
+            <cmr-field>
+               <cmr-field-name>jobs</cmr-field-name> 
+               <cmr-field-type>java.util.Set</cmr-field-type> 
+            </cmr-field> 
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>job-has-gangsters</ejb-relationship-role-name>
+            
+            <multiplicity>Many</multiplicity> 
+            
+            <relationship-role-source>   
+               <ejb-name>JobEJB</ejb-name> 
+            </relationship-role-source> 
+          
+            <cmr-field> 
+               <cmr-field-name>gangsters</cmr-field-name>
+               <cmr-field-type>java.util.Set</cmr-field-type> 
+            </cmr-field> 
+         </ejb-relationship-role> 
+      </ejb-relation> 
+
+      <ejb-relation>
+         <ejb-relation-name>Organization-Boss</ejb-relation-name>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>organization-has-a-boss</ejb-relationship-role-name>
+
+            <multiplicity>One</multiplicity> 
+
+            <relationship-role-source> 
+               <ejb-name>OrganizationEJB</ejb-name> 
+            </relationship-role-source> 
+            
+            <cmr-field>
+               <cmr-field-name>theBoss</cmr-field-name> 
+            </cmr-field> 
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>boss-runs-an-organization</ejb-relationship-role-name>
+            
+            <multiplicity>One</multiplicity> 
+            
+            <relationship-role-source>   
+               <ejb-name>GangsterEJB</ejb-name> 
+            </relationship-role-source> 
+
+         </ejb-relationship-role> 
+      </ejb-relation> 
+   </relationships>
+
+   <assembly-descriptor>
+
+      <container-transaction>
+         <method>
+            <ejb-name>OrganizationEJB</ejb-name>
+            <method-name>*</method-name>
+         </method>
+         <method>
+            <ejb-name>GangsterEJB</ejb-name>
+            <method-name>*</method-name>
+         </method>
+         <method>
+            <ejb-name>JobEJB</ejb-name>
+            <method-name>*</method-name>
+         </method>
+         <trans-attribute>Required</trans-attribute>
+      </container-transaction>
+
+   </assembly-descriptor>
+</ejb-jar>

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/ejb-jar.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml (added)
+++ geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,162 @@
+/**
+ *  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.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jbosscmp-jdbc PUBLIC   
+   "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
+   "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
+
+<jbosscmp-jdbc>
+   <defaults>
+      <datasource>java:/DefaultDS</datasource>
+      <datasource-mapping>Hypersonic SQL</datasource-mapping>
+      <create-table>true</create-table>
+      <remove-table>true</remove-table>
+      <pk-constraint>true</pk-constraint>
+      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
+   </defaults>
+
+   <enterprise-beans>
+
+      <entity>
+         <ejb-name>OrganizationEJB</ejb-name>
+         <table-name>organization</table-name>
+
+         <cmp-field>
+            <field-name>name</field-name>
+            <column-name>name</column-name>
+         </cmp-field>
+         <cmp-field>
+            <field-name>description</field-name>
+            <column-name>desc</column-name>
+            <not-null/>
+         </cmp-field>
+      </entity>
+
+      <entity>
+         <ejb-name>GangsterEJB</ejb-name>
+         <table-name>gangster</table-name>
+
+         <cmp-field>
+            <field-name>gangsterId</field-name>
+            <column-name>id</column-name>
+         </cmp-field>
+         <cmp-field>
+            <field-name>name</field-name>
+            <column-name>name</column-name>
+            <not-null/>
+         </cmp-field>
+         <cmp-field>
+            <field-name>nickName</field-name>
+            <column-name>nick_name</column-name>
+            <jdbc-type>VARCHAR</jdbc-type>
+            <sql-type>VARCHAR(64)</sql-type>
+         </cmp-field>
+         <cmp-field>
+            <field-name>badness</field-name>
+            <column-name>badness</column-name>
+         </cmp-field>
+      </entity>
+
+      <entity>
+         <ejb-name>JobEJB</ejb-name>
+         <table-name>job</table-name>
+
+         <cmp-field>
+            <field-name>name</field-name>
+            <column-name>name</column-name>
+         </cmp-field>
+         <cmp-field>
+            <field-name>score</field-name>
+            <column-name>score</column-name>
+         </cmp-field>
+         <cmp-field>
+            <field-name>setupCost</field-name>
+            <column-name>setup_cost</column-name>
+         </cmp-field>
+      </entity>
+   </enterprise-beans>
+
+   <relationships>
+      <ejb-relation>
+         <ejb-relation-name>Organization-Gangster</ejb-relation-name>
+         <foreign-key-mapping/>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>org-has-gangsters</ejb-relationship-role-name>
+            <key-fields>
+               <key-field>
+                  <field-name>name</field-name>
+                  <column-name>organization</column-name>
+               </key-field>
+            </key-fields>
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>gangster-belongs-to-org</ejb-relationship-role-name>
+            <key-fields/>
+         </ejb-relationship-role> 
+      </ejb-relation> 
+
+      <ejb-relation>
+         <ejb-relation-name>Gangster-Jobs</ejb-relation-name>
+         <relation-table-mapping>
+            <table-name>gangster_job</table-name>
+         </relation-table-mapping>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>gangster-has-jobs</ejb-relationship-role-name>
+            <key-fields>
+               <key-field>
+                  <field-name>gangsterId</field-name>
+                  <column-name>gangster</column-name>
+               </key-field>
+            </key-fields>
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>job-has-gangsters</ejb-relationship-role-name>
+            <key-fields>
+               <key-field>
+                  <field-name>name</field-name>
+                  <column-name>job</column-name>
+               </key-field>
+            </key-fields>
+         </ejb-relationship-role> 
+      </ejb-relation> 
+
+      <ejb-relation>
+         <ejb-relation-name>Organization-Boss</ejb-relation-name>
+         <foreign-key-mapping/>
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>organization-has-a-boss</ejb-relationship-role-name>
+            <key-fields/>
+         </ejb-relationship-role> 
+
+         <ejb-relationship-role> 
+            <ejb-relationship-role-name>boss-runs-an-organization</ejb-relationship-role-name>
+            <key-fields>
+               <key-field>
+                  <field-name>gangsterId</field-name>
+                  <column-name>the_boss</column-name>
+               </key-field>
+            </key-fields>
+         </ejb-relationship-role> 
+      </ejb-relation> 
+   </relationships>
+</jbosscmp-jdbc>

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test-resources/jbosscmp-jdbc.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,42 @@
+/**
+ *  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.cmp;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+
+import org.apache.apps.j2gmigrator.descriptors.DescriptorsTool;
+import org.apache.apps.j2gmigrator.descriptors.cmp.CMPDescriptorTool;
+
+
+/**
+ * Author: amila
+ * Date: Aug 30, 2006
+ */
+public class TestCMPDescriptorsTool extends TestCase {
+
+    public void testMigrate() {
+
+        DescriptorsTool descriptorsTool = new DescriptorsTool();
+        File file = new File("test-resources/jbosscmp-jdbc.xml");
+        CMPDescriptorTool cmpDescriptorTool = new CMPDescriptorTool();
+        cmpDescriptorTool.migrate(file);
+
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestCMPDescriptorsTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,37 @@
+/**
+ *  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.cmp;
+
+import junit.framework.TestCase;
+
+import org.apache.apps.j2gmigrator.descriptors.cmp.EJBJarXmlProcessor;
+import org.apache.apps.j2gmigrator.descriptors.cmp.dto.Relationships;
+import org.dom4j.DocumentException;
+
+public class TestEJBjarXmlProcessor extends TestCase {
+
+    public void testGetRelationships(){
+        EJBJarXmlProcessor ejbJarXmlProcessor = new EJBJarXmlProcessor("test-resources/jboss-xml/ejb-jar.xml");
+        try {
+            Relationships relationships =  ejbJarXmlProcessor.getRelationships();
+            System.out.println("ok");
+        } catch (DocumentException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-cmp-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/cmp/TestEJBjarXmlProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/META-INF/MANIFEST.MF (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ejb_migration_plugin Plug-in
+Bundle-SymbolicName: com.ibm.j2g.descriptors.ejb; 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.util,com.ibm.j2g.descriptors
+Eclipse-LazyStart: true
+Bundle-ClassPath: .

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,26 @@
+/**
+ *  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/,\
+               .,\
+               lib/dom4j-1.6.1.jar,\
+               lib/jaxen-1.1-beta-6.jar,\
+               lib/junit-3.8.1.jar,\
+               lib/log4j-1.2.12.jar,\
+               lib/pull-parser-2.1.10.jar

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-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.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension point="com.ibm.j2g.descriptors.migrations">
+      <migration class="com.ibm.j2g.descriptors.ejb.EJBDescriptorTool"/>
+   </extension>
+</plugin>

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-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.
+log4j.rootLogger=INFO
+
+#define loggers
+#pluging logger
+log4j.logger.com.ibm.j2g=DEBUG,console
+
+# console is set to be a ConsoleAppender.
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+
+# console uses PatternLayout.
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+#log4j.appender.console.layout.ConversionPattern=[%t] %-5p %l - %m%n
+log4j.appender.console.layout.ConversionPattern=[%t] %-5p - %m%n
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/common-logging.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,206 @@
+/**
+ *  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.ejb;
+
+
+import org.apache.apps.j2gmigrator.IFileMigration;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.descriptors.ejb.bean.EntityBeanMigrator;
+import org.apache.apps.j2gmigrator.descriptors.ejb.bean.SessionBeanMigrator;
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.security.SecurityElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.util.Constants;
+import org.apache.apps.j2gmigrator.descriptors.xmlutil.XMLConversionHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+public class EJBDescriptorTool implements IFileMigration {
+
+    private IOutput out = Tool.getCurrent().getOutput();
+
+    private Log logger = LogFactory.getLog(EJBDescriptorTool.class);
+
+    private EnvirionmentElementProcessor envirionmentElementProcessor;
+
+    private SessionBeanMigrator sessionBeanMigrator;
+
+    private EntityBeanMigrator entityBeanMigrator;
+
+    private NamingElementProcessor namingElementProcessor;
+
+    private SecurityElementProcessor securityElementProcessor;
+
+    public EJBDescriptorTool() {
+
+        envirionmentElementProcessor = new EnvirionmentElementProcessor();
+        namingElementProcessor = new NamingElementProcessor(envirionmentElementProcessor);
+        sessionBeanMigrator = new SessionBeanMigrator(envirionmentElementProcessor,
+                namingElementProcessor);
+        entityBeanMigrator = new EntityBeanMigrator(envirionmentElementProcessor,
+                namingElementProcessor);
+        securityElementProcessor = new SecurityElementProcessor();
+
+    }
+
+    /**
+     * migrates both the jboss.xml and jbosscmp-jdbc.xml file to openejb-jar.xml
+     * in geronimo
+     * 
+     * @param file
+     * @return migrate sucess or not
+     */
+
+    public boolean migrate(File file) {
+        boolean migrated = false;
+            String directoryName = file.getParent();
+            String jbossFileName = file.getName();
+            logger.debug("Directory Name ==> " + directoryName + " jboss file Name ==> "
+                    + jbossFileName);
+
+            if (jbossFileName.equals(Constants.JBOSS_JBOSS_XML_FILE)) {
+                out.info("Converting Jboss.xml file in " + directoryName);
+                try {
+                    // check whether the jbosscmp-jdbc.xml file is present and
+                    // if so load it and process it.
+                    Document jbossDocument = XMLConversionHelper.getDocument(file);
+                    Document geronimoDocument = XMLConversionHelper
+                            .getOpenEJBJarDocument(directoryName);
+                    migrate(jbossDocument.getRootElement(), geronimoDocument.getRootElement());
+                    String geronimoOpenEjbJarFileName = directoryName + File.separator
+                            + Constants.GERONIMO_OPEN_EJB_XML_FILE;
+                    XMLConversionHelper.saveOpenEJBDocument(geronimoOpenEjbJarFileName,
+                            geronimoDocument);
+                    migrated = true;
+                    out.info("Successfully migrated the Jboss.xml file in "
+                            + directoryName + ", with the error and warning messages as shown");
+                } catch (DocumentException e) {
+                	out.error("Errors occurs while reading xml descriptor "
+    						+ file.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());
+                }
+            } else if (jbossFileName.equals(Constants.EJB_JAR_XML_FILE)){
+                out.info("Converting ejb-jar.xml file in " + directoryName);
+                out.info("Nothing to convert. Keep the file as it is");
+            }
+        return migrated;
+    }
+
+    private void migrate(Element jbossRootElement, Element geronimoRootElement) {
+
+        // iterate through all the elements and convert them accordingly
+        Element jbossRootChildElement;
+        for (Iterator iter = jbossRootElement.elements().iterator(); iter.hasNext();) {
+            jbossRootChildElement = (Element) iter.next();
+            if (jbossRootChildElement.getName().equals("security-domain")) {
+                securityElementProcessor.setSecurityDomain(jbossRootChildElement.getText());
+            } else if (jbossRootChildElement.getName().equals("enterprise-beans")) {
+                logger.debug("migrating enterprise-beans");
+                // process the enterprise bean element
+                // add enterprise beans element to geronimo
+                // this element is in the same name space as the root element
+                Element geronimoEnterpriseBean = XMLConversionHelper.getGeronimoElement(
+                        geronimoRootElement, "//ejb:enterprise-beans", "enterprise-beans",
+                        geronimoRootElement.getNamespace());
+                migrateEnterpriseBeans(jbossRootChildElement, geronimoEnterpriseBean);
+            } else if (jbossRootChildElement.getName().equals("assembly-descriptor")) {
+                migrateAssemblyDescriptor(jbossRootChildElement, geronimoRootElement);
+            } else {
+                out.warn("The Element '" + jbossRootChildElement.getName() + "' is not supported",
+                        XMLConversionHelper.getLineNumber(jbossRootChildElement),
+                        XMLConversionHelper.getColumnNumber(jbossRootChildElement));
+                logger.debug("The Element '" + jbossRootChildElement.getName()
+                        + "' is not supported");
+            }
+        }
+    }
+
+    private void migrateAssemblyDescriptor(Element jbossAssemblyDescriptor,
+            Element geronimoRootElement) {
+
+        Element jbossAssemblyDescriptorChildElement;
+        for (Iterator iter = jbossAssemblyDescriptor.elements().iterator(); iter.hasNext();) {
+            jbossAssemblyDescriptorChildElement = (Element) iter.next();
+            if (jbossAssemblyDescriptorChildElement.getName().equals("security-role")) {
+                Element geronimoRoleMapping = securityElementProcessor
+                        .getGeronimoSecurityRoleElement(geronimoRootElement);
+                securityElementProcessor.migrateSecurityRole(jbossAssemblyDescriptorChildElement,
+                        geronimoRoleMapping);
+            } else {
+                out.warn("The Element '" + jbossAssemblyDescriptorChildElement.getName()
+                        + "' is not supported", XMLConversionHelper
+                        .getLineNumber(jbossAssemblyDescriptorChildElement), XMLConversionHelper
+                        .getColumnNumber(jbossAssemblyDescriptorChildElement));
+                logger.debug("The Element '" + jbossAssemblyDescriptorChildElement.getName()
+                        + "' is not supported");
+            }
+        }
+    }
+
+    /**
+     * this migrates the enterprise-beans part
+     * 
+     * @param jbossEnterpriseBeans
+     * @param geronimoEnterpriseBeans
+     */
+    private void migrateEnterpriseBeans(Element jbossEnterpriseBeans,
+            Element geronimoEnterpriseBeans) {
+
+        Element jbossEnterpriseBeanChildElement;
+        for (Iterator iter = jbossEnterpriseBeans.elements().iterator(); iter.hasNext();) {
+            jbossEnterpriseBeanChildElement = (Element) iter.next();
+            if (jbossEnterpriseBeanChildElement.getName().equals("session")) {
+                // session beans can only come from jboss.xml file
+                logger.debug("migrating session beans");
+                QName qname = new QName("session", geronimoEnterpriseBeans.getNamespace());
+                Element geronimoSession = geronimoEnterpriseBeans.addElement(qname);
+                sessionBeanMigrator.migrateBean(jbossEnterpriseBeanChildElement, geronimoSession);
+            } else if (jbossEnterpriseBeanChildElement.getName().equals("entity")) {
+                logger.debug("migrating entity beans");
+                // get the session ejb name
+                Element ejbNameElement = jbossEnterpriseBeanChildElement.element("ejb-name");
+                String ejbName = ejbNameElement.getText();
+                logger.debug("Converting ejb session with name ==> " + ejbName);
+                // create a session bean in geronimo
+                String xpath = "//ejb:enterprise-beans/ejb:entity[ejb:ejb-name/text() = '"
+                        + ejbName + "']";
+                logger.debug("Find existing ejb using query ==>" + xpath);
+                Element geronimoEntity = XMLConversionHelper.getGeronimoElement(
+                        geronimoEnterpriseBeans, xpath, "entity", geronimoEnterpriseBeans
+                                .getNamespace());
+                entityBeanMigrator.migrateBean(jbossEnterpriseBeanChildElement, geronimoEntity);
+            } else {
+                out.warn("The Element '" + jbossEnterpriseBeanChildElement.getName()
+                        + "' is not supported", XMLConversionHelper
+                        .getLineNumber(jbossEnterpriseBeanChildElement), XMLConversionHelper
+                        .getColumnNumber(jbossEnterpriseBeanChildElement));
+                logger.debug("The Element '" + jbossEnterpriseBeanChildElement.getName()
+                        + "' is not supported");
+            }
+        }
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/EJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,188 @@
+/**
+ *  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.ejb.bean;
+
+import org.dom4j.Element;
+import org.dom4j.QName;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.util.Constants;
+import org.apache.apps.j2gmigrator.descriptors.xmlutil.XMLConversionHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+
+public class BeanMigrator {
+
+    private IOutput out = Tool.getCurrent().getOutput();
+
+    private Log logger = LogFactory.getLog(BeanMigrator.class);
+
+    protected EnvirionmentElementProcessor envirionmentElementProcessor;
+
+    protected NamingElementProcessor namingElementProcessor;
+
+    public BeanMigrator(EnvirionmentElementProcessor envirionmentElementProcessor,
+            NamingElementProcessor namingElementProcessor) {
+        this.envirionmentElementProcessor = envirionmentElementProcessor;
+        this.namingElementProcessor = namingElementProcessor;
+    }
+
+    /**
+     * migrates the common methods for all the methods
+     * 
+     * @param jbossBeanElment
+     * @param geronimoBeanElemnt
+     * @return migrated or not
+     */
+    public boolean migrateBean(Element jbossBeanElment, Element geronimoBeanElemnt) {
+        boolean migrated = true;
+        if (jbossBeanElment.getName().equals("ejb-name")) {
+            // add ejb name to geronimo bean
+            // we have to check the ejb name since ejb name can put by the
+            // jbosscmp-jar as well.
+            String xpath = "//ejb:ejb-name[text() ='" + jbossBeanElment.getText() + "']";
+            logger.debug("Find existing ejb names with xpath ==> " + xpath);
+            if (!XMLConversionHelper.isNodeAvailable(geronimoBeanElemnt, xpath)) {
+                logger.debug("adding ejb-name to bean with name ==> " + jbossBeanElment.getText());
+                QName qname = new QName("ejb-name", geronimoBeanElemnt.getNamespace());
+                Element geronimoEJBName = geronimoBeanElemnt.addElement(qname);
+                geronimoEJBName.setText(jbossBeanElment.getText());
+            } else {
+                logger.debug("ejb-name already exists");
+            }
+
+        } else if (jbossBeanElment.getName().equals("resource-ref")) {
+            QName qname = new QName("resource-ref", geronimoBeanElemnt
+                    .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+            Element geronimoResourceRef = geronimoBeanElemnt.addElement(qname);
+            namingElementProcessor.migrateResourceRef(jbossBeanElment, geronimoResourceRef);
+        } else if (jbossBeanElment.getName().equals("ejb-ref")) {
+            // get the jndi name
+            String jndiName = jbossBeanElment.elementText("jndi-name");
+            // find bean element matching jndiname
+            String xpath = "//enterprise-beans/session[jndi-name/text() ='" + jndiName
+                    + "']/ejb-name";
+            Element element = XMLConversionHelper.getJbossElement(jbossBeanElment.getDocument(),
+                    xpath);
+
+            // check reference for a entity bean
+            if (element == null) {
+                xpath = "//enterprise-beans/entity[jndi-name/text() ='" + jndiName + "']/ejb-name";
+                element = XMLConversionHelper.getJbossElement(jbossBeanElment.getDocument(), xpath);
+            }
+
+            if (element != null) {
+
+                QName qname = new QName("ejb-ref", geronimoBeanElemnt
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoEJBRef = geronimoBeanElemnt.addElement(qname);
+                migrateEJBRef(jbossBeanElment, geronimoEJBRef);
+                qname = new QName("ejb-link", geronimoEJBRef
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoEJBLink = geronimoEJBRef.addElement(qname);
+                geronimoEJBLink.setText(element.getText());
+
+            } else {
+                out.error(
+                        "The Element 'ejb-ref' is not supported. It is not possible to determine the EJB name "
+                                + "from the jndi name. Please migrate this element manually",
+                        XMLConversionHelper.getLineNumber(jbossBeanElment), XMLConversionHelper
+                                .getColumnNumber(jbossBeanElment));
+                logger
+                        .error("The Element 'ejb-ref' is not supported. It is not possible to determine the EJB name "
+                                + "from the jndi name. Please migrate this element manually");
+            }
+
+        } else if (jbossBeanElment.getName().equals("ejb-local-ref")) {
+
+            // get the jndi name
+            String jndiName = jbossBeanElment.elementText("local-jndi-name");
+            // find bean element matching jndiname
+            String xpath = "//enterprise-beans/session[local-jndi-name/text() ='" + jndiName
+                    + "']/ejb-name";
+            Element element = XMLConversionHelper.getJbossElement(jbossBeanElment.getDocument(),
+                    xpath);
+
+            // check reference for a entity bean
+            if (element == null) {
+                xpath = "//enterprise-beans/entity[local-jndi-name/text() ='" + jndiName
+                        + "']/ejb-name";
+                element = XMLConversionHelper.getJbossElement(jbossBeanElment.getDocument(), xpath);
+            }
+
+            if (element != null) {
+                logger.debug("EJB reference found");
+                QName qname = new QName("ejb-local-ref", geronimoBeanElemnt
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoEJBLocalRef = geronimoBeanElemnt.addElement(qname);
+                migrateEJBLocalRef(jbossBeanElment, geronimoEJBLocalRef);
+                qname = new QName("ejb-link", geronimoEJBLocalRef
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoEJBLink = geronimoEJBLocalRef.addElement(qname);
+                geronimoEJBLink.setText(element.getText());
+
+            } else {
+                out.error(
+                        "The Element 'ejb-local-ref' is not supported. It is not possible to determine the EJB name "
+                                + "from the jndi name. Please migrate this element manually",
+                        XMLConversionHelper.getLineNumber(jbossBeanElment), XMLConversionHelper
+                                .getColumnNumber(jbossBeanElment));
+                logger
+                        .error("The Element 'ejb-local-ref' is not supported. It is not possible to determine the EJB name "
+                                + "from the jndi name. Please migrate this element manually");
+            }
+
+        } else {
+            migrated = false;
+        }
+
+        return migrated;
+    }
+
+    private void migrateEJBRef(Element jbossEJBRef, Element geronimoEJBRef) {
+
+        Element jbossEJBChildRef;
+        for (Iterator iter = jbossEJBRef.elementIterator(); iter.hasNext();) {
+            jbossEJBChildRef = (Element) iter.next();
+            if (jbossEJBChildRef.getName().equals("ejb-ref-name")) {
+                QName qname = new QName("ref-name", geronimoEJBRef
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoRefName = geronimoEJBRef.addElement(qname);
+                geronimoRefName.setText(jbossEJBChildRef.getText());
+            }
+        }
+    }
+
+    private void migrateEJBLocalRef(Element jbossEJBRef, Element geronimoEJBRef) {
+
+        Element jbossEJBChildRef;
+        for (Iterator iter = jbossEJBRef.elementIterator(); iter.hasNext();) {
+            jbossEJBChildRef = (Element) iter.next();
+            if (jbossEJBChildRef.getName().equals("ejb-ref-name")) {
+                QName qname = new QName("ref-name", geronimoEJBRef
+                        .getNamespaceForPrefix(Constants.NAMING_NAME_SPACE_PREFIX));
+                Element geronimoRefName = geronimoEJBRef.addElement(qname);
+                geronimoRefName.setText(jbossEJBChildRef.getText());
+            }
+        }
+    }
+
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/BeanMigrator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,54 @@
+/**
+ *  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.ejb.bean;
+
+import org.dom4j.Element;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+
+public class EntityBeanMigrator extends JNDIBeanMigrator {
+
+    private IOutput out = Tool.getCurrent().getOutput();
+    private Log logger = LogFactory.getLog(EntityBeanMigrator.class);
+
+    public EntityBeanMigrator(EnvirionmentElementProcessor envirionmentElementProcessor,
+            NamingElementProcessor namingElementProcessor) {
+        super(envirionmentElementProcessor, namingElementProcessor);
+    }
+
+    public boolean migrateBean(Element jbossEntity, Element geronimoEntity) {
+        Element jbossEntityChildElement;
+        for (Iterator iter = jbossEntity.elements().iterator(); iter.hasNext();) {
+            jbossEntityChildElement = (Element) iter.next();
+
+            // do the migration only if super classes can not
+            if (!super.migrateBean(jbossEntityChildElement, geronimoEntity)) {
+                // TODO: entity bean secific migrations
+                out.warn("The Element '" + jbossEntityChildElement.getName()
+                        + "' is not supported");
+            }
+        }
+        return true;
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/EntityBeanMigrator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,53 @@
+/**
+ *  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.ejb.bean;
+
+
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+import org.dom4j.Element;
+import org.dom4j.QName;
+
+public class JNDIBeanMigrator extends BeanMigrator {
+
+
+    public JNDIBeanMigrator(EnvirionmentElementProcessor envirionmentElementProcessor,
+            NamingElementProcessor namingElementProcessor) {
+        super(envirionmentElementProcessor, namingElementProcessor);
+    }
+
+    public boolean migrateBean(Element jbossBeanElment, Element geronimoBeanElemnt) {
+        boolean migrated = true;
+        if (!super.migrateBean(jbossBeanElment, geronimoBeanElemnt)) {
+            if (jbossBeanElment.getName().equals("jndi-name")) {
+                // add ejb name to geronimo session
+                QName qname = new QName("jndi-name", geronimoBeanElemnt.getNamespace());
+                Element geronimoJndiName = geronimoBeanElemnt.addElement(qname);
+                geronimoJndiName.setText(jbossBeanElment.getText());
+            } else if (jbossBeanElment.getName().equals("local-jndi-name")) {
+                // add ejb name to geronimo session
+                QName qname = new QName("local-jndi-name", geronimoBeanElemnt.getNamespace());
+                Element geronimoLocalJndiName = geronimoBeanElemnt.addElement(qname);
+                geronimoLocalJndiName.setText(jbossBeanElment.getText());
+            } else {
+                migrated = false;
+            }
+        }
+        return migrated;
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/JNDIBeanMigrator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,29 @@
+/**
+ *  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.ejb.bean;
+
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+
+
+public class MessageDrivenBeanMigrator extends BeanMigrator {
+
+    public MessageDrivenBeanMigrator(EnvirionmentElementProcessor envirionmentElementProcessor,
+            NamingElementProcessor namingElementProcessor) {
+        super(envirionmentElementProcessor, namingElementProcessor);
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/MessageDrivenBeanMigrator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,53 @@
+/**
+ *  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.ejb.bean;
+
+import org.dom4j.Element;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.descriptors.env.EnvirionmentElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.naming.NamingElementProcessor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+
+
+public class SessionBeanMigrator extends JNDIBeanMigrator {
+
+    private static Log logger = LogFactory.getLog(SessionBeanMigrator.class);
+    private IOutput out = Tool.getCurrent().getOutput();
+
+    public SessionBeanMigrator(EnvirionmentElementProcessor envirionmentElementProcessor,
+            NamingElementProcessor namingElementProcessor) {
+        super(envirionmentElementProcessor, namingElementProcessor);
+    }
+
+    public boolean migrateBean(Element jbossSession, Element geronimoSession) {
+        Element jbossSessionChildElement;
+        for (Iterator iter = jbossSession.elements().iterator(); iter.hasNext();) {
+            jbossSessionChildElement = (Element) iter.next();
+            // do the migration only if super classes can not
+            if (!super.migrateBean(jbossSessionChildElement, geronimoSession)) {
+                // TODO: session bean secific migrations
+                out.warn("The Element '" + jbossSessionChildElement.getName()
+                        + "' is not supported");
+            }
+        }
+        return true;
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/ejb/bean/SessionBeanMigrator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,42 @@
+/**
+ *  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.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss PUBLIC
+   "-//JBoss//DTD JBOSS 3.0//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
+
+<jboss>
+   <enterprise-beans>
+      <session>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <jndi-name>ejb/EJBTestRunner</jndi-name>
+      </session>
+      <entity>
+         <ejb-name>OrganizationEJB</ejb-name>
+         <local-jndi-name>crimeportal/Organization</local-jndi-name>
+      </entity>
+      <entity>
+         <ejb-name>GangsterEJB</ejb-name>
+         <local-jndi-name>crimeportal/Gangster</local-jndi-name>
+      </entity>
+      <entity>
+         <ejb-name>JobEJB</ejb-name>
+         <local-jndi-name>crimeportal/Job</local-jndi-name>
+      </entity>
+   </enterprise-beans>
+</jboss>

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test-resources/jboss.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java (added)
+++ geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,41 @@
+/**
+ *  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.ejb;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+
+import org.apache.apps.j2gmigrator.descriptors.DescriptorsTool;
+import org.apache.apps.j2gmigrator.descriptors.ejb.EJBDescriptorTool;
+
+
+/**
+ * Author: amila
+ * Date: Aug 22, 2006
+ */
+public class TestEJBDescriptorTool extends TestCase {
+
+    public void testMigrate() {
+
+        DescriptorsTool descriptorsTool = new DescriptorsTool();
+        File file = new File("test-resources/jboss.xml");
+        EJBDescriptorTool ejbDescriptorTool = new EJBDescriptorTool();
+        ejbDescriptorTool.migrate(file);
+
+    }
+}

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/ejb-migration-plugin/test/org/apache/apps/j2gmigrator/descriptors/ejb/TestEJBDescriptorTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/META-INF/MANIFEST.MF (added)
+++ geronimo/sandbox/j2g/src2/enterprise-migration-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: Enterprise_migration_plugin Plug-in
+Bundle-SymbolicName: com.ibm.j2g.descriptors.app; 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.descriptors,
+ com.ibm.j2g.util
+Eclipse-LazyStart: true
+Bundle-ClassPath: .

Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/build.properties (added)
+++ geronimo/sandbox/j2g/src2/enterprise-migration-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/enterprise-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml (added)
+++ geronimo/sandbox/j2g/src2/enterprise-migration-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.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+    <extension point="com.ibm.j2g.descriptors.migrations">
+      	<migration class="com.ibm.j2g.descriptors.app.ApplicationDescriptorTool"/>
+   </extension>
+</plugin>

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties (added)
+++ geronimo/sandbox/j2g/src2/enterprise-migration-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.
+log4j.rootLogger=INFO
+
+#define loggers
+#pluging logger
+log4j.logger.com.ibm.j2g= DEBUG,console
+
+# console is set to be a ConsoleAppender.
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+
+# console uses PatternLayout.
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+#log4j.appender.console.layout.ConversionPattern=[%t] %-5p %l - %m%n
+log4j.appender.console.layout.ConversionPattern=[%t] %-5p - %m%n
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java (added)
+++ geronimo/sandbox/j2g/src2/enterprise-migration-plugin/src/org/apache/apps/j2gmigrator/descriptors/app/ApplicationDescriptorTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,144 @@
+/**
+ *  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 java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.QName;
+import org.apache.apps.j2gmigrator.IFileMigration;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.descriptors.security.SecurityElementProcessor;
+import org.apache.apps.j2gmigrator.descriptors.util.Constants;
+import org.apache.apps.j2gmigrator.descriptors.xmlutil.XMLConversionHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ApplicationDescriptorTool implements IFileMigration {
+
+    private IOutput out = Tool.getCurrent().getOutput();
+
+    private String directoryName;
+
+    private Log logger = LogFactory.getLog(ApplicationDescriptorTool.class);
+
+    private SecurityElementProcessor securityElementProcessor;
+
+    public ApplicationDescriptorTool() {
+        securityElementProcessor = new SecurityElementProcessor();
+    }
+
+    public boolean migrate(File file) {
+        boolean migrated = false;
+            directoryName = file.getParent();
+            String jbossFileName = file.getName();
+            logger.debug("Directory Name ==> " + directoryName + " jboss file Name ==> "
+                    + jbossFileName);
+
+            if (jbossFileName.equals(Constants.JBOSS_JBOSS_APPLICATION_XML_FILE)) {
+                out.info("Converting Jboss-app.xml file in " + directoryName);
+                try {
+                    // check whether the jbosscmp-jdbc.xml file is present and
+                    // if so load it and process it.
+                    Document jbossDocument = XMLConversionHelper.getDocument(file);
+                    Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument(
+                            Constants.APPLICATION_NAME_SPACE, "application");
+                    migrate(jbossDocument.getRootElement(), geronimoDocument.getRootElement());
+                    String geronimoOpenEjbJarFileName = directoryName + File.separator
+                            + Constants.GERONIMO_APPLICATION_XML_FILE;
+                    XMLConversionHelper.saveGeronimoDocument(geronimoOpenEjbJarFileName,
+                            geronimoDocument);
+                    migrated = true;
+                    out.info("Successfully migrated the Jboss-app.xml file in "
+                            + directoryName + ", with the error and warning messages as shown");
+                } catch (DocumentException e) {
+                	out.error("Errors occurs while reading xml descriptor "
+    						+ file.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());
+                }
+            } else if (jbossFileName.equals(Constants.APPLICATION_XML_FILE)){
+                out.info("Converting application.xml file in " + directoryName);
+                out.info("Nothing to convert. Keep the file as it is");
+            }
+        return migrated;
+    }
+
+    private void migrate(Element jbossRootElement, Element geronimoRootElement) {
+
+        Element jbossRootChildElement;
+        for (Iterator iter = jbossRootElement.elements().iterator(); iter.hasNext();) {
+            jbossRootChildElement = (Element) iter.next();
+            if (jbossRootChildElement.getName().equals("security-domain")) {
+                securityElementProcessor.setSecurityDomain(jbossRootChildElement.getText());
+            } else if (jbossRootChildElement.getName().equals("unauthenticated-principal")) {
+                // set the default principal in security element processor
+                securityElementProcessor.setDefaultPrincipal(jbossRootChildElement.getText());
+            } else if (jbossRootChildElement.getName().equals("security-role")) {
+                Element geronimoRoleMapping = securityElementProcessor
+                        .getGeronimoSecurityRoleElement(geronimoRootElement);
+                securityElementProcessor.migrateSecurityRole(jbossRootChildElement,
+                        geronimoRoleMapping);
+            } else {
+                out.warn("The Element '" + jbossRootChildElement.getName() + "' does not support ",
+                        XMLConversionHelper.getLineNumber(jbossRootChildElement),
+                        XMLConversionHelper.getColumnNumber(jbossRootChildElement));
+                logger.debug("The Element '" + jbossRootChildElement.getName()
+                        + "' does not support ");
+            }
+        }
+    }
+
+    private void migrateModule(Element jbossModule, Element geronimoModule) {
+
+        Element jbossModuleChildElement;
+        for (Iterator iter = jbossModule.elements().iterator(); iter.hasNext();) {
+            jbossModuleChildElement = (Element) iter.next();
+            if (jbossModuleChildElement.getName().equals("service")) {
+                // TODO: figure out properly
+                // for the moment we add connector element to replace the
+                // service
+                String serviceName = jbossModuleChildElement.getText();
+                String firstPart = serviceName.substring(0, serviceName.lastIndexOf("."));
+                // add conector element
+                QName qname = new QName("connector", geronimoModule.getNamespace());
+                Element connectorElement = geronimoModule.addElement(qname);
+                connectorElement.setText(firstPart + ".rar");
+
+                // add alt-dd element
+                qname = new QName("alt-dd", geronimoModule.getNamespace());
+                Element altDDElement = geronimoModule.addElement(qname);
+                altDDElement.setText(firstPart + ".xml");
+            } else {
+                out.warn("The Element '" + jbossModuleChildElement.getName()
+                        + "' does not support ", XMLConversionHelper
+                        .getLineNumber(jbossModuleChildElement), XMLConversionHelper
+                        .getColumnNumber(jbossModuleChildElement));
+                logger.debug("The Element '" + jbossModuleChildElement.getName()
+                        + "' does not support ");
+            }
+        }
+    }
+}



Mime
View raw message