Uploaded image for project: 'Blossom'
  1. Blossom
  2. BLOSSOM-174

Areas don't seem to respect exclusion rules from component-scan

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Neutral
    • None
    • None
    • None
    • None

    Description

      Hi Tobias,

      in my blossom-servlet.xml I use the following code inspired by the Maven archetype:

      <context:component-scan base-package="xzy" use-default-filters="false">
      	<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.Template"/>
      	<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.Area"/>
      	<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.DialogFactory"/>
      	<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.VirtualURIMapper"/>
      </context:component-scan>

      This works well as such.

      Now, one of the next steps in our project was using different spring profiles (see http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/) because our project has different deployment types which partially require different templates (i.e. Spring Controllers) and we didn't want to confuse the editors with templates being shown as available in the backend although they're not applicable in the current mode.

      Thus I created different profiles like this:

      <beans profile="abc">
      	<context:component-scan base-package="xzy" use-default-filters="false">
      		<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.Template"/>
      		<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.Area"/>
      		<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.DialogFactory"/>
      		<context:include-filter type="annotation" expression="info.magnolia.module.blossom.annotation.VirtualURIMapper"/>
      
      		<context:exclude-filter type="annotation" expression="my.Annotation"/>
      	</context:component-scan>
      </beans>

      This, too, is finally working after a lot of research and trial and error. I'm very happy about that.
      At least it is working for Controllers. That's good news.

      However, it is not working for Areas. Although I proved with the debugger in org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider (line 329, in method isCandidateComponent()) that the area in question is reported as excluded by Spring, the excluded area is finally created in the rendering phase.

      You will probably argue it's not a problem, I'm not forced to use any area in my JSP file if I don't like it. However the idea is to have several @Area classes in one controller which have the same are name (e.g. several areas with the signature

      @Area(value="sidebar", title="Sidebar")

      ) and to make them mutually exclusive by the marker annotations as just described. If Blossom doesn't respect the exclusion rules, like it seems, this approach won't work.

      The whole subject is a little tricky, I can't guarantee that the problem is with Blossom, but because everything else is working as described above, it's hard to find another explanation at the moment.

      Thanks a lot for looking into it on occasion.

      Best Regards,
      Torsten

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              tmattsson Tobias Mattsson
              tln TLN
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD