1 Reply Latest reply on Nov 24, 2010 9:48 AM by mtaal

    not getting weld:exclude to work...

    mtaal
      Hi,
      I am using Weld beta 1.1.0.

      I tried to get weld:exclude to work but Weld does not seem to pick this up. I use Weld in a tomcat environment.
      When checking the weld source code and debugging it seemed that the url scanner is not using excluded directories. The URL Scanner has this code to scan a directory:


         private void handleDirectory(File file, String path, List<String> classes, List<URL> urls)
         {
            handleDirectory(file, path, new File[0], classes, urls);
         }

         private void handleDirectory(File file, String path, File[] excludedDirectories, List<String> classes, List<URL> urls)
         {
      ....}


      As you can see the excludedDirectories is a path of length [0], it is never set and neither updated. Both methods are private and are not called from anywhere else.

      Maybe I made a mistake in my settings, or is there another way to get this working correctly?

      Btw, to limit the memory footprint, is there a possibility to tell Weld to only load/scan beans which have an explicit scope annotation (or other qualifier to tell them the bean is weld enabled)?

      Thanks!

      gr. Martin

      btw, here is the beans.xml I use:

      <beans xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:weld="http://jboss.org/schema/weld/beans"
              xsi:schemaLocation="
                 http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd
                 http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
         
          <weld:scan>
              <weld:exclude name="org.mytest.**"/>
          </weld:scan>

      </beans>

        • 1. Re: not getting weld:exclude to work...
          mtaal
          Oeps... my mistake :-), actually the beans.xml was read, but if there are exclude tags then at least one include tag is needed, for example like this:

          <beans xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:weld="http://jboss.org/schema/weld/beans"
                  xsi:schemaLocation="
                     http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd
                     http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
             
              <weld:scan>
                  <weld:include name="**"/>
                  <weld:exclude name="org.mytest.**"/>
              </weld:scan>

          </beans>

          This works for me.

          gr. Martin