[jboss-cvs] JBossAS SVN: r106034 - in projects/scanning/trunk: scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 14 11:43:28 EDT 2010


Author: alesj
Date: 2010-06-14 11:43:28 -0400 (Mon, 14 Jun 2010)
New Revision: 106034

Modified:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DeploymentUtilsFactory.java
Log:
Allow for config via DU.

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-06-14 15:22:36 UTC (rev 106033)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-06-14 15:43:28 UTC (rev 106034)
@@ -92,6 +92,9 @@
       this.unit = unit;
       this.finder = DeploymentUtilsFactory.getFinder(unit);
       this.handler = DeploymentUtilsFactory.getHandler(unit);
+
+      allowQueryInvocationSearch = DeploymentUtilsFactory.getAttachment(unit, "org.jboss.scanning.hibernate.allowQueryInvocationSearch", Boolean.class, Boolean.FALSE);      
+      cacheNewResults = DeploymentUtilsFactory.getAttachment(unit, "org.jboss.scanning.hibernate.cacheNewResults", Boolean.class, Boolean.FALSE);
    }
 
    /**

Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DeploymentUtilsFactory.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DeploymentUtilsFactory.java	2010-06-14 15:22:36 UTC (rev 106033)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DeploymentUtilsFactory.java	2010-06-14 15:43:28 UTC (rev 106034)
@@ -70,6 +70,44 @@
    }
 
    /**
+    * Get attachment.
+    *
+    * @param unit the deployment unit
+    * @param expectedType the expected attachment type
+    * @param defaultValue the default value
+    * @return found attachment or default value
+    */
+   public static <T> T getAttachment(DeploymentUnit unit, Class<T> expectedType, T defaultValue)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expected type");
+
+      return getAttachment(unit, expectedType.getName(), expectedType, defaultValue);
+   }
+
+   /**
+    * Get attachment.
+    *
+    * @param unit the deployment unit
+    * @param key the attachment key
+    * @param expectedType the expected attachment type
+    * @param defaultValue the default value
+    * @return found attachment or default value
+    */
+   public static <T> T getAttachment(DeploymentUnit unit, String key, Class<T> expectedType, T defaultValue)
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null deployment unit");
+      if (key == null)
+         throw new IllegalArgumentException("Null key");
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expected type");
+
+      T attachment = unit.getAttachment(key, expectedType);
+      return attachment != null ? attachment : defaultValue;
+   }
+
+   /**
     * Get util.
     *
     * @param unit the deployment unit



More information about the jboss-cvs-commits mailing list