You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/12/10 23:23:11 UTC

svn commit: r603073 - in /openejb/trunk/openejb3/container/openejb-core/src/main: java/org/apache/openejb/config/AnnotationDeployer.java java/org/apache/openejb/config/AutoConfig.java resources/org/apache/openejb/config/rules/Messages.properties

Author: dblevins
Date: Mon Dec 10 14:23:10 2007
New Revision: 603073

URL: http://svn.apache.org/viewvc?rev=603073&view=rev
Log:
Cleaned messages a bit.  Fixed potential bug with cmp persistence-unit possibly messing up default persistence-unit rules.

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
    openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=603073&r1=603072&r2=603073&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Mon Dec 10 14:23:10 2007
@@ -1350,11 +1350,15 @@
 
                 { // Little quick validation for common mistake
                     Class type = member.getType();
+                    boolean shouldReturn = false;
                     if (EntityManager.class.isAssignableFrom(type)){
                         validationContext.get().fail(consumer.getJndiConsumerName(), "resourceRef.onEntityManager", refName);
+                        shouldReturn = true;
                     } else if (EntityManagerFactory.class.isAssignableFrom(type)){
                         validationContext.get().fail(consumer.getJndiConsumerName(), "resourceRef.onEntityManagerFactory", refName);
+                        shouldReturn = true;
                     }
+                    if (shouldReturn) return;
                 }
                 String type;
                 if (resource.type() != java.lang.Object.class) {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java?rev=603073&r1=603072&r2=603073&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java Mon Dec 10 14:23:10 2007
@@ -192,6 +192,21 @@
     private PersistenceUnit resolvePersistenceRef(LinkResolver<PersistenceUnit> persistenceUnits, PersistenceRef ref, URI moduleURI, String componentName, ValidationContext validation) {
         PersistenceUnit unit = persistenceUnits.resolveLink(ref.getPersistenceUnitName(), moduleURI);
 
+        // Explicitly check if we messed up the "if there's only one,
+        // that's what you get" rule by adding our "cmp" unit.
+        Collection<PersistenceUnit> cmpUnits = persistenceUnits.values("cmp");
+        if (cmpUnits.size() > 0 && persistenceUnits.values().size() - cmpUnits.size() == 1) {
+            // We did, there is exactly one non-cmp unit.  Let's find it.
+            for (PersistenceUnit persistenceUnit : persistenceUnits.values()) {
+                if (!persistenceUnit.getName().equals("cmp")){
+                    // Found it
+                    unit = persistenceUnit;                                                                                                                 
+                    break;
+                }
+            }
+        }
+
+
         // try again using the ref name
         if (unit == null){
             unit = persistenceUnits.resolveLink(ref.getName(), moduleURI);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties?rev=603073&r1=603072&r2=603073&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties Mon Dec 10 14:23:10 2007
@@ -374,8 +374,8 @@
 
 # fail(componentName, "persistenceContextRef.noMatches", refShortName, unitName, join(", ", availableUnits));
 1.persistenceContextRef.noMatches = Persistence unit not found
-2.persistenceContextRef.noMatches = Persistence unit not found: @PersistenceContext(name="{0}", unitName="{1}").  Available units [{1}]
-3.persistenceContextRef.noMatches = The persistence unit "{1}" does not exist.  Update the "{0}" PersistenceContext ref to one of the available units [{1}] or declare the unit in a persistence.xml like the following:\
+2.persistenceContextRef.noMatches = Persistence unit not found for @PersistenceContext(name="{0}", unitName="{1}").  Available units [{2}]
+3.persistenceContextRef.noMatches = The persistence unit "{1}" does not exist.  Update the "{0}" PersistenceContext ref to one of the available units [{2}] or declare the unit in a persistence.xml like the following:\
   <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">\
     <persistence-unit name="{1}">\
       <jta-data-source>java:openejb/Resource/myDataSource</jta-data-source>\
@@ -418,8 +418,8 @@
 
 # fail(componentName, "persistenceUnitRef.noMatches", refShortName, unitName, join(", ", availableUnits));
 1.persistenceUnitRef.noMatches = Persistence unit not found
-2.persistenceUnitRef.noMatches = Persistence unit not found: @PersistenceUnit(name="{0}", unitName="{1}").  Available units [{1}]
-3.persistenceUnitRef.noMatches = The persistence unit "{1}" does not exist.  Update the "{0}" PersistenceUnit ref to one of the available units [{1}] or declare the unit in a persistence.xml like the following:\
+2.persistenceUnitRef.noMatches = Persistence unit not found for ref @PersistenceUnit(name="{0}", unitName="{1}").  Available units [{2}]
+3.persistenceUnitRef.noMatches = The persistence unit "{1}" does not exist.  Update the "{0}" PersistenceUnit ref to one of the available units [{2}] or declare the unit in a persistence.xml like the following:\
   <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">\
     <persistence-unit name="{1}">\
       <jta-data-source>java:openejb/Resource/myDataSource</jta-data-source>\