tsgrp / OpenContent

TSG's Web Services for ECM Repositories
8 stars 4 forks source link

Duplicate Bean Creation #97

Open jharkin22 opened 4 years ago

jharkin22 commented 4 years ago

Currently OpenContent creates duplicates for many of it's beans between the servlet app context and the "main" app context. This is because both contexts do a component scan (in oc-rest-spring.xml for the servlet context and core-bean-config.xml for the main context). This hasn't led to any actual issues yet, but could down the line and would be a good idea to clean up. It also adds to the memory usage of OC.

One solution is to have the servlet context create any controllers while the main context would create everything else. This would looks something like

<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> in oc-rest-spring.xml

<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> in core-bean-config.xml