geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r558005 - in /geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb: EJBDescriptorTool.java annotation/AnnotationConverter.java
Date Fri, 20 Jul 2007 14:27:33 GMT
Author: pmcmahan
Date: Fri Jul 20 07:27:32 2007
New Revision: 558005

URL: http://svn.apache.org/viewvc?view=rev&rev=558005
Log:
GERONIMO-3328 addition warning messages for EJB 3.0 support for J2G.  Patch submitted by Viet
Nguyen.

Modified:
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/EJBDescriptorTool.java
    geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/annotation/AnnotationConverter.java

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/EJBDescriptorTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/EJBDescriptorTool.java?view=diff&rev=558005&r1=558004&r2=558005
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/EJBDescriptorTool.java
(original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/EJBDescriptorTool.java
Fri Jul 20 07:27:32 2007
@@ -130,11 +130,13 @@
                 try {
                     // get the dom4j representation from the persistence.xml files
                     Document persistenceDoc = XMLConversionHelper.getPersistenceDocument(directoryName);
+                    // populate the differences
+                    HashMap<String, String> diffs = populatePersistenceDifferences();
                     // migrate from the jboss persistence.xml to geronimo's persistence.xml
-                    migratePersistence(persistenceDoc.getRootElement());
+                    migratePersistence(persistenceDoc.getRootElement(), diffs);
                     // construct the path
                     String geronimoPersistenceFileName = directoryName + File.separator
-                    + Constants.PERSISTENCE_XML_FILE;
+                                                                       + Constants.PERSISTENCE_XML_FILE;
                     // save the file
                     XMLConversionHelper.saveGeronimoDocument(geronimoPersistenceFileName,
persistenceDoc);
                     migrated = true;
@@ -148,17 +150,22 @@
                 } catch(IOException e) {
                     out.error("IO exception " + e.getMessage());
                 }
-             }
-         return migrated;
-     }
-    private void migratePersistence(Element rootElement) {
-        // populate the differences
-        HashMap<String, String> diffs = populatePersistenceDifferences();
+            }
+        return migrated;
+    }
+
+    private void migratePersistence(Element rootElement, HashMap<String, String> diffs)
{
         // iterate through all the elements and convert them accordingly
         Element rootChildElement;
+        boolean hasJTA = false;
+        boolean hasNonJTA = false;
         for(Iterator it = rootElement.elements().iterator(); it.hasNext(); ) {
             rootChildElement = (Element) it.next();
-            if(rootChildElement.getName().equals("property")) {
+            if(rootChildElement.getName().equals("jta-data-source")) {
+                hasJTA = true;
+            } else if(rootChildElement.getName().equals("non-jta-data-source")) {
+                hasNonJTA = true;
+            } else if(rootChildElement.getName().equals("property")) {
                 // swap out the name attribute of each <property> element
                 Attribute nameAttr = rootChildElement.attribute("name");
                 String nameValue = nameAttr.getValue();
@@ -183,8 +190,15 @@
                 }
             } else {
                 // recurse until I get to the end of the tree or when I see the <property>
elements
-                migratePersistence(rootChildElement);
+                migratePersistence(rootChildElement, diffs);
             }
+        }
+        // when there is a jta-data-source, provide a non-jta-data-source tag
+        // if it does not already exist
+        if(hasJTA && !hasNonJTA) {
+            QName nonJTA = new QName("non-jta-data-source", rootElement.getNamespace());
+            Element nonJTAElement = rootElement.addElement(nonJTA);
+            out.warn("You should set the text of <non-jta-data-source> to point to
a non-JTA datasource.");
         }
     }
 	    

Modified: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/annotation/AnnotationConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/annotation/AnnotationConverter.java?view=diff&rev=558005&r1=558004&r2=558005
==============================================================================
--- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/annotation/AnnotationConverter.java
(original)
+++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.descriptors/src/org/apache/geronimo/j2g/descriptors/ejb/annotation/AnnotationConverter.java
Fri Jul 20 07:27:32 2007
@@ -43,9 +43,12 @@
     // location of the properties file used to extract the differences
     private final String PROP_ANNOTATION_FILE = "../properties/org.apache.geronimo.j2g.descriptors.ejb.annotation/annotation_differences.properties";
 
-    // annotations that may require further configuratoin by the user
+    // annotations that MAY require further configuration by the user
     private final String[] ambiguousAnnotations = {"@Resource", "@MessageDriven"};
 
+    // annotations that WILL require further configuration by the user
+    private final String[] needsConfigurationAnnotations = {"@Stateless", "@Stateful", "@Resource"};
+
     private final IOutput out;
 
     private Log log = LogFactory.getLog(AnnotationConverter.class);
@@ -131,6 +134,17 @@
                 out.warn(ambiguousAnnotations[i] + " annotations may not be fully specified
in "
                                     + "the deployable. To fix this, you can create what these
" 
                                     + "are supposed to reference and set a dependency on
it.");
+            }
+        }
+        // warn the user if there will be further configuration needed in the web.xml
+        // becaues jboss creates these references automatically, but geronimo does not
+        for(int i = 0; i < needsConfigurationAnnotations.length; i++) {
+            if(fileStr.contains(needsConfigurationAnnotations[i])) {
+                if(needsConfigurationAnnotations[i].equals("@Resource")) {
+                    out.warn("IMPORTANT: You need to update web.xml to include a <resource-ref>
if you are referring to a managed connection factory or <message-destination-ref> if
you are referring to a message destination (e.g. queue).");
+                } else {
+                    out.warn("IMPORTANT: You need to update web.xml to include a <ejb-local-ref>
if you wish to use this EJB in a web app." );
+                }
             }
         }
         return listOfAnnotations;



Mime
View raw message