[jboss-cvs] JBossAS SVN: r67683 - trunk/ejb3/src/main/org/jboss/injection.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Dec 1 05:11:21 EST 2007


Author: scott.stark at jboss.org
Date: 2007-12-01 05:11:21 -0500 (Sat, 01 Dec 2007)
New Revision: 67683

Modified:
   trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
Log:
JBCTS-717, Restore logic for mapped name defaults for xml generated from annotations

Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2007-12-01 07:25:39 UTC (rev 67682)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2007-12-01 10:11:21 UTC (rev 67683)
@@ -145,6 +145,7 @@
          // EJBTHREE-712
          // TODO: refactor with handlePropertyAnnotation
          String resTypeName = envRef.getType();
+         String mappedName = envRef.getMappedName();
          try
          {
             if(resTypeName != null)
@@ -162,6 +163,31 @@
                   InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
                   continue;
                }
+               else if (resType.equals(UserTransaction.class))
+               {
+                  final InjectionContainer ic = container;
+                  InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+                  {
+                     public UserTransactionPropertyInjector create(BeanProperty property)
+                     {
+                        return new UserTransactionPropertyInjector(property, ic);
+                     }
+                  };
+                  if(envRef.getInjectionTargets() != null)
+                  {
+                     InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                     continue;
+                  }
+                  else
+                  {
+                     mappedName = "java:comp/UserTransaction";
+                  }
+               }
+               else if (resType.equals(ORB.class))
+               {
+                  mappedName = "java:comp/ORB";
+                  continue;
+               }
             }
          }
          catch(ClassNotFoundException e)
@@ -171,7 +197,7 @@
          
          String encName = "env/" + envRef.getResourceEnvRefName();
          if (container.getEncInjectors().containsKey(encName)) continue;
-         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+         if (mappedName == null || mappedName.equals(""))
          {
             throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
          }
@@ -242,6 +268,14 @@
       String mappedName = ref.mappedName();
       if (mappedName == null || mappedName.equals(""))
       {
+         // Handle class level @Resource(type=ORB.class)
+         if(ORB.class.isAssignableFrom(ref.type()))
+         {
+            mappedName = "java:comp/ORB";
+         }
+      }
+      if (mappedName == null || mappedName.equals(""))
+      {
          throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
                +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
       }




More information about the jboss-cvs-commits mailing list