[jboss-cvs] JBossAS SVN: r112243 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/common and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 15 12:03:24 EDT 2011


Author: jesper.pedersen
Date: 2011-09-15 12:03:24 -0400 (Thu, 15 Sep 2011)
New Revision: 112243

Modified:
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersLogger.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
   projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
Log:
[JBJCA-675] Feedback with incorrect configuration

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java	2011-09-14 20:43:33 UTC (rev 112242)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java	2011-09-15 16:03:24 UTC (rev 112243)
@@ -107,7 +107,7 @@
     * Unable to inject
     * @param clz The class name
     * @param name The name
-    * @param value
+    * @param value The value
     * @return The value
     */
    @Message(id = 20060, value = "Unable to inject: %s property: %s value: %s")

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersLogger.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersLogger.java	2011-09-14 20:43:33 UTC (rev 112242)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersLogger.java	2011-09-15 16:03:24 UTC (rev 112243)
@@ -106,4 +106,26 @@
    @LogMessage(level = WARN)
    @Message(id = 20008, value = "Invalid config-property: %s")
    public void invalidConfigProperty(String cp);
+
+   /**
+    * Connection definition invalid
+    * @param clz The class name
+    */
+   @LogMessage(level = WARN)
+   @Message(id = 20009, value = "Invalid connection definition with class-name: %s")
+   public void connectionDefinitionInvalid(String clz);
+
+   /**
+    * Connection definition class-name null
+    */
+   @LogMessage(level = ERROR)
+   @Message(id = 20010, value = "Connection definition with missing class-name")
+   public void connectionDefinitionNull();
+
+   /**
+    * Admin object class-name null
+    */
+   @LogMessage(level = ERROR)
+   @Message(id = 20011, value = "Admin object with missing class-name")
+   public void adminObjectNull();
 }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-09-14 20:43:33 UTC (rev 112242)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-09-15 16:03:24 UTC (rev 112243)
@@ -445,10 +445,12 @@
     * @param clz The fully quilified class name for the managed connection factory
     * @param mcfs The managed connection facotries
     * @param defs The connection definitions
+    * @param cl The class loader
     * @return The metadata; <code>null</code> if none could be found
     * @exception DeployException Thrown in case of configuration error
     */
-   protected Set<CommonConnDef> findConnectionDefinitions(String clz, List<String> mcfs, List<CommonConnDef> defs)
+   protected Set<CommonConnDef> findConnectionDefinitions(String clz, List<String> mcfs, List<CommonConnDef> defs,
+                                                          ClassLoader cl)
       throws DeployException
    {
       Set<CommonConnDef> result = null;
@@ -466,10 +468,23 @@
                throw new DeployException(clz + " not a valid connection definition");
             }
 
-            result = new HashSet<CommonConnDef>(1);
-            result.add(cd);
+            boolean add = true;
+            if (cd.getClassName() != null)
+            {
+               if (!verifyManagedConnectionFactory(cd.getClassName(), cl))
+               {
+                  log.connectionDefinitionInvalid(cd.getClassName());
+                  add = false;
+               }
+            }
 
-            return result;
+            if (add)
+            {
+               result = new HashSet<CommonConnDef>(1);
+               result.add(cd);
+
+               return result;
+            }
          }
 
          // If there are multiple definitions the MCF class name is mandatory
@@ -478,12 +493,24 @@
 
          for (CommonConnDef cd : defs)
          {
-            if (clz.equals(cd.getClassName()))
+            if (cd.getClassName() == null)
             {
-               if (result == null)
-                  result = new HashSet<CommonConnDef>();
+               log.connectionDefinitionNull();
+            }
+            else
+            {
+               if (clz.equals(cd.getClassName()))
+               {
+                  if (result == null)
+                     result = new HashSet<CommonConnDef>();
 
-               result.add(cd);
+                  result.add(cd);
+               }
+               else
+               {
+                  if (!verifyManagedConnectionFactory(cd.getClassName(), cl))
+                     log.connectionDefinitionInvalid(cd.getClassName());
+               }
             }
          }
       }
@@ -492,6 +519,31 @@
    }
 
    /**
+    * Verify the MCF definition
+    * @param clz The class name
+    * @param cl The class loader
+    * @return True if MCF, otherwise false
+    */
+   private boolean verifyManagedConnectionFactory(String clz, ClassLoader cl)
+   {
+      if (clz != null)
+      {
+         try
+         {
+            Class<?> c = Class.forName(clz, true, cl);
+            if (ManagedConnectionFactory.class.isAssignableFrom(c))
+               return true;
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+
+      return false;
+   }
+
+   /**
     * Find the metadata for an admin object
     * @param clz The fully quilified class name for the admin object
     * @param aos The admin object classes
@@ -529,12 +581,19 @@
 
          for (org.jboss.jca.common.api.metadata.common.CommonAdminObject cao : defs)
          {
-            if (clz.equals(cao.getClassName()))
+            if (cao.getClassName() == null)
             {
-               if (result == null)
-                  result = new HashSet<CommonAdminObject>();
+               log.adminObjectNull();
+            }
+            else
+            {
+               if (clz.equals(cao.getClassName()))
+               {
+                  if (result == null)
+                     result = new HashSet<CommonAdminObject>();
 
-               result.add(cao);
+                  result.add(cao);
+               }
             }
          }
       }
@@ -1044,7 +1103,7 @@
                   if (cdDefs != null)
                   {
                      connectionDefinitions = 
-                        findConnectionDefinitions(ra10.getManagedConnectionFactoryClass().getValue(), mcfs, cdDefs);
+                        findConnectionDefinitions(ra10.getManagedConnectionFactoryClass().getValue(), mcfs, cdDefs, cl);
                   }
                }
 
@@ -1055,7 +1114,7 @@
                   if (cdDefs != null)
                   {
                      connectionDefinitions =
-                        findConnectionDefinitions(ra10.getManagedConnectionFactoryClass().getValue(), mcfs, cdDefs);
+                        findConnectionDefinitions(ra10.getManagedConnectionFactoryClass().getValue(), mcfs, cdDefs, cl);
                   }
                }
 
@@ -1412,7 +1471,7 @@
                               {
                                  connectionDefinitions =
                                     findConnectionDefinitions(cdMeta.getManagedConnectionFactoryClass()
-                                                              .getValue(), mcfs, cdDefs);
+                                                              .getValue(), mcfs, cdDefs, cl);
                               }
                            }
 
@@ -1424,7 +1483,7 @@
                               {
                                  connectionDefinitions = 
                                     findConnectionDefinitions(cdMeta.getManagedConnectionFactoryClass().getValue(),
-                                                              mcfs, cdDefs);
+                                                              mcfs, cdDefs, cl);
                               }
                            }
 

Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml	2011-09-14 20:43:33 UTC (rev 112242)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml	2011-09-15 16:03:24 UTC (rev 112243)
@@ -760,6 +760,21 @@
             <entry>Invalid config property</entry>
           </row>
           <row>
+            <entry>20009</entry>
+            <entry><code>WARN</code></entry>
+            <entry>Invalid connection definition</entry>
+          </row>
+          <row>
+            <entry>20010</entry>
+            <entry><code>ERROR</code></entry>
+            <entry>Connection definition with missing class-name</entry>
+          </row>
+          <row>
+            <entry>20011</entry>
+            <entry><code>ERROR</code></entry>
+            <entry>Admin object with missing class-name</entry>
+          </row>
+          <row>
             <entry>20051</entry>
             <entry><code>EXCEPTION</code></entry>
             <entry>Unable to start</entry>



More information about the jboss-cvs-commits mailing list